Jump to content
  • Advertisement
Sign in to follow this  
felipedrl

How to convert from Perspective to Orthogonal projection

This topic is 3609 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
    glPushAttrib(GL_TRANSFORM_BIT);

        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 );
        glLoadIdentity();

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

    glPopAttrib();
}

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