Archived

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

loloh

I need some help

Recommended Posts

loloh    122
I have that : ... GLuint LoadTexture( const char * filename, int wrap ) { int width, height; BYTE * data; FILE * file; file = fopen( filename, "rb" ); if ( file == NULL ) return 0; width = 256; height = 256; data = malloc( width * height * 3 ); //error with data fread( data, width * height * 3, 1, file ); fclose( file ); .... } ... and I have an error that I really don''t understand : cannot convert from ''void *'' to ''unsigned char *'' can you describe me why this is wrong ?

Share this post


Link to post
Share on other sites
MENTAL    383
fread((void*) data, width * height * 3, 1, file );

should do it. if not, then do

fread((void) data, width * height * 3, 1, file );

bascially, "void *" means it just wants a memory address, and it couldnt care less what type of memory it points to, so yeah, just shove (void*) or (void) infront of "data" and it will work.


MEBTAL

Share this post


Link to post
Share on other sites
loloh    122
thanks for your help
but the error is from this line :
data = malloc( width * height * 3 );

I tried your suggestion but that don''t work

Share this post


Link to post
Share on other sites