Re: Error Making Context Current JOGL 2.0 rc9
Posted by
Sven Gothel on
Aug 04, 2012; 11:31pm
URL: https://forum.jogamp.org/Error-Making-Context-Current-JOGL-2-0-rc9-tp4025517p4025757.html
On 08/05/2012 12:29 AM, Moa [via jogamp] wrote:
> I figured out what the problem was in my case.
>
> Using JoGL from early 2012 I found I needed to render by doing something like
> this:
>
> public void display(GLAutoDrawable drawable) {
> try {
> if (!drawable.getContext().isCurrent()) {
> drawable.getContext().makeCurrent();
> }
> // Do the rendering ...
> } finally {
> drawable.getContext().release();
> }
> }
>
> By the time I got around to upgrading to JoGL 2.0 rc9 I found that this code
> was raising a "Context not current" exception. That's when I found this
> thread. Now I have worked through the issue and believe I have an explanation
> and fix (for my code at least).
>
> The problem here is the call to release the context. If I remove that then I
> can render without this "Context not current" exception successfully on
> Windows, Linux and Mac OS X (10.8, although GLCanvas doesn't work here due to
> broken Mac pbuffer support, but GLJPanel works nicely).
>
Right, see
<
http://forum.jogamp.org/OSX-Lion-issues-PBuffers-tp4021385p4025756.html>
> It appears that the paintComponent() method of JoGL don't ensure that the
> context is current before drawing, so if you release the context it doesn't
> get re-bound and the exception is raised. If any of the JoGL maintainers are
> reading this thread then perhaps you could consider overriding
> paintComponent() to acquire the GL context if doesn't have it already, that
> way things would be a lot more robust (IMHO) no matter what a JoGL client
> developer did.
>
> To make things crystal clear, doing rendering using the following code works
> for me using JoGL 2.0 rc9 (and pre-rc10):
>
> public void display(GLAutoDrawable drawable) {
> try {
> if (!drawable.getContext().isCurrent()) {
> drawable.getContext().makeCurrent();
> }
> // Do the rendering ...
> } catch (Throwable th) {
> // Log and supress/ignore the exception. Do not release the OpenGL context.
> }
> }
>
> I hope this helps someone in the future.
We have to evaluate this .. i.e. the above code shall not be required
or even recommended ..
If you are able to find the culprit / bug .. happy to fix it.
~Sven