We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › GLGraphics Threaded Class- No OpenGL context
Page Index Toggle Pages: 1
GLGraphics Threaded Class- No OpenGL context (Read 1323 times)
GLGraphics Threaded Class- No OpenGL context
Apr 23rd, 2009, 11:28pm
 
I implemented a class that implements Runnable.  When I try to run a GLSL filter in this thread via GLTextureFilter.apply(), I get this error:

Code:
Exception in thread "Thread-6" javax.media.opengl.GLException: No OpenGL context current on this thread
at javax.media.opengl.glu.GLU.getCurrentGL(GLU.java:234)
at javax.media.opengl.glu.GLU.gluOrtho2D(GLU.java:1184)
at codeanticode.glgraphics.GLState.setOrthographicView(GLState.java:66)
at codeanticode.glgraphics.GLTextureFilter.setGLConf(GLTextureFilter.java:488)
at codeanticode.glgraphics.GLTextureFilter.apply(GLTextureFilter.java:202)
at codeanticode.glgraphics.GLTextureFilter.apply(GLTextureFilter.java:141)

I think it's because this thread doesn't know anything about the OpenGL canvas I created in the main processing thread via size().  Is there a way to create a second canvas or share the main thread's canvas?
Re: GLGraphics Threaded Class- No OpenGL context
Reply #1 - Apr 24th, 2009, 2:04am
 
I believe that OpenGL isn't thread-safe, that is it doesn't work across threads properly.

It may be possible to create a completely separate GLContext for your thread, but then I think you'd have problems getting any data from it to your main context to actually show anything you've drawn to it.
Re: GLGraphics Threaded Class- No OpenGL context
Reply #2 - Apr 24th, 2009, 6:29am
 
In this case, I do not need to draw anything in my work thread--I just want to run a shader that does some GPGPU calculations.  The results will be transferred/stored in an array.
Page Index Toggle Pages: 1