Here Texture Loading by JXA !

Started by broumbroum, April 22, 2009, 00:17:33

Previous topic - Next topic

broumbroum

Hi all ! Since some have asked for this, I'm just releasing a limited TEXTURE LOADING pack for the LWJGL.org forum here.
there are at most 3 java classes files.
Sf3Texture._loadTexture(BufferedImage, 0);

Loads a texture in a DataBuffer and
validatePixelBuffer();

converts the DataBuffer to any format you want : specify a GL Texture format as _ExtAbgr value and you're on (hopefully) !

Sf3Texture is HIGHLY INSPIRED BY DevIL TextureLoader class I've been found on the web last year. LoL
:D

EDIT : RFE posted with new zip package http://lwjgl.org/forum/index.php/topic,4181.0.html

broumbroum

Hi !
updated the link with a new zip, because of the last crash with the webservers, it was broken.
;D

EDIT : updated the BufferIO, for re-using of direct buffers (not a big deal =)

jediTofu

awesome, what image formats are supported?  what features are supported (scaling, cropping, etc.)?
cool story, bro

broumbroum

That's supposed to be any by ImageIO.read(f) supported image formats...

mstWeal

Cool, I can make good use of that. My own texture loading routine is not as performant as it could be as I had problems with some PNGs. On my computer they would show up normal and on a friends computer they looked bluish. If I changed from RGB to BGR it looked ok for my friend but blueish on my machine ^ ^ Therefore I always copy the complete image into another temporary BufferedImage, which makes my texture loading about twice expensive as it should be  ::)

How about including this officially into LWJGL? Maybe not into the core but as optional extension. I see two main reasons for that:
- If these would be official classes they would receive the same treatment as any other LWJGL class when making changes to LWJGL (otherwise a future LWJGL version could make the classes incompatible)
- Pretty much every game developer needs the ability to load textures. If you program it yourself you might not end up with a solution that is as performant as it could be (see my example above)

jediTofu

Quote from: mstWeal on November 28, 2010, 08:56:56
Cool, I can make good use of that. My own texture loading routine is not as performant as it could be as I had problems with some PNGs. On my computer they would show up normal and on a friends computer they looked bluish. If I changed from RGB to BGR it looked ok for my friend but blueish on my machine ^ ^ Therefore I always copy the complete image into another temporary BufferedImage, which makes my texture loading about twice expensive as it should be  ::)

How about including this officially into LWJGL? Maybe not into the core but as optional extension. I see two main reasons for that:
- If these would be official classes they would receive the same treatment as any other LWJGL class when making changes to LWJGL (otherwise a future LWJGL version could make the classes incompatible)
- Pretty much every game developer needs the ability to load textures. If you program it yourself you might not end up with a solution that is as performant as it could be (see my example above)

The recommended way is actually Slick-Util (can also load fonts and sounds/music):
http://slick.cokeandcode.com/wiki/doku.php?id=loading_and_binding_opengl_textures_with_slick-util
http://slick.cokeandcode.com/downloads/util/
http://slick.cokeandcode.com/javadoc-util/

I completely agree that it would be nice to have LWJGL already include image/music loading.  It does have built-in wave loading.  However, I'd rather it not use ImageIO (which Slick-Util and most image libraries out there use)...
cool story, bro

broumbroum

I've never been using slick, because I've got good performance with my code.
@jeditofu I also have coded a Sound loading class, which I could provide here. It relies on the same BufferIO class, and has some calls to the jlayer API when handling mp3's. I'll look for an upload soon.
@mstWeal thank you for your feedback, you're welcome ! You may want to post your comment on sf.net/projects/sf3jswing for rating .
;)

EDIT : I'll post an [RFE] soon. cu
EDIT : RFE posted http://lwjgl.org/forum/index.php/topic,4181.0.html