java3d
  1. java3d
  2. JAVA3D-593

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

    Details

    • Type: Task Task
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 1.5.2
    • Fix Version/s: not determined
    • Component/s: j3d-core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • 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

      1. RasterBugReport.java
        4 kB
        tanek
      2. zbuffer.patch
        2 kB
        tanek

        Activity

        Hide
        tanek added a comment -

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

        Show
        tanek added a comment - 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(); }
        Hide
        tanek added a comment -

        Created an attachment (id=367)
        The patch file

        Show
        tanek added a comment - Created an attachment (id=367) The patch file
        Hide
        tanek added a comment -

        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:

        Show
        tanek added a comment - 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:
        Hide
        tanek added a comment -

        Created an attachment (id=368)
        The test program

        Show
        tanek added a comment - Created an attachment (id=368) The test program

          People

          • Assignee:
            java3d-issues
            Reporter:
            tanek
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: