EXCEPTION_ACCESS_VIOLATION in glDeleteLists()

Started by Fool Running, February 05, 2004, 18:51:29

Previous topic - Next topic

Fool Running

I'm porting a game engine I wrote in GL4Java to LWJGL and I realized that glDeleteLists() is not getting called correctly, so I fixed it to be called at the correct time (on finalize of one of the game engine's objects).  When the code executes, however it throws a EXCEPTION_ACCESS_VIOLATION in native code.

Here is a snipet of my code (all irrelevant code deleted  :D )

id = GL.glGenLists(1);
GL.glNewList(id, GL_COMPILE);
    // create object
GL.glEndList();

// have fun rendering lots of frames

public void finalize(){
    if(id != -1) GL.glDeleteLists(id, 1);
    id = -1;
}

Any suggestions would be great.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

princec

Been there, done that, got the T-shirt!

finalize() is called in a different thread! So the context is invalid, so ... your drivers crash. Which they shouldn't do, but they do, nonetheless.

Same goes for every other thing you were using finalize for. Really what you want is WeakReferences and a reference queue to sort this out but I never quite got round to making it work properly myself.

Cas :)

Fool Running

Thanks for the info.  :lol:

I fixed it by destroying all displaylists before they get finalized. Still not sure how to handle the objects that get destroyed in the middle of running the game, but will work on that.   :roll:

Thanks again
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D