我创建这样的纹理:
//Create temp SDL_Surface
SDL_Surface* surface = IMG_Load(this->path.c_str());
//If we successfully loaded an image
if (surface)
{
SDL_DisplayFormatAlpha(surface);
bounds = GameRectangle(surface->w, surface->h);
GLuint object(0);
glGenTextures(1, &object);
glBindTexture(GL_TEXTURE_2D, object);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
SDL_FreeSurface(surface);
return object;
}
glDeleteTextures() 可以正确释放 VRAM,但系统 RAM 会保留并不断增加,直到游戏崩溃。
我将它定位到 SDL_Surface,显然表面内存没有被释放。
有任何想法吗?