I'm trying to use the gluLookAt() function to control zooming in and out. Right now it isn't changing the matrix at all and I don't know why.
Here's the relevant code:
// Basic Opengl display function
void onDisplay()
{
// Clear the initial buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Set up viewing transformation, looking down -Z axis
glLoadIdentity();
gluLookAt(0, 0, zPosition, 0, 0, -1, 0, 1, 0);
// Draw the complete Mandelbrot set picture
glDrawPixels(520, 520, GL_RGB, GL_FLOAT, pixels);
//glLoadIdentity();
glutSwapBuffers();
}
void keyPressed (unsigned char key, int x, int y)
{
if(key == 'w')
{
printf("pressed %a", key);
printf("\n");
zPosition -= 1.0;
glutPostRedisplay();
}
}
Is it something to do with the glLoadIdentity() calls? I'm not too familiar with the different identities in openGL.
So how can I change this code to make a keypress on w zoom in?