Jump to content
  • Advertisement
Sign in to follow this  
Code-R

OpenGL Orthographic viewport problems

This topic is 4858 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

I'm trying to use an ortho viewport with FBOs. when I don't setup the orthographic view, rendering is fine. when I try to use it, nothing is rendered. here's my opengl calls log:
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,1)
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
glDisable(GL_DEPTH_TEST)
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glOrtho(0.000000,1024.000000,0.000000,768.000000,-1.000000,1.000000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glColor4fv([1.000000,1.000000,1.000000,1.000000])
glTranslatef(512.000000,384.000000,0.000000)
glActiveTextureARB(GL_TEXTURE0)
glEnable(GL_TEXTURE_2D)
glEnable(GL_DEPTH_TEST)
glBindTexture(GL_TEXTURE_2D,3)
glBegin(GL_QUADS) Textures[ (0,3) ] 
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([0.000000,0.000000,0.000000])
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([0.000000,1.000000,0.000000])
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([1.000000,1.000000,0.000000])
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([1.000000,0.000000,0.000000])
glEnd()
glMatrixMode(GL_PROJECTION)
glPopMatrix()
//Frame ends here
//This part draws the FBO to a fullscreen quad. it's tested, and it works.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0)
glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_LINE_BIT | GL_POLYGON_BIT | GL_POLYGON_STIPPLE_BIT | GL_PIXEL_MODE_BIT | GL_LIGHTING_BIT | GL_FOG_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_VIEWPORT_BIT | GL_TRANSFORM_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_HINT_BIT | GL_EVAL_BIT | GL_LIST_BIT | GL_TEXTURE_BIT | GL_SCISSOR_BIT)
glDisable(GL_DEPTH_TEST)
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glOrtho(0.000000,1024.000000,768.000000,0.000000,-1.000000,1.000000)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
glActiveTexture(GL_TEXTURE0)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D,1)
glBegin(GL_QUADS) Textures[ (0,1) ] 
glColor3f(1.000000,1.000000,1.000000)
glTexCoord2f(0.000000,0.000000)
glVertex3f(0.000000,768.000000,0.000000)
glTexCoord2f(1.000000,0.000000)
glVertex3f(1024.000000,768.000000,0.000000)
glTexCoord2f(1.000000,1.000000)
glVertex3f(1024.000000,0.000000,0.000000)
glTexCoord2f(0.000000,1.000000)
glVertex3f(0.000000,0.000000,0.000000)
glEnd()
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
glPopAttrib()
wglSwapBuffers(0xd601137f)=true 

any ideas? TIA

Share this post


Link to post
Share on other sites
Advertisement
glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_LINE_BIT | GL_POLYGON_BIT | GL_POLYGON_STIPPLE_BIT | GL_PIXEL_MODE_BIT | GL_LIGHTING_BIT | GL_FOG_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | *****GL_VIEWPORT_BIT***** | GL_TRANSFORM_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_HINT_BIT | GL_EVAL_BIT | GL_LIST_BIT | GL_TEXTURE_BIT | GL_SCISSOR_BIT);

I noticed you Pushed the GL_VIEWPORT_BIT, now i dont know if it is that but try removing

glPopAttrib() --> And see if u get results!

Share this post


Link to post
Share on other sites
nop, that wasn't it. besides, this part is in the part that renders the fb to a fullscreen quad, and i'm sure it works, becuase when I draw stuff in non-ortho, it shows up perfectly ok.

any ideas?

Share this post


Link to post
Share on other sites
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([0.000000,0.000000,0.000000])
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([0.000000,1.000000,0.000000])
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([1.000000,1.000000,0.000000])
glMultiTexCoord2fv(GL_TEXTURE0,0xb225a4)
glVertex3fv([1.000000,0.000000,0.000000])

crap im such an idiot... its right infront of me!!!!

Okay in Projection your screen looks like this


-1------------>X +1
|
|
|
|
Y+1

And thats why it works on projection compared to ur current ortho settings
which are
0------------>X +1024
|
|
|
|
Y+786


The reason is GL_VIEWPORT already set the Drawing area, all you do when you edit the projection matrix is change how the stuff get Transformed onto that area.

Try Replacing your ortho values with
glOrtho(0.000000,1.024*2,0.000000,0.768*2,-1.000000,1.000000)

Share this post


Link to post
Share on other sites
nope, didn't work. I'm wondering why the part that renders the fbo to a fullscreen quad using a similar method works, but this doesn't...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
well, I think I know what it is

glOrtho(0.000000,1024.000000,768.000000,0.000000,-1.000000,1.000000);

should be.

glOrtho(0.000000, 0.000000, 1024.000000, 768.000000,-1.000000,1.000000);

Share this post


Link to post
Share on other sites
Thanks! I got it now! actually, it should be (0,1024,768,0), as I use the bottom left as the origin. Thanks again everyone, ratings++.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!