I am working on a Graphics API for DOS. Its going great untill now.
I wrote the texture mapper and that, and now I am trying to load a bitmap to 'create' a texture from a file. I tried modfying the cBoard FAQ's bitmap loader... but for some reason I just get static? It works okay on it's own... but one I change it to load into my texture pointer it dies... here is the troubling function:
UPDATE: I re-wrote it, and I think I know what the problem is!!!
For some reason, it sort of warps the image, the image IS being loaded... but for some reason its being entered into the buffer incorrectly, I am going to try rewritingthe mapper...
UPDATE: AGAIN... I think the mapper AND the loader are at fault... I have discovered that the loader is laodign a warnped image still... even without the mapper's imperfections.
(For this project I am compiling using Bc5 IDE):
u_IBitmap *DLG_Runtime::LoadBMP (char *filename){
struct BMPHeader {
char ID[2];
unsigned long Size;
unsigned long _Res;
unsigned long Foffset;
unsigned long hsize;
unsigned long sizeX;
unsigned long sizeY;
unsigned int Planes;
unsigned int BitsPerPel;
unsigned long Compression;
unsigned long bitlen;
unsigned long xmet;
unsigned long ymet;
unsigned long Bits;
//unsigned long *Pallet;
//char *CompUnused;
} Header;
u_IBitmap *Ret = new u_IBitmap;
_uZeroMemory((char*)Ret,sizeof(u_IBitmap));
//This checks for the file
ifstream BMPFile(filename, ios::binary);
if (BMPFile == NULL) {
return (u_IBitmap*)NULL;
}
BMPFile.read((char*)&Header,sizeof(Header));
Ret->sizeX = Header.sizeX;
Ret->sizeY = Header.sizeY;
Ret->data = new char[Ret->sizeX*Ret->sizeY];
BMPFile.seekg(Header.Foffset);
BMPFile.read(Ret->data,Ret->sizeX*Ret->sizeY);
BMPFile.close();
return Ret;
}
Here is the 'u_IBitmap' struct:
struct u_IBitmap
{
unsigned long sizeX,sizeY;
char *data;
};
The texture mapper itself seems to work... but this I beleive if the bad function...
SPH