I have created a GLFW window and have already made a camera, but the WindowCallbackAdapter input seems choppy. It's not like the Keyboard.isKeyDown(). When the key is down it doesn't move smoothly, you can see that it moves, but the time in between input checks is slow. I was wondering if there is a way to get smooth input, instead of what the GLFW window has.
WindowCallback.set(WindowID, new WindowCallbackAdapter() {
@Override
public void key(long window, int key, int scancode, int action, int mods) {
if(key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
glfwSetWindowShouldClose(WindowID, GL_TRUE);
}
if(key == GLFW_KEY_W) {
GameClass.camera.moveZ(0.3f);
}
if(key == GLFW_KEY_S) {
GameClass.camera.moveZ(-0.3f);
}
if(key == GLFW_KEY_A) {
GameClass.camera.moveX(0.3f);
}
if(key == GLFW_KEY_D) {
GameClass.camera.moveX(-0.3f);
}
}
});
you can emulate Keyboard.isKeyDown() with GLFW as follows:
public static boolean isKeyDown(int key) {
return GLFW.glfwGetKey(window, key) == GLFW.GLFW_PRESS;
}
Quote from: kappa on November 24, 2014, 10:31:20
you can emulate Keyboard.isKeyDown() with GLFW as follows:
public static boolean isKeyDown(int key) {
return GLFW.glfwGetKey(window, key) == GLFW.GLFW_PRESS;
}
Ah thank you! it works :)
Another question, do you know how to get mouse dx/dy for camera rotation?
Yes, simply get the mouse position every frame and subtract the last frames mouse position from it and you'll get the mouse dx/dy.