Glfw keyboard input

well I have debugged my code and it does not want to increment or decrement my move_x variables.
here is my code
float move_x = 0.0f;

void key_callback(GLFWwindow*, int key, int scancode, int action, int mods)
if (key == GLFW_KEY_LEFT && action == GLFW_PRESS)
else if (key == GLFW_KEY_RIGHT && action == GLFW_PRESS)

Please read the Forum Posting Guidelines. In particular, Before You Post #4, Posting Guideline #4, and Posting Source Code.

1 Like

ok well I used the debugger and when I step into the move_x variable it does not change value. I have used this function in other programs and it works, I think I am missing something. I think my problem in how I use the move_x variable with the vertices array. here is that code.
GLfloat vertices[] =
// Positions // Colors // Texture Coords
-0.10f+move_x, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // Top Right
-0.10f+move_x, -0.80f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // Bottom Right
0.10f+move_x, -0.80f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // Bottom Left
0.10f+move_x, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // Top Left

can I get some help on my problem

If you want help, then it would be useful to provide enough code for someone to be able to provide you with that help. Simply showing us a fragment of a function and saying “this isn’t incrementing the variable, please help,” just isn’t enough information for someone to help you.

For example, you show us this vertices array. Well… where is it? How does it get used? We cannot know any of that simply by showing us the array. And without knowing any of that, there’s nothing we can do.

Again, please read and follow the Forum Posting Guidelines.

well I put the array in the game loop and it works

  1. I’m not sure key_callback(…) are called if you don’t swap_buffers() … you can check that swapBuffere() exists within a program while()-loop
  2. I havn’t seen shorthand
    before. try var+=1.f; unless you are sure that it’ll work as is.
  3. Incrementing an int by default one unit makes sense … but, is the basic unit of a decimal number still 1.0 ?