moving in x direction using glLookAt()

I just started using openGL. I’m having trouble with moving the view of the camera. I want to move the scene a little to the left when i click on the left side in my program. Is there something i have to do to refresh the view? here’s what i have in the myMouse function:

if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && x < (win_width/2)){
	printf ("X is on the left side of the screen at %i

", x);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(-2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

This should work i thought but it doesn’t change the scene at all, x used to be 2.0 and i’m changing it to -2.0 when i click once, just something simple, thanks!

I’ve never used gluLookAt in this way. But I do know that when I do the following it works fine…

In RenderScene (after setting MatrixMode to ModelView) use
gluLookAt(px,py,pz,vx,vy,vz,ux,uy,uz);
where each variable is set to a value either here directly or earlier in the program as an initial setting say in initGL routine.

In your KeyPress routine adjust the variable for the direction you want to change with something like the following:

px++; which will increase px by 1

The next time the renderscene is executed the camera/view will have altered to suit. You will only really notice this though if something is nearby to be affected by the movement.

Tina

you just need to call glutPostRedisplay(); at the end of your mouse function to reprint the screen again i have assumed you are using glut

Originally posted by Chadyo:
[b]I just started using openGL. I’m having trouble with moving the view of the camera. I want to move the scene a little to the left when i click on the left side in my program. Is there something i have to do to refresh the view? here’s what i have in the myMouse function:

if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && x < (win_width/2)){
printf ("X is on the left side of the screen at %i
", x);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(-2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

This should work i thought but it doesn’t change the scene at all, x used to be 2.0 and i’m changing it to -2.0 when i click once, just something simple, thanks![/b]