diff options
author | Sven Gothel <[email protected]> | 2013-04-18 03:16:33 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-04-18 03:16:33 +0200 |
commit | fd418a69eca7b8c1bb74244982305fc6004d0a52 (patch) | |
tree | 8497ba7ce287b3295e6be8e2344e701cdb7c90e7 /src/jogl/classes/javax/media/opengl/awt | |
parent | 3cc6fd350fe56ac5b344ee75cfa8bfe4dcc44f1b (diff) |
Fix Bug 720: Unify all platform specific GLContextImpl specializations; Fix Bug 719 - Windows BITMAP Offscreen Orientation is not propagated through API
Fix Bug 719 - Windows BITMAP Offscreen Orientation is not propagated through API
Depends on Bug 720, since cleaning up GLContextImpl* is required to move
property 'GLContext.isGLOrientationFlippedVertical()'
to 'GLDrawable.isGLOriented()' where it belongs!
Windows BITMAP GLDrawable impl. isGLOriented() shall return false,
while we keep the BITMAPINFOHEADER's height field negative
to remove the need for vertical flip when used w/ AWT or Windows, ..
Then property 'GLDrawable.isGLOriented()' has to be recognized throughout the
utility functions, i.e. TextureData's mustFlipVertically and hence TextureIO writer.
Fix Bug 720: Unify all platform specific GLContextImpl specializations
GLContextImpl shall have only _one_ unique platform derivative
to allow proper swapping of GLDrawables of any type via:
- 'GLAutoDrawable.setContext(GLContext newCtx, boolean destroyPrevCtx)', which calls
- 'GLContext.setGLDrawable(GLDrawable readWrite, boolean setWriteOnly)'
Exception: External context may be specialized.
All drawable specific property handling shall be provided
and implemented (if possible) via GLDrawable specializations.
- GLContext.isGLOrientationFlippedVertical() -> GLDrawable.isGLOriented()
- PNGImage.createFromData() takes 'isGLOriented' to properly handle vertical flipping simply by line ordering
- TextureIO's PNG writer passes TextureData's getMustFlipVertically() as isGLOriented to PNGImage.createFromData()
- GLReadBufferUtil respects GLDrawable's isGLOriented() when creating TextureData instance.
- Screenshot respects GLDrawable's isGLOriented()
- Screenshot is deprecated, use GLReadBufferUtil.
- Removed all PBuffer attributes, i.e. floatingPoint, RenderToTexture and RenderToTextureRectangle.
- Allows removal of special pbuffer handling in GLContext* implementations.
- Removed also from GLCapabilities*
- Removed from deprecated GLPbuffer
Impact:
- Low, users who desire to render into a texture shall use our FBO GLOffscreenDrawable.
- Only use case was the deprecated GLPbuffer
- floating point framebuffer technology is still patented anyways :)
- Removed Java2DGLContext, which was only used for OSX's GLJPanel Java2D bridge,
which is no more supported anyways.
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 6 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 40 |
2 files changed, 20 insertions, 26 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c1d5fb1d2..b7a24a777 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -887,6 +887,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override + public boolean isGLOriented() { + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.isGLOriented() : true; + } + + @Override public NativeSurface getNativeSurface() { final GLDrawable _drawable = drawable; return (null != _drawable) ? _drawable.getNativeSurface() : null; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index e82ad54c3..6ef695319 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -83,17 +83,12 @@ import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.awt.Java2D; -import jogamp.opengl.awt.Java2DGLContext; import jogamp.opengl.util.glsl.GLSLTextureRaster; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLPixelStorageModes; -// FIXME: Subclasses need to call resetGLFunctionAvailability() on their -// context whenever the displayChanged() function is called on their -// GLEventListeners - /** A lightweight Swing component which provides OpenGL rendering support. Provided for compatibility with Swing user interfaces when adding a heavyweight doesn't work either because of @@ -627,6 +622,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override + public boolean isGLOriented() { + if(null != backend) { + return backend.getDrawable().isGLOriented(); + } + return true; + } + + @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { return backend.getChosenGLCapabilities(); } @@ -916,7 +919,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final int fboTextureUnit = 0; private GLContextImpl offscreenContext; - private boolean flippedVertical; + private boolean flipVertical; // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -941,9 +944,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { isInitialized = true; final GL gl = offscreenContext.getGL(); - flippedVertical = offscreenContext.isGLOrientationFlippedVertical(); + flipVertical = offscreenDrawable.isGLOriented(); final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); - if( USE_GLSL_TEXTURE_RASTERIZER && chosenCaps.isFBO() && flippedVertical && gl.isGL2ES2() ) { + if( USE_GLSL_TEXTURE_RASTERIZER && chosenCaps.isFBO() && flipVertical && gl.isGL2ES2() ) { final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode(); helper.setAutoSwapBufferMode(false); final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable; @@ -1054,14 +1057,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing 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) { + if(!flipVertical || null != glslTextureRaster) { final int[] readBackIntBuffer = ((DataBufferInt) offscreenImage.getRaster().getDataBuffer()).getData(); readBackInts = IntBuffer.wrap(readBackIntBuffer); } else { readBackInts = IntBuffer.allocate(readBackWidthInPixels * readBackHeightInPixels); } if(DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flippedVertical+", glslTextureRaster "+(null!=glslTextureRaster)); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", 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()); } @@ -1101,7 +1104,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } else { gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, glFormat, glType, readBackInts); - if ( flippedVertical ) { + if ( flipVertical ) { // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases // where !offscreenContext.offscreenImageNeedsVerticalFlip(), @@ -1641,28 +1644,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println("-- Created External Drawable: "+joglDrawable); System.err.println("-- Created Context: "+joglContext); } - } else if (factory.canCreateContextOnJava2DSurface(device)) { - // Mac OS X code path - joglContext = factory.createContextOnJava2DSurface(g, j2dContext); - if (DEBUG) { - System.err.println("-- Created Context: "+joglContext); - } } - /*if (DEBUG) { - joglContext.setGL(new DebugGL2(joglContext.getGL().getGL2())); - }*/ - if (Java2D.isFBOEnabled() && Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT && fbObjectWorkarounds) { createNewDepthBuffer = true; } } - if (joglContext instanceof Java2DGLContext) { - // Mac OS X code path - ((Java2DGLContext) joglContext).setGraphics(g); - } - helper.invokeGL(joglDrawable, joglContext, updaterDisplayAction, updaterInitAction); } } finally { |