Skip to content

Commit

Permalink
- let the texture manager handle the special OpenGL textures so that …
Browse files Browse the repository at this point in the history
…they get deleted and recreated when needed.
  • Loading branch information
coelckers committed Feb 15, 2018
1 parent 80a0d15 commit ef55386
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/gl/compatibility/gl_20.cpp
Expand Up @@ -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;
}
Expand Down
13 changes: 4 additions & 9 deletions src/gl/renderer/gl_renderer.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions src/gl/renderer/gl_renderer.h
Expand Up @@ -133,10 +133,10 @@ class FGLRenderer

FShadowMap mShadowMap;

FTexture *gllight;
FTexture *glpart2;
FTexture *glpart;
FTexture *mirrortexture;
FTextureID glLight;
FTextureID glPart2;
FTextureID glPart;
FTextureID mirrorTexture;

float mSky1Pos, mSky2Pos;

Expand Down
11 changes: 6 additions & 5 deletions src/gl/scene/gl_sprite.cpp
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/gl/scene/gl_walls_draw.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ef55386

Please sign in to comment.