gluScaleImage problems

As one of my first experiments with jogl, I decided to port a md2 loader from one of the c++ tutorials I had read. Everything works fine except for one part where gluScaleImage is used to scale non-standard texture sizes to a power of two. Whenever my program gets to that statement, I get the error:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [F
      at net.java.games.jogl.impl.GLUImpl.gluScaleImageJava(GLUImpl.java:494)
      at net.java.games.jogl.impl.GLUImpl.gluScaleImage(GLUImpl.java:959)
      at MD2Model.LoadPCXTexture(MD2Model.java:737)
      at MD2Model.LoadTexture(MD2Model.java:486)
      at MD2Model.load(MD2Model.java:166)
      at GLPanel1.init(GLPanel1.java:53)
      at net.java.games.jogl.impl.GLDrawableHelper.init(GLDrawableHelper.java:68)
      at net.java.games.jogl.GLCanvas$InitAction.run(GLCanvas.java:234)
      at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(WindowsGLContext.java:168)
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:129)
      at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:246)
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.invokeGL(WindowsOnscreenGLContext.java:76)
      at net.java.games.jogl.GLCanvas$2.run(GLCanvas.java:122)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

at this line:

myGLU.gluScaleImage (GL.GL_RGBA, thisTexture.width, thisTexture.height, GL.GL_UNSIGNED_BYTE, unscaledData, thisTexture.scaledWidth, thisTexture.scaledHeight, GL.GL_UNSIGNED_BYTE, thisTexture.data);

With textures that don’t need resizing, the rest of the code works fine by just copying unscaledData onto thisTexture.data. (both are arrays of floats to hold the texture data) Any input would be greatly appreciated

-Ben

Hi,

in the new release of jogl (1.1 b09) the signature of the gluScaleImage() method changed. Now it needs an array instead on a Buffer. Maybe this causes your ClassCastException.

Regards

Torsten

Nope, I store my data in arrays of floats. With the classcast exception, I tried changing the format of the arrays, but I got the exception on everything except for bytes, which are too small to hold the data.

There is definitely a bug here in the recent Java port of the GLU routines. Do you have a test case which shows the correct and incorrect behavior? Could you please file a bug with the JOGL Issue Tracker and attach it? I’d like to confirm that the bug fix is correct. Thanks.

FYI, a bug fix that seems correct was just checked in and will be present in the next JOGL beta. You can temporarily switch back to the old C implementation of the GLU routines by specifying the system property -Djogl.glu.nojava on the command line. If you have the ability to build the source tree to confirm the bug fix before the next beta comes out that would be really helpful. Thanks for pointing out the problem.

Well, unfortunately right now I don’t have the time to figure out how to build the source tree, but I’ll definately check it with the next beta. Do you still want my code?

Yes, if you could file a bug with the JOGL Issue Tracker (request Observer status and once granted open a bug) and attach your test case that would be great. Thanks.