diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3de02a36..0a89f9fb5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1043,7 +1043,6 @@ set (PCH_SOURCES g_statusbar/shared_sbar.cpp gl/compatibility/gl_20.cpp gl/data/gl_vertexbuffer.cpp - gl/dynlights/gl_glow.cpp gl/dynlights/gl_lightbuffer.cpp gl/dynlights/gl_aabbtree.cpp gl/dynlights/gl_shadowmap.cpp diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp deleted file mode 100644 index 1f9d910a2..000000000 --- a/src/gl/dynlights/gl_glow.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2005-2016 Christoph Oelckers -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// -/* -** gl_glow.cpp -** Glowing flats like Doomsday -** -**/ - -#include "w_wad.h" -#include "sc_man.h" -#include "v_video.h" -#include "r_defs.h" -#include "textures/textures.h" - -#include "gl/dynlights/gl_glow.h" - -//========================================================================== -// -// Checks whether a sprite should be affected by a glow -// -//========================================================================== -int gl_CheckSpriteGlow(sector_t *sector, int lightlevel, const DVector3 &pos) -{ - float bottomglowcolor[4]; - bottomglowcolor[3] = 0; - auto c = sector->planes[sector_t::floor].GlowColor; - if (c == 0) - { - FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)]; - if (tex != NULL && tex->isGlowing()) - { - if (!tex->bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor)); - if (tex->isGlowing()) // recheck the current animation frame. - { - tex->GetGlowColor(bottomglowcolor); - bottomglowcolor[3] = (float)tex->GlowHeight; - } - } - } - else if (c != ~0u) - { - bottomglowcolor[0] = c.r / 255.f; - bottomglowcolor[1] = c.g / 255.f; - bottomglowcolor[2] = c.b / 255.f; - bottomglowcolor[3] = sector->planes[sector_t::floor].GlowHeight; - } - - if (bottomglowcolor[3]> 0) - { - double floordiff = pos.Z - sector->floorplane.ZatPoint(pos); - if (floordiff < bottomglowcolor[3]) - { - int maxlight = (255 + lightlevel) >> 1; - double lightfrac = floordiff / bottomglowcolor[3]; - if (lightfrac < 0) lightfrac = 0; - lightlevel = int(lightfrac*lightlevel + maxlight*(1 - lightfrac)); - } - } - return lightlevel; -} - -//========================================================================== -// -// Checks whether a wall should glow -// -//========================================================================== -bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolor) -{ - bool ret = false; - bottomglowcolor[3] = topglowcolor[3] = 0; - auto c = sector->planes[sector_t::ceiling].GlowColor; - if (c == 0) - { - FTexture *tex = TexMan[sector->GetTexture(sector_t::ceiling)]; - if (tex != NULL && tex->isGlowing()) - { - if (!tex->bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::ceiling)); - if (tex->isGlowing()) // recheck the current animation frame. - { - ret = true; - tex->GetGlowColor(topglowcolor); - topglowcolor[3] = (float)tex->GlowHeight; - } - } - } - else if (c != ~0u) - { - topglowcolor[0] = c.r / 255.f; - topglowcolor[1] = c.g / 255.f; - topglowcolor[2] = c.b / 255.f; - topglowcolor[3] = sector->planes[sector_t::ceiling].GlowHeight; - ret = topglowcolor[3] > 0; - } - - c = sector->planes[sector_t::floor].GlowColor; - if (c == 0) - { - FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)]; - if (tex != NULL && tex->isGlowing()) - { - if (!tex->bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor)); - if (tex->isGlowing()) // recheck the current animation frame. - { - ret = true; - tex->GetGlowColor(bottomglowcolor); - bottomglowcolor[3] = (float)tex->GlowHeight; - } - } - } - else if (c != ~0u) - { - bottomglowcolor[0] = c.r / 255.f; - bottomglowcolor[1] = c.g / 255.f; - bottomglowcolor[2] = c.b / 255.f; - bottomglowcolor[3] = sector->planes[sector_t::floor].GlowHeight; - ret = bottomglowcolor[3] > 0; - } - return ret; -} - diff --git a/src/gl/dynlights/gl_glow.h b/src/gl/dynlights/gl_glow.h deleted file mode 100644 index eb433c999..000000000 --- a/src/gl/dynlights/gl_glow.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef __GL_GLOW -#define __GL_GLOW - -struct sector_t; - -void gl_InitGlow(const char * lumpnm); -int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, const DVector3 &pos); -bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolor); - -#endif diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 163d7a00a..a664b3729 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -46,7 +46,6 @@ #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" -#include "gl/dynlights/gl_glow.h" #include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/shaders/gl_shader.h" diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 884eafcfa..2875e5619 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -45,7 +45,6 @@ #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_quaddrawer.h" -#include "gl/dynlights/gl_glow.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_clipper.h" diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 45cc254e4..8fb81e88b 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -34,7 +34,6 @@ #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" -#include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/scene/gl_scenedrawer.h" diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index a5bb341f0..6acfb8717 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -48,7 +48,6 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" -#include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_scenedrawer.h" #include "gl/scene/gl_portal.h" @@ -425,7 +424,7 @@ void GLSprite::Draw(int pass) secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane; int thislight = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; - int thisll = actor == nullptr? thislight : (uint8_t)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_viewpoint.TicFrac)); + int thisll = actor == nullptr? thislight : (uint8_t)actor->Sector->CheckSpriteGlow(thislight, actor->InterpolatedPosition(r_viewpoint.TicFrac)); FColormap thiscm; thiscm.CopyFog(Colormap); @@ -947,7 +946,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) rendersector->GetCeilingLight() : rendersector->GetFloorLight()); foglevel = (uint8_t)clamp(rendersector->lightlevel, 0, 255); - lightlevel = gl_CheckSpriteGlow(rendersector, lightlevel, thingpos); + lightlevel = rendersector->CheckSpriteGlow(lightlevel, thingpos); ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; ThingColor.a = 255; diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index 07f5303fd..f56465a25 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -28,7 +28,6 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" -#include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/shaders/gl_shader.h" diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 56e9e004f..beb478dfd 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -39,7 +39,6 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" #include "gl/dynlights/gl_dynlight.h" -#include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" #include "gl/scene/gl_scenedrawer.h" @@ -1537,7 +1536,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) gltexture = NULL; - if (gl_GetWallGlow(frontsector, topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW; + if (frontsector->GetWallGlow(topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW; topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; @@ -1773,7 +1772,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * RenderStyle = STYLE_Normal; Colormap = frontsector->Colormap; - if (gl_GetWallGlow(frontsector, topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW; + if (frontsector->GetWallGlow(topglowcolor, bottomglowcolor)) flags |= GLWF_GLOW; topplane = frontsector->ceilingplane; bottomplane = frontsector->floorplane; dynlightindex = -1; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 3cbaa32d4..18edfdc30 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -36,7 +36,6 @@ #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/dynlights/gl_dynlight.h" -#include "gl/dynlights/gl_glow.h" #include "gl/dynlights/gl_lightbuffer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_portal.h" diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 7bc2abeb6..754b0cc1e 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -41,7 +41,6 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" -#include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_scenedrawer.h" #include "gl/models/gl_models.h" @@ -330,7 +329,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { lightlevel = (2 * lightlevel + 255) / 3; } - lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos()); + lightlevel = viewsector->CheckSpriteGlow(lightlevel, playermo->Pos()); } diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index db3e0d9e9..307948ece 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -115,21 +115,7 @@ int TexFormat[]={ -//========================================================================== -// -// GL status data for a texture -// -//========================================================================== - -FTexture::MiscGLInfo::MiscGLInfo() throw() -{ - bNoExpand = false; - - Material[1] = Material[0] = NULL; - SystemTexture[1] = SystemTexture[0] = NULL; -} - -FTexture::MiscGLInfo::~MiscGLInfo() +FTexture::GLTexInfo::~GLTexInfo() { for (int i = 0; i < 2; i++) { diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 9b01a0f1a..94a1fe8a5 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -3,7 +3,7 @@ // Copyright 1993-1996 id Software // Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman // Copyright 1999-2016 Randy Heit -// Copyright 2002-2017 Christoph Oelckers +// Copyright 2002-2018 Christoph Oelckers // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -1527,6 +1527,112 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt) } + //========================================================================== + // + // Checks whether a sprite should be affected by a glow + // + //========================================================================== + + int sector_t::CheckSpriteGlow(int lightlevel, const DVector3 &pos) + { + float bottomglowcolor[4]; + bottomglowcolor[3] = 0; + auto c = planes[sector_t::floor].GlowColor; + if (c == 0) + { + FTexture *tex = TexMan[GetTexture(sector_t::floor)]; + if (tex != NULL && tex->isGlowing()) + { + if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor)); + if (tex->isGlowing()) // recheck the current animation frame. + { + tex->GetGlowColor(bottomglowcolor); + bottomglowcolor[3] = (float)tex->GlowHeight; + } + } + } + else if (c != ~0u) + { + bottomglowcolor[0] = c.r / 255.f; + bottomglowcolor[1] = c.g / 255.f; + bottomglowcolor[2] = c.b / 255.f; + bottomglowcolor[3] = planes[sector_t::floor].GlowHeight; + } + + if (bottomglowcolor[3]> 0) + { + double floordiff = pos.Z - floorplane.ZatPoint(pos); + if (floordiff < bottomglowcolor[3]) + { + int maxlight = (255 + lightlevel) >> 1; + double lightfrac = floordiff / bottomglowcolor[3]; + if (lightfrac < 0) lightfrac = 0; + lightlevel = int(lightfrac*lightlevel + maxlight * (1 - lightfrac)); + } + } + return lightlevel; + } + + //========================================================================== + // + // Checks whether a wall should glow + // + //========================================================================== + bool sector_t::GetWallGlow(float *topglowcolor, float *bottomglowcolor) + { + bool ret = false; + bottomglowcolor[3] = topglowcolor[3] = 0; + auto c = planes[sector_t::ceiling].GlowColor; + if (c == 0) + { + FTexture *tex = TexMan[GetTexture(sector_t::ceiling)]; + if (tex != NULL && tex->isGlowing()) + { + if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::ceiling)); + if (tex->isGlowing()) // recheck the current animation frame. + { + ret = true; + tex->GetGlowColor(topglowcolor); + topglowcolor[3] = (float)tex->GlowHeight; + } + } + } + else if (c != ~0u) + { + topglowcolor[0] = c.r / 255.f; + topglowcolor[1] = c.g / 255.f; + topglowcolor[2] = c.b / 255.f; + topglowcolor[3] = planes[sector_t::ceiling].GlowHeight; + ret = topglowcolor[3] > 0; + } + + c = planes[sector_t::floor].GlowColor; + if (c == 0) + { + FTexture *tex = TexMan[GetTexture(sector_t::floor)]; + if (tex != NULL && tex->isGlowing()) + { + if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor)); + if (tex->isGlowing()) // recheck the current animation frame. + { + ret = true; + tex->GetGlowColor(bottomglowcolor); + bottomglowcolor[3] = (float)tex->GlowHeight; + } + } + } + else if (c != ~0u) + { + bottomglowcolor[0] = c.r / 255.f; + bottomglowcolor[1] = c.g / 255.f; + bottomglowcolor[2] = c.b / 255.f; + bottomglowcolor[3] = planes[sector_t::floor].GlowHeight; + ret = bottomglowcolor[3] > 0; + } + return ret; + } + + //=========================================================================== // // diff --git a/src/r_defs.h b/src/r_defs.h index 7f17e8466..00062f668 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -663,6 +663,9 @@ public: FSectorPortal *ValidatePortal(int which); void CheckPortalPlane(int plane); + int CheckSpriteGlow(int lightlevel, const DVector3 &pos); + bool GetWallGlow(float *topglowcolor, float *bottomglowcolor); + enum { diff --git a/src/textures/textures.h b/src/textures/textures.h index 49cf29343..6e8a3aec3 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -477,15 +477,15 @@ public: public: - struct MiscGLInfo + struct GLTexInfo { FMaterial *Material[2] = { nullptr, nullptr }; FGLTexture *SystemTexture[2] = { nullptr, nullptr }; bool bNoExpand = false; - ~MiscGLInfo(); + ~GLTexInfo(); }; - MiscGLInfo gl_info; + GLTexInfo gl_info; void GetGlowColor(float *data); bool isGlowing() { return bGlowing; }