JPCT and Jide Docking Framework

Started by kavyro, September 01, 2021, 10:42:00 AM

Previous topic - Next topic

kavyro

Sent the project link to you in a private message. The forum reported it as "successful" even I can't see the message in the list of Messages. Hopefully you got it :)

EgonOlsen

#16
Yes, I did. I played around with it, but I can't see anything wrong in the way in which jPCT handles this. I think that this is either an issue with LWJGL's AWTGLCanvas or Jide is doing some hacky things to work its magic that interfere with what LWJGL expects from AWT/Swing.

I managed to configure jPCT in a way that at least the box shows up, but the colors were all white after an undock. I think what happens here, is that the GL context that is bound to the AWTGLCanvas by some magic is lost when Jide undocks the canvas. When talking to an invalid context, it often happens that some things still work while others fail. This is more a driver bug than a feature, because actually, rendering into an invalid context should give you no rendering at all.

If that's the issue, I think that recreating the FrameBuffer actually is the correct solution here.

kavyro

Ic. Hopefully reseting renderer will fix the issue at the end. Could you share the way you managed to have the box visible in white? That might give a hint for more possible solutions.

Another question... :)
I applied the solution to main project, but it fails with many NPEs inside of JPCT:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.NullPointerException
at com.threed.jpct.AWTJPCTCanvas.paintGL(AWTJPCTCanvas.java:238)
at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:339)
at org.lwjgl.opengl.AWTGLCanvas.update(AWTGLCanvas.java:368)
at java.desktop/sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at java.desktop/sun.awt.RepaintArea.paint(RepaintArea.java:232)
at java.desktop/sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:358)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5073)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.NullPointerException
at org.lwjgl.BufferChecks.checkDirect(BufferChecks.java:126)
at org.lwjgl.opengl.GL11.glDrawElements(GL11.java:1101)
at com.threed.jpct.CompiledInstance.render(CompiledInstance.java:732)
at com.threed.jpct.AWTGLRenderer.drawVertexArray(AWTGLRenderer.java:1349)
at com.threed.jpct.AWTJPCTCanvas.paintGL(AWTJPCTCanvas.java:198)
... 24 more


Maybe you have a quick hint why is happening so?

EgonOlsen

#18
The white box appeared after setting Config.glUseVBO and Config.glVertexArrays both to false. But that's not a good option, because it hinders performance and doesn't really help anyway.

About the exception: Actually, that's a NP in LWJGL, not in jPCT. I think it's a race condition when the AWT thread is still paiting while you switch the buffer in some other thread. This might cause LWJGL to lose the context und crash.

You somehow have to make sure that no painting happens when switching or switch in the AWT thread (an IPaintListener can help with that)...but I'm not sure that the latter is a good idea though.

EgonOlsen

Oh, and one other thing: You can (and should) remove this line from the Renderer class:


_buffer.enableRenderer(IRenderer.RENDERER_OPENGL);


It's not needed here and will bite you once the window has the same dimensions as a valid fullscreen video mode by some coincidence.

kavyro

Thank you EgonOlsen for you hints. I'll continue to dig into this issue...