Original Post
I am having problems to load bitmap texture files to my 2d tile based game. By using the NeHe's tutorial on applying textures, I had no problem applying textures to the 2d map. However, as I add more bitmap texture files to the game, I found out that there is a bound to load the bitmap images to the array. I load all my textures to the array TextureImage[] I realized that I could only load up to 126 textures to the array. I could compile and run ok when I have more than 126 textures loaded, but only the first 126 textures in the array would be displayed on the map. I believed that I could set the third parameter of memset() to a larger number like sizeof(void *)*2 expecting it would double the size to 126*2, however it didnt help at all. Maybe I just dont understand the structure of it. I did googling around a little bit but cannot seem to find anything helpful. Each tile size is 64 by 64 px, 24-bit. I think it is not really that big for a 2d game to have more than 126 bitmaps because many games have more heavier graphics than this. It must be something I can set to allocate bigger size for the texture array to hold more textures. Can anyone show me what I did wrong? Thanks! [Edited by - dannielum on September 23, 2006 5:07:47 PM]
AUX_RGBImageRec *TextureImage[TOTAL_TILES];
memset(TextureImage,0,sizeof(void *)*1);
TextureImage[0] = LoadBMP("Data/tiles/tile1.bmp");
...
TextureImage[TOTAL_TILES] = LoadBMP("Data/tiles/tile126.bmp");
//texture tiles
glGenTextures(TOTAL_TILES, &texture[0]); // We are generating textures
for (int i=0; i<TOTAL_TILES; i++)
{
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX,
TextureImage->sizeY, 0, GL_RGB,
GL_UNSIGNED_BYTE, TextureImage->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
for (int t = 0; t < TOTAL_TILES; t++)
{
if (TextureImage[t])
{
if (TextureImage[t]->data)
{
free(TextureImage[t]->data);
}
free(TextureImage[t]);
}
}