TextureIO on Android - No suitable reader for given stream when loading standard formats

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

TextureIO on Android - No suitable reader for given stream when loading standard formats

Peter F
Hello,

I'm updating our android section of our code base to use JOGL with Android with the help of NEWT.

I'm having trouble with TextureIO when running on Android devices - when so far on platforms such as AWT things run fine.

I'm calling:

InputStream stream = assetManager.open( filePath );
System.out.println( "stream = " + stream );
TextureData data = TextureIO.newTextureData( GLContext.gl().getGLProfile(), stream, false, suffix );

Where the GL Profile is GL2ES2 & the suffix is .png

My logcat shows:

( 3694): stream = android.content.res.AssetManager$AssetInputStream@410773a0
( 3694):
( 3694): java.io.IOException: No suitable reader for given stream
( 3694): at com.jogamp.opengl.util.texture.TextureIO.newTextureDataImpl(TextureIO.java:852)
( 3694): at com.jogamp.opengl.util.texture.TextureIO.newTextureData(TextureIO.java:246)

I'm using the JOGL Android native dependencies in my Android specific project - replacing the standard ones elsewhere.
The file exists & the stream is created for it successfully so far as I can tell.
It looks as though TextureIO is having trouble with the AssetInputStream Android object itself? Am I even going about this correctly? I haven't been able to find an example of loading a texture on android using JOGL.

Any help much appreciated!
Reply | Threaded
Open this post in threaded view
|

Re: TextureIO on Android - No suitable reader for given stream when loading standard formats

gouessej
Administrator
Hi

It should work but you should pass "png" instead of ".png":
https://github.com/gouessej/Ardor3D/blob/master/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java#L183
https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java#L1135
https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java#L157

Actually, you weren't using the PNG loader of JOGL but the AWT SPI under the hood. As you passed the wrong suffix, your code was working on the desktop thanks to AWT. Take care of the vertical orientation, feel free to look at the first link I posted in order to fix that.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextureIO on Android - No suitable reader for given stream when loading standard formats

Peter F
Thank you! I was using some regular String methods to isolate the suffix of the file path, using the getFileSuffix function shown TextureIO successfully loaded all image assets, I must have been doing something wrong &/or maybe that I've had to update my JOGL version from 2.0-rc11 to 2.2.0 may have had unseen complications here. Either way, thank you very much! I've been at this all day :)
Reply | Threaded
Open this post in threaded view
|

Re: TextureIO on Android - No suitable reader for given stream when loading standard formats

gouessej
Administrator
You're welcome. I'm happy to help JogAmp users :)

getFileSuffix() is a method of JogAmp's Ardor3D Continuation, this feature will be moved to JOGL itself:
https://jogamp.org/bugzilla/show_bug.cgi?id=1042

I did something worse several months ago, I passed null as a suffix, the AWT SPI was always used. We learn from our mistakes.
Julien Gouesse | Personal blog | Website