Jump to content
  • Advertisement
Sign in to follow this  

glOrtho mapping problem

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

Hey everyone, I have a piece of code in my program drawing stuff in 2D. I essentially want to use a Ortho projection to do this so i can sort quads by depth. My program is 1440x900 maxDepth=1000; .... public void enable2D(){ GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glOrtho(0, 1440, 900, 0, -maxDepth, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); } public void disable2D(){ GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); } public void render(){ enable2D(); //BEGIN 2D --------------- GL11.glDisable(GL11.GL_LIGHTING); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(pos.p[0], pos.p[1],pos.p[2]); GL11.glVertex3f(pos.p[0], pos.p[1]+height,pos.p[2]); GL11.glVertex3f(pos.p[0]+width, pos.p[1]+height,pos.p[2]); GL11.glVertex3f(pos.p[0]+width, pos.p[1],pos.p[2]); GL11.glEnd(); //END 2D --------------- disable2D(); } ______________ So the quad renders, but kind of off. I defined a Quad of width 500 by height 200. I changed it's y-position to 700. If all is well, the bottom of my quad should touch the bottom of the viewport. However as it is now, there is about 80 pixels of blank space below the Quad. This drift however is incremental. If i define the same Quad at y-position 0. It draws perfectly at the top. This problem doesn't affect the Quad in the x-axis however. At first I thought it was due to perspective change, but it doesn't seem so. I have changed different values of maxDepth such as 1000->1. But results are the same. Has anyone exhibited this before?

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!