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()
def viewport3D(rect,angle,near,far):
glViewport(*rect)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(angle,float(rect[2])/float(rect[3]),near,far)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
Ortho Trouble
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.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
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.
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.
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
Thanks,
G
replacingwithLets the code work normally; otherwise, I don't see anything.
-G
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()
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()
-G
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement