From 59a1ab0312492a251a0efc700d040a5f71e88611 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 8 Mar 2013 22:36:44 +0100 Subject: GLJPanel: Add DEBUG_VIEWPORT flag, Add USE_GLSL_TEXTURE_RASTERIZER flag, DEBUG reshape trace. - Add DEBUG_VIEWPORT flag Via explicit property 'jogl.debug.GLJPanel.Viewport' (not via jogl.debug=all) Traces the current GL Viewport in OffscreenBackend.postGL(..) - Add USE_GLSL_TEXTURE_RASTERIZER flag Via explicit property 'jogl.gljpanel.noglsl'. Disables use of GLSL FBO flipping. DEBUG reshape trace --- .../classes/javax/media/opengl/awt/GLJPanel.java | 67 ++++++++++++++-------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'src/jogl') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 6c28c75ab..5f9551610 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -124,6 +124,8 @@ import com.jogamp.opengl.util.GLPixelStorageModes; @SuppressWarnings("serial") public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("GLJPanel"); + private static final boolean DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); + private static final boolean USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); private GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; @@ -139,13 +141,23 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private GLContext shareWith; private int additionalCtxCreationFlags = 0; - // Width of the actual GLJPanel - private int panelWidth = 0; - private int panelHeight = 0; - // Lazy reshape notification + // Lazy reshape notification: reshapeWidth -> panelWidth -> backend.width private boolean handleReshape = false; private boolean sendReshape = true; + // For handling reshape events lazily: reshapeWidth -> panelWidth -> backend.width + private int reshapeWidth; + private int reshapeHeight; + + // Width of the actual GLJPanel: reshapeWidth -> panelWidth -> backend.width + private int panelWidth = 0; + private int panelHeight = 0; + + // These are always set to (0, 0) except when the Java2D / OpenGL + // pipeline is active + private int viewportX; + private int viewportY; + // The backend in use private Backend backend; @@ -157,17 +169,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing Java2D.isOGLPipelineResourceCompatible() && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); - // For handling reshape events lazily - // private int reshapeX; - // private int reshapeY; - private int reshapeWidth; - private int reshapeHeight; - - // These are always set to (0, 0) except when the Java2D / OpenGL - // pipeline is active - private int viewportX; - private int viewportY; - private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override @@ -401,6 +402,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); + if (DEBUG) { + System.err.println(getThreadName()+": GLJPanel.reshape: " +reshapeWidth+"x"+reshapeHeight + " -> " + width+"x"+height); + } // reshapeX = x; // reshapeY = y; reshapeWidth = width; @@ -659,6 +663,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return; } + if (DEBUG) { + System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " +panelWidth+"x"+panelHeight + " -> " + reshapeWidth+"x"+reshapeHeight); + } // Pull down reshapeWidth and reshapeHeight into panelWidth and // panelHeight eagerly in order to complete initialization, and // force a reshape later @@ -691,14 +698,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } private boolean handleReshape() { + if (DEBUG) { + System.err.println(getThreadName()+": GLJPanel.handleReshape: " +panelWidth+"x"+panelHeight + " -> " + reshapeWidth+"x"+reshapeHeight); + } panelWidth = reshapeWidth; panelHeight = reshapeHeight; - if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.handleReshape: (w,h) = (" + - panelWidth + "," + panelHeight + ")"); - } - return backend.handleReshape(); } @@ -931,7 +936,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final GL gl = offscreenContext.getGL(); flippedVertical = offscreenContext.isGLOrientationFlippedVertical(); final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); - if( chosenCaps.isFBO() && flippedVertical && gl.isGL2ES2() ) { + if( USE_GLSL_TEXTURE_RASTERIZER && chosenCaps.isFBO() && flippedVertical && gl.isGL2ES2() ) { + final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode(); helper.setAutoSwapBufferMode(false); final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable; try { @@ -951,7 +957,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if(null != fboFlipped) { fboFlipped.destroy(gl); fboFlipped = null; - } + } + helper.setAutoSwapBufferMode(_autoSwapBufferMode); } } else { fboFlipped = null; @@ -1039,21 +1046,28 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing glFormat = GL.GL_BGRA; glType = GL.GL_UNSIGNED_BYTE; // offscreenContext.getDefaultPixelDataType(); + offscreenImage = new BufferedImage(panelWidth, panelHeight, withAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); if(!flippedVertical || null != glslTextureRaster) { - offscreenImage = new BufferedImage(panelWidth, panelHeight, withAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); final int[] readBackIntBuffer = ((DataBufferInt) offscreenImage.getRaster().getDataBuffer()).getData(); readBackInts = IntBuffer.wrap(readBackIntBuffer); } else { - offscreenImage = new BufferedImage(panelWidth, panelHeight, withAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); readBackInts = IntBuffer.allocate(readBackWidthInPixels * readBackHeightInPixels); } if(DEBUG) { - System.err.println(getThreadName()+": OffscreenBackend postGL offscreenImage-init: flippedVertical "+flippedVertical+", glslTextureRaster "+(null!=glslTextureRaster)); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flippedVertical+", glslTextureRaster "+(null!=glslTextureRaster)); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight +", readBackSizeInPixels "+readBackWidthInPixels+"x"+readBackHeightInPixels); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: offscreenImage "+offscreenImage.getWidth()+"x"+offscreenImage.getHeight()); } } final GL gl = offscreenContext.getGL(); + if( DEBUG_VIEWPORT ) { + int[] vp = new int[] { 0, 0, 0, 0 }; + gl.glGetIntegerv(GL.GL_VIEWPORT, vp, 0); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: "+vp[0]+"/"+vp[1]+" "+vp[2]+"x"+vp[3]); + } + // Save current modes psm.setAlignment(gl, 1, 1); if(gl.isGL2GL3()) { @@ -1141,6 +1155,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing offscreenDrawable = _drawableNew; } } + if (DEBUG) { + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.handleReshape: " +panelWidth+"x"+panelHeight + " -> " + _drawable.getWidth()+"x"+_drawable.getHeight()); + } panelWidth = _drawable.getWidth(); panelHeight = _drawable.getHeight(); readBackWidthInPixels = panelWidth; -- cgit v1.2.3