porting my project from JOGL to LWJGL - Display.update() error

Started by Eternity, November 21, 2008, 08:31:42

Previous topic - Next topic

Eternity

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

Eternity

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

wolf_m

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.

Matzon

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

Eternity

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?

Orangy Tang

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.

Eternity

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

Orangy Tang

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).