diff options
author | Sven Gothel <[email protected]> | 2014-02-14 06:37:13 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-02-14 06:37:13 +0100 |
commit | 82f679b064784213591b460fc5eaa1f5f196fbd1 (patch) | |
tree | 58baaf8ee0461d8f481c287223192e78583983f6 /src/jogl/classes/javax | |
parent | fb12b0b6fa37d3a4136bb04597b3c32b15832c82 (diff) |
Bug 975 - GLJPanel's OffscreenDrawable shall not double swap - Use default auto-swap mechanims
Refines commit 908ebd99d1eb57ce773a1fdd67c76886da86b9e6
Note that the test case decide whether to auto-swap (after read-pixels)
or not auto-swap (manual swap before read-pixels).
See UITestCase.swapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps):
Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels.
Usually one uses the default-read-buffer, i.e. GL.GL_FRONT for single-buffer
and GL.GL_BACK for double-buffer GLDrawables
and GL.GL_COLOR_ATTACHMENT0 for offscreen framebuffer objects.
Here swap-buffers shall happen after calling reading pixels, the default.
However, multisampling offscreen GLFBODrawables utilize swap-buffers to downsample
the multisamples into the readable sampling sink.
In this case, we require a swap-buffers before reading pixels.
Returns: chosenCaps.isFBO() && chosenCaps.getSampleBuffers()
+++
- GLJPanel:
- Remove SurfaceUpdatedListener mechanism in favor of
default auto-swap-buffer via GLDrawableHelper.
This removes complexity.
- postGL does not need to perform explicit swapBuffer operation,
but rely on GLDrawableHelper and the default mechanism.
This is also compatible w/ J2D backend.
- Use GLDrawableHelper for setAutoSwapBufferMode(..) and getAutoSwapBufferMode()
+++
UnitTests:
- UITestCase:
- Add 'boolean swapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps)'
to determine whether swapBuffers() must occure before read-pixels. See above.
- GLReadBuffer00Base*
- remove explicit addSnapshotGLEL/removeSnapshotGLEL
- add TextRendererGLEL, to display frame-count and -dimension
- SnapshotGLEL*
- simply toggle auto-swap in their init(..) and dispose(..) method!
- clear back-buffer if 'swapBuffersBeforeRead'
to test whether the right buffer is being used for read-pixels.
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 66a757d10..c80b405b5 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -60,7 +60,6 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -355,7 +354,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.chooser = chooser; helper = new GLDrawableHelper(); - helper.setAutoSwapBufferMode(false); /** Always handles buffer swapping in Backend! */ if( null != shareWith ) { helper.setSharedContext(null, shareWith); } @@ -945,18 +943,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void setAutoSwapBufferMode(boolean onOrOff) { - // In the current implementation this is a no-op. - // All Backend's require control of buffer swapping, - // i.e. as required for MSAA offscreen FBO buffer. + public void setAutoSwapBufferMode(boolean enable) { + helper.setAutoSwapBufferMode(enable); } @Override public boolean getAutoSwapBufferMode() { - // In the current implementation this is a no-op. - // All Backend's require control of buffer swapping, - // i.e. as required for MSAA offscreen FBO buffer. - return true; + return helper.getAutoSwapBufferMode(); } @Override @@ -1402,8 +1395,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private volatile GLContextImpl offscreenContext; // volatile: avoid locking for read-only access private boolean flipVertical; - private boolean needsSwapBuffers = true; - // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -1439,12 +1430,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing chooser, panelWidth, panelHeight); offscreenDrawable.setRealized(true); - offscreenDrawable.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { - @Override - public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { - needsSwapBuffers = false; - } } ); - offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]); offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { @@ -1564,7 +1549,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public final boolean preGL(Graphics g) { - needsSwapBuffers = true; + // Empty in this implementation return true; } @@ -1579,6 +1564,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public final void postGL(Graphics g, boolean isDisplay) { if (isDisplay) { + // offscreenDrawable is already swapped, + // either by GLDrawableHelper.invoke or user's GLEL according to auto-swap-buffer-mode. + final GL gl = offscreenContext.getGL(); final int componentCount; @@ -1666,10 +1654,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); } - if( needsSwapBuffers ) { - offscreenDrawable.swapBuffers(); - } - if(null != glslTextureRaster) { // implies flippedVertical final boolean viewportChange; final int[] usrViewport = new int[] { 0, 0, 0, 0 }; |