AssertionError GLU gluScaleImage

Hi. I’m using gluScaleImage and I received the following AssertionErrror:

     [java] java.lang.AssertionError
     [java]     at net.java.games.jogl.impl.mipmap.Image.fill_image(Image.java:359)
     [java]     at net.java.games.jogl.impl.mipmap.Mipmap.gluScaleImage(Mipmap.java:560)
     [java]     at net.java.games.jogl.impl.GLUImpl.gluScaleImageJava(GLUImpl.java:515)
     [java]     at net.java.games.jogl.impl.GLUImpl.gluScaleImage(GLUImpl.java:973)
     ...

Does anyone know what the condition for this assertion is?

Thanks,
Andrew

This looks like a bug in either SGI’s original sources for the GLU mipmap code or in the Java port of these sources. Could you please provide the image you’re building mipmaps for and the snippet of code you’re using to build the mipmaps? Or could you file a bug with the Issue Tracker on the JOGL home page and attach them?

You can find the sources in the jogl-src.zip archive for the release you’re using. However you’re using a pretty old release at this point and I’d recommend upgrading to either JSR-231 beta 2 or one of the current nightly builds. However I don’t know whether this will fix your problem. There have been a couple of bug fixes to the Java port of the GLU mipmap code since the release you’re working with.

You may be able to work around this with the command-line argument -Djogl.glu.nojava .

Ken, hi.

I just looked at the source for net.java.games.jogl.impl.mipmap.Image and I’m still not sure what is wrong. The fact that this is an assertion and not, say, a NullPointerException leads me to suspect that I’m not using this routine in the expected manner. The image being scaled is arbitrary, but it will contain normalized 16bit grayscale values in every case. Here are the arguments I’m specifying to gluScaleImage:

        int error = 
          glu.gluScaleImage(
            GL.GL_LUMINANCE, // format
            origWidth,
            origHeight,
            GL.GL_FLOAT,     // data type
            srcBuffer,
            newWidth,
            newHeight,
            GL.GL_FLOAT,
            destBuffer );

Where srcBuffer is a ByteBuffer containing normalized float data and has a capacity of origWidthorigHeight4 and destBuffer is a ByteBuffer containing float data ans has a capacity of newWidthnewHeight4.

Here is the assertion in the jogl src at the end of the Image.fill_image method:

      // iterators should be one byte past end
      if( !Mipmap.isTypePackedPixel( type ) ) {
        assert( iter2 == ( width * height * components ) );

Perhaps I should try this with integral values instead?

The GLU mipmap implementation in JOGL is a straight port of the original C sources from SGI’s open-source GLU implementation. However some bugs were introduced during this port (it’s a lot of code) and there were some bugs in the original code as well. It would be best if you could supply the image that is causing the problems. It really sounds like there is a bug in the Java port of this code.