Jump to content
  • Advertisement
Sign in to follow this  

How to convert from Perspective to Orthogonal projection

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

Hi, I want to be able to switch back and forth my projection type just like blender does it. I store the left, right, top, bottom, near, and far values that define my frustum. how do I convert these value to the ones a need to define an orthogonal projection? For now I have something like this:
void Camera::render()
    // Store the current matrix and change it to modelview

        glMatrixMode( GL_MODELVIEW );
        Real viewMatrix[16];
        orientation.quatToMatrix( viewMatrix );
        glLoadMatrixf( viewMatrix );
        glTranslatef( -pos.x, -pos.y, -pos.z );
        glLoadMatrixd( viewMatrix );
        glTranslated( -pos.x, -pos.y, -pos.z );
        glMatrixMode( GL_PROJECTION );

        if ( frustum.perspective )
            glFrustum( frustum.left, frustum.right, frustum.bottom, frustum.top,         frustum.near, frustum.far);
            glOrtho( frustum.left, frustum.right, frustum.bottom, frustum.top, frustum.near, frustum.far );


So, when I call glOrtho passing the same values I had in glFrustum to it, it doesn't work, I actually get a smaller vis. volume. Any insights? Thanks in advance.

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!