Jump to content
  • Advertisement
Sign in to follow this  
Niddles

OpenGL Camera Problem

This topic is 4157 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!