0

My problem is that I am rendering a quad with opengl. This code:

public void render() {
    System.out.println("Test");
    GL11.glPushMatrix();
    GL11.glTranslated(300,300,0);


    GL11.glColor3f(1f, 1f,1f);
    GL11.glRotatef(0, 0, 0, 1);
    GL11.glScalef(64, 64, 0);
    GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2i(0, 0);
        GL11.glVertex2i(1, 0);
        GL11.glVertex2i(1,1);
        GL11.glVertex2i(0, 1);
    GL11.glEnd();

    GL11.glPopMatrix();
}

This should appear as a nice clean square as the size is 64x64, although it appears like this.

Whats odd about this I have drawn correctly an image behind it which is fine. I have stopped drawing this image/quad and it still causes the same problem. I cannot see any problem with the code above.

If this snippet of code comes in handy this is my OpenGl initialization code:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 720, 0, 1280, 1, -1);
    glMatrixMode(GL_MODELVIEW);

Just now I tested it in another lwjgl configuration and it had no effect.

Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
Capitals
  • 3
  • 2

1 Answers1

1

That is aspect ratio problem.You should take care of this in your glOrtho() method.Here is what you need.Also check this and this one.More web search would do the trick without asking it here ;)

Also,try gluOrtho instead.See this answer.

Community
  • 1
  • 1
Michael IV
  • 11,016
  • 12
  • 92
  • 223
  • Okay, I had a play around with your first link and all it game me is:[link](http://puu.sh/4lf8E.png) but I will continue to search on the web to find out how to fix the aspect ratio problem. Thank you for alerting it to me. – Capitals Sep 07 '13 at 13:24
  • Thanks, gluOrtho looks like it was what I needed in the circumstances. I'll try and replace all deprecated code to remove this issue. It is a shame I cannot up-vote you :( – Capitals Sep 07 '13 at 17:31