[JAVA3D-593] GraphicsContext3D.doReadRaster throws two NullPointerException when reading z-buffer and the source offset is buggy Created: 21/Aug/08  Updated: 21/Aug/08

Status: Open
Project: java3d
Component/s: j3d-core
Affects Version/s: 1.5.2
Fix Version/s: not determined

Type: Task Priority: Blocker
Reporter: tanek Assignee: java3d-issues
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: Java Source File RasterBugReport.java     Text File zbuffer.patch    
Issuezilla Id: 593

 Description   

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.

The patch has to be applied in j3dcore directory with the command :

patch -p2 < zbuffer.patch

A program that shows the problem is on the



 Comments   
Comment by tanek [ 21/Aug/08 ]

The zbuffer.patch file :

diff --git a/j3d-core/src/classes/share/javax/media/j3d/GraphicsContext3D.java
b/j3d-core/src/classes/share/javax/media/j3d/GraphicsContext3D.java
index 91d175c..65081b2 100644
— a/j3d-core/src/classes/share/javax/media/j3d/GraphicsContext3D.java
+++ b/j3d-core/src/classes/share/javax/media/j3d/GraphicsContext3D.java
@@ -2344,20 +2344,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();
}

Comment by tanek [ 21/Aug/08 ]

Created an attachment (id=367)
The patch file

Comment by tanek [ 21/Aug/08 ]

The stack trace :

Exception occurred during Canvas3D callback:
java.lang.NullPointerException
at
javax.media.j3d.GraphicsContext3D.doReadRaster(GraphicsContext3D.java:2354)
at javax.media.j3d.GraphicsContext3D.readRaster(GraphicsContext3D.java:2253)
at
org.jcae.viewer3d.test.RasterBugReport$1.postSwap(RasterBugReport.java:98)
at javax.media.j3d.Renderer.doWork(Renderer.java:291)
at javax.media.j3d.J3dThread.run(J3dThread.java:275)
Exception occurred during Canvas3D callback:

Comment by tanek [ 21/Aug/08 ]

Created an attachment (id=368)
The test program

Generated at Fri Jul 29 07:33:17 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.