diff options
Diffstat (limited to 'src/net/java/games/jogl/impl/GLPbufferImpl.java')
-rw-r--r-- | src/net/java/games/jogl/impl/GLPbufferImpl.java | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/src/net/java/games/jogl/impl/GLPbufferImpl.java b/src/net/java/games/jogl/impl/GLPbufferImpl.java index 4e8bd7c63..6e83f0d0e 100644 --- a/src/net/java/games/jogl/impl/GLPbufferImpl.java +++ b/src/net/java/games/jogl/impl/GLPbufferImpl.java @@ -52,20 +52,24 @@ import net.java.games.jogl.*; interface so can be interacted with via its display() method. */ public class GLPbufferImpl implements GLPbuffer { - // GLPbufferContext + private GLDrawableImpl pbufferDrawable; private GLContextImpl context; private GLDrawableHelper drawableHelper = new GLDrawableHelper(); private boolean isInitialized=false; private int floatMode; - public GLPbufferImpl(GLContext context) { - this.context = (GLContextImpl) context; + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, + GLContext parentContext) { + this.pbufferDrawable = pbufferDrawable; + context = (GLContextImpl) pbufferDrawable.createContext(parentContext); + context.setSynchronized(true); } - public void display() { - maybeDoSingleThreadedWorkaround(displayOnEventDispatchThreadAction, - displayAction, - false); + public GLContext createContext(GLContext shareWith) { + return pbufferDrawable.createContext(shareWith); + } + + public void setRealized(boolean realized) { } public void setSize(int width, int height) { @@ -74,13 +78,17 @@ public class GLPbufferImpl implements GLPbuffer { } public int getWidth() { - // FIXME - throw new GLException("Not yet implemented"); + return pbufferDrawable.getWidth(); } public int getHeight() { - // FIXME - throw new GLException("Not yet implemented"); + return pbufferDrawable.getHeight(); + } + + public void display() { + maybeDoSingleThreadedWorkaround(displayOnEventDispatchThreadAction, + displayAction, + false); } public void addGLEventListener(GLEventListener listener) { @@ -91,6 +99,14 @@ public class GLPbufferImpl implements GLPbuffer { drawableHelper.removeGLEventListener(listener); } + public GLContext getContext() { + return context; + } + + public GLDrawable getDrawable() { + return pbufferDrawable; + } + public GL getGL() { return context.getGL(); } @@ -108,11 +124,11 @@ public class GLPbufferImpl implements GLPbuffer { } public void setAutoSwapBufferMode(boolean onOrOff) { - context.setAutoSwapBufferMode(onOrOff); + drawableHelper.setAutoSwapBufferMode(onOrOff); } public boolean getAutoSwapBufferMode() { - return context.getAutoSwapBufferMode(); + return drawableHelper.getAutoSwapBufferMode(); } public void swapBuffers() { @@ -141,15 +157,6 @@ public class GLPbufferImpl implements GLPbuffer { context.releasePbufferFromTexture(); } - public GLContext getContext() { - return context; - } - - // FIXME: workaround for problems with deferring reshape actions - public GLDrawableHelper getDrawableHelper() { - return drawableHelper; - } - //---------------------------------------------------------------------- // No-ops for ComponentEvents // @@ -188,6 +195,7 @@ public class GLPbufferImpl implements GLPbuffer { public void destroy() { context.destroy(); + pbufferDrawable.destroy(); } public int getFloatingPointMode() { @@ -221,7 +229,7 @@ public class GLPbufferImpl implements GLPbuffer { throw new GLException(e); } } else { - drawableHelper.invokeGL(context, invokeGLAction, isReshape, initAction); + drawableHelper.invokeGL(pbufferDrawable, context, invokeGLAction, initAction); } } @@ -242,8 +250,9 @@ public class GLPbufferImpl implements GLPbuffer { private DisplayAction displayAction = new DisplayAction(); class SwapBuffersAction implements Runnable { + // FIXME: currently a no-op public void run() { - context.swapBuffers(); + pbufferDrawable.swapBuffers(); } } private SwapBuffersAction swapBuffersAction = new SwapBuffersAction(); @@ -253,14 +262,14 @@ public class GLPbufferImpl implements GLPbuffer { // being resized on the AWT event dispatch thread class DisplayOnEventDispatchThreadAction implements Runnable { public void run() { - drawableHelper.invokeGL(context, displayAction, false, initAction); + drawableHelper.invokeGL(pbufferDrawable, context, displayAction, initAction); } } private DisplayOnEventDispatchThreadAction displayOnEventDispatchThreadAction = new DisplayOnEventDispatchThreadAction(); class SwapBuffersOnEventDispatchThreadAction implements Runnable { public void run() { - drawableHelper.invokeGL(context, swapBuffersAction, false, initAction); + drawableHelper.invokeGL(pbufferDrawable, context, swapBuffersAction, initAction); } } private SwapBuffersOnEventDispatchThreadAction swapBuffersOnEventDispatchThreadAction = |