Greetings!
I am doing a small 2D game as a school project and as the newbie I am I got stuck when trying to make the character look at the current cursor position.
Right now I am just trying to draw a quad at the cursor position to make sure that it will give the right value later.
The relevant code looks like this:
POINT cp;
GetCursorPos(&cp);
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(cp.x,cp.y,-5.0f);
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-0.03f,0.03f,0.0f); // Top Left
glVertex3f(0.03f,0.03f,0.0f); // Top Right
glVertex3f(0.03f,-0.03f,0.0f); // Bottom Right
glVertex3f(-0.03f,-0.03f,0.0f); // Bottom Left
glEnd();
The program draws a quad that reacts to the mouse, however it is drawn in the wrong place and its reaction to mouse movement is extremely jumpy. (Moving the mouse a little wont do anything but once it comes outside a “zone” the quad jumps what looks like several units)
I have tried to correct this manually by dividing and subtracting the value x and y to make the quad fit under the cursor, however this does not make them less jumpy.
So to my question: Is there a better way to do this or am I doing something horribly wrong with the current method?