I’m lost…the attached programs blow up with an unexpected error in the Java runtime. If I take out either the texture related commands OR the display list handling - it works. Similar code works in c#/OpenTK and pyOpenGL. I will attach both program files…but the relavant code will follow (just an ugly example):
public void display(GLAutoDrawable drawable) {
System.err.println("display");
GL gl = drawable.getGL();
// Clear the drawing area
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// Reset the current matrix to the "identity"
gl.glLoadIdentity();
// Move the "drawing cursor" around
gl.glTranslatef(-1.5f, 0.0f, -6.0f);
if (flag) {
displaylist = gl.glGenLists(1);
gl.glNewList(displaylist, GL.GL_COMPILE);
if (texture == null) {
try {
texture = TextureIO.newTexture(new File("C:\\Documents and Settings\\LD003\\My Documents\\Python Projects\\pyBzEdit2\\textures\\wall.png"), false);
} catch (IOException e) {
}
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
texture.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
texture.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
}
texture.enable();
texture.bind();
gl.glBegin(GL.GL_TRIANGLES);
gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Set the current drawing color to white
gl.glTexCoord2f(0.0f, 1.0f);
gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top
gl.glTexCoord2f(-1.0f, -1.0f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
gl.glTexCoord2f(1.0f, -1.0f);
gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
// Finished Drawing The Triangle
gl.glEnd();
texture.disable();
gl.glEndList();
gl.glCallList(displaylist);
} else {
gl.glCallList(displaylist);
}
// Move the "drawing cursor" to another position
gl.glTranslatef(3.0f, 0.0f, 0.0f);
// Draw A Quad
gl.glBegin(GL.GL_QUADS);
gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f); // Set the current drawing color to light blue
gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
gl.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
// Done Drawing The Quad
gl.glEnd();
// Flush all drawing operations to the graphics card
gl.glFlush();
}