Login  Register

Re: Rules for sharing context between GLJPanels?

Posted by Sven Gothel on Aug 28, 2014; 10:40pm
URL: https://forum.jogamp.org/Rules-for-sharing-context-between-GLJPanels-tp4032950p4032951.html

On 08/28/2014 11:23 PM, Marian Schedenig [via jogamp] wrote:

> I'm working on a level editor which I originally wrote with plain Java2D and
> later converted to JOGL.
>
> The original Java2D implementation had several JPanels, a big one for actually
> editing a level and many small ones as level previews. Each panel was
> connected to the same instance of my ResourceManager class which held all the
> images (now textures) and knew how to paint itself when an update was necessary.
>
> When I switched my game to JOGL, I quick-and-dirtily turned each of these
> panels into a GLJPanel, with its own ResourceManager (because instantiating
> the ResourceManager required a GL context). Aside from certainly wasting a lot
> of resources, this also makes things horribly slow when, while scrolling
> through the list of level previews, each panel that's displayed for the first
> time reads and initialises its textures.
>
> I've therefore been trying to switch to a shared GL context which would be the
> home of the ResourceManager. It's been mostly trial and error and Google
> searches (the link on the GLJPanel Javadoc page that would presumably provide
> more info doesn't exist:
> https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/spec-overview.html#SHARING).
Try GLSharedContextSetter
  <http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLSharedContextSetter.html>

as mentioned in GLJPanel and other implementations itself
  <http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/awt/GLJPanel.html>

we also mentioned it in our SIGGRAPH 2014 BOF.

You may also add jogl-test.jar and it's sources jogl-test-java-src.zip
to your IDE and see the unit tests by GLSharedContextSetter methods calltree.

Hope this helps.

~Sven


signature.asc (828 bytes) Download Attachment