1

I am displaying a quad in a pseudo-2D canvas via OpenGL. To do so, I use orthographic projection via:

gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(-ratio, ratio, -1, 1, 0, 10000);

The coordinates of the displayed quad are:

float[] quadCoords = {-10.0f, -10.0f, 5.0f, 
                       10.0f, -10.0f, 5.0f, 
                       10.0f,  10.0f, 5.0f, 
                      -10.0f,  10.0f, 5.0f};

This quad is rendered as 2 triangles (I spare you the code). I am also applying a texture, which is working nicely. The "camera" is defined before rendering the quad like so:

gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, -10.0f, -10.0f, -5, -10.0f, -10.0f, 0f, 0f, 1.0f, 0.0f);

As you can see, the viewport centers at [-10, -10, 0], which should be centered at the bottom left corner of the quad. However, when rendering the scene, it looks like this:

OpenGL Screenshot

This appears to be the RIGHT bottom corner - but it is not. I checked it, and it turns out the X axis is flipped. Am I doing something wrong with gluLookAt? Or have I missed something?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
manmal
  • 3,900
  • 2
  • 30
  • 42

1 Answers1

3

Ok that's a little silly, but I found the answer minutes after writing this question (hours after it occurred):

The "camera" is looking at the backside of the quad. Assigning "0" for all z-coordinates of the quad and "+1" for the z-coordinate of the eyepoint in gluLookAt fixed it.

manmal
  • 3,900
  • 2
  • 30
  • 42