Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texture Loading

Started by guitarplayer Dec 13, 2002 at 2:43 PM 2 replies 1k views
Original Post
guitarplayer
guitarplayer
Ok, i found out that glaux implementation of auxDIBImageLoad on lcc(version 3.3) is buggy, and doesn't work on Win 2000, generating general protection faults.(Tried to compile Nehe's lesson 06, and it did compiled but got gpfs.. the .exe that comes with the sources doesn't. I guessed it has to do with the compiler). So I, in my all boreness and inspiration, tried to implement a 256px x 256 px image loader. It didn't worked either... and I dont know C memory management very well... can someone help me on this one?(i am actually not interested if the image is DIB or RGB or RGBA, I want the damn thing to at least open garbage texture that are 192kbyte longer. i'll cope with that later )(the code is *really* inspired on Nehe's lesson 06)
    

AUX_RGBImageRec * LoadBMP(char * name)
{
	FILE * file=NULL;
	AUX_RGBImageRec * result=NULL;
	unsigned char data[256*256*3];
	memset(result,0,sizeof(AUX_RGBImageRec *)); //

	if(!nome)
	{
		return NULL;
	}
	arquivo=fopen(nome,"rb");

	if(arquivo)
	{
		memset(result->data,0,sizeof(arquivo));
		for(int i = 0; i<sizeof(arquivo);i++)
			fscanf(arquivo,"%uc",data[i]);
		for(int i = 0; i<sizeof(arquivo);i++)
			result->data[i]=data[i];
		result->sizeX=256;
		result->sizeY=256;
		return result;
	}
	return NULL;
}
    
thats the idea, but i get error at the first memset(wondering if general programming would be the best place to ask it rather. ) [edited by - guitarplayer on December 13, 2002 3:50:16 PM]
----------------------------I would rather burn dollars than USA flags... but they are too expensive!
odizzy
odizzy
Should the if(!nome) and fopen(nome.... be ''name''
guitarplayer
guitarplayer
Nah, thats translating error to the post, but its run time error, not compiling error.It was actually..
I can load it now, the problem was about me using memset instead of malloc... now i will try to figure out about file formats. :D
Because strangely i draw some random quads(2 triangles actually) and then all turns to black, with actually texture not working hehe... but thank you guys.

[edited by - guitarplayer on December 13, 2002 4:45:01 PM]
----------------------------I would rather burn dollars than USA flags... but they are too expensive!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.