salbeira
salbeira

Reputation: 2591

JOGL render outside of display(GLAutoDrawable drawable)

For my purposes, I want to clear the drawing surface of my canvas and grab the current GL2 object, save it to a managing wrapper and use it one step later, after returning from the canvas's display() method (that in turn calls the display(GLAutoDrawable drawable) method). It seems though, that after returning from the display() method, something happens that causes the GL object to defunction, like when I want to get an available textureID by calling glGenBuffers(1, buffer) I recieve 0 - not a valid textureID to load a texture into.

Is there a way to make the GL object work outside of the display method? (gl.getContext().makeCurrent() does not change anything ...)

Edit: After tinkering around, it seems that the call to glGenTextures does actually nothing - when I create a texture within the display method and then call it later from outside the call to display, I get the same textureID that was in the buffer before - so the call does not change the value within the buffer - also glGetError returns 0 ...

Edit2: Java: openGL: JOGL: What happens behind the scenes when I call the display() method? contained that question, but no answer was given on how to do it. It might be interesting to see a step by step method to do it, if having the code somewhere once, one might not need to modify it ...

Upvotes: 0

Views: 879

Answers (1)

gouessej
gouessej

Reputation: 4075

Rather use GLAutoDrawable.invoke(), it's safer than trying to get the GLContext stored in the GLAutoDrawable and calling makeCurrent() on it. Anyway, you're trying to defeat the main purpose of GLEventListener which is both useless and dangerous. Finally, the best place to get advises about JOGL is the official JogAmp forum as we can't be everywhere: http://forum.jogamp.org

Upvotes: 0

Related Questions