LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Role on January 27, 2005, 15:13:48

Title: Initialization in thread (it's bugs or not)??
Post by: Role on January 27, 2005, 15:13:48
Hello all,
This is my first attempt to use LWJGL
I want to port my 2D game engine (GTGE (http://goldenstudios.or.id/products/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
Title: Initialization in thread (it's bugs or not)??
Post by: baegsi on January 27, 2005, 15:21:38
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
Title: Thanks!
Post by: Role on January 27, 2005, 23:56:44
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
Title: Initialization in thread (it's bugs or not)??
Post by: kaltenbach on February 10, 2005, 04:30:37
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!
Title: Initialization in thread (it's bugs or not)??
Post by: baegsi on February 10, 2005, 08:28:06
I think this is an issue of OpenGL in general
Title: Initialization in thread (it's bugs or not)??
Post by: Role on February 10, 2005, 11:14:23
I guess so, cos I remember JOGL has this issue too when I port my graphics engine to JOGL.
Title: Initialization in thread (it's bugs or not)??
Post by: kaltenbach on February 10, 2005, 14:17:23
sure enough: when I rewrote the code to have all OpenGL calls be done from only one thread, things worked again fine.

Thanks!