jME2 does not support non-power-of-2 textures?

Hi,

I run into a weird problem. A have just recently switched from jME1 to jME2 (I know I should do it much earlier:)) and I found out that code which worked is now not working - I mean in runtime, not at compile time (Of course I made changes emerging from jME2 API changes).

The problem I run into is with textures which has not sized of power of 2.



Working code in jME1:


TextureState textureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      Texture sheet = TextureManager.loadTexture(AnimationTexture.class.getResource("/resources/MainScreen.png"),Texture.MM_LINEAR, Texture.FM_LINEAR);
      textureState.setTexture(sheet);
      
      Quad q = new Quad("s", 800, 600);
      q.setRenderState(textureState);
      q.updateRenderState();
      
      rootNode.attachChild(q);
      rootNode.updateRenderState();
      rootNode.updateGeometricState(0f, true);



Not working code in jME2:


TextureState textureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      Texture sheet = TextureManager.loadTexture(AnimationTexture.class.getResource("/resources/MainScreen.png"),Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear);
      textureState.setTexture(sheet);

      
      Quad q = new Quad("s", 800, 600);
      q.setRenderState(textureState);
      q.updateRenderState();
      
      rootNode.attachChild(q);
      rootNode.updateRenderState();
      rootNode.updateGeometricState(0f, true);



Following exception is thrown:


8.9.2009 8:07:02 com.jme.scene.state.lwjgl.LWJGLTextureState load
WARNING: (card unsupported) Attempted to apply texture with size that is not power of 2: 1 024x768
8.9.2009 8:07:02 com.jmex.game.DefaultUncaughtExceptionHandler uncaughtException
SEVERE: Main game loop broken by uncaught exception
java.lang.NoClassDefFoundError: org/lwjgl/util/glu/MipMap
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
                .......and so on;-)



So my question is? Is it possible that it is jME2 fault?.. eh.. I meant jME2 feature?:)
Please tell me it isn't - I can not imagine how much work it would mean to make all texture power of 2. It would be so clumsy to create various images to our game if every single one has to have size of power of 2.

Yea, I should also note that those two pieces of code were run on the same machine (WinXP) and the old one works whilst the new one does not.

Thanks for any input.

hey there.



the non-power-of-two thingy depends on the card, and your card does not support non-power-of-two textures (as you can see in the log output). What happens then is that jme automatically scales the textures to the nearest power-of-two texture size, which takes time at startup and/or doesnt look that good. Rescale / create new Textures yourself with power-of-two sizes.



The exception and the hang of the app is because of a different problem, it seems you miss a native library.

Hi,



that's the answer I like to hear:-)… So there is generally no problem in jME2 to use textures with various sizes. So the problem is on my side… probably the libraries, as you said… phee all those libraries, native libraries, config paths, etc… I would not post here this question if I did not try to configure everything right, but now I know where to invest time … once again:-)



Thanks for reply

One interesting thing… both projects (with the codes above - jME1, jME2) run fine if I use texture which has size of power of 2. And if change the texture then the jME2 project crashes:-((…

might be because, when the textures is 2^n jme does not have to resize and when jme 2.0 has to resize it loads the class which it cannot find  :wink:

Seems like you're missing the lwjgl_util.jar in your classpath, that's where the MipMap class is defined. If this was a native library problem you would get something like "can't find lwjgl in java.library.path" instead.

lwjgl_util.jar?.. hmm that might be the problem… I do not have such library… I have only lwjgl.jar (563 202 B) and lwjgl.dll (153 600 B)…



Right now I'm nor sure where did I get them… but I think I got them from SVN along with the source of jME2 (if so, why lwjgl_util.jar is not distributed with it?).



I'll look for lwjgl_util.jar on the internet and try it. It is true that in my new (obtained with jME2) lwjgl.jar has no MipMap.class - at least I cound not find it. While in my old (used by jME1) lwjgl.jar I found MipMap.class - even though it is not on "org/lwjgl/util/glu/MipMap" path (path from exception)…

hmm… looking on the path of MipMap makes me think that someone made refactoring and extracted the util directory in separate .jar (that lwjgl_util.jar Momoko_fan was talking about)…





By the way running jME2 on my Mac is fine… so it is definitely problem with my windows libraries

So problem solved!

Momoko_Fan hit the… a… something with nail and a head… :slight_smile: (not a native english speaker)

It was really caused by missing lwjgl_util.jar. I found it in the downloadable stable .zip version of jME2.



Thank you guys… a valueable lesson learnt - never trust a single library, every library needs at least another one to work properly:-)