Sign in to follow this  

glOrtho mapping problem

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this