From e68da4331a182e0492bed0a5f2b5e4d717ec6ed6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 26 Dec 2019 00:46:05 +0100 Subject: [PATCH] Also clean up textures not created by SetPixels --- Source/Native/OpenGL/GLTexture.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Native/OpenGL/GLTexture.cpp b/Source/Native/OpenGL/GLTexture.cpp index f41d86a0..c3c65582 100644 --- a/Source/Native/OpenGL/GLTexture.cpp +++ b/Source/Native/OpenGL/GLTexture.cpp @@ -128,8 +128,11 @@ GLuint GLTexture::GetTexture(GLRenderDevice* device) { if (mTexture == 0) { - Device = device; - ItTexture = Device->mTextures.insert(Device->mTextures.end(), this); + if (Device == nullptr) + { + Device = device; + ItTexture = Device->mTextures.insert(Device->mTextures.end(), this); + } GLint oldActiveTex = GL_TEXTURE0; glGetIntegerv(GL_ACTIVE_TEXTURE, &oldActiveTex); @@ -189,7 +192,11 @@ GLuint GLTexture::GetFramebuffer(GLRenderDevice* device, bool usedepthbuffer) { if (mDepthRenderbuffer == 0) { - Device = device; + if (Device == nullptr) + { + Device = device; + ItTexture = Device->mTextures.insert(Device->mTextures.end(), this); + } glGenRenderbuffers(1, &mDepthRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, mDepthRenderbuffer); @@ -216,7 +223,11 @@ GLuint GLTexture::GetPBO(GLRenderDevice* device) { if (mPBO == 0) { - Device = device; + if (Device == nullptr) + { + Device = device; + ItTexture = Device->mTextures.insert(Device->mTextures.end(), this); + } glGenBuffers(1, &mPBO); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO);