我有一個GLTexture類從文件初始化紋理用下面的方法:GL_TEXTUREs是否需要釋放/釋放?
void GLTexture::LoadBMP(char *name)
{
// Create a place to store the texture
AUX_RGBImageRec *TextureImage[1];
// Set the pointer to NULL
memset(TextureImage,0,sizeof(void *)*1);
// Load the bitmap and assign our pointer to it
TextureImage[0] = auxDIBImageLoad(name);
// Just in case we want to use the width and height later
width = TextureImage[0]->sizeX;
height = TextureImage[0]->sizeY;
// Generate the OpenGL texture id
glGenTextures(1, &texture[0]);
// Bind this texture to its id
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Use mipmapping filter
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// Generate the mipmaps
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Cleanup
if (TextureImage[0])
{
if (TextureImage[0]->data)
free(TextureImage[0]->data);
free(TextureImage[0]);
}
}
哪個不處置,似乎數據。紋理,然後在程序中使用通過調用這個函數
void GLTexture::Use()
{
glEnable(GL_TEXTURE_2D); // Enable texture mapping
glBindTexture(GL_TEXTURE_2D, texture[0]); // Bind the texture as the current one
}
由於質地必須以某種方式駐留在內存中爲它能夠被束縛,我想知道如果任何額外的清潔任務是由於在退出?或者在加載方法中是否足夠....
這似乎是「閱讀文檔」的好候選 –
請不要使用AUX庫來加載圖像。即使它適合你,也只會鼓勵其他人這樣做。 –