Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MARS_999

gluLookAt() problems

This topic is 5680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!