Jump to content
  • Advertisement
Sign in to follow this  
one mind

glortho troubles

This topic is 5083 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 have setup my screen with 4 viewports with all perspective. I am trying to set my bottom left viewport to an ortho projection but it doesn't work. Here is the code ww and hh are the width and height of my window Gl.glViewport(0,0,ww,hh); //clear the color buffer to the clear color Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); // Clear the matrix Gl.glLoadIdentity(); //bottom left Gl.glViewport(0, 0, ww/2, hh/2); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Gl.glOrtho(0.0,ww/2,0.0,hh/2,-1.0,100.0);; Gl.glMatrixMode(Gl.GL_MODELVIEW); // Viewing transformation Glu.gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); Render(); I've noticed by using small values like -1 and 1 in glortho seem to work. I dont get it. Thanks for any help Cheers :)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by one mind
Hi, I have setup my screen with 4 viewports with all perspective. I am trying to set my bottom left viewport to an ortho projection but it doesn't work.

It doesn't work? What, more exactly, goes wrong? Could you post a screenshot or otherwise describe what is happening?

Share this post


Link to post
Share on other sites
Hi, I'm just using 100 for testing, why? what should it be?
Anyway, the code i have above renders a blank screen.
Here is code I am using i got from Nate Robbins example

Gl.glOrtho(-ratio, ratio, -ratio, ratio, -10, 256);

Where ratio = width/height;

This works well except when the window is sized down in one axis, like if u make the window smaller by dragging the right edge left, the ortho view dissappers.

Does anyone have like an exact formula for the input of orthogl?

Thanks again :)

Share this post


Link to post
Share on other sites
Quote:
Original post by one mind
Hi, I'm just using 100 for testing, why? what should it be?

Well, it should be as much as you need :)
I don't see why there would be a problem with a far plane at distance 100. Just make sure all objects that should be visible are between the near and far planes.

Quote:
Anyway, the code i have above renders a blank screen.
Here is code I am using i got from Nate Robbins example

Gl.glOrtho(-ratio, ratio, -ratio, ratio, -10, 256);

Where ratio = width/height;

This works well except when the window is sized down in one axis, like if u make the window smaller by dragging the right edge left, the ortho view dissappers.

Well, the ratio says how many times greater the width is than the height, right? So if you do like this:
Gl.glOrtho(-ratio, ratio, -1.0, 1.0, -10, 256);

the view volume's width and height will have the same ratio as the window's width and height.
Try it, and see if it works better :)

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!