summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJulian Ibarz <[email protected]>2012-11-23 20:30:13 -0800
committerHarvey Harrison <[email protected]>2012-11-23 20:30:13 -0800
commit51f8fa18eb65a3a95a163bef71fcfffb49063be6 (patch)
treeb4675775e3b37efd3bcb8a1a5de99ea1cda396c4 /src
parentaeaf36684124a82eb30ab13de3d4f6ceff071bd4 (diff)
j3dcore: avoid null pointer when reading raster depth-only from Canvas3d
Taken from java3d issue 593: When I'm reading the z-buffer with a Raster, a NullPointerException occurs (in fact, two). This is because the image raster is accessed whereas is not initialized, and also because we send the depthComp to the native readRaster function instead of the real buffer (i named it depthBuffer). Also the destination offset is send to the native readRaster function instead of source offset. I made a very light patch that corrects this bugs. Signed-off-by: Julian Ibarz <[email protected]> Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/classes/share/javax/media/j3d/GraphicsContext3D.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/classes/share/javax/media/j3d/GraphicsContext3D.java b/src/classes/share/javax/media/j3d/GraphicsContext3D.java
index f37686d..b0919eb 100644
--- a/src/classes/share/javax/media/j3d/GraphicsContext3D.java
+++ b/src/classes/share/javax/media/j3d/GraphicsContext3D.java
@@ -2332,20 +2332,33 @@ public class GraphicsContext3D extends Object {
canvas3d.makeCtxCurrent();
canvas3d.syncRender(canvas3d.ctx, true);
Point rasterSrcOffset = new Point();
- ras.getDstOffset(rasterSrcOffset);
+ ras.getSrcOffset(rasterSrcOffset);
DepthComponentRetained depthComp = ras.depthComponent;
int depthType = 0;
+ Object depthBuffer = null;
if(depthComp != null) {
depthType = depthComp.type;
+ depthBuffer = (depthType == DepthComponentRetained.DEPTH_COMPONENT_TYPE_FLOAT) ? floatBuffer : intBuffer;
}
+
+ int imageDataType = 0;
+ int imageFormatType = 0;
+ Object imageBuffer = null;
+
+ if ( (ras.type & Raster.RASTER_COLOR) != 0) {
+ imageDataType = image.getImageDataTypeIntValue();
+ imageFormatType = image.getImageFormatTypeIntValue(false);
+ imageBuffer = image.imageData.get();
+ }
+
Pipeline.getPipeline().readRaster(canvas3d.ctx,
ras.type, rasterSrcOffset.x, rasterSrcOffset.y,
rasterSize.width, rasterSize.height, canvasSize.height,
- image.getImageDataTypeIntValue(),
- image.getImageFormatTypeIntValue(false),
- image.imageData.get(),
- depthType, depthComp);
+ imageDataType,
+ imageFormatType,
+ imageBuffer,
+ depthType, depthBuffer);
canvas3d.drawingSurfaceObject.unLock();
}