glGenLists bug?

Started by oXineteX, November 02, 2005, 10:44:28

Previous topic - Next topic

oXineteX

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.

Matzon

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.

oXineteX

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

oXineteX

ahm i give me the answer self ;) Yes it works, but is there no other way?

Fool Running

Quote... is there no other way?
Sorry, but no.  Thats what you have to do with OpenGL. :)
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Orangy Tang

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.

Whackjack

Why not just synchronize on the block of code you are executing?

Fool Running

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:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D