ortho + perspective + ortho

hello everyone,
i have a huge terrain being loaded up onto my window. i have a 2d othro projection in my display rountine, then i have a perspective projection. how can i add another ortho projection to my display routine. is it possible?
im using my 2d othro projection to show up a backrground image and a scale showing the elevation and the associated color. what happens is when i zoom in all the way into my sceen, the scale hides behind the scene, cause its being rendered before the perspective projection shows the terrain and other info. i want to bring the scale in front.

i m using VB6

'load the projection matrix with identity
glMatrixMode mmProjection
glLoadIdentity

'set projection to 2D othrographic to render the frame buffer image
glOrtho -mintWidth / 2, mintWidth / 2, -mintHeight / 2, mintHeight / 2, -10, 10 '(mdblzmax - mdblzmin) / 2, -(mdblzmax - mdblzmin) / 2

glMatrixMode GL_MODELVIEW
glLoadIdentity


render background and scale

'set the projection to perspective
glMatrixMode GL_PROJECTION

glPushMatrix

glLoadIdentity

gluPerspective msngFieldOfView, msngAspectRatio, mdblNearField, mdblFarField

glPushMatrix

glMatrixMode GL_MODELVIEW
glLoadIdentity

glPushMatrix
.............


Render the terrain


glPopMatrix 'pop projection matrix
glPopMatrix 'pop modelview matrix
glPopMatrix 'pop the scene

do i have to add another projection matrix and a modelview matrix or can i somehow use the earlier set ortho projection, cause the new one is exactly equal to the old one.

thank you

do i have to add another projection matrix and a modelview matrix or can i somehow use the earlier set ortho projection, cause the new one is exactly equal to the old one.
you can use an earlier matrix, that’s the point of pushing the stack to begin with, to save the matrix state.

the second push of the projection matrix (in your code), right before the switch to modelview, is not needed.

[b]

you can use an earlier matrix, that’s the point of pushing the stack to begin with, to save the matrix state.

the second push of the projection matrix (in your code), right before the switch to modelview, is not needed.[/b]
that is exactly what i am tryin to do, but my background is not being rendered. my scale shows up fine n so does my scene rendered in the perspective proj. ne help would be really appreciated.

this is how it looks :

'clear the color buffer
glClear clrColorBufferBit

'load the projection matrix with identity
glMatrixMode mmProjection
glLoadIdentity

'set projection to 2D othrographic to render the frame buffer image
glOrtho -mintWidth / 2, mintWidth / 2, -mintHeight / 2, mintHeight / 2, -10, 10 '(mdblzmax - mdblzmin) / 2, -(mdblzmax - mdblzmin) / 2

glMatrixMode GL_MODELVIEW
glLoadIdentity


Render the background

glPushMatrix

'set the projection to perspective
glMatrixMode GL_PROJECTION

glPushMatrix

glLoadIdentity

gluPerspective msngFieldOfView, msngAspectRatio, mdblNearField, mdblFarField

glMatrixMode GL_MODELVIEW
glLoadIdentity


Load terrain

glPopMatrix 'pop projection matrix
glPopMatrix 'pop the scene

with this setup, neither my scale nor my background img is being shown.

anyone??? plzzzz

You are pushing the projection once, but not popping it, which will eventually giev stack overflow error.

You are pushing the modelview once, but popping it twice, which would give underflow errors.

Use glGetError. It is your friend.

k now it looks like this :

'set back ground color of the scene
glClearColor OGLRed(Me.BackColor) / 255, OGLGreen(Me.BackColor) / 255, OGLBlue(Me.BackColor) / 255, 1
'clear the color buffer
glClear clrColorBufferBit
'load the projection matrix with identity
glMatrixMode mmProjection
glLoadIdentity
'set projection to 2D othrographic to render the frame buffer image
glOrtho -mintWidth / 2, mintWidth / 2, -mintHeight / 2, mintHeight / 2, -10, mdblZmax
glMatrixMode GL_MODELVIEW
glLoadIdentity

render background img

glMatrixMode GL_PROJECTION
glPushMatrix
glLoadIdentity
gluPerspective msngFieldOfView, msngAspectRatio, mdblNearField, mdblFarField
glMatrixMode GL_MODELVIEW
glLoadIdentity

render scene

glPopMatrix 'pop projection matrix

draw scale

now, the scale shows , but the backgound img doesnt. the only error i get is 1280 = invalid enum. i dont know what it really means, but i get this msg when im tryin to map a texture as my background.

alright, i have my code like this now, but i cannot c the background yet.

glMatrixMode mmProjection
glLoadIdentity

'set projection to 2D othrographic to render the frame buffer image
glOrtho -mintWidth / 2, mintWidth / 2, -mintHeight / 2, mintHeight / 2, -10, mdblZmax

glMatrixMode mmModelView
glLoadIdentity

no transformations, only a quad with a texture is being rendered

'set the projection to perspective
glMatrixMode mmProjection

glPushMatrix
glLoadIdentity
gluPerspective msngFieldOfView, msngAspectRatio, mdblNearField, mdblFarField
glMatrixMode mmModelView
glPushMatrix
glLoadIdentity

glPopMatrix 'pop modelview matrix

glMatrixMode mmProjection
glPopMatrix

glFinish 'finish

'swap the buffers
SwapBuffers mlngPic1hDC