Jump to content
  • Advertisement
Sign in to follow this  
Niddles

OpenGL Camera Problem

This topic is 4079 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

Hello, I have come here after looking through 10 pages of google searching for an answer to this. I am using OpenGl and C++, and I cannot get a camera to work. I am using gluLookAt on the modelview matrix. Look:
void Camera::UpdateCamera()
    {
        glMatrixMode(GL_MODELVIEW);
        gluLookAt(CameraPosition.x, CameraPosition.y, CameraPosition.z,
                  CameraLook.x, CameraLook.y, CameraLook.z,
                  CameraUp.x, CameraUp.y, CameraUp.z);
    }
}
void EngineBase::Render()
{
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
        EngineCamera.UpdateCamera();
        glPushMatrix();
        glLoadIdentity();
        scene.Render();
        glPopMatrix();
        SDL_GL_SwapBuffers();
        Sleep(1);
}

I can't figure out why it won't work, because It looks extremely logical. Help please! Thanks =)

Share this post


Link to post
Share on other sites
Advertisement
Your problem is that you're overwriting your modelview matrix with the identity matrix.

EngineCamera.UpdateCamera();
glPushMatrix();
glLoadIdentity(); <---- This overwrites everything that happens in your UpdateCamera()

Hope that helps...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!