Hello Guest

gluLookAt

  • 0 Replies
  • 5965 Views
gluLookAt
« on: March 05, 2012, 05:24:12 »
I'm trying to use gluLookAt to set up a perspective where I'm looking down at the "floor" (currently just a grid) such that the grid appears somewhat trapezoidal.  That is, I want to be looking "down" the "z" axis towards the floor and at the same time somewhat up the "y" axis.  Here's my code so far:

Code: [Select]
    // set up projection

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(40.0f, (float)Display.getWidth() / (float)Display.getHeight(), 0.0f, 1000.0f);

    // set up the model view

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GLU.gluLookAt(0.0f, 5.0f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);

    // draw grid

    GL11.glColor3f(0.0f, 1.0f, 0.0f);

    int x, y;

    for (x = -10; x < 10; x ++) {
      for (y = -10; y < 10; y++) {
        GL11.glBegin(GL11.GL_LINE_LOOP);
        GL11.glVertex3f(x, y, 0);
        GL11.glVertex3f(x + 1, y, 0);
        GL11.glVertex3f(x + 1, y + 1, 0);
        GL11.glVertex3f(x, y + 1, 0);
        GL11.glEnd();
      }
    }

Im my coordinate system, the "Z" coordinates are the ones that come out of the screen towards me, and "x" is left-to-right and "y" is bottom-to-top.

With this code, I don't see anything at all.  If I comment out the call to gluLookAt, I can see the intersection of four tiles in the grid.  I've tried different combinations of values to gluLookAt, but none of them work.  What am I doing wrong?