LWJGL Forum

Programming => OpenGL => Topic started by: Eternity on November 21, 2008, 08:31:42

Title: porting my project from JOGL to LWJGL - Display.update() error
Post by: Eternity on November 21, 2008, 08:31:42
hey.

i'm completely new to lwjgl and ive been strugling since monday to port over my 7000 line project from jogl. i think i got most of it right but i have 2 big issues atm. 1. display.update() always generates a org.lwjgl.opengl.OpenGLException: Invalid enum (1280). and 2. if i dont do all opengl calls in the same thread i get Nullpointer exceptions, i would like to for instance load VBO's and textures in a thread thats separate from the thread the renders the scene

thnx
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: Eternity on November 21, 2008, 09:35:58
ok i just found the method to make the context current on a specific thread so thats sorted now my only problem is the fact the Display.update() generates above mentioned error
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: wolf_m on November 21, 2008, 09:41:58
Quote from: Eternity on November 21, 2008, 08:31:42
1. display.update() always generates a org.lwjgl.opengl.OpenGLException: Invalid enum (1280).
You need to check for GL errors explicitly to find out what went wrong, and that directly after you do stuff.
Otherwise, you always get the errors at update().

So we can't tell you what went wrong here. You need to check for GL errors after your individual GL statements.

That slows the whole stuff down - once everything works, delete the error checks again.

You can get errors with GL11.glGetError().
Quote
and 2. if i dont do all opengl calls in the same thread i get Nullpointer exceptions, i would like to for instance load VBO's and textures in a thread thats separate from the thread the renders the scene
If you're in a different thread, you have to switch to the context of your rendering Display to load stuff for it.
http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/changingcontexts

Or you could theoretically share lists, I don't know whether that's implemented though - I never looked into it.
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: Matzon on November 21, 2008, 09:42:20
the enum issue is because you *somewhere* in your code are using an invalid enum to pass to a method.
You can find the issue with sprinkling glGetErrors in your code - or you can try an compile a debug lwjgl.jar: http://lwjgl.org/forum/index.php/topic,2638.0.html
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: Eternity on November 21, 2008, 12:16:32
ok thnx i debugged it like that and i got it running (well for the most part at least). ive ran all my testing aplications on the engine and they are all fine except for one (the most complex one) that generates a org.lwjgl.opengl.OpenGLException: Stack overflow (1283) after running fine for about 10 frames. any idea what might cause this?
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: Orangy Tang on November 21, 2008, 18:48:43
That's probably an opengl matrix stack overflow. The matrix stacks are typically quite small (32 for modelview, 2 for projection and texture). Either you're doing too many pushMatrix() per frame and overflowing, or (more likey) you've got a push() without a corresponding pop() and so you "leak" stack space and overflow after a few frames.
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: Eternity on November 22, 2008, 23:33:12
k ya i found such a occurence in my code (pushing but not popping) for sum reason JOGL didnt have a problem with it wich is kinda weird.. anyway its fixed now  ;D

thnx
Title: Re: porting my project from JOGL to LWJGL - Display.update() error
Post by: Orangy Tang on November 23, 2008, 19:38:50
Quote from: Eternity on November 22, 2008, 23:33:12
k ya i found such a occurence in my code (pushing but not popping) for sum reason JOGL didnt have a problem with it wich is kinda weird.. anyway its fixed now  ;D

thnx
LWJGL automatically calls glGetError in Display.update() and throws an exception if it returns anything. This means that gl errors tend to get caught much earlier while developing rather than behaving oddly when you test it on other person's machines. ;D IIRC Jogl only calls glGetError if you enable the debug pipeline (which isn't on by default).