Also clean up textures not created by SetPixels

This commit is contained in:
Magnus Norddahl 2019-12-26 00:46:05 +01:00
parent 9d5f8ec7c1
commit e68da4331a

View file

@ -128,8 +128,11 @@ GLuint GLTexture::GetTexture(GLRenderDevice* device)
{ {
if (mTexture == 0) if (mTexture == 0)
{ {
Device = device; if (Device == nullptr)
ItTexture = Device->mTextures.insert(Device->mTextures.end(), this); {
Device = device;
ItTexture = Device->mTextures.insert(Device->mTextures.end(), this);
}
GLint oldActiveTex = GL_TEXTURE0; GLint oldActiveTex = GL_TEXTURE0;
glGetIntegerv(GL_ACTIVE_TEXTURE, &oldActiveTex); glGetIntegerv(GL_ACTIVE_TEXTURE, &oldActiveTex);
@ -189,7 +192,11 @@ GLuint GLTexture::GetFramebuffer(GLRenderDevice* device, bool usedepthbuffer)
{ {
if (mDepthRenderbuffer == 0) if (mDepthRenderbuffer == 0)
{ {
Device = device; if (Device == nullptr)
{
Device = device;
ItTexture = Device->mTextures.insert(Device->mTextures.end(), this);
}
glGenRenderbuffers(1, &mDepthRenderbuffer); glGenRenderbuffers(1, &mDepthRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, mDepthRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, mDepthRenderbuffer);
@ -216,7 +223,11 @@ GLuint GLTexture::GetPBO(GLRenderDevice* device)
{ {
if (mPBO == 0) if (mPBO == 0)
{ {
Device = device; if (Device == nullptr)
{
Device = device;
ItTexture = Device->mTextures.insert(Device->mTextures.end(), this);
}
glGenBuffers(1, &mPBO); glGenBuffers(1, &mPBO);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO);