From d01bc452bade917b78602ae2ea2fbfcf0b7f2731 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Apr 2018 13:00:33 +0200 Subject: [PATCH] - moved all variables not related to the hardware renderer's texture state out of gl_info. --- src/gl/dynlights/gl_glow.cpp | 12 ++++++------ src/gl/renderer/gl_renderstate.h | 4 ++-- src/gl/scene/gl_skydome.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 2 +- src/gl/textures/gl_material.cpp | 14 +++++++------- src/gl/textures/gl_texture.cpp | 12 +----------- src/r_data/gldefs.cpp | 24 +++++++++++------------ src/r_data/models/models_voxel.cpp | 3 +-- src/textures/skyboxtexture.cpp | 2 +- src/textures/texture.cpp | 5 +++++ src/textures/textures.h | 31 +++++++++++++++--------------- 12 files changed, 53 insertions(+), 60 deletions(-) diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp index 86818106e..1f9d910a2 100644 --- a/src/gl/dynlights/gl_glow.cpp +++ b/src/gl/dynlights/gl_glow.cpp @@ -48,11 +48,11 @@ int gl_CheckSpriteGlow(sector_t *sector, int lightlevel, const DVector3 &pos) FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)]; if (tex != NULL && tex->isGlowing()) { - if (!tex->gl_info.bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor)); + 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->gl_info.GlowHeight; + bottomglowcolor[3] = (float)tex->GlowHeight; } } } @@ -93,12 +93,12 @@ bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolo FTexture *tex = TexMan[sector->GetTexture(sector_t::ceiling)]; if (tex != NULL && tex->isGlowing()) { - if (!tex->gl_info.bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::ceiling)); + 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->gl_info.GlowHeight; + topglowcolor[3] = (float)tex->GlowHeight; } } } @@ -117,12 +117,12 @@ bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolo FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)]; if (tex != NULL && tex->isGlowing()) { - if (!tex->gl_info.bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor)); + 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->gl_info.GlowHeight; + bottomglowcolor[3] = (float)tex->GlowHeight; } } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 0a1012d91..7263df960 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -158,8 +158,8 @@ public: mTempTM = TM_MODULATE; } mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; - mShaderTimer = mat->tex->gl_info.shaderspeed; - SetSpecular(mat->tex->gl_info.Glossiness, mat->tex->gl_info.SpecularLevel); + mShaderTimer = mat->tex->shaderspeed; + SetSpecular(mat->tex->Glossiness, mat->tex->SpecularLevel); mat->Bind(clampmode, translation); } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index a6eda805b..80cb361df 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -519,7 +519,7 @@ void GLSkyPortal::DrawContents() drawer->SetupView(0, 0, 0, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); - if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) + if (origin->texture[0] && origin->texture[0]->tex->bSkybox) { RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 60eea0b59..a5bb341f0 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -940,7 +940,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) // allow disabling of the fullbright flag by a brightmap definition // (e.g. to do the gun flashes of Doom's zombies correctly. fullbright = (thing->flags5 & MF5_BRIGHT) || - ((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->gl_info.bDisableFullbright)); + ((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->bDisableFullbright)); lightlevel = fullbright ? 255 : gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index e8c555ea4..7bc2abeb6 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -176,7 +176,7 @@ static bool isBright(DPSprite *psp) { FMaterial * tex = FMaterial::ValidateTexture(lump, false, false); if (tex) - disablefullbright = tex->tex->gl_info.bDisableFullbright; + disablefullbright = tex->tex->bDisableFullbright; } return psp->GetState()->GetFullbright() && !disablefullbright; } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index a851f88cd..dce6f815e 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -130,7 +130,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture() if (tex->UseType==ETextureType::Null) return NULL; // Cannot register a NULL texture if (mHwTexture == NULL) { - mHwTexture = new FHardwareTexture(tex->gl_info.bNoCompress); + mHwTexture = new FHardwareTexture(tex->bNoCompress); } return mHwTexture; } @@ -314,21 +314,21 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) if (tx->bWarped) { mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2 - tx->gl_info.shaderspeed = static_cast(tx)->GetSpeed(); + tx->shaderspeed = static_cast(tx)->GetSpeed(); } else if (tx->bHasCanvas) { - if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) + if (tx->shaderindex >= FIRST_USER_SHADER) { - mShaderIndex = tx->gl_info.shaderindex; + mShaderIndex = tx->shaderindex; } // no brightmap for cameratexture } else { - if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) + if (tx->shaderindex >= FIRST_USER_SHADER) { - mShaderIndex = tx->gl_info.shaderindex; + mShaderIndex = tx->shaderindex; } else { @@ -763,7 +763,7 @@ again: { if (expand) { - if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER) + if (tex->bWarped || tex->bHasCanvas || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap)) { tex->gl_info.bNoExpand = true; goto again; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 4f7a6b104..db3e0d9e9 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -123,17 +123,7 @@ int TexFormat[]={ FTexture::MiscGLInfo::MiscGLInfo() throw() { - GlowHeight = 128; - bSkybox = false; - bFullbright = false; - bDisableFullbright = false; - bNoFilter = false; - bNoCompress = false; bNoExpand = false; - shaderspeed = 1.f; - shaderindex = 0; - Glossiness = 10.0f; - SpecularLevel = 0.1f; Material[1] = Material[0] = NULL; SystemTexture[1] = SystemTexture[0] = NULL; @@ -222,7 +212,7 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall)) { FTexture *tex = TexMan.ByIndex(i); - if (tex->gl_info.bSkybox) + if (tex->bSkybox) { FSkyBox *sb = static_cast(tex); for (int i = 0; i<6; i++) diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index 9b3836035..92c7a91d7 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -1013,7 +1013,7 @@ class GLDefsParser sc.MustGetString(); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny); FTexture *tex = TexMan[flump]; - if (tex) tex->gl_info.bAutoGlowing = tex->bGlowing = tex->gl_info.bFullbright = true; + if (tex) tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true; } } else if (sc.Compare("WALLS")) @@ -1024,7 +1024,7 @@ class GLDefsParser sc.MustGetString(); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Wall,FTextureManager::TEXMAN_TryAny); FTexture *tex = TexMan[flump]; - if (tex) tex->gl_info.bAutoGlowing = tex->bGlowing = tex->gl_info.bFullbright = true; + if (tex) tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true; } } else if (sc.Compare("TEXTURE")) @@ -1042,19 +1042,19 @@ class GLDefsParser { if (sc.CheckNumber()) { - if (tex) tex->gl_info.GlowHeight = sc.Number; + if (tex) tex->GlowHeight = sc.Number; if (!sc.CheckString(",")) goto skip_fb; } sc.MustGetStringName("fullbright"); - if (tex) tex->gl_info.bFullbright = true; + if (tex) tex->bFullbright = true; } skip_fb: sc.SetCMode(false); if (tex && color != 0) { - tex->gl_info.bAutoGlowing = false; + tex->bAutoGlowing = false; tex->bGlowing = true; tex->GlowColor = color; } @@ -1153,7 +1153,7 @@ class GLDefsParser bmtex->bMasked = false; tex->Brightmap = bmtex; } - tex->gl_info.bDisableFullbright = disable_fullbright; + tex->bDisableFullbright = disable_fullbright; } @@ -1212,13 +1212,13 @@ class GLDefsParser { sc.MustGetFloat(); if (tex) - tex->gl_info.Glossiness = (float)sc.Float; + tex->Glossiness = (float)sc.Float; } else if (sc.Compare("specularlevel")) { sc.MustGetFloat(); if (tex) - tex->gl_info.SpecularLevel = (float)sc.Float; + tex->SpecularLevel = (float)sc.Float; } else { @@ -1273,7 +1273,7 @@ class GLDefsParser } if (disable_fullbright_specified) - tex->gl_info.bDisableFullbright = disable_fullbright; + tex->bDisableFullbright = disable_fullbright; } @@ -1414,16 +1414,16 @@ class GLDefsParser Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); return; } - tex->gl_info.shaderspeed = speed; + tex->shaderspeed = speed; for (unsigned i = 0; i < usershaders.Size(); i++) { if (!usershaders[i].CompareNoCase(maplumpname)) { - tex->gl_info.shaderindex = i + FIRST_USER_SHADER; + tex->shaderindex = i + FIRST_USER_SHADER; return; } } - tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; + tex->shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; } } } diff --git a/src/r_data/models/models_voxel.cpp b/src/r_data/models/models_voxel.cpp index 087b80657..fe58c398f 100644 --- a/src/r_data/models/models_voxel.cpp +++ b/src/r_data/models/models_voxel.cpp @@ -80,8 +80,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox) WidthBits = 4; HeightBits = 4; WidthMask = 15; - gl_info.bNoFilter = true; - gl_info.bNoCompress = true; + bNoCompress = true; } //=========================================================================== diff --git a/src/textures/skyboxtexture.cpp b/src/textures/skyboxtexture.cpp index f5d8450b2..943b1f442 100644 --- a/src/textures/skyboxtexture.cpp +++ b/src/textures/skyboxtexture.cpp @@ -38,7 +38,7 @@ FSkyBox::FSkyBox() { faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL; UseType = ETextureType::Override; - gl_info.bSkybox = true; + bSkybox = true; fliptop = false; } diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index aeb631e49..2914b43c6 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -184,6 +184,11 @@ FTexture::FTexture (const char *name, int lumpnum) { bBrightmapChecked = false; bGlowing = false; + bAutoGlowing = false; + bFullbright = false; + bDisableFullbright = false; + bSkybox = false; + bNoCompress = false; bTranslucent = -1; diff --git a/src/textures/textures.h b/src/textures/textures.h index 566097e77..49cf29343 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -256,6 +256,11 @@ public: uint8_t bFullNameTexture : 1; uint8_t bBrightmapChecked : 1; // Set to 1 if brightmap has been checked uint8_t bGlowing : 1; // Texture glow color + uint8_t bAutoGlowing : 1; // Glow info is determined from texture image. + uint8_t bFullbright : 1; // always draw fullbright + uint8_t bDisableFullbright : 1; // This texture will not be displayed as fullbright sprite + uint8_t bSkybox : 1; // is a cubic skybox + uint8_t bNoCompress : 1; int8_t bTranslucent : 2; bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures @@ -263,8 +268,14 @@ public: int16_t SkyOffset; FloatRect *areas = nullptr; int areacount = 0; + int GlowHeight = 128; PalEntry GlowColor = 0; int HiresLump = -1; // For external hires textures. + float Glossiness = 10.f; + float SpecularLevel = 0.1f; + float shaderspeed = 1.f; + int shaderindex = 0; + struct Span @@ -468,29 +479,17 @@ public: struct MiscGLInfo { - FMaterial *Material[2]; - FGLTexture *SystemTexture[2]; - float Glossiness; - float SpecularLevel; - int GlowHeight; - int shaderindex; - float shaderspeed; - bool bAutoGlowing : 1; // Glow info is determined from texture image. - bool bFullbright:1; // always draw fullbright - bool bSkybox:1; // This is a skybox - bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite - bool bNoFilter:1; - bool bNoCompress:1; - bool bNoExpand:1; + FMaterial *Material[2] = { nullptr, nullptr }; + FGLTexture *SystemTexture[2] = { nullptr, nullptr }; + bool bNoExpand = false; - MiscGLInfo() throw (); ~MiscGLInfo(); }; MiscGLInfo gl_info; void GetGlowColor(float *data); bool isGlowing() { return bGlowing; } - bool isFullbright() { return gl_info.bFullbright; } + bool isFullbright() { return bFullbright; } void CreateDefaultBrightmap(); bool FindHoles(const unsigned char * buffer, int w, int h); static bool SmoothEdges(unsigned char * buffer,int w, int h);