- moved all variables not related to the hardware renderer's texture state out of gl_info.

This commit is contained in:
Christoph Oelckers 2018-04-02 13:00:33 +02:00
parent 1fc4c9801b
commit d01bc452ba
12 changed files with 53 additions and 60 deletions

View file

@ -48,11 +48,11 @@ int gl_CheckSpriteGlow(sector_t *sector, int lightlevel, const DVector3 &pos)
FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)]; FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)];
if (tex != NULL && tex->isGlowing()) 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. if (tex->isGlowing()) // recheck the current animation frame.
{ {
tex->GetGlowColor(bottomglowcolor); 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)]; FTexture *tex = TexMan[sector->GetTexture(sector_t::ceiling)];
if (tex != NULL && tex->isGlowing()) 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. if (tex->isGlowing()) // recheck the current animation frame.
{ {
ret = true; ret = true;
tex->GetGlowColor(topglowcolor); 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)]; FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)];
if (tex != NULL && tex->isGlowing()) 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. if (tex->isGlowing()) // recheck the current animation frame.
{ {
ret = true; ret = true;
tex->GetGlowColor(bottomglowcolor); tex->GetGlowColor(bottomglowcolor);
bottomglowcolor[3] = (float)tex->gl_info.GlowHeight; bottomglowcolor[3] = (float)tex->GlowHeight;
} }
} }
} }

View file

@ -158,8 +158,8 @@ public:
mTempTM = TM_MODULATE; mTempTM = TM_MODULATE;
} }
mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex;
mShaderTimer = mat->tex->gl_info.shaderspeed; mShaderTimer = mat->tex->shaderspeed;
SetSpecular(mat->tex->gl_info.Glossiness, mat->tex->gl_info.SpecularLevel); SetSpecular(mat->tex->Glossiness, mat->tex->SpecularLevel);
mat->Bind(clampmode, translation); mat->Bind(clampmode, translation);
} }

View file

@ -519,7 +519,7 @@ void GLSkyPortal::DrawContents()
drawer->SetupView(0, 0, 0, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); drawer->SetupView(0, 0, 0, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); 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); RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
} }

View file

@ -940,7 +940,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
// allow disabling of the fullbright flag by a brightmap definition // allow disabling of the fullbright flag by a brightmap definition
// (e.g. to do the gun flashes of Doom's zombies correctly. // (e.g. to do the gun flashes of Doom's zombies correctly.
fullbright = (thing->flags5 & MF5_BRIGHT) || 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 : lightlevel = fullbright ? 255 :
gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?

View file

@ -176,7 +176,7 @@ static bool isBright(DPSprite *psp)
{ {
FMaterial * tex = FMaterial::ValidateTexture(lump, false, false); FMaterial * tex = FMaterial::ValidateTexture(lump, false, false);
if (tex) if (tex)
disablefullbright = tex->tex->gl_info.bDisableFullbright; disablefullbright = tex->tex->bDisableFullbright;
} }
return psp->GetState()->GetFullbright() && !disablefullbright; return psp->GetState()->GetFullbright() && !disablefullbright;
} }

View file

@ -130,7 +130,7 @@ FHardwareTexture *FGLTexture::CreateHwTexture()
if (tex->UseType==ETextureType::Null) return NULL; // Cannot register a NULL texture if (tex->UseType==ETextureType::Null) return NULL; // Cannot register a NULL texture
if (mHwTexture == NULL) if (mHwTexture == NULL)
{ {
mHwTexture = new FHardwareTexture(tex->gl_info.bNoCompress); mHwTexture = new FHardwareTexture(tex->bNoCompress);
} }
return mHwTexture; return mHwTexture;
} }
@ -314,21 +314,21 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
if (tx->bWarped) if (tx->bWarped)
{ {
mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2 mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2
tx->gl_info.shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed(); tx->shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed();
} }
else if (tx->bHasCanvas) 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 // no brightmap for cameratexture
} }
else else
{ {
if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) if (tx->shaderindex >= FIRST_USER_SHADER)
{ {
mShaderIndex = tx->gl_info.shaderindex; mShaderIndex = tx->shaderindex;
} }
else else
{ {
@ -763,7 +763,7 @@ again:
{ {
if (expand) 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; tex->gl_info.bNoExpand = true;
goto again; goto again;

View file

@ -123,17 +123,7 @@ int TexFormat[]={
FTexture::MiscGLInfo::MiscGLInfo() throw() FTexture::MiscGLInfo::MiscGLInfo() throw()
{ {
GlowHeight = 128;
bSkybox = false;
bFullbright = false;
bDisableFullbright = false;
bNoFilter = false;
bNoCompress = false;
bNoExpand = false; bNoExpand = false;
shaderspeed = 1.f;
shaderindex = 0;
Glossiness = 10.0f;
SpecularLevel = 0.1f;
Material[1] = Material[0] = NULL; Material[1] = Material[0] = NULL;
SystemTexture[1] = SystemTexture[0] = NULL; SystemTexture[1] = SystemTexture[0] = NULL;
@ -222,7 +212,7 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall)) if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
{ {
FTexture *tex = TexMan.ByIndex(i); FTexture *tex = TexMan.ByIndex(i);
if (tex->gl_info.bSkybox) if (tex->bSkybox)
{ {
FSkyBox *sb = static_cast<FSkyBox*>(tex); FSkyBox *sb = static_cast<FSkyBox*>(tex);
for (int i = 0; i<6; i++) for (int i = 0; i<6; i++)

View file

@ -1013,7 +1013,7 @@ class GLDefsParser
sc.MustGetString(); sc.MustGetString();
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny);
FTexture *tex = TexMan[flump]; 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")) else if (sc.Compare("WALLS"))
@ -1024,7 +1024,7 @@ class GLDefsParser
sc.MustGetString(); sc.MustGetString();
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Wall,FTextureManager::TEXMAN_TryAny); FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Wall,FTextureManager::TEXMAN_TryAny);
FTexture *tex = TexMan[flump]; 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")) else if (sc.Compare("TEXTURE"))
@ -1042,19 +1042,19 @@ class GLDefsParser
{ {
if (sc.CheckNumber()) if (sc.CheckNumber())
{ {
if (tex) tex->gl_info.GlowHeight = sc.Number; if (tex) tex->GlowHeight = sc.Number;
if (!sc.CheckString(",")) goto skip_fb; if (!sc.CheckString(",")) goto skip_fb;
} }
sc.MustGetStringName("fullbright"); sc.MustGetStringName("fullbright");
if (tex) tex->gl_info.bFullbright = true; if (tex) tex->bFullbright = true;
} }
skip_fb: skip_fb:
sc.SetCMode(false); sc.SetCMode(false);
if (tex && color != 0) if (tex && color != 0)
{ {
tex->gl_info.bAutoGlowing = false; tex->bAutoGlowing = false;
tex->bGlowing = true; tex->bGlowing = true;
tex->GlowColor = color; tex->GlowColor = color;
} }
@ -1153,7 +1153,7 @@ class GLDefsParser
bmtex->bMasked = false; bmtex->bMasked = false;
tex->Brightmap = bmtex; tex->Brightmap = bmtex;
} }
tex->gl_info.bDisableFullbright = disable_fullbright; tex->bDisableFullbright = disable_fullbright;
} }
@ -1212,13 +1212,13 @@ class GLDefsParser
{ {
sc.MustGetFloat(); sc.MustGetFloat();
if (tex) if (tex)
tex->gl_info.Glossiness = (float)sc.Float; tex->Glossiness = (float)sc.Float;
} }
else if (sc.Compare("specularlevel")) else if (sc.Compare("specularlevel"))
{ {
sc.MustGetFloat(); sc.MustGetFloat();
if (tex) if (tex)
tex->gl_info.SpecularLevel = (float)sc.Float; tex->SpecularLevel = (float)sc.Float;
} }
else else
{ {
@ -1273,7 +1273,7 @@ class GLDefsParser
} }
if (disable_fullbright_specified) 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()); Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
return; return;
} }
tex->gl_info.shaderspeed = speed; tex->shaderspeed = speed;
for (unsigned i = 0; i < usershaders.Size(); i++) for (unsigned i = 0; i < usershaders.Size(); i++)
{ {
if (!usershaders[i].CompareNoCase(maplumpname)) if (!usershaders[i].CompareNoCase(maplumpname))
{ {
tex->gl_info.shaderindex = i + FIRST_USER_SHADER; tex->shaderindex = i + FIRST_USER_SHADER;
return; return;
} }
} }
tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; tex->shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER;
} }
} }
} }

View file

@ -80,8 +80,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox)
WidthBits = 4; WidthBits = 4;
HeightBits = 4; HeightBits = 4;
WidthMask = 15; WidthMask = 15;
gl_info.bNoFilter = true; bNoCompress = true;
gl_info.bNoCompress = true;
} }
//=========================================================================== //===========================================================================

View file

@ -38,7 +38,7 @@ FSkyBox::FSkyBox()
{ {
faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL; faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL;
UseType = ETextureType::Override; UseType = ETextureType::Override;
gl_info.bSkybox = true; bSkybox = true;
fliptop = false; fliptop = false;
} }

View file

@ -184,6 +184,11 @@ FTexture::FTexture (const char *name, int lumpnum)
{ {
bBrightmapChecked = false; bBrightmapChecked = false;
bGlowing = false; bGlowing = false;
bAutoGlowing = false;
bFullbright = false;
bDisableFullbright = false;
bSkybox = false;
bNoCompress = false;
bTranslucent = -1; bTranslucent = -1;

View file

@ -256,6 +256,11 @@ public:
uint8_t bFullNameTexture : 1; uint8_t bFullNameTexture : 1;
uint8_t bBrightmapChecked : 1; // Set to 1 if brightmap has been checked uint8_t bBrightmapChecked : 1; // Set to 1 if brightmap has been checked
uint8_t bGlowing : 1; // Texture glow color 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; int8_t bTranslucent : 2;
bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures
@ -263,8 +268,14 @@ public:
int16_t SkyOffset; int16_t SkyOffset;
FloatRect *areas = nullptr; FloatRect *areas = nullptr;
int areacount = 0; int areacount = 0;
int GlowHeight = 128;
PalEntry GlowColor = 0; PalEntry GlowColor = 0;
int HiresLump = -1; // For external hires textures. int HiresLump = -1; // For external hires textures.
float Glossiness = 10.f;
float SpecularLevel = 0.1f;
float shaderspeed = 1.f;
int shaderindex = 0;
struct Span struct Span
@ -468,29 +479,17 @@ public:
struct MiscGLInfo struct MiscGLInfo
{ {
FMaterial *Material[2]; FMaterial *Material[2] = { nullptr, nullptr };
FGLTexture *SystemTexture[2]; FGLTexture *SystemTexture[2] = { nullptr, nullptr };
float Glossiness; bool bNoExpand = false;
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;
MiscGLInfo() throw ();
~MiscGLInfo(); ~MiscGLInfo();
}; };
MiscGLInfo gl_info; MiscGLInfo gl_info;
void GetGlowColor(float *data); void GetGlowColor(float *data);
bool isGlowing() { return bGlowing; } bool isGlowing() { return bGlowing; }
bool isFullbright() { return gl_info.bFullbright; } bool isFullbright() { return bFullbright; }
void CreateDefaultBrightmap(); void CreateDefaultBrightmap();
bool FindHoles(const unsigned char * buffer, int w, int h); bool FindHoles(const unsigned char * buffer, int w, int h);
static bool SmoothEdges(unsigned char * buffer,int w, int h); static bool SmoothEdges(unsigned char * buffer,int w, int h);