I Know it has something to do with freeing memory up memory for the specific texture, but I don't know exactly how it works step by step, its something I've been looking at for 3 days now, can't seem to catch it :\Code: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 }
I think, this takes the iArray textureimage[0] and sets it equal to the bitmap "Data/NeHe.bmp", then sets the Status bool to TRUE, which ultimately means the texture was successfully loaded....Code:// 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
Right?
Oh I see, TextureImage is declared as a pointer to the memory store for texture[1]!!! So Every time they refer to TextureImage theyre referring to the bmp I have it set to... Genius! programming is so Genius! (Note to all, Still don't understand most of it)



LinkBack URL
About LinkBacks



