loading bmp from & writing bmp to .dat file
I need help!
I need to know how to load a bitmap(or tga)(nehe style),
if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
{
Status=TRUE;
glGenTextures(1, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]>sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
and then save it into a class. I will then write that class to a file("texture.dat" or something). And then I want to be able to read the texture or bmp from the file and thereby not having to have a folder full of bmp´s in my gamedir.
Thanx!
Edited by - vile on November 24, 2001 3:31:39 AM
November 24, 2001 12:46 PM
I''m not sure what you want, but if you want to make your own data file, that you load it automatically without any bmp or others functions. Do this:
Make white 256x256 bmp file (24-bit), now look the code wiht hex editor. You will see that the first 36 (or 35 I don''t remeber) are really odd numbers, and after that there will be values FFFFFFFF... (256,256,256...) this values tells red, green and blue values (FFFFFF is white and FF0000 is red) you can simple delete the first 36 values (which tell something about bmp format)...
Sorry but I am busy.
Make white 256x256 bmp file (24-bit), now look the code wiht hex editor. You will see that the first 36 (or 35 I don''t remeber) are really odd numbers, and after that there will be values FFFFFFFF... (256,256,256...) this values tells red, green and blue values (FFFFFF is white and FF0000 is red) you can simple delete the first 36 values (which tell something about bmp format)...
Sorry but I am busy.
Thanx for the reply, but I didn´t understand what you told me to do.
I just want a way to use textures in my program, without having to use a folder full of images so that the user can change these images.
I just want a way to use textures in my program, without having to use a folder full of images so that the user can change these images.
I just did a similar thing yesterday for my map format. I just wrote a small dos program that opens a heightmap, and all the textures used, and writes it to a single file.....
all you have to do is have a header(array) of however many bytes you want, saying how big each texture is, and mabe which one is which, then you just write that data for each texture one after another.
Then when you need to load the textures, you read in the header, then read in the number of bytes for teh first texture, then read in the number of bytes for teh second texture, and so on...
Hope you understand what I mean =)
all you have to do is have a header(array) of however many bytes you want, saying how big each texture is, and mabe which one is which, then you just write that data for each texture one after another.
Then when you need to load the textures, you read in the header, then read in the number of bytes for teh first texture, then read in the number of bytes for teh second texture, and so on...
Hope you understand what I mean =)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement