loading an image

Started by
15 comments, last by apocalexiz 20 years, 9 months ago
hy there i want to use *.tga files for my textures...so i want to write my own picture loader the *.tga file specs dont look hard to understand but my problem is...whats the best and fast way to store some picture in memory? so that iam able to present the data to opengl and opengl will show it i dont want to see any sourccode about tga files but if anybody knows some easy implementations of a *.bmp loader or something, give it to me bye
Advertisement
quote:so i want to write my own picture loader the *.tga file

quote:i dont want to see any sourccode about tga files

You really don''t know what you want, do you?
quote:but if anybody knows some easy implementations of a *.bmp loader or something, give it to me

Look up the NeHe tutorials (http://nehe.gamedev.net/). He''s got a working implementation of a BMP texture loader in his tuts.
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
hm....i do know what i want to do but i dont want to see any source code in this thread
look it up at wotsit.org
I''m assuming you''re using OpenGL since Direct3D has the D3DX library to load images for you.

My advice would be to load the image file header into a matching structure (you may have to use #pragma pack to make sure your structure is tightly aligned), allocate a buffer big enough to hold the image data in, read in the image data, pass it to opengl using the a format compatible with that in the image header, then free your buffer.

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
kingston
********

i already have the file format specification

sisapete
********

>pass it to opengl using the a format compatible with that in
>the image header

where can i look up wich formats r compatible with tga? because i also want to use the alpha value...

extracting the image data is no problem, i know where to find and how to determine the length...

bye
so it''s easy to pass the data to GL use the BMP format.

windows has the header structs of the BMP frmt already defined
BMPFILEHEADER & BMPINFOHEADER

just read a BMPFILEHEADER and a BMPINFOHEADER from the start of the file, then seek to the fileheader.bioffBits position and read the data. one tricky thing is that bmp has the images rows aligned to 4bytes. that means that if the image is 255X255 each column in fact has 256 bytes the last one beeing discardable.

its extremely easy. the aux lib of GL has a loading func for dibs (auxDIBimageLoaded or smth like that)

the TGA format is quite similar only the headers differ.

/*ilici*/
It''s pretty easy to use alpha. Just use GL_RGBA instead of GL_RGB when creating your texture in OpenGL. The image format section of the image header will tell you if you have alpha or not.

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
ahh..i understood...i only have to make a header, that iam able to provide opengl with information like height,width,pixel depth, using alpha or not etc., so that open gl is able to switch in the correct display mode. and i dont need a complete file format description right?

bye

Be careful with your terms, it shows that you may not understand fully what you''re doing.

OpenGL has no knowledge of display modes.
Display modes have little to do with texture loading.

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

This topic is closed to new replies.

Advertisement