Jump to content
  • Advertisement
Sign in to follow this  
Wizumwalt_

reset the viewing volume

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

Is it good practice to use glOrtho from my display() method rather than my redisplay() because my problem is that I don't know the size of the model till it's loaded. I've been working w/ a model I already know the size of. It works like this. 1. Empty canvas initializes (redisplay() sets size of new window frame and viewing volume). 2. User loads a model. 3. I calculate the size of the model (i.e. min/max x, y, z, centroid, etc...) 4. Now I need to reset glOrtho's viewing volume according to model and not the one I just used to initialize my canvas w/ in the redisplay method. What method is that done with, or is it ok to call glOrtho again?

Share this post


Link to post
Share on other sites
Advertisement
glOrtho creates a transformation matrix used for orthogonal projection and multiplies it with the current transformation matrix (typically the projection matrix). When calling glOrtho again it creates a new matrix and multiplies it with the current matrix once again. Thus it stores two glOrtho-transformations. If you want to reset the current transformation matrix so it has only your new transformation you could call glLoadIdentity before glOrtho to reset the current matrix (load it with the identity matrix) and because of that also resetting the viewing volume.

glMatrixMode(GL_PROJECTION); //apply subsequent matrix multiplications to the current projection matrix
glLoadIdentity(); //reset it to a identity matrix - no transformation
glOrtho(/*new values...*/); //a new view volume is set

If the old matrix is important one can also save it with glPushMatrix() and later get it back with glPopMatrix().

\Jimmy H

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!