Author Topic: Unsupported Texture width  (Read 7722 times)

Offline orkshaman

  • byte
  • *
  • Posts: 25
    • View Profile
Unsupported Texture width
« on: May 02, 2011, 08:51:56 pm »
Hello world example gives "Unsupported Texture width" error on emulator and on HTC phone, but on my LG P500 all works ok.

Code: [Select]
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.icon)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);

TextureManager.getInstance().addTexture("0", new Texture(getResources().getDrawable(R.raw.zero),true));

Quote
05-02 18:45:11.181: INFO/jPCT-AE(656): Loading Texture...
05-02 18:45:11.201: INFO/jPCT-AE(656): Loading Texture...
05-02 18:45:11.211: INFO/jPCT-AE(656): [ 1304361911212 ] - ERROR: Unsupported Texture width: 96
05-02 18:45:11.221: INFO/jPCT-AE(656): [ 1304361911221 ] - ERROR: java.lang.RuntimeException: [ 1304361911212 ] - ERROR: Unsupported Texture width: 96
05-02 18:45:11.221: INFO/jPCT-AE(656):     at com.threed.jpct.Logger.log(Logger.java:179)
05-02 18:45:11.221: INFO/jPCT-AE(656):     at com.threed.jpct.Texture.loadTexture(Texture.java:687)
05-02 18:45:11.221: INFO/jPCT-AE(656):     at com.threed.jpct.Texture.<init>(Texture.java:190)
05-02 18:45:11.221: INFO/jPCT-AE(656):     at com.threed.jpct.Texture.<init>(Texture.java:226)
05-02 18:45:11.221: INFO/jPCT-AE(656):     at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:190)
05-02 18:45:11.221: INFO/jPCT-AE(656):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1120)
05-02 18:45:11.221: INFO/jPCT-AE(656):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
05-02 18:45:11.251: INFO/ActivityManager(438): Displayed activity com.threed.jpct.example/.HelloWorld: 1533 ms (total 1533 ms)
05-02 18:45:11.261: WARN/dalvikvm(656): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
05-02 18:45:11.271: ERROR/AndroidRuntime(656): Uncaught handler: thread GLThread 8 exiting due to uncaught exception
05-02 18:45:11.301: ERROR/AndroidRuntime(656): java.lang.RuntimeException: [ 1304361911221 ] - ERROR: java.lang.RuntimeException: [ 1304361911212 ] - ERROR: Unsupported Texture width: 96
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Logger.log(Logger.java:179)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Texture.loadTexture(Texture.java:687)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Texture.<init>(Texture.java:190)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Texture.<init>(Texture.java:226)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:190)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1120)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Logger.log(Logger.java:179)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Logger.log(Logger.java:138)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Texture.loadTexture(Texture.java:717)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Texture.<init>(Texture.java:190)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.Texture.<init>(Texture.java:226)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:190)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1120)
05-02 18:45:11.301: ERROR/AndroidRuntime(656):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
05-02 18:45:11.371: INFO/Process(438): Sending signal. PID: 656 SIG: 3
05-02 18:45:11.371: INFO/dalvikvm(656): threadid=7: reacting to signal 3
05-02 18:45:11.371: ERROR/dalvikvm(656): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
05-02 18:45:11.590: ERROR/gralloc(438): [unregister] handle 0x4e45f0 still locked (state=40000001)
05-02 18:45:14.560: INFO/Process(656): Sending signal. PID: 656 SIG: 9
05-02 18:45:14.580: INFO/WindowManager(438): WIN DEATH: Window{44dc24d8 com.threed.jpct.example/com.threed.jpct.example.HelloWorld paused=false}
05-02 18:45:14.580: INFO/ActivityManager(438): Process com.threed.jpct.example (pid 656) has died.
05-02 18:45:14.600: INFO/WindowManager(438): WIN DEATH: Window{44df45d8 SurfaceView paused=false}
05-02 18:45:14.640: INFO/UsageStats(438): Unexpected resume of com.android.launcher while already resumed in com.threed.jpct.example
05-02 18:45:15.021: WARN/InputManagerService(438): Got RemoteException sending setActive(false) notification to pid 656 uid 10028
05-02 18:45:20.361: DEBUG/dalvikvm(587): GC freed 123 objects / 5416 bytes in 67ms
Texture size is 64x64 not 96x96 :)

Here this project from Eclipse:
http://zalil.ru/30966425
« Last Edit: May 02, 2011, 08:59:41 pm by orkshaman »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Unsupported Texture width
« Reply #1 on: May 02, 2011, 11:48:19 pm »
Depending on the devices and on the Android version, bitmaps from drawable get scaled when loading. The HelloWorld example uses it's own icon as a texture. Just put some other fitting bitmap in raw and load that instead.

Offline orkshaman

  • byte
  • *
  • Posts: 25
    • View Profile
Re: Unsupported Texture width
« Reply #2 on: May 03, 2011, 06:14:25 am »
EgonOlsen, but icon loads properly. Error comes when it tries to load R.raw.zero texture. :-\
« Last Edit: May 03, 2011, 06:18:02 am by orkshaman »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Unsupported Texture width
« Reply #3 on: May 03, 2011, 10:32:45 am »
That's because you are loading it as a Drawable. Don't do that. Drawables will be scaled by Android under some circumstances. Use either bitmaps or an inputstream instead.

Offline orkshaman

  • byte
  • *
  • Posts: 25
    • View Profile
Re: Unsupported Texture width
« Reply #4 on: May 03, 2011, 10:37:38 am »
Thank you EgonOlsen.