diff options
author | Sven Gothel <[email protected]> | 2013-04-27 01:45:14 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-04-27 01:45:14 +0200 |
commit | 29e5caf61c1e09d2b225f4d42f5a384dd6eef9a8 (patch) | |
tree | 1a36b7444b1cb29d5829beab095d3a3ed1ce6390 /src/jogl/classes | |
parent | 94ea306d1809290db678d3181619bdc39d4334bb (diff) |
Complete commit e7064ece049705e013d80985eae698ce0ee3c4e3: Add getDefaultPixelDataFormat(), complementing getDefaultPixelDataType()
Diffstat (limited to 'src/jogl/classes')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLContext.java | 3 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 66 |
2 files changed, 40 insertions, 29 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 288329310..95342d455 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1040,6 +1040,9 @@ public abstract class GLContext { /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataType(); + /** Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ + public abstract int getDefaultPixelDataFormat(); + /** * @return The extension implementing the GLDebugOutput feature, * either <i>GL_ARB_debug_output</i> or <i>GL_AMD_debug_output</i>. diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index b947bd693..bd2d21cc9 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -107,6 +107,9 @@ public abstract class GLContextImpl extends GLContext { protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; + private volatile boolean pixelDataEvaluated; + private int /* pixelDataInternalFormat, */ pixelDataFormat, pixelDataType; + protected GL gl; protected static final Object mappedContextTypeObjectLock; @@ -175,6 +178,8 @@ public abstract class GLContextImpl extends GLContext { boundFBOTarget[0] = 0; // draw boundFBOTarget[1] = 0; // read } + + pixelDataEvaluated = false; super.resetStates(); } @@ -1807,40 +1812,43 @@ public abstract class GLContextImpl extends GLContext { @Override public int getDefaultPixelDataType() { - if(!pixelDataTypeEvaluated) { - synchronized(this) { - if(!pixelDataTypeEvaluated) { - evalPixelDataType(); - pixelDataTypeEvaluated = true; - } - } - } + evalPixelDataType(); return pixelDataType; } - private volatile boolean pixelDataTypeEvaluated = false; - int /* pixelDataInternalFormat, */ pixelDataFormat, pixelDataType; + @Override + public int getDefaultPixelDataFormat() { + evalPixelDataType(); + return pixelDataFormat; + } private final void evalPixelDataType() { - /* if(isGL2GL3() && 3 == components) { - pixelDataInternalFormat=GL.GL_RGB; - pixelDataFormat=GL.GL_RGB; - pixelDataType = GL.GL_UNSIGNED_BYTE; - } else */ if(isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format)) { - final int[] glImplColorReadVals = new int[] { 0, 0 }; - gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0); - gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); - // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; - pixelDataFormat = glImplColorReadVals[0]; - pixelDataType = glImplColorReadVals[1]; - } else { - // RGBA read is safe for all GL profiles - // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; - pixelDataFormat=GL.GL_RGBA; - pixelDataType = GL.GL_UNSIGNED_BYTE; - } - // TODO: Consider: - // return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; + if(!pixelDataEvaluated) { + synchronized(this) { + if(!pixelDataEvaluated) { + /* if(isGL2GL3() && 3 == components) { + pixelDataInternalFormat=GL.GL_RGB; + pixelDataFormat=GL.GL_RGB; + pixelDataType = GL.GL_UNSIGNED_BYTE; + } else */ if(isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format)) { + final int[] glImplColorReadVals = new int[] { 0, 0 }; + gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0); + gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); + // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; + pixelDataFormat = glImplColorReadVals[0]; + pixelDataType = glImplColorReadVals[1]; + } else { + // RGBA read is safe for all GL profiles + // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; + pixelDataFormat=GL.GL_RGBA; + pixelDataType = GL.GL_UNSIGNED_BYTE; + } + // TODO: Consider: + // return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; + pixelDataEvaluated = true; + } + } + } } //---------------------------------------------------------------------- |