diff options
author | Chien Yang <[email protected]> | 2007-02-20 16:59:05 +0000 |
---|---|---|
committer | Chien Yang <[email protected]> | 2007-02-20 16:59:05 +0000 |
commit | 06f4f82c18649fa3d32ca540061c13573dd81861 (patch) | |
tree | 045f8efa67efabb5a06de3626470f65cf9111ea2 /src | |
parent | 18bb2c758c8c70e6393f2b7ad7fe3205b401e26a (diff) |
Fixed Issue 416 : JOGL: ClassCastException in Renderer with NioImageBuffer
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@778 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/jogl/javax/media/j3d/JoglPipeline.java | 91 |
1 files changed, 74 insertions, 17 deletions
diff --git a/src/classes/jogl/javax/media/j3d/JoglPipeline.java b/src/classes/jogl/javax/media/j3d/JoglPipeline.java index 7fb5c4b..8a16114 100644 --- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java +++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java @@ -12,6 +12,7 @@ package javax.media.j3d; +import com.sun.j3d.internal.ByteBufferWrapper; import java.awt.*; import java.io.*; import java.lang.reflect.*; @@ -5771,7 +5772,6 @@ class JoglPipeline extends Pipeline { int boundaryWidth, int dataType, Object data) { - /* TODO Chien : Need to support INT, and NIO buffers */ if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DImage()"); GL gl = context(ctx).getGL(); @@ -5858,11 +5858,20 @@ class JoglPipeline extends Pipeline { return; } + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) { + gl.glTexImage3D(GL.GL_TEXTURE_3D, level, internalFormat, width, height, depth, boundaryWidth, format, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[]) data)); - + } + else { + gl.glTexImage3D(GL.GL_TEXTURE_3D, + level, internalFormat, + width, height, depth, boundaryWidth, + format, GL.GL_UNSIGNED_BYTE, (ByteBuffer) data); + } + } else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) { @@ -5899,10 +5908,17 @@ class JoglPipeline extends Pipeline { gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f); } - gl.glTexImage3D(GL.GL_TEXTURE_3D, - level, internalFormat, - width, height, depth, boundaryWidth, - format, type, IntBuffer.wrap((int[]) data)); + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { + gl.glTexImage3D(GL.GL_TEXTURE_3D, + level, internalFormat, + width, height, depth, boundaryWidth, + format, type, IntBuffer.wrap((int[]) data)); + } else { + gl.glTexImage3D(GL.GL_TEXTURE_3D, + level, internalFormat, + width, height, depth, boundaryWidth, + format, type, (Buffer) data); + } /* Restore Alpha scale and bias */ if(forceAlphaToOne) { @@ -6031,9 +6047,16 @@ class JoglPipeline extends Pipeline { default: assert false; return; - } + } - ByteBuffer buf = ByteBuffer.wrap((byte[]) data); + ByteBuffer buf = null; + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) { + buf = ByteBuffer.wrap((byte[]) data); + } + else { + buf = (ByteBuffer) data; + } + int offset = (tilew * tileh * imgZOffset + tilew * imgYOffset + imgXOffset) * numBytes; buf.position(offset); @@ -6079,7 +6102,14 @@ class JoglPipeline extends Pipeline { gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f); } - IntBuffer buf = IntBuffer.wrap((int[]) data); + IntBuffer buf = null; + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { + buf = IntBuffer.wrap((int[]) data); + } + else { + buf = (IntBuffer) data; + } + int offset = tilew * tileh * imgZOffset + tilew * imgYOffset + imgXOffset; buf.position(offset); @@ -6387,9 +6417,17 @@ class JoglPipeline extends Pipeline { return; } - gl.glTexImage2D(target, level, internalFormat, - width, height, boundaryWidth, - format, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[]) data)); + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) { + + gl.glTexImage2D(target, level, internalFormat, + width, height, boundaryWidth, + format, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[])data)); + } + else { + gl.glTexImage2D(target, level, internalFormat, + width, height, boundaryWidth, + format, GL.GL_UNSIGNED_BYTE, (Buffer) data); + } } else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) { @@ -6427,9 +6465,16 @@ class JoglPipeline extends Pipeline { gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f); } - gl.glTexImage2D(target, level, internalFormat, - width, height, boundaryWidth, - format, type, IntBuffer.wrap((int[]) data)); + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { + gl.glTexImage2D(target, level, internalFormat, + width, height, boundaryWidth, + format, type, IntBuffer.wrap((int[])data)); + } + else { + gl.glTexImage2D(target, level, internalFormat, + width, height, boundaryWidth, + format, type, (Buffer) data); + } /* Restore Alpha scale and bias */ if(forceAlphaToOne) { @@ -6553,7 +6598,13 @@ class JoglPipeline extends Pipeline { return; } - ByteBuffer buf = ByteBuffer.wrap((byte[]) data); + ByteBuffer buf = null; + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) { + buf = ByteBuffer.wrap((byte[]) data); + } + else { + buf = (ByteBuffer) data; + } // offset by the imageOffset buf.position((tilew * imgYOffset + imgXOffset) * numBytes); @@ -6595,7 +6646,13 @@ class JoglPipeline extends Pipeline { gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f); } - IntBuffer buf = IntBuffer.wrap((int[]) data); + IntBuffer buf = null; + if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) { + buf = IntBuffer.wrap((int[]) data); + } + else { + buf = (IntBuffer) data; + } // offset by the imageOffset buf.position(tilew * imgYOffset + imgXOffset); |