Issue Details (XML | Word | Printable)

Key: JAVA3D-593
Type: Task Task
Status: Open Open
Priority: Blocker Blocker
Assignee: java3d-issues
Reporter: tanek
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
java3d

GraphicsContext3D.doReadRaster throws two NullPointerException when reading z-buffer and the source offset is buggy

Created: 21/Aug/08 02:34 AM   Updated: 21/Aug/08 02:41 AM
Component/s: j3d-core
Affects Version/s: 1.5.2
Fix Version/s: not determined

Time Tracking:
Not Specified

File Attachments: 1. Java Source File RasterBugReport.java (4 kB) 21/Aug/08 02:41 AM - tanek
2. Text File zbuffer.patch (2 kB) 21/Aug/08 02:37 AM - tanek

Environment:

Operating System: All
Platform: All


Issuezilla Id: 593
Tags:
Participants: java3d-issues and tanek


 Description  « Hide

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



tanek added a comment - 21/Aug/08 02:36 AM

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();
}


tanek added a comment - 21/Aug/08 02:37 AM

Created an attachment (id=367)
The patch file


tanek added a comment - 21/Aug/08 02:40 AM

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:


tanek added a comment - 21/Aug/08 02:41 AM

Created an attachment (id=368)
The test program