diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index d714d3e46d..3321f95613 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -459,8 +459,8 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, FVector3 & nearP bool gl_SetupLightTexture() { - if (GLRenderer->gllight == nullptr) return false; - FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); + if (!GLRenderer->glLight.isValid()) return false; + FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->glLight, false, false); gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false); return true; } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 74bd81c177..a401fc9b85 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -104,7 +104,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mSkyVBO = nullptr; gl_spriteindex = 0; mShaderManager = nullptr; - gllight = glpart2 = glpart = mirrortexture = nullptr; mLights = nullptr; m2DDrawer = nullptr; mTonemapPalette = nullptr; @@ -172,10 +171,10 @@ void FGLRenderer::Initialize(int width, int height) } else mVAOID = 0; - if (gl.legacyMode) gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); - glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); - glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); - mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); + if (gl.legacyMode) glLight = TexMan.CheckForTexture("glstuff/gllight.png", FTexture::TEX_MiscPatch); + glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", FTexture::TEX_MiscPatch); + glPart = TexMan.CheckForTexture("glstuff/glpart.png", FTexture::TEX_MiscPatch); + mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", FTexture::TEX_MiscPatch); mVBO = new FFlatVertexBuffer(width, height); mSkyVBO = new FSkyVertexBuffer; @@ -206,10 +205,6 @@ FGLRenderer::~FGLRenderer() if (mVBO != NULL) delete mVBO; if (mSkyVBO != NULL) delete mSkyVBO; if (mLights != NULL) delete mLights; - if (glpart2) delete glpart2; - if (glpart) delete glpart; - if (gllight) delete gllight; - if (mirrortexture) delete mirrortexture; if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); if (mVAOID != 0) { diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index eb71cd4bed..857ed72eaa 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -133,10 +133,10 @@ public: FShadowMap mShadowMap; - FTexture *gllight; - FTexture *glpart2; - FTexture *glpart; - FTexture *mirrortexture; + FTextureID glLight; + FTextureID glPart2; + FTextureID glPart; + FTextureID mirrorTexture; float mSky1Pos, mSky2Pos; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c07aceed4c..cfaa34f6ff 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -1185,19 +1185,20 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s // [BB] Load the texture for round or smooth particles if (gl_particles_style) { - FTexture *lump = NULL; + FTextureID lump; if (gl_particles_style == 1) { - lump = GLRenderer->glpart2; + lump = GLRenderer->glPart2; } else if (gl_particles_style == 2) { - lump = GLRenderer->glpart; + lump = GLRenderer->glPart; } + else lump.SetNull(); - if (lump != NULL) + if (lump.isValid()) { - gltexture = FMaterial::ValidateTexture(lump, true); + gltexture = FMaterial::ValidateTexture(lump, true, false); translation = 0; ul = gltexture->GetUL(); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index d69ceeb4dd..beeb103a0f 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -260,7 +260,7 @@ void GLWall::RenderFogBoundary() //========================================================================== void GLWall::RenderMirrorSurface() { - if (GLRenderer->mirrortexture == NULL) return; + if (!GLRenderer->mirrorTexture.isValid()) return; // For the sphere map effect we need a normal of the mirror surface, FVector3 v = glseg.Normal(); @@ -288,7 +288,7 @@ void GLWall::RenderMirrorSurface() gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); - FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false); + FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrorTexture, false, false); gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false); flags &= ~GLWF_GLOW;