diff options
Diffstat (limited to 'src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java')
-rw-r--r-- | src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java index a3c502b7c..150468bfb 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java @@ -40,8 +40,12 @@ package net.java.games.jogl.impl.macosx; import java.awt.Component; +import java.awt.EventQueue; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import net.java.games.jogl.*; import net.java.games.jogl.impl.*; @@ -73,4 +77,42 @@ public class MacOSXGLContextFactory extends GLContextFactory { GLCapabilitiesChooser chooser) { return new MacOSXOffscreenGLDrawable(capabilities); } + + public boolean canCreateGLPbuffer(GLCapabilities capabilities, + int initialWidth, + int initialHeight) { + return true; + } + + public GLPbuffer createGLPbuffer(final GLCapabilities capabilities, + final int initialWidth, + final int initialHeight, + final GLContext shareWith) { + final List returnList = new ArrayList(); + Runnable r = new Runnable() { + public void run() { + MacOSXPbufferGLDrawable pbufferDrawable = new MacOSXPbufferGLDrawable(capabilities, + initialWidth, + initialHeight); + GLPbufferImpl pbuffer = new GLPbufferImpl(pbufferDrawable, shareWith); + returnList.add(pbuffer); + } + }; + maybeDoSingleThreadedWorkaround(r); + return (GLPbuffer) returnList.get(0); + } + + private void maybeDoSingleThreadedWorkaround(Runnable action) { + if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) { + try { + EventQueue.invokeAndWait(action); + } catch (InvocationTargetException e) { + throw new GLException(e.getTargetException()); + } catch (InterruptedException e) { + throw new GLException(e); + } + } else { + action.run(); + } + } } |