Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dfanuk

changing to a different type of projection on the fly...

This topic is 5940 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 In my program I need to change to ortho2D type projection to draw something after drawing some things in Perspective projection. so this is my code from DrawGLScene, it comes after I''ve drawn some quads and text: Code: glPushMatrix(); glMatrixMode(GL_PROJECTION); gluOrtho2D(97, 542, 433, 124); //switch to ortho projection to draw the lines glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f,0.0f,-6.0f); //do some stuff glPopMatrix(); The problem at the mo is that I get a blank screen. If I comment out the above code I get the things I had previously drawn but if I leave it in I get nothing but the colour I have set the background to. any ideas what I am doing wrong? thanks Gareth <>< ps I have put 97, 542, 433, 124 because I want a small section on my screen only, but before I came up with that idea I had it at 0, 640, 480, 0 I''m not sure about this either

Share this post


Link to post
Share on other sites
Advertisement
Hi,
I think you should call glMatrixMode(GL_PROJECTION) *before* glPushMatrix() and before glPopMatrix()...

----
David Sporn AKA Sporniket

[edited by - davidsporn on April 18, 2002 11:24:22 AM]

Share this post


Link to post
Share on other sites
ah right, ok thanks

what about the pop matrix line, is that in the right place?

I just had a thought, should I be specifying a viewport in this bit of code too?

glViewport(97, 542, 433, 124);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
gluOrtho2D(0.0, 640.0, 480.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glTranslatef(0.0f,0.0f,-6.0f);

//do stuff here

glPopMatrix();

I just tried this new code and it just does the same as before

thanks,
Gareth
<><

Share this post


Link to post
Share on other sites
You need glLoadIdenity after glPushMatrix, since gluOrtho does not replace the matrix, but multiplies the projection matrix with the current matrix and then replaces the current matrix with this resulting matrix.

-Lev

[edited by - Lev Povalahev on April 18, 2002 11:48:09 AM]

Share this post


Link to post
Share on other sites
You also need to specify the projection matrix mode before the popmatrix call, otherwise OGL will pop the modelview matrix.

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

/ Yann

Share this post


Link to post
Share on other sites

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