Hi,
I am trying to load three photos at the same time in a window. Two of the photos are changing at each loop and one photo is just a logo. The program is running very slow. Any ideas what I should be doing in the program differently? Thanks in advance. Here is how I am loading photos:
bool loadbmp(UINT textureArray[], LPSTR strFileName, int ID)//(NEW) the name of our function
{
if(!strFileName) return false;//If no file name was given then return a false value
AUX_RGBImageRec *pBitMap = auxDIBImageLoad(strFileName); //Load the file into a new variable where we can then manipulate it into our texture array
if(pBitMap == NULL) exit(0);// If no data was loaded then exit the program.
glGenTextures(1, &textureArray[ID]);// Generate one texture into our texture array in the slot defined
glBindTexture(GL_TEXTURE_2D, textureArray[ID]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0,3,pBitMap->sizeX, pBitMap->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, pBitMap->data);
if (pBitMap) //If pBitMap still has a value then we want to clear it.
{
if (pBitMap->data)
{
free(pBitMap->data);
}
free(pBitMap);
}
return true;
}
Then I run:
glDisable(GL_TEXTURE_2D);
//Anf finally i do this:
glutSwapBuffers();
Sorry, I am a bit new to this. but could you explain more. I am calling loadbmp() for each new image that i am going to load including the logo. which lines should I use for each new image and which ones should I use only once?
By the way - don’t use glGenTexture for each texture you load. This way you will keep filling up memeory on GPU since you do not call glDeleteTextures anywhere.
If you use only 3 textures at once, then simply use glGenTextures once to create them and from now on you will only need to replace images for these textures.