From 29e5caf61c1e09d2b225f4d42f5a384dd6eef9a8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 27 Apr 2013 01:45:14 +0200 Subject: Complete commit e7064ece049705e013d80985eae698ce0ee3c4e3: Add getDefaultPixelDataFormat(), complementing getDefaultPixelDataType() --- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 66 +++++++++++++---------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl') 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; + } + } + } } //---------------------------------------------------------------------- -- cgit v1.2.3