LoadGLTextures quesrion
how efficient is this function when you have many textures to load? about 50 textures for example. does it use up a lot of memory since all of them are bitmaps? but sometimes i don't need to use all of them. how do i only load up the ones i need?
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[0]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}
free(TextureImage[0]); // Free The Image Structure
}
return Status; // Return The Status
}
Unless you're guaranteed not to use them in the application at all, then loading them all at the application start up is the best to go.
Reading from Disk is quite a slow operation and so you want to avoid this as much as possible during Run-Time. You should have plenty of memory available to you as graphics cards have 256Mb+ nowadays along with about the same as minimum in RAM so I wouldn't worry about the texture buffer unless you're loading up gigabytes of data.
Reading from Disk is quite a slow operation and so you want to avoid this as much as possible during Run-Time. You should have plenty of memory available to you as graphics cards have 256Mb+ nowadays along with about the same as minimum in RAM so I wouldn't worry about the texture buffer unless you're loading up gigabytes of data.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement