diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 3a34a7cbc..ed3541ec9 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -49,6 +49,7 @@ #include "gl/shaders/gl_presentshader.h" #include "gl/shaders/gl_postprocessshaderinstance.h" #include "gl/stereo3d/gl_stereo3d.h" +#include "gl/textures/gl_hwtexture.h" #include "r_videoscale.h" //========================================================================== diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 64556b287..92c4c277d 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -33,6 +33,7 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_colormap.h" #include "gl/dynlights//gl_lightbuffer.h" #include "gl/renderer/gl_renderbuffers.h" diff --git a/src/gl/scene/gl_swscene.cpp b/src/gl/scene/gl_swscene.cpp index c76c44b79..4a028111b 100644 --- a/src/gl/scene/gl_swscene.cpp +++ b/src/gl/scene/gl_swscene.cpp @@ -29,6 +29,7 @@ #include "gl/system/gl_debug.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_hwtexture.h" #include "gl_swscene.h" #include "w_wad.h" #include "d_player.h" diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e7f719c62..2d3cb490b 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -116,8 +116,8 @@ public: enum { - //GLWF_CLAMPX=1, use GLT_* for these! - //GLWF_CLAMPY=2, + GLWF_CLAMPX=1, + GLWF_CLAMPY=2, GLWF_SKYHACK=4, GLWF_GLOW=8, // illuminated by glowing flats GLWF_NOSPLITUPPER=16, diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index b89cea40e..7c42202e1 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -33,6 +33,7 @@ #include "hwrenderer/dynlights/hw_dynlightdata.h" #include "gl/system/gl_cvars.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_lightdata.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" @@ -601,7 +602,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto { bool normalize = false; if (gltexture->tex->bHasCanvas) normalize = true; - else if (flags & GLT_CLAMPY) + else if (flags & GLWF_CLAMPY) { // for negative scales we can get negative coordinates here. normalize = (tcs[UPLFT].v > tcs[LOLFT].v || tcs[UPRGT].v > tcs[LORGT].v); @@ -651,7 +652,7 @@ void GLWall::CheckTexturePosition(FTexCoordInfo *tci) if ((tcs[UPLFT].v == 0.f && tcs[UPRGT].v == 0.f && tcs[LOLFT].v <= 1.f && tcs[LORGT].v <= 1.f) || (tcs[UPLFT].v >= 0.f && tcs[UPRGT].v >= 0.f && tcs[LOLFT].v == 1.f && tcs[LORGT].v == 1.f)) { - flags |= GLT_CLAMPY; + flags |= GLWF_CLAMPY; } } else @@ -672,7 +673,7 @@ void GLWall::CheckTexturePosition(FTexCoordInfo *tci) if ((tcs[LOLFT].v == 0.f && tcs[LORGT].v == 0.f && tcs[UPLFT].v <= 1.f && tcs[UPRGT].v <= 1.f) || (tcs[LOLFT].v >= 0.f && tcs[LORGT].v >= 0.f && tcs[UPLFT].v == 1.f && tcs[UPRGT].v == 1.f)) { - flags |= GLT_CLAMPY; + flags |= GLWF_CLAMPY; } } @@ -688,7 +689,7 @@ void GLWall::CheckTexturePosition(FTexCoordInfo *tci) if ((tcs[UPLFT].u == 0.f && tcs[LOLFT].u == 0.f && tcs[UPRGT].u <= 1.f && tcs[LORGT].u <= 1.f) || (tcs[UPLFT].u >= 0.f && tcs[LOLFT].u >= 0.f && tcs[UPRGT].u == 1.f && tcs[LORGT].u == 1.f)) { - flags |= GLT_CLAMPX; + flags |= GLWF_CLAMPX; } } } @@ -941,15 +942,15 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, if ((textureoffset == 0 && righttex <= tci.mRenderWidth) || (textureoffset >= 0 && righttex == tci.mRenderWidth)) { - flags |= GLT_CLAMPX; + flags |= GLWF_CLAMPX; } else { - flags &= ~GLT_CLAMPX; + flags &= ~GLWF_CLAMPX; } if (!wrap) { - flags |= GLT_CLAMPY; + flags |= GLWF_CLAMPY; } } if (mirrory) @@ -1081,7 +1082,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, } // restore some values that have been altered in this function glseg=glsave; - flags&=~(GLT_CLAMPX|GLT_CLAMPY|GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); + flags&=~(GLWF_CLAMPX|GLWF_CLAMPY|GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); RenderStyle = STYLE_Normal; } @@ -1192,7 +1193,7 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, alpha = 1.0f; lightlevel = savelight; Colormap = savecolor; - flags &= ~GLT_CLAMPY; + flags &= ~GLWF_CLAMPY; } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 2f7ad330d..bb78983f5 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -327,7 +327,7 @@ void GLWall::RenderTextured(int rflags) if (type == RENDERWALL_M2SNF) { - if (flags & GLT_CLAMPY) + if (flags & GLWF_CLAMPY) { if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); } diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index fa55339d7..a70354f95 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -34,6 +34,7 @@ #include "gl/system/gl_cvars.h" #include "gl/system/gl_debug.h" #include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_colormap.h" #include "gl/textures/gl_material.h" #include "gl/textures/gl_samplers.h" diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 5a0ba827c..758ecb7c9 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -16,18 +16,13 @@ class FCanvasTexture; class AActor; typedef TMap SpriteHits; + // For error catching while changing parameters. enum EInvalid { Invalid = 0 }; -enum -{ - GLT_CLAMPX=1, - GLT_CLAMPY=2 -}; - class FHardwareTexture { public: diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 9f28fe038..942a256e1 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -30,6 +30,7 @@ #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_hwtexture.h" #include "gl/textures/gl_material.h" #include "gl/shaders/gl_shader.h" @@ -634,7 +635,7 @@ void FMaterial::FlushAll() { for(int i=mMaterials.Size()-1;i>=0;i--) { - mMaterials[i]->Clean(true); + mMaterials[i]->mBaseLayer->Clean(true); } // This is for shader layers. All shader layers must be managed by the texture manager // so this will catch everything. @@ -652,3 +653,9 @@ void FMaterial::ClearLastTexture() { last = NULL; } + +void FMaterial::Clean(bool f) +{ + // This somehow needs to deal with the other layers as well, but they probably need some form of reference counting to work properly... + mBaseLayer->Clean(f); +} diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 3d4c2cc6a..7fe2b7ed0 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -4,8 +4,6 @@ #include "m_fixed.h" #include "textures/textures.h" -#include "gl/textures/gl_hwtexture.h" -#include "gl/renderer/gl_colormap.h" #include "i_system.h" #include "r_defs.h" @@ -112,10 +110,7 @@ public: void Bind(int clamp, int translation); - void Clean(bool f) - { - mBaseLayer->Clean(f); - } + void Clean(bool f); void BindToFrameBuffer(); // Patch drawing utilities diff --git a/src/textures/textures.h b/src/textures/textures.h index a979aad35..7474961d4 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -44,6 +44,8 @@ #include "r_data/r_translate.h" #include +typedef TMap SpriteHits; + enum MaterialShaderIndex { SHADER_Default,