Hi,
My use case involves removing and then adding back a GLCanvas (or GLJPanel) to an AWT (or Swing) layout. When doing such sequence of
add/remove/add a component, the GLEventListener will have its method invoked in this order
- init()
- display()
- dispose() (while removing the canvas)
- init() (again due to the component being added again)
Everything is handled cleanly in JOGL, except in the "legacy" TextRenderer (which usually does a great job). Indeed, when running the test mentionned above, I got a JVM crash
Stack: [0x0000000172d10000,0x0000000172f13000], sp=0x0000000172f10040, free space=2048k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [GLEngine+0x12a8fc] gleRunVertexSubmitImmediate+0x1814
C [GLEngine+0x21d74] glDrawArrays_Exec+0x268
C [libjogl_desktop.dylib+0x238e8] Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glDrawArrays1__IIIJ+0x40
j jogamp.opengl.gl4.GL4bcImpl.dispatch_glDrawArrays1(IIIJ)V+0
j jogamp.opengl.gl4.GL4bcImpl.glDrawArrays(III)V+45
J 1629 C1 com.jogamp.opengl.util.awt.TextRenderer$Pipelined_QuadRenderer.drawVertexArrays()V (236 bytes) @ 0x00000001059b236c [0x00000001059b1600+0xd6c]
J 1663 C1 com.jogamp.opengl.util.awt.TextRenderer.flushGlyphPipeline()V (15 bytes) @ 0x00000001059ca04c [0x00000001059c9e80+0x1cc]
j com.jogamp.opengl.util.awt.TextRenderer.endRendering(Z)V+1
j com.jogamp.opengl.util.awt.TextRenderer.endRendering()V+2
j org.jzy3d.painters.NativeDesktopPainter.drawText(Lorg/jzy3d/painters/Font;Ljava/lang/String;Lorg/jzy3d/maths/Coord3d;Lorg/jzy3d/colors/Color;F)V+215
Reading more in detail the code of
TextRenderer shows that the crash happens here.
I presume the GL context is somehow reset and that we lost the vertex/texture buffers.
I tried using the immediate mode with TextRenderer.setUseVertexArrays(false).
It avoids the crash, but the text is replaced by black pixels as shown below.
Does anyone see a way to fix this?