Login  Register

Re: GLContext outside GLEventListener

Posted by gouessej on Jan 06, 2014; 9:06am
URL: https://forum.jogamp.org/GLContext-outside-GLEventListener-tp4031115p4031116.html

Hi

Please look at the Java documentation, there are several methods to retrieve GL and GLContext:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLContext.html#getCurrent()
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLContext.html#getCurrentGL()

You should rather initialize your OpenGL resources in the init() method of your GLEventListener or add a GLRunnable into a queue. If you don't want to do that, get a GLContext, make it current, perform your OpenGL calls and release it. I advise you to look at the unit tests demonstrating the use of shared contexts.

Edit.: setSharedContext() can be used in your case.
Julien Gouesse | Personal blog | Website