LWJGL Forum

Programming => OpenGL => Topic started by: Trudko on February 06, 2007, 06:40:54

Title: Othographics projection
Post by: Trudko on February 06, 2007, 06:40:54
Iam trying to render my 3d model in 2d environment using orthographic projection. But when I try it nothing is rendered. Here is code for turning on the orthographics projection

public void turnOnOrtho() {

GL11.glPushAttrib(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_ENABLE_BIT);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();


GL11.glLoadIdentity();
GL11.glOrtho(0, 1024, 768, 0, -1, 1);

GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LIGHTING); 
}

            public void turnOffOrtho() {

GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
GL11.glPopAttrib();
}

And this code is for rendering
okno.turnOnOrtho();
    GL11.glPushMatrix();
               GL11.glTranslatef(positionX,positionY,0);
               GL11.glRotatef(90,1,0,0);
               GL11.glScalef(0.01f,0.01f,0.01f);
              // these two orders are good I am sure because it works in perspective projection but in ortho they dont.
textura.bind(); 
model.render();

GL11.glPopMatrix();
okno.turnOffOrtho();
Title: Re: Othographics projection
Post by: HopeDagger on February 07, 2007, 14:01:27
Have you tried increasing the near/far planes of your ortho projection? A total Z-size of 3 (-1 to 1) is pretty small; it's likely your model doesn't fit into such a space and is being clipped entirely. Also remember that the coordinates that your model uses should reflect the fact that your coordinate system is differently constructed in an orthogonal projection.

Good luck!