View Full Version : gluBuild2DMipmaps()...

01-24-2002, 02:02 PM
OK, I am writing my game engine to use any size bitmaps up to 256x256, but I have a question about gluBuild2DMipmaps. If I declare my array for bit storage as 256x256x3, then read in a 32x32 image, since the height and width are passed to gluBuild2DMipmaps, would it properly build the image? Here's a coding example if I am not clear enough.

//Load Bitmaps
BOOL LoadTextures()
short int height, width;
GLubyte image[256][256][3];
FILE *in;

//read in height, width, and bit array
//of a 32x32 24bit bitmap

return TRUE;

If that should work great, otherwise it may be the problem with my bitmaps over 32x32 in size coming out funny-looking (not correct).


Tolga Dalman
01-24-2002, 03:41 PM
hello seph,

to get this clear: you want to build a texture from an 256x256x3 array, which only contains 32x32x3? i really didn't get this, how do you exactly read your data in?
you know the problem, you have to terminate it!
simply write a function for each mode (32x32x3, 256x256x3,....) like
BOOL LoadTextures(int tX, int tY, int tD).


01-25-2002, 01:58 AM
Use dynamic memory allocation instead of static, when you want to use a buffer of that size. Then you can allocate as much memory as you need.

Anyways, if you read the image as raw data directly into that buffer, without messing with index into the buffer, and pass the image's true size to gluBuild2DMipmaps, then you won't have any problems. After all, your 3D array is just a large linear buffer in memory, that you access as if it was a 3D array.