• Advertisement
Sign in to follow this  

manual loading of textures

This topic is 4214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there any tutorials or articals on how to load textures not supported by dx helper functions and how to understand and use different color modes also understanding how to plot a pixel where i want eg height, width, pitch. ive been avoiding this stuff for a few years now, time i stopped running away :p tnx

Share this post


Link to post
Share on other sites
Advertisement
I have written several image format libraries (including a realtime jpeg codec for the Gameboy Advance) and trust me, you do not want get into this kind of details. It includes knowing the file format specifications inside out and correctly implementing them in your program. This is a tedious task and offers little to no advantage over using available, stable and proven libraries.

It is not a trivial task to write a loader for complex file formats such as DDS, JPEG or PNG and really not worth the trouble, considering the D3DX library, GDI+, devIL and several others are freely available and known to work well.

Dynamic textures, however, is a whole different topic. Take a look at the SDK reference for more information on that.

Share this post


Link to post
Share on other sites
Well simple formats like PCX, TGA (some versions) or BMP is fairly easy to implement. Others, like darookie said, are a lot more complex and not so much fun.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I've used DevIL to load my textures in OpenGL and DirectX 9 programs.
http://openil.sourceforge.net/

Its a little complicated in directx9 coz you have to create a DX texture object in system memory (theres a param which says which memory to use, use the system flag), then get a lock to its data, then copy the data from DevIL into the texture.
Then you have to create a second texture in hardware memory (default), and copy the system memory texture into the new texture.

Share this post


Link to post
Share on other sites
I found D3DX functions to not suit my needs. As such, I had to get libjpeg and libpng working. If you can do it with d3dx however it's a whole different story. Make sure however you regen your mipmaps correctly when using normalmaps.

Getting libpng to work is rather easy: take the correct source and compile (it comes in VC7 project form but VC2005 does have no problem in compiling it).

libjpeg is a lot nastier: for some reason I don't really get, they still want to support DOS, so some definitions will conflict with Win32's defs. It takes some care before you can build it.

TGA: completely redundant with PNG in the real world. I don't support it anymore, although you may want to do for legacy reasons. Writting a decent loader takes a day of work (taking 97% compatibility). In three years I've used it, I stumbled only twice in non-compatible files.

OpenEXR: da bomb but if you don't need it then you can leave it out. Although I have built it, I still never used it. Building was rather smooth.

BMP: the only good reason I find for using them is because M$ keeps putting paintbrush on their boxes.

DDS: this takes some time to write, mainly because DDS is actually a family of formats. If you have to decompress DXTn for some reason, it'll take a while, but still far from being hard.

HDR radiance maps: still to look at them, but probably easy.

Bottom line: in fact, the only thing which requires some care is JPG. The rest is not trivial nor excessively difficult so, in my opinion, image loading libraries are somwehat pointless. Burn me!

Share this post


Link to post
Share on other sites
thanks but i still would like to go ahead with it so any articles/tutorials??

Share this post


Link to post
Share on other sites
how to understand and use different color modes also understanding how to plot a pixel where i want eg height, width, pitch.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement