Jump to content
  • Advertisement
Sign in to follow this  
r_bewick

OpenGL Change view

This topic is 2804 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 am new to OpenGL and was wondering how to change the view from drawing 3d to drawing 2d text and back again. (so when I draw 2d (-1,1) will be top left and (1,-1) will be bottom right)
Thanks,
r_bewick

Share this post


Link to post
Share on other sites
Advertisement
You need to change the projection matrix to map (-1,-1) to (1,1) to your screen coordinates.

Something like:

glMatrixMode(GL_PROJECTION);
gluPerspective(...);
glMatrixMode(GL_MODELVIEW);

...render 3d scene...

glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1,1,1,-1,-1,1);
glDisable(GL_DEPTH_TEST);

...draw text...

glEnable(GL_DEPTH_TEST);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();



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!