Login  Register

Incorrect context on GLCanvas drawable

Posted by MarcoNL on Oct 19, 2021; 5:30pm
URL: https://forum.jogamp.org/Incorrect-context-on-GLCanvas-drawable-tp4041391.html

Hi.
I am using JOGL (2.4.0-rc-20210111) together with VTK 9.0.1.

In particular, I am using the GLCanvas component embedded into VTK's vtkJoglCanvasComponent.

My application works quite fine (both on Windows and on macOS - with Java 8 JRE).

However, I am facing a strange sporadic crash when I invoke a function in my application which removes the GLCanvas-based GUI panel from its container, and then adds it to a newly-created JFrame (it's a kind of "full screen mode" function of my application). This crash seems to happen only on Windows, while I've been unable to reproduce it on macOS so far.

In VTK's vtkJoglCanvasComponent class, there is a GLEventListener, whose init() callback gets called both upon initial display of the GLCanvas-based GUI panel, and then again when the GLCanvas-based GUI panel is added to the newly-created JFrame. Between the two init() calls, there is a dispose() call which is invoked when the GLCanvas-based GUI panel is removed form its original container.

Upon first invocation of the init() callback, if I call 'drawable.getContext()', I obtain an OpenGL 4.6 context, and everything works like a charm.

On the other side, upon the second invocation of the init() callback (after addition of the GLCanvas to the new JFrame), **SOMETIMES** calling 'drawable.getContext()', I obtain an OpenGL 1.1 context. When this happens, then VTK crashes, because VTK 9 requires at least OpenGL 3.2 in order to work properly.

I know that my description of the problem is quite limited, but can you guess why I **SOMETIMES** get an OpenGL 1.1 context upon init() with my GLCanvas-based panel?

This happens on many different Windows PCs with many different display adapters / drivers, when I invoke this "full screen mode" feature in my application (which works as described above: remove GLCanvas from its container --> create a new JFrame --> add the GLCanvas to the new JFrame).

It may be something in VTK, but I was just wondering if you could guess where the problem might be, and maybe point us in the correct direction.

Also, let me mention that for some reason this issue seems to appear more frequently with Jetbrain's Java 8 JRE, even though I have had a few occurrences of the issue even with Adopt OpenJDK Java 8 JRE.

Thanks in advance and best regards,

Marco Sambin