DisplayLists in JOGL

Can a displayList be deleted and replaced with a new displayList after initialization? I keep trying but am only getting the scene that was created in the original list.

I call from inside the init method.
int myList = gl.glGenLists(1);
gl.glNewList(myList, GL.GL_COMPILE)
//code to draw default scene

Later for new scene I call,
gl.glNewList(myList, GL.GL_COMPILE);
//code to draw new scene

I have read that if I create a newList with the same int reference then it will overwrite the original list, but I keep seeing the same default scene from the first init method displayList

if I try to call deleteLists(myList) and myList = gl.glgenLists(1) before creating the new scene, then I see nothing but background color.

The right way is to just call glNewList with the same handle. This will delete the list and reuse the handle, but it won’t release the handle back for a possible namespace collision.

There’s something horribly asymmetric about calling genlists then deletelists and then reusing the handle, you would need another genlists call. You could easily get a handle collision on that reused integer. Either use genlists and respect it or don’t use it (you don’t need it, you can just use your own unique integers provided you know you aren’t going to collide with other software you call or write).

You should also note that delete lists requires another parameter.

I am using JOGL and found out the following:

You can not store the GL reference and use it outside of your GLEventListener’s methods (init, display, reshape, etc.) If you need to update a display list upon mouse click, set a flag in your GLEventListener from your MouseListener and have the GLEventListener do the processing during the next display().

The only possible explanation would be the lack of a valid context.

Yes, it has something to do with the GLEventListener executing in its own thread, so the rest of the class does not have a valid gl context. Now that I think about out, I’ve read somewhere about a single thread workaround option when you build your program. I don’t know if it’s relative to this though. Kind of makes you long for the times when you program in C/C++ doesn’t it?