Hello,
i think there is a "little bug". I create a function which generate at runtime new Displaylists. Normal i want to call the function with a button. The Result is this:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenLists(GL11.java:1177)
When i call without GenLists creation all goes fine. When i call the function without an AWT Element (i say: call the function at Frame 200) all goes fine.
Only when i call this function over an AWT/Swing Element.
Any Idea why???
Thanks!
P.S.: Sry my English is not so good, as it should.
OpenGL is not threadsafe. You need to make sure that the thread interacting with OpenGL is the same at all times.
Else you get into some messy context management.
okai, i understand.
First there is my Main OPENGL thread, which works and call all the functions. Actually my "Mainloop" And than there is a other Thread the "AWT".
So will it work when i only set a flag with the button and the Mainloop call the function, because the flag is set?
oXineteX
ahm i give me the answer self ;) Yes it works, but is there no other way?
Quote... is there no other way?
Sorry, but no. Thats what you have to do with OpenGL. :)
If you're doing lots of interaction with the AWT event thread, the flag approach can get messy quickly. A simple solution is to just put all the events into a queue and flush that queue every frame in your main loop.
Why not just synchronize on the block of code you are executing?
The way I understand it, the native OpenGL contexts aren't able to run in multiple threads, so a synchronize wouldn't work either.
Someone can correct me on this :roll: