diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java | 114 |
1 files changed, 37 insertions, 77 deletions
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java index c6eb15f..a308368 100644 --- a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java +++ b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java @@ -118,7 +118,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline private static final boolean MINIMISE_NATIVE_CALLS_OTHER = true; // This MUST be true on android fullscreen - // setPostiion on a GLWindow can lock-up if true + // setPosition on a GLWindow can lock-up if true + // also with on and offscreen must be false too private static final boolean NEVER_RELEASE_CONTEXT = false; /** @@ -3734,28 +3735,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline if ((type & Raster.RASTER_COLOR) != 0) { - int oglFormat = 0; + int format = 0; if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) { switch (imageFormat) { case ImageComponentRetained.TYPE_BYTE_BGR: - oglFormat = GL2ES2.GL_BGR; + format = GL2ES2.GL_BGR; break; case ImageComponentRetained.TYPE_BYTE_RGB: - oglFormat = GL2ES2.GL_RGB; + format = GL2ES2.GL_RGB; break; case ImageComponentRetained.TYPE_BYTE_ABGR: - oglFormat = GL2ES2.GL_RGBA; + format = GL2ES2.GL_RGBA; break; case ImageComponentRetained.TYPE_BYTE_RGBA: // all RGB types are stored as RGBA - oglFormat = GL2ES2.GL_RGBA; + format = GL2ES2.GL_RGBA; break; case ImageComponentRetained.TYPE_BYTE_LA: // all LA types are stored as LA8 - oglFormat = GL2ES2.GL_LUMINANCE_ALPHA; + format = GL2ES2.GL_LUMINANCE_ALPHA; break; case ImageComponentRetained.TYPE_BYTE_GRAY: case ImageComponentRetained.TYPE_USHORT_GRAY: @@ -3767,32 +3768,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline return; } - gl.glReadPixels(xSrcOffset, yAdjusted, width, height, oglFormat, GL.GL_UNSIGNED_BYTE, + gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[]) imageBuffer)); if (DO_OUTPUT_ERRORS) outputErrors(ctx); } else if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { - int intType = GL2.GL_UNSIGNED_INT_8_8_8_8; - //boolean forceAlphaToOne = false; - switch (imageFormat) { - /* GL_BGR */ - case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */ - oglFormat = GL.GL_RGBA; - intType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; - //forceAlphaToOne = true; + case ImageComponentRetained.TYPE_INT_BGR: + //PJ does this work correctly? + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_RGB: + format = GL2ES2.GL_RGB; break; - case ImageComponentRetained.TYPE_INT_RGB: /* Assume XRGB format */ - //forceAlphaToOne = true; - /* Fall through to next case */ case ImageComponentRetained.TYPE_INT_ARGB: - oglFormat = GL2.GL_BGRA; - intType = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; + format = GL2ES2.GL_RGBA; break; - /* This method only supports 3 and 4 components formats and INT types. */ + // This method only supports 3 and 4 components formats and INT types. case ImageComponentRetained.TYPE_BYTE_LA: case ImageComponentRetained.TYPE_BYTE_GRAY: case ImageComponentRetained.TYPE_USHORT_GRAY: @@ -3805,22 +3800,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline return; } - // Force Alpha to 1.0 if needed - //if (forceAlphaToOne - //{ - // gl.glPixelTransferf(GL2.GL_ALPHA_SCALE, 0.0f); - // gl.glPixelTransferf(GL2.GL_ALPHA_BIAS, 1.0f); - //} - - gl.glReadPixels(xSrcOffset, yAdjusted, width, height, oglFormat, intType, IntBuffer.wrap((int[]) imageBuffer)); + gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, IntBuffer.wrap((int[]) imageBuffer)); if (DO_OUTPUT_ERRORS) outputErrors(ctx); - // Restore Alpha scale and bias - //if (forceAlphaToOne) - //{ - // gl.glPixelTransferf(GL2.GL_ALPHA_SCALE, 1.0f); - // gl.glPixelTransferf(GL2.GL_ALPHA_BIAS, 0.0f); - //} } else @@ -5934,22 +5916,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) { - int type = GL2.GL_UNSIGNED_INT_8_8_8_8; - boolean forceAlphaToOne = false; switch (imageFormat) { - /* GL_BGR */ - case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */ - format = GL2ES2.GL_RGBA; - type = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; - forceAlphaToOne = true; + case ImageComponentRetained.TYPE_INT_BGR: + //PJ does this work correctly? + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_RGB: + format = GL2ES2.GL_RGB; break; - case ImageComponentRetained.TYPE_INT_RGB: /* Assume XRGB format */ - forceAlphaToOne = true; - /* Fall through to next case */ case ImageComponentRetained.TYPE_INT_ARGB: - format = GL2ES2.GL_BGRA; - type = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; + format = GL2ES2.GL_RGBA; break; // This method only supports 3 and 4 components formats and INT types. case ImageComponentRetained.TYPE_BYTE_LA: @@ -5964,21 +5941,15 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline return; } - if (forceAlphaToOne) - { - // this is probably fine - // new Throwable("forceAlphaToOne").printStackTrace(); - } - if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { - gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, type, IntBuffer.wrap((int[]) data)); + gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE, IntBuffer.wrap((int[]) data)); if (DO_OUTPUT_ERRORS) outputErrors(ctx); } else { - gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, type, (Buffer) data); + gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE, (Buffer) data); if (DO_OUTPUT_ERRORS) outputErrors(ctx); } @@ -6110,22 +6081,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) { int format = 0; - int type = GL2.GL_UNSIGNED_INT_8_8_8_8; - boolean forceAlphaToOne = false; switch (imageFormat) { - // GL_BGR - case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */ - format = GL2ES2.GL_RGBA; - type = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; - forceAlphaToOne = true; + case ImageComponentRetained.TYPE_INT_BGR: + //PJ does this work correctly? + format = GL2ES2.GL_RGB; + break; + case ImageComponentRetained.TYPE_INT_RGB: + format = GL2ES2.GL_RGB; break; - case ImageComponentRetained.TYPE_INT_RGB: /* Assume XRGB format */ - forceAlphaToOne = true; - /* Fall through to next case */ case ImageComponentRetained.TYPE_INT_ARGB: - format = GL2ES2.GL_BGRA; - type = GL2.GL_UNSIGNED_INT_8_8_8_8_REV; + format = GL2ES2.GL_RGBA; break; // This method only supports 3 and 4 components formats and INT types. case ImageComponentRetained.TYPE_BYTE_LA: @@ -6140,12 +6106,6 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline return; } - if (forceAlphaToOne) - { - //Probably fine - //new Throwable("forceAlphaToOne").printStackTrace(); - } - IntBuffer buf = null; if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { @@ -6158,7 +6118,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline // offset by the imageOffset buf.position(tilew * imgYOffset + imgXOffset); - gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, buf); + gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, buf); if (DO_OUTPUT_ERRORS) outputErrors(ctx); } @@ -7021,8 +6981,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline private static void checkGLSLShaderExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean hasgl13) { - //PJPJ GL2ES2 MUST support shaders, and the support is NOT an extension - // Force shaders to be disabled, since no multitexture support + //PJPJ Gl2ES2 MUST support shaders, and the support is NOT an extension + // Force shaders to be disabled, since no multitexture support // if (!hasgl13) // return; |