Initialization in thread (it's bugs or not)??

Started by Role, January 27, 2005, 15:13:48

Previous topic - Next topic

Role

Hello all,
This is my first attempt to use LWJGL
I want to port my 2D game engine (GTGE) graphics engine to use LWJGL..

Everything is fine until I get to function org.lwjgl.opengl.Display.update();
It throw org.lwjgl.opengl.OpenGLException: Invalid operation (1282) when I call the function in a thread.
But when not in a thread this function working perfectly.
So is this bugs or not? Why can't call that function in a Thread?
I hope this is bugs since my engine need to use Thread to run the game in applet mode, my game engine use 3 different mode, applet, java2d windowed and fullscreen, and now trying to get lwjgl windowed and fullscreen, also jogl windowed and fullscreen without need to change any line of code :)

And is it good to use LWJGL to make 2D games? My game engine is *only* intended to make 2D games....


Thanks for any enlightment...


PS: I use lwjgl-win32-0.94
D Java Game Engine
GTGE  Website | GTGE Forum

baegsi

I don't know if I understand your problem right, but what I know is that all OpenGL operations have to happen in the same thread so you can't split your calls between several threads. This is an OpenGL issue.

Regarding 2D games:yes absolutly. I do it, but more impressing results can be found at puppygames

Role

Thanks it worked now!
I move all the display initialization in the thread that call Display.update()

Any resources for 2D rendering in LWJGL?
Like drawing rectangle, circle, filling it, and stuff like all in java.awt.Graphics2D?

Thanks
D Java Game Engine
GTGE  Website | GTGE Forum

kaltenbach

Quote from: "baegsi"I don't know if I understand your problem right, but what I know is that all OpenGL operations have to happen in the same thread so you can't split your calls between several threads. This is an OpenGL issue.

While doing my first LWJGL based application development (on Mac OS X) I encountered crashes of the Java VM which I tracked down to be in calls to

   
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);


After seeing your post I realize that this might be due to the fact that the call to glClear is done in a thread different from the one in which OpenGL was initialized. Now I am curious to learn more about this restriction of having all OpenGL calls be done from the same Thread: is this an LWJGL issue, an issue with specific OpenGL drivers (e.g. under Mac OS X), or with OpenGL in general?

Thanks for any pointer!

baegsi

I think this is an issue of OpenGL in general

Role

I guess so, cos I remember JOGL has this issue too when I port my graphics engine to JOGL.
D Java Game Engine
GTGE  Website | GTGE Forum

kaltenbach

sure enough: when I rewrote the code to have all OpenGL calls be done from only one thread, things worked again fine.

Thanks!