glFrustrum() same as glOrtho()

BlitzMax Forums/OpenGL Module/glFrustrum() same as glOrtho()

ImaginaryHuman(Posted 2006) [#1]
I create a display using glOrtho() for a normal 2D orthorgraphic projection, and I define it as having coordinates in the range 0..ScreenWidth x 0..ScreenHeight, so only using the positive coordinates, rather than using -1 to +1 in both directions. Then I can use glVertex() with proper coordinates to position things to the pixel.

What I want to be able to do is switch back and forth between glOrtho() and glFrustrum() displays for times when I want there to be perspective projection or when I just want a 2D environment. I can't seem to get the right settings for glFrustrum() so that coordinates are in the same range as with glOrtho. I need to be able to NOT modify the glVertex() calls and just use one set of calls regardless of the projection matrix. I tried passing similar parameters to glFrustrum() e.g. 0,0,ScreenWidth,ScreenHeight,1,20 as an example, since the near and far have to be positive values, but then this means that when i use glVertex2f() for 2d graphics, displayed in the 3d environment, they assume a Z coord of 0 which is not within the viewable frustrum. I tried adding a glTranslatef() to the modelview matrix to move the camera (right?) back so that maybe things come into view, but regardless of moving it + or - amounts in Z I still just get nothing being displayed.

What's the correct parameters for glFrustrum() to create the same results as glOrtho() without having to define Z values for vertices?


ImaginaryHuman(Posted 2006) [#2]
Anyone?