# OpenGL Ortho Trouble

This topic is 3675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, This should be a pretty basic question. Soon after I began OpenGL a few years ago, I realized that, among other things, I didn't know how to do Ortho projections. It never really became important, so I didn't really worry about it. I decided it would be good to know. Currently, my view is made using the latter function in this code snippet.
def viewport2D(rect,near,far):
glViewport(*rect)
glMatrixMode(GL_PROJECTION)
glOrtho(rect[0],rect[2],rect[1],rect[3],near,far)
glMatrixMode(GL_MODELVIEW)
def viewport3D(rect,angle,near,far):
glViewport(*rect)
glMatrixMode(GL_PROJECTION)
gluPerspective(angle,float(rect[2])/float(rect[3]),near,far)
glMatrixMode(GL_MODELVIEW)

The former, which I use in exactly the same way, is my assumption of how to do Ortho. Unfortunately, I see nothing when using it on several demos. Sorry, just don't see anything--only the fill color, black. Any idea why this might be? Thanks, Ian

##### Share on other sites
glOrtho(rect[0],rect[2],rect[1],rect[3],near,far)

My gut feeling is you have this set wrong or you have rendered your objects in front or behind the near/far planes. Make sure you have a near far plane e.g. -100,100 to start with and translate to say 10 or something.

##### Share on other sites
Even with the near/far planes set to large numbers, I don't see anything. If the context of the code is important, here is a link to the source: http://www.geometrian.com/Programs/OpenGL Library 1.4.zip The last test tests ortho. I don't see anything when I run it.
Thanks,
G

##### Share on other sites
replacing
def viewport2D(rect,near,far):    glViewport(*rect)    glMatrixMode(GL_PROJECTION)    glLoadIdentity()    glOrtho(rect[0],rect[2],rect[1],rect[3],near,far)    glMatrixMode(GL_MODELVIEW)    glLoadIdentity()
with
def viewport2D(rect,near,far):    glViewport(*rect)    glMatrixMode(GL_PROJECTION)    glLoadIdentity()    gluPerspective(45,float(rect[2])/float(rect[3]),near,far)    glMatrixMode(GL_MODELVIEW)    glLoadIdentity()
Lets the code work normally; otherwise, I don't see anything.
-G

##### Share on other sites
Update:

I just realized, I can see stuff, but now the objects are in screen coordinates. So the cube at (0,0,0) is now 1 pixel big and at the bottom left corner of the screen.

I wanted the Ortho to make the perspective parallel, like the way these objects are seen: http://leannekroll.files.wordpress.com/2008/06/iso.gif.

In short, I want to see the 3D objects just as they were seen in perspective, but in and isometric projection. Is there a nice way to do that?

-G

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632904
• Total Posts
3009150
• ### Who's Online (See full list)

There are no registered users currently online

×