I'm starting to play with LWJGL. I have taken this sample code, which works fine. Then, I wanted to change the way the loop is stopped. Here is my new code for the "while" loop:
while (true) {
// Clear the screen and depth buffer
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
// set the color of the quad (R,G,B,A)
GL11.glColor3f(0.5f,0.5f,1.0f);
// draw quad
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(100,100);
GL11.glVertex2f(100+200,100);
GL11.glVertex2f(100+200,100+200);
GL11.glVertex2f(100,100+200);
GL11.glEnd();
Display.update();
if(Display.isCloseRequested()) {
Display.destroy();
throw new Exception("Normal termination");
}
}
This time an exception is thrown to get out of the loop. The "start" method throws Exception, and my "main" is as follows:
public static void main(String[] argv) {
QuadExample quadExample = new QuadExample();
try {
quadExample.start();
} catch (Exception e) {
e.printStackTrace();
}
}
With this new structure, the program crashes with the error:
Invalid memory access of location 0x0 rip=0x7fff86d8cf0c
instead of terminating properly when I close it.
For information, I'm running that on Mac OS X 10.6.7, with JavaSE-1.6.
I saw a similar issue here and tried with -Xint
. It solves the problem. Any idea what can go wrong without -Xint?