Hi folks;
I am making a 3D application in OpenGL (in C) where the camera view is controlled by the mouse. Here is a snippit of the code:
void aim_camera(int x, int y) {
if (lastPos[0] == x && lastPos[1] == y)
return;
if (x < lastPos[0])
yrot += 1.5f;
if (x > lastPos[0])
yrot -= 1.5f;
if (y < lastPos[1]) {
z -= 0.2f;
lookupdown -= 1.0f;
}
if (y > lastPos[1]) {
z += 0.2f;
lookupdown += 1.0f;
}
lastPos[0] = x;
lastPos[1] = y;
}
My question is this; when I get to the edge of the screen I have the obvious problem where I cannot rotate the view any more. I want to restore the mouse position to the middile of the screen when this happens. I understand there are functions out there that allow a person to do that but thus far I've not come up with anything. Can anyone out there help?