Author Topic: JPCT and Jide Docking Framework  (Read 464 times)

Offline kavyro

  • byte
  • *
  • Posts: 11
    • View Profile
Re: JPCT and Jide Docking Framework
« Reply #15 on: September 08, 2021, 10:37:00 am »
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 :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12224
    • View Profile
    • http://www.jpct.net
Re: JPCT and Jide Docking Framework
« Reply #16 on: September 08, 2021, 01:54:53 pm »
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.
« Last Edit: September 08, 2021, 02:05:45 pm by EgonOlsen »

Offline kavyro

  • byte
  • *
  • Posts: 11
    • View Profile
Re: JPCT and Jide Docking Framework
« Reply #17 on: September 09, 2021, 10:43:41 am »
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:
Code: [Select]
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12224
    • View Profile
    • http://www.jpct.net
Re: JPCT and Jide Docking Framework
« Reply #18 on: September 09, 2021, 11:02:51 am »
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.
« Last Edit: September 09, 2021, 02:40:29 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12224
    • View Profile
    • http://www.jpct.net
Re: JPCT and Jide Docking Framework
« Reply #19 on: September 09, 2021, 11:05:23 am »
Oh, and one other thing: You can (and should) remove this line from the Renderer class:

Code: [Select]
_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.

Offline kavyro

  • byte
  • *
  • Posts: 11
    • View Profile
Re: JPCT and Jide Docking Framework
« Reply #20 on: September 10, 2021, 10:22:44 am »
Thank you EgonOlsen for you hints. I'll continue to dig into this issue...