Skip to main content
gamedev.net
🔒 Locked

gluLookAt() problems

Started by MARS_999 1 reply 250+ views
Original Post
MARS_999
MARS_999
I have a tiling engine going. I have a 20x20 tile on the screen. Now I want to move around it. When I use gluLookAt() I end up moving the whole 20x20 array. I dont'' want to do this. I want to move the camera around so the tiles stay still? If I use glTranslatef() instead the tiles dont'' even show up? I am using
  

gluPerspective(90.0f, static_cast<float>(SCREEN_WIDTH_1280) / static_cast<float>(SCREEN_HEIGHT_1024), 1.0f, 100.0f);
  
and
  
gluLookAt(0.0, 0.0, -30.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  
I dont'' see what would be wrong with any of the functions above. They work but when I remove gluLookAt() and use glTranslatef() to move around instead I get nothing? Any ideas why that would be. Thanks
_walrus
_walrus
Are you using operating under the correct transformation stack? The model view as opposed to projection?

ur projection setup should be like this:

setupProjection {
glMatrixMode( GL_PROJECTION ); // Select the projection matrix
glLoadIdentity(); // and reset it
// Calculate the aspect ratio of the view
gluPerspective( fov, sceneBounds.size.width/sceneBounds.size.height, near, far );
glMatrixMode( GL_MODELVIEW ); // Select the modelview matrix

}

void draw()
{
//perserve the top of the model view stack (just incase there is any there)
glPushMatrix();
glMultMatrix(cameraTransform); //or use glLoookAt(), or translate....etc

// draw your objects here
glPopMatrix(); //revert to the top of the model view stack
}
MARS_999
MARS_999
Thanks for the reply but I have my code setup almost the same way you have displayed yours. Thanks again.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.