0
votes

Our current assignment requires us to use older fixed-pipeline methods in openGL. We're using LWJGL 2.9.3. The following code displays a triangle. The problem is, it flickers like crazy. The Display.swapBuffers() method doesn't throw an exception, and it doesn't make any difference if I include it or not. I created this example based off this StackOverflow question:

gluPerspective, glViewport, gluLookAt and the GL_PROJECTION and GL_MODELVIEW Matricies

glViewport(0, 0, Display.getWidth(), Display.getHeight());

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 10, 0, 10, -1, 100);

glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);

gluLookAt(0, 0, 0, 0, 0, 1, 0, 1, 0);
glBegin(GL_POLYGON);
    glVertex3d(1, 1, 1);
    glVertex3d(1, 5, 1);
    glVertex3d(5, 5, 1);
glEnd();
glFlush();
try {
    Display.swapBuffers();
} catch (Exception e) {
    e.printStackTrace();
}

EDIT

One other thing. If I call glLoadIdentity() after glMatrixMode(GL_MODELVIEW), it's as if the gluLookAt() method is ignored. I just see a blank black screen if I do that. But if I don't, it keeps multiplying with itself (if I change the eye position from 0,0,0).

1

1 Answers

0
votes

The reason for the flickering was that the gluLookAt() function was swapping back and forth between looking different directions.