Loading Textures

Started by
16 comments, last by THACO 19 years, 10 months ago
I am curious what best format would be to use for textures. I would use textures for sprites and also texture mapping on 3d objects, Should i use .bmp .tga .jpeg. Also I see at the tutorials at NeHe they use the GLaux for loading of bmps and i was looing around the internet and saw that glaux is old and unsupported because of some flaws and memory leaks. Are there any other tutorials or functions to use, are there functions in GLUT to help with loading of textures? -THACO p.s. i use eclipse with c++ and when i include the glaux library the exe will not run because it cannot find glaux.dll i can still compile using LCC compiler instead of mingw but its a pain.
Advertisement
out of all those .TGA is the best. It supports the ALPHA channel, which is really handy (They hav to be 32bit tho). Use Photoshop or PSP for those. Also, for a nice .TGA loader. Nip over to www.gametutorials.com for a really neat .tga loader.

As for GLUT i dontuse it, so i wudnt know...


------------

"Here lies a toppled God,
His fall was not a small one,
We but built his pedastle,
A narrow, and a tall one"
Frank Herbert (Dune:Messiah)

[edited by - Kris2456 on June 7, 2004 5:55:19 PM]
------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
Why don''t you just write a graphics library that reads and writes to all of those formats? You can get a lot of information online, and if you aren''t sure what you want to use, just support them all.
If you don''t need an alpha channel, use bmp 8 bit.
256 colors/texture is more than enough, the size is smaller than 16/32 TGA (uncompressed TGA), and there is no image loss.
JPG is a bad idea, since you might want to use texture compression, in which case the quality would be further degraded.
That sounds good,thanks Raduprv for reminding me about 8 bit bmps that is a good idea.
Kris thanks for the link that will be very helpful
sirSolarius i would like to do that because the more the better but if there are certain reason for certain formats its always good to know the proper time to use formats

-THACO
I vote for PNG, since it''s losslessly compressable (ah, English...) and supports a full alpha channel as well.

If you use SDL as your foundation, you can load in any filetype using SDL_image. There''s no reason to write your own file loading library if it''s already been done.
Just decide on a format, and make your own loading function.
My BMP loading function is about 60 lines of C. I made it in a few hours. There is no need to have additional dependencies for loading a texture.
or use one of the many libraries out there, such as FreeImage, Corona and DevIL (too tired to get links, search sourceforge.net for details)
In my recent post about color keying I posted a function which can load in bmp, jpg, gif, png, and tga and convert it to an opengl texture. It also can color key the texture if you want.
It is dependent upon sdl and sdl_image...

Well, in the end, OpenGL always want pure RGB/RGBA data, so whatever format you use, you must decompress it into this. This might hoever be different if you use texture compression, but I couldn''t tell for sure.

TGA is, as said, a good format, since it has alpha, and can be saved to by many programs. If you use uncompressed TGA''s, the code to load it is really simple as well.

In my opinion, the best method is to use some library, just as leiavoia said. As long as you get your RGB/RGBA data in the end, you can use anything.
The only problem is, as always to get people to download the library (unless you link it statically, or can bundle it with your package).

Some people use uncompressed image formats, and then compress all data with a general-purpose algorithm. The drawback to this is that the compression ratio is likely to be less efficient for image data, compared to that of a image-specific algorithm.

Xarragonxarragon@swipnet.se

This topic is closed to new replies.

Advertisement