I am trying to make a 2d game in opengl c++. I want to sroll a triangle using mouse movement. so I draw the triangle first. so far, I succeeded in making the triangle scroll when i move the mouse.
I used these 2 lines :
case WM_MOUSEMOVE:
X += (GLfloat)LOWORD(lParam);
and then, in my drawing function, I do this:
glTranslatef(x,0.0f,0.0f);
So the triangle is moving with the mouse movement so far. But the problem is, I want it to move left when I move the mouse left and to move right when i move the mouse right.
No matter how I move the mouse, the triangle moves right and never left. Even when I move the mouse up or down,it just moves right.
How can I solve this?