- let the texture manager handle the special OpenGL textures so that they get deleted and recreated when needed.

This commit is contained in:
Christoph Oelckers 2018-02-15 17:56:04 +01:00
parent 80a0d15bc7
commit ef55386d9f
5 changed files with 18 additions and 22 deletions

View file

@ -459,8 +459,8 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, FVector3 & nearP
bool gl_SetupLightTexture() bool gl_SetupLightTexture()
{ {
if (GLRenderer->gllight == nullptr) return false; if (!GLRenderer->glLight.isValid()) return false;
FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->glLight, false, false);
gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false); gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false);
return true; return true;
} }

View file

@ -104,7 +104,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
mSkyVBO = nullptr; mSkyVBO = nullptr;
gl_spriteindex = 0; gl_spriteindex = 0;
mShaderManager = nullptr; mShaderManager = nullptr;
gllight = glpart2 = glpart = mirrortexture = nullptr;
mLights = nullptr; mLights = nullptr;
m2DDrawer = nullptr; m2DDrawer = nullptr;
mTonemapPalette = nullptr; mTonemapPalette = nullptr;
@ -172,10 +171,10 @@ void FGLRenderer::Initialize(int width, int height)
} }
else mVAOID = 0; else mVAOID = 0;
if (gl.legacyMode) gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); if (gl.legacyMode) glLight = TexMan.CheckForTexture("glstuff/gllight.png", FTexture::TEX_MiscPatch);
glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", FTexture::TEX_MiscPatch);
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); glPart = TexMan.CheckForTexture("glstuff/glpart.png", FTexture::TEX_MiscPatch);
mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", FTexture::TEX_MiscPatch);
mVBO = new FFlatVertexBuffer(width, height); mVBO = new FFlatVertexBuffer(width, height);
mSkyVBO = new FSkyVertexBuffer; mSkyVBO = new FSkyVertexBuffer;
@ -206,10 +205,6 @@ FGLRenderer::~FGLRenderer()
if (mVBO != NULL) delete mVBO; if (mVBO != NULL) delete mVBO;
if (mSkyVBO != NULL) delete mSkyVBO; if (mSkyVBO != NULL) delete mSkyVBO;
if (mLights != NULL) delete mLights; 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 (mFBID != 0) glDeleteFramebuffers(1, &mFBID);
if (mVAOID != 0) if (mVAOID != 0)
{ {

View file

@ -133,10 +133,10 @@ public:
FShadowMap mShadowMap; FShadowMap mShadowMap;
FTexture *gllight; FTextureID glLight;
FTexture *glpart2; FTextureID glPart2;
FTexture *glpart; FTextureID glPart;
FTexture *mirrortexture; FTextureID mirrorTexture;
float mSky1Pos, mSky2Pos; float mSky1Pos, mSky2Pos;

View file

@ -1185,19 +1185,20 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
// [BB] Load the texture for round or smooth particles // [BB] Load the texture for round or smooth particles
if (gl_particles_style) if (gl_particles_style)
{ {
FTexture *lump = NULL; FTextureID lump;
if (gl_particles_style == 1) if (gl_particles_style == 1)
{ {
lump = GLRenderer->glpart2; lump = GLRenderer->glPart2;
} }
else if (gl_particles_style == 2) 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; translation = 0;
ul = gltexture->GetUL(); ul = gltexture->GetUL();

View file

@ -260,7 +260,7 @@ void GLWall::RenderFogBoundary()
//========================================================================== //==========================================================================
void GLWall::RenderMirrorSurface() 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, // For the sphere map effect we need a normal of the mirror surface,
FVector3 v = glseg.Normal(); FVector3 v = glseg.Normal();
@ -288,7 +288,7 @@ void GLWall::RenderMirrorSurface()
gl_RenderState.AlphaFunc(GL_GREATER,0); gl_RenderState.AlphaFunc(GL_GREATER,0);
glDepthFunc(GL_LEQUAL); 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); gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false);
flags &= ~GLWF_GLOW; flags &= ~GLWF_GLOW;