1
\$\begingroup\$

I am using GLFW 3.2.1

Currently I am implementing a camera. For the vertical controls I am using space to go up and shift to go down.

For all other keys, pressing the key results in the section of the code associated with the key always executing.

But for shift, it only gets exectuted when pressing and releasing but not while keeping the key pressed.

The key callbak is:

#define CAM_SPEED 0.2f
void static key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GLFW_TRUE);

    if(key == GLFW_KEY_W)
    {
        c.translateForward(CAM_SPEED);
    }
    if(key == GLFW_KEY_S)
    {
        c.translateForward(-CAM_SPEED);
    }
    if(key == GLFW_KEY_A)
    {
        c.translateSideways(-CAM_SPEED);
    }
    if(key == GLFW_KEY_D)
    {
        c.translateSideways(CAM_SPEED);
    }
    if(key == GLFW_KEY_SPACE)
    {
        c.translate(vec3(0,1,0)*CAM_SPEED);
    }
    if(key == GLFW_KEY_LEFT_SHIFT || mods==GLFW_MOD_SHIFT)
    {
        c.translate(vec3(0,-1,0)*CAM_SPEED);
    }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.