Texture:illegal image size

I know the image has to be a power of 2 for both dimensions. My image is 256x256 but the following still throws the illegal image size exception. Is there some bug I should be aware of?

TextureLoader loader = new TextureLoader(path, this);
ImageComponent2D image = loader.getImage();
System.out.println(image.getWidth() + “x” + image.getHeight());
// this prints out 256x256
Texture2D texture = new Texture2D();
texture.setImage(0, image);
// and here I get:
//Exception in thread “main” java.lang.IllegalArgumentException: Texture:illegal image size
at javax.media.j3d.TextureRetained.checkImageSize(TextureRetained.java:400)
at javax.media.j3d.TextureRetained.initImage(TextureRetained.java:345)
at javax.media.j3d.Texture.setImage(Texture.java:940)
at RotationTesterWithTexture.(RotationTesterWithTexture.java:52)
at RotationTesterWithTexture.main(RotationTesterWithTexture.java:65)

Is there any MediaTracker impl. in the TextureLoader ? this error occurs when the image isn’t fully loaded in vram.

I’m using the built-in TextureLoader for this but I’m fairly certain that it is handling the MediaTracker implementation.

I’m also getting 256x256 printed to the console. Normally I would have seen 0x0 if the image had not been loaded which leads me to believe the tracking is in place.

sounds good… did you check for the IllegalArgumentException for this method ? http://javadesktop.org/lg3d/javadoc/0-7-1-latest/api/org/jdesktop/lg3d/sg/Texture.html#setImage(int,%20org.jdesktop.lg3d.sg.ImageComponent)
It seems not to accept different sizes when the texture is already part of the scene… I’m not Java3D experienced but check for that scene status issue ! :smiley:
Plus it is not true that all sub-classes of Texture will accept the setImage() functionnality, try setDetailedImage() which will better reflect the Texture2D detailed features !

Thanks for the help. The setDetailedImage() worked in the meantime for me to figure some stuff out. I upgraded to Java 6 and the method below magically started workiing. It also supports images that aren’t a power of 2 if your graphics card does too.

public static Texture2D getTexture(String path)
{
TextureLoader texLoader = new TextureLoader(path, null);
Texture2D texture = (Texture2D) texLoader.getTexture();
if (texture == null)
System.out.println("Cannot load texture from " + path);
else {
System.out.println("Loaded texture from " + path);
texture.setEnable(true);
}
return texture;
} // end getTexture