Archived

This topic is now archived and is closed to further replies.

Rossonero

Texture Loading without glaux library

Recommended Posts

Just look around and see how many games actually use bitmaps as textures - a bitmap is generally considered a large graphics format, and therefore generally not used to store larger images. Any gamewriter should write his own texture loading routines (it''s dead easy for non-compressed formats, such as dib''s, but can become very tricky when getting to images using more difficult compression algorithms - such as jpeg''s, although jpeg''s are not generally used in the game industry as they represent the lossy side of compressed image formats). You could always turn to 3rd party libraries for more difficult formats, but I strongly urge you to not use glaux and write your own bitmap loading routine - simply open up the format specification and see what each byte means - it''s like following a roadmap. Things get more complicated when you try to load RLE encoded bitmaps, so you might want to skip those for the time being, but I''m pretty cofident you won''t be using any 4 or 8 bit bitmaps in your games anyway (mostly)... Just make sure all of your textures are 24-bit, though - that way you won''t run into any surprises when loading and displaying them!

Crispy

Share this post


Link to post
Share on other sites
The simplest would be TGA since it''s only 18 bytes of header then just raw data. OK, it can be compressd (RLE, huffman, quadtree,...) but 95% of images there are just uncomressed RGB(A)

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
bmp are ok and easy but thyey need space, of course, but there is other way:
pack your bmps with rar for example download unrar.dll library (it comes with winrar) and during loading textures, just unpack that (rar routine with unrar.dll is very easy and can be found almost everywhere) and load normal bmp. Size is reduced nearly 10-15 times!
some others trick:
change some magic bytes in rar (6 bytes first for example) and most of users cant change your textures in game.
some other good packers:
tar - open source so you can include it in your code easly
lzh - as above
and dont forget delete your bmps after loading

Share this post


Link to post
Share on other sites
raw or bitmap. stick to bitmap, though - you''ll only need Paint to convert images to this format... Check out this place. Also, remember that color bytes are stored in reverse order in a bitmap (bgr) - so you''ll need to swap them. Furthermore, refrain from using the WinAPI bitmap header structs, and write your own. No biggie. Why? Portability.

Crispy

Share this post


Link to post
Share on other sites
quote:
Original post by moore52
pack your bmps with rar for example download unrar.dll library


I''ve never used texture packing, but simple tests show that .rar, while being my personal favorite and better than .zip, is hopelessly slower than the latter (packing 2 s vs 7 s, unpacking 1 s vs 2 s), so if possible use some faster packing algorithm. Quake3 uses zip-compression for its textures, afair, so maybe there''s a free lib out there - not sure - too lazy to run a search, too

Crispy

Share this post


Link to post
Share on other sites
quote:
Original post by Crispy
[quote]Original post by moore52
pack your bmps with rar for example download unrar.dll library


I''ve never used texture packing, but simple tests show that .rar, while being my personal favorite and better than .zip, is hopelessly slower than the latter (packing 2 s vs 7 s, unpacking 1 s vs 2 s), so if possible use some faster packing algorithm. Quake3 uses zip-compression for its textures, afair, so maybe there''s a free lib out there - not sure - too lazy to run a search, too

Crispy



http://www.gzip.org/zlib/

Fe doeyr, Frender Doeyr,Ein sjoelv doeyr paa sama vis.
Eg veit et som aldri doeyr, dom over kvar ein doed.
Cattle die, Friends die, You yourself will also die.
I know something that never dies, the memory of every dead.

Share this post


Link to post
Share on other sites