- moved all GLDEFS parsing into a dedicated source file.

- split gl_postprocessshader.h in two so that the hardware independent part can be used by GLDEFS without pulling in all of OpenGL.
This commit is contained in:
Christoph Oelckers 2018-04-02 12:28:20 +02:00
parent fd6fbc76c6
commit 1fc4c9801b
18 changed files with 1925 additions and 1841 deletions

View File

@ -1055,7 +1055,6 @@ set (PCH_SOURCES
gl/renderer/gl_postprocess.cpp
gl/renderer/gl_postprocessstate.cpp
gl/shaders/gl_shader.cpp
gl/shaders/gl_texshader.cpp
gl/shaders/gl_shaderprogram.cpp
gl/shaders/gl_postprocessshader.cpp
gl/shaders/gl_shadowmapshader.cpp
@ -1144,6 +1143,7 @@ set (PCH_SOURCES
intermission/intermission.cpp
intermission/intermission_parse.cpp
r_data/colormaps.cpp
r_data/gldefs.cpp
r_data/a_dynlightdata.cpp
r_data/r_translate.cpp
r_data/sprites.cpp

View File

@ -176,6 +176,7 @@ extern bool gameisdead;
extern bool demorecording;
extern bool M_DemoNoPlay; // [RH] if true, then skip any demos in the loop
extern bool insave;
extern TDeletingArray<FLightDefaults *> LightDefaults;
// PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -2772,6 +2773,7 @@ void D_DoomMain (void)
DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods
FS_Close(); // destroy the global FraggleScript.
DeinitMenus();
LightDefaults.Clear(); // this can leak heap memory if it isn't cleared.
// delete DoomStartupInfo data
DoomStartupInfo.Name = (const char*)0;

View File

@ -793,6 +793,147 @@ void ADynamicLight::OnDestroy()
}
//==========================================================================
//
//
//
//==========================================================================
void AActor::AttachLight(unsigned int count, const FLightDefaults *lightdef)
{
ADynamicLight *light;
if (count < AttachedLights.Size())
{
light = barrier_cast<ADynamicLight*>(AttachedLights[count]);
assert(light != NULL);
}
else
{
light = Spawn<ADynamicLight>(Pos(), NO_REPLACE);
light->target = this;
light->owned = true;
light->ObjectFlags |= OF_Transient;
//light->lightflags |= LF_ATTENUATE;
AttachedLights.Push(light);
}
light->flags2&=~MF2_DORMANT;
lightdef->ApplyProperties(light);
}
//==========================================================================
//
// per-state light adjustment
//
//==========================================================================
extern TArray<FLightDefaults *> StateLights;
void AActor::SetDynamicLights()
{
TArray<FInternalLightAssociation *> & LightAssociations = GetInfo()->LightAssociations;
unsigned int count = 0;
if (state == NULL) return;
if (LightAssociations.Size() > 0)
{
ADynamicLight *lights, *tmpLight;
unsigned int i;
lights = tmpLight = NULL;
for (i = 0; i < LightAssociations.Size(); i++)
{
if (LightAssociations[i]->Sprite() == sprite &&
(LightAssociations[i]->Frame()==frame || LightAssociations[i]->Frame()==-1))
{
AttachLight(count++, LightAssociations[i]->Light());
}
}
}
if (count == 0 && state->Light > 0)
{
for(int i= state->Light; StateLights[i] != NULL; i++)
{
if (StateLights[i] != (FLightDefaults*)-1)
{
AttachLight(count++, StateLights[i]);
}
}
}
for(;count<AttachedLights.Size();count++)
{
AttachedLights[count]->flags2 |= MF2_DORMANT;
memset(AttachedLights[count]->args, 0, 3*sizeof(args[0]));
}
}
//==========================================================================
//
// Needed for garbage collection
//
//==========================================================================
size_t AActor::PropagateMark()
{
for (unsigned i = 0; i<AttachedLights.Size(); i++)
{
GC::Mark(AttachedLights[i]);
}
return Super::PropagateMark();
}
//==========================================================================
//
// This is called before saving the game
//
//==========================================================================
void AActor::DeleteAllAttachedLights()
{
TThinkerIterator<AActor> it;
AActor * a;
ADynamicLight * l;
while ((a=it.Next()))
{
a->AttachedLights.Clear();
}
TThinkerIterator<ADynamicLight> it2;
l=it2.Next();
while (l)
{
ADynamicLight * ll = it2.Next();
if (l->owned) l->Destroy();
l=ll;
}
}
//==========================================================================
//
//
//
//==========================================================================
void AActor::RecreateAllAttachedLights()
{
TThinkerIterator<AActor> it;
AActor * a;
while ((a=it.Next()))
{
a->SetDynamicLights();
}
}
//==========================================================================
//
// CCMDs
//
//==========================================================================
CCMD(listlights)
{
int walls, sectors, subsecs;

View File

@ -8,17 +8,28 @@ EXTERN_CVAR(Bool, gl_attachedlights)
class ADynamicLight;
class FSerializer;
class FLightDefaults;
enum ELightType
{
PointLight,
PulseLight,
FlickerLight,
RandomFlickerLight,
SectorLight,
DummyLight,
ColorPulseLight,
ColorFlickerLight,
RandomColorFlickerLight
};
enum
{
LIGHT_RED = 0,
LIGHT_GREEN = 1,
LIGHT_BLUE = 2,
LIGHT_INTENSITY = 3,
LIGHT_SECONDARY_INTENSITY = 4,
LIGHT_SCALE = 3,
LIGHT_RED = 0,
LIGHT_GREEN = 1,
LIGHT_BLUE = 2,
LIGHT_INTENSITY = 3,
LIGHT_SECONDARY_INTENSITY = 4,
LIGHT_SCALE = 3,
};
enum LightFlag
@ -32,24 +43,111 @@ enum LightFlag
LF_SPOT = 64
};
//==========================================================================
//
// Light definitions
//
//==========================================================================
class FLightDefaults
{
public:
FLightDefaults(FName name, ELightType type);
void ApplyProperties(ADynamicLight * light) const;
FName GetName() const { return m_Name; }
void SetParameter(double p) { m_Param = p; }
void SetArg(int arg, int val) { m_Args[arg] = val; }
int GetArg(int arg) { return m_Args[arg]; }
uint8_t GetAttenuate() const { return m_attenuate; }
void SetOffset(float* ft) { m_Pos.X = ft[0]; m_Pos.Z = ft[1]; m_Pos.Y = ft[2]; }
void SetSubtractive(bool subtract) { m_subtractive = subtract; }
void SetAdditive(bool add) { m_additive = add; }
void SetDontLightSelf(bool add) { m_dontlightself = add; }
void SetAttenuate(bool on) { m_attenuate = on; }
void SetHalo(bool halo) { m_halo = halo; }
void SetDontLightActors(bool on) { m_dontlightactors = on; }
void SetSpot(bool spot) { m_spot = spot; }
void SetSpotInnerAngle(double angle) { m_spotInnerAngle = angle; }
void SetSpotOuterAngle(double angle) { m_spotOuterAngle = angle; }
void OrderIntensities()
{
if (m_Args[LIGHT_INTENSITY] > m_Args[LIGHT_SECONDARY_INTENSITY])
{
std::swap(m_Args[LIGHT_INTENSITY], m_Args[LIGHT_SECONDARY_INTENSITY]);
m_swapped = true;
}
}
protected:
FName m_Name;
int m_Args[5] = { 0,0,0,0,0 };
double m_Param = 0;
DVector3 m_Pos = { 0,0,0 };
ELightType m_type;
int8_t m_attenuate = -1;
bool m_subtractive = false;
bool m_additive = false;
bool m_halo = false;
bool m_dontlightself = false;
bool m_dontlightactors = false;
bool m_swapped = false;
bool m_spot = false;
double m_spotInnerAngle = 10.0;
double m_spotOuterAngle = 25.0;
};
//==========================================================================
//
// Light associations (intermediate parser data)
//
//==========================================================================
class FLightAssociation
{
public:
//FLightAssociation();
FLightAssociation(FName actorName, const char *frameName, FName lightName)
: m_ActorName(actorName), m_AssocLight(lightName)
{
strncpy(m_FrameName, frameName, 8);
}
FName ActorName() { return m_ActorName; }
const char *FrameName() { return m_FrameName; }
FName Light() { return m_AssocLight; }
void ReplaceLightName(FName newName) { m_AssocLight = newName; }
protected:
char m_FrameName[8];
FName m_ActorName, m_AssocLight;
};
//==========================================================================
//
// Light associations per actor class
//
//==========================================================================
class FInternalLightAssociation
{
public:
FInternalLightAssociation(FLightAssociation * asso);
int Sprite() const { return m_sprite; }
int Frame() const { return m_frame; }
const FLightDefaults *Light() const { return m_AssocLight; }
protected:
int m_sprite;
int m_frame;
FLightDefaults * m_AssocLight;
};
typedef TFlags<LightFlag> LightFlags;
DEFINE_TFLAGS_OPERATORS(LightFlags)
enum ELightType
{
PointLight,
PulseLight,
FlickerLight,
RandomFlickerLight,
SectorLight,
DummyLight,
ColorPulseLight,
ColorFlickerLight,
RandomColorFlickerLight
};
struct FLightNode
{
FLightNode ** prevTarget;

View File

@ -33,75 +33,6 @@
#include "gl/dynlights/gl_glow.h"
//===========================================================================
//
// Reads glow definitions from GLDEFS
//
//===========================================================================
void gl_InitGlow(FScanner &sc)
{
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
sc.MustGetString();
if (sc.Compare("FLATS"))
{
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
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;
}
}
else if (sc.Compare("WALLS"))
{
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
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;
}
}
else if (sc.Compare("TEXTURE"))
{
sc.SetCMode(true);
sc.MustGetString();
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny);
FTexture *tex = TexMan[flump];
sc.MustGetStringName(",");
sc.MustGetString();
PalEntry color = V_GetColor(NULL, sc.String);
//sc.MustGetStringName(",");
//sc.MustGetNumber();
if (sc.CheckString(","))
{
if (sc.CheckNumber())
{
if (tex) tex->gl_info.GlowHeight = sc.Number;
if (!sc.CheckString(",")) goto skip_fb;
}
sc.MustGetStringName("fullbright");
if (tex) tex->gl_info.bFullbright = true;
}
skip_fb:
sc.SetCMode(false);
if (tex && color != 0)
{
tex->gl_info.bAutoGlowing = false;
tex->bGlowing = true;
tex->GlowColor = color;
}
}
}
}
//==========================================================================
//
// Checks whether a sprite should be affected by a glow

View File

@ -62,6 +62,7 @@
#include "gl/shaders/gl_fxaashader.h"
#include "gl/shaders/gl_presentshader.h"
#include "gl/shaders/gl_postprocessshader.h"
#include "gl/shaders/gl_postprocessshaderinstance.h"
#include "gl/stereo3d/gl_stereo3d.h"
#include "r_videoscale.h"

View File

@ -60,6 +60,7 @@
#include "gl/shaders/gl_present3dRowshader.h"
#include "gl/shaders/gl_shadowmapshader.h"
#include "gl/shaders/gl_postprocessshader.h"
#include "gl/shaders/gl_postprocessshaderinstance.h"
#include "gl/stereo3d/gl_stereo3d.h"
#include "gl/textures/gl_material.h"
#include "gl/textures/gl_samplers.h"

View File

@ -33,6 +33,7 @@
#include "gl/renderer/gl_postprocessstate.h"
#include "gl/renderer/gl_renderbuffers.h"
#include "gl/shaders/gl_postprocessshader.h"
#include "gl/shaders/gl_postprocessshaderinstance.h"
#include "textures/textures.h"
#include "textures/bitmap.h"

View File

@ -1,10 +1,5 @@
#pragma once
#include "gl_shaderprogram.h"
#include <map>
class PostProcessShaderInstance;
enum class PostProcessUniformType
{
Undefined,
@ -35,38 +30,3 @@ struct PostProcessShader
extern TArray<PostProcessShader> PostProcessShaders;
class PostProcessShaderInstance
{
public:
PostProcessShaderInstance(PostProcessShader *desc) : Desc(desc) { }
~PostProcessShaderInstance();
void Run();
PostProcessShader *Desc;
private:
bool IsShaderSupported();
void CompileShader();
void UpdateUniforms();
void BindTextures();
FShaderProgram mProgram;
FBufferedUniformSampler mInputTexture;
std::map<FTexture*, int> mTextureHandles;
};
class FCustomPostProcessShaders
{
public:
FCustomPostProcessShaders();
~FCustomPostProcessShaders();
void Run(FString target);
private:
std::vector<std::unique_ptr<PostProcessShaderInstance>> mShaders;
FCustomPostProcessShaders(const FCustomPostProcessShaders &) = delete;
FCustomPostProcessShaders &operator=(const FCustomPostProcessShaders &) = delete;
};

View File

@ -0,0 +1,42 @@
#pragma once
#include "gl_shaderprogram.h"
#include <map>
struct PostProcessShader;
class PostProcessShaderInstance
{
public:
PostProcessShaderInstance(PostProcessShader *desc) : Desc(desc) { }
~PostProcessShaderInstance();
void Run();
PostProcessShader *Desc;
private:
bool IsShaderSupported();
void CompileShader();
void UpdateUniforms();
void BindTextures();
FShaderProgram mProgram;
FBufferedUniformSampler mInputTexture;
std::map<FTexture*, int> mTextureHandles;
};
class FCustomPostProcessShaders
{
public:
FCustomPostProcessShaders();
~FCustomPostProcessShaders();
void Run(FString target);
private:
std::vector<std::unique_ptr<PostProcessShaderInstance>> mShaders;
FCustomPostProcessShaders(const FCustomPostProcessShaders &) = delete;
FCustomPostProcessShaders &operator=(const FCustomPostProcessShaders &) = delete;
};

View File

@ -599,7 +599,7 @@ static const FDefaultShader defaultshaders[]=
{nullptr,nullptr,nullptr,nullptr}
};
static TArray<FString> usershaders;
TArray<FString> usershaders;
struct FEffectShader
{
@ -872,157 +872,6 @@ void gl_DestroyUserShaders()
// todo
}
//==========================================================================
//
// Parses a shader definition
//
//==========================================================================
void gl_ParseHardwareShader(FScanner &sc, int deflump)
{
sc.MustGetString();
if (sc.Compare("postprocess"))
{
sc.MustGetString();
PostProcessShader shaderdesc;
shaderdesc.Target = sc.String;
shaderdesc.Target.ToLower();
bool validTarget = false;
if (sc.Compare("beforebloom")) validTarget = true;
if (sc.Compare("scene")) validTarget = true;
if (sc.Compare("screen")) validTarget = true;
if (!validTarget)
sc.ScriptError("Invalid target '%s' for postprocess shader",sc.String);
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
sc.MustGetString();
if (sc.Compare("shader"))
{
sc.MustGetString();
shaderdesc.ShaderLumpName = sc.String;
sc.MustGetNumber();
shaderdesc.ShaderVersion = sc.Number;
if (sc.Number > 450 || sc.Number < 330)
sc.ScriptError("Shader version must be in range 330 to 450!");
}
else if (sc.Compare("name"))
{
sc.MustGetString();
shaderdesc.Name = sc.String;
}
else if (sc.Compare("uniform"))
{
sc.MustGetString();
FString uniformType = sc.String;
uniformType.ToLower();
sc.MustGetString();
FString uniformName = sc.String;
PostProcessUniformType parsedType = PostProcessUniformType::Undefined;
if (uniformType.Compare("int") == 0)
parsedType = PostProcessUniformType::Int;
else if (uniformType.Compare("float") == 0)
parsedType = PostProcessUniformType::Float;
else if (uniformType.Compare("vec2") == 0)
parsedType = PostProcessUniformType::Vec2;
else if (uniformType.Compare("vec3") == 0)
parsedType = PostProcessUniformType::Vec3;
else
sc.ScriptError("Unrecognized uniform type '%s'", sc.String);
if (parsedType != PostProcessUniformType::Undefined)
shaderdesc.Uniforms[uniformName].Type = parsedType;
}
else if (sc.Compare("texture"))
{
sc.MustGetString();
FString textureName = sc.String;
sc.MustGetString();
FString textureSource = sc.String;
shaderdesc.Textures[textureName] = textureSource;
}
else if (sc.Compare("enabled"))
{
shaderdesc.Enabled = true;
}
else
{
sc.ScriptError("Unknown keyword '%s'", sc.String);
}
}
PostProcessShaders.Push(shaderdesc);
}
else
{
ETextureType type = ETextureType::Any;
if (sc.Compare("texture")) type = ETextureType::Wall;
else if (sc.Compare("flat")) type = ETextureType::Flat;
else if (sc.Compare("sprite")) type = ETextureType::Sprite;
else sc.UnGet();
bool disable_fullbright = false;
bool thiswad = false;
bool iwad = false;
int maplump = -1;
FString maplumpname;
float speed = 1.f;
sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type);
FTexture *tex = TexMan[no];
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
sc.MustGetString();
if (sc.Compare("shader"))
{
sc.MustGetString();
maplumpname = sc.String;
}
else if (sc.Compare("speed"))
{
sc.MustGetFloat();
speed = float(sc.Float);
}
}
if (!tex)
{
return;
}
if (maplumpname.IsNotEmpty())
{
if (tex->bWarped != 0)
{
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
return;
}
tex->gl_info.shaderspeed = speed;
for (unsigned i = 0; i < usershaders.Size(); i++)
{
if (!usershaders[i].CompareNoCase(maplumpname))
{
tex->gl_info.shaderindex = i + FIRST_USER_SHADER;
return;
}
}
tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER;
}
}
}
static bool IsConsolePlayer(player_t *player)
{
AActor *activator = player ? player->mo : nullptr;

View File

@ -405,28 +405,6 @@ public:
}
};
enum MaterialShaderIndex
{
SHADER_Default,
SHADER_Warp1,
SHADER_Warp2,
SHADER_Brightmap,
SHADER_Specular,
SHADER_SpecularBrightmap,
SHADER_PBR,
SHADER_PBRBrightmap,
SHADER_NoTexture,
SHADER_BasicFuzz,
SHADER_SmoothFuzz,
SHADER_SwirlyFuzz,
SHADER_TranslucentFuzz,
SHADER_JaggedFuzz,
SHADER_NoiseFuzz,
SHADER_SmoothNoiseFuzz,
SHADER_SoftwareFuzz,
FIRST_USER_SHADER
};
enum
{
LIGHTBUF_BINDINGPOINT = 1

View File

@ -166,274 +166,6 @@ void FTexture::SetSpriteAdjust()
}
}
//==========================================================================
//
// Parses a material definition
//
//==========================================================================
void gl_ParseMaterial(FScanner &sc, int deflump)
{
ETextureType type = ETextureType::Any;
bool disable_fullbright = false;
bool disable_fullbright_specified = false;
bool thiswad = false;
bool iwad = false;
FTexture *textures[6];
const char *keywords[7] = { "brightmap", "normal", "specular", "metallic", "roughness", "ao", nullptr };
const char *notFound[6] = { "Brightmap", "Normalmap", "Specular texture", "Metallic texture", "Roughness texture", "Ambient occlusion texture" };
memset(textures, 0, sizeof(textures));
sc.MustGetString();
if (sc.Compare("texture")) type = ETextureType::Wall;
else if (sc.Compare("flat")) type = ETextureType::Flat;
else if (sc.Compare("sprite")) type = ETextureType::Sprite;
else sc.UnGet();
sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable);
FTexture *tex = TexMan[no];
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
sc.MustGetString();
if (sc.Compare("disablefullbright"))
{
// This can also be used without a brightness map to disable
// fullbright in rotations that only use brightness maps on
// other angles.
disable_fullbright = true;
disable_fullbright_specified = true;
}
else if (sc.Compare("thiswad"))
{
// only affects textures defined in the WAD containing the definition file.
thiswad = true;
}
else if (sc.Compare ("iwad"))
{
// only affects textures defined in the IWAD.
iwad = true;
}
else if (sc.Compare("glossiness"))
{
sc.MustGetFloat();
if (tex)
tex->gl_info.Glossiness = sc.Float;
}
else if (sc.Compare("specularlevel"))
{
sc.MustGetFloat();
if (tex)
tex->gl_info.SpecularLevel = sc.Float;
}
else
{
for (int i = 0; keywords[i] != nullptr; i++)
{
if (sc.Compare (keywords[i]))
{
sc.MustGetString();
if (textures[i])
Printf("Multiple %s definitions in texture %s\n", keywords[i], tex? tex->Name.GetChars() : "(null)");
textures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (!textures[i])
Printf("%s '%s' not found in texture '%s'\n", notFound[i], sc.String, tex? tex->Name.GetChars() : "(null)");
break;
}
}
}
}
if (!tex)
{
return;
}
if (thiswad || iwad)
{
bool useme = false;
int lumpnum = tex->GetSourceLump();
if (lumpnum != -1)
{
if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetIwadNum()) useme = true;
if (thiswad && Wads.GetLumpFile(lumpnum) == deflump) useme = true;
}
if (!useme) return;
}
FTexture **bindings[6] =
{
&tex->Brightmap,
&tex->Normal,
&tex->Specular,
&tex->Metallic,
&tex->Roughness,
&tex->AmbientOcclusion
};
for (int i = 0; keywords[i] != nullptr; i++)
{
if (textures[i])
{
textures[i]->bMasked = false;
*bindings[i] = textures[i];
}
}
if (disable_fullbright_specified)
tex->gl_info.bDisableFullbright = disable_fullbright;
}
//==========================================================================
//
// Parses a brightmap definition
//
//==========================================================================
void gl_ParseBrightmap(FScanner &sc, int deflump)
{
ETextureType type = ETextureType::Any;
bool disable_fullbright=false;
bool thiswad = false;
bool iwad = false;
FTexture *bmtex = NULL;
sc.MustGetString();
if (sc.Compare("texture")) type = ETextureType::Wall;
else if (sc.Compare("flat")) type = ETextureType::Flat;
else if (sc.Compare("sprite")) type = ETextureType::Sprite;
else sc.UnGet();
sc.MustGetString();
FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable);
FTexture *tex = TexMan[no];
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
sc.MustGetString();
if (sc.Compare("disablefullbright"))
{
// This can also be used without a brightness map to disable
// fullbright in rotations that only use brightness maps on
// other angles.
disable_fullbright = true;
}
else if (sc.Compare("thiswad"))
{
// only affects textures defined in the WAD containing the definition file.
thiswad = true;
}
else if (sc.Compare ("iwad"))
{
// only affects textures defined in the IWAD.
iwad = true;
}
else if (sc.Compare ("map"))
{
sc.MustGetString();
if (bmtex != NULL)
{
Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name.GetChars() : "(null)");
}
bmtex = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
if (bmtex == NULL)
Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name.GetChars() : "(null)");
}
}
if (!tex)
{
return;
}
if (thiswad || iwad)
{
bool useme = false;
int lumpnum = tex->GetSourceLump();
if (lumpnum != -1)
{
if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetIwadNum()) useme = true;
if (thiswad && Wads.GetLumpFile(lumpnum) == deflump) useme = true;
}
if (!useme) return;
}
if (bmtex != NULL)
{
/* I do not think this is needed any longer
if (tex->bWarped != 0)
{
Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name.GetChars());
return;
}
*/
bmtex->bMasked = false;
tex->Brightmap = bmtex;
}
tex->gl_info.bDisableFullbright = disable_fullbright;
}
//==========================================================================
//
// Parses a GLBoom+ detail texture definition
//
// Syntax is this:
// detail
// {
// (walls | flats) [default_detail_name [width [height [offset_x [offset_y]]]]]
// {
// texture_name [detail_name [width [height [offset_x [offset_y]]]]]
// }
// }
// This merely parses the block and returns no error if valid. The feature
// is not actually implemented, so nothing else happens.
//==========================================================================
void gl_ParseDetailTexture(FScanner &sc)
{
while (!sc.CheckToken('}'))
{
sc.MustGetString();
if (sc.Compare("walls") || sc.Compare("flats"))
{
if (!sc.CheckToken('{'))
{
sc.MustGetString(); // Default detail texture
if (sc.CheckFloat()) // Width
if (sc.CheckFloat()) // Height
if (sc.CheckFloat()) // OffsX
if (sc.CheckFloat()) // OffsY
{
// Nothing
}
}
else sc.UnGet();
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
sc.MustGetString(); // Texture
if (sc.GetString()) // Detail texture
{
if (sc.CheckFloat()) // Width
if (sc.CheckFloat()) // Height
if (sc.CheckFloat()) // OffsX
if (sc.CheckFloat()) // OffsY
{
// Nothing
}
}
else sc.UnGet();
}
}
}
}
//==========================================================================
//
// DFrameBuffer :: PrecacheTexture

File diff suppressed because it is too large Load Diff

1589
src/r_data/gldefs.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -108,96 +108,5 @@ bool FSkyBox::UseBasePalette()
void FSkyBox::Unload ()
{
//for(int i=0;i<6;i++) if (faces[i]) faces[i]->Unload();
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void ParseGldefSkybox(FScanner &sc)
{
int facecount=0;
sc.MustGetString();
FSkyBox * sb = new FSkyBox;
sb->Name = sc.String;
sb->Name.ToUpper();
if (sc.CheckString("fliptop"))
{
sb->fliptop = true;
}
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
sc.MustGetString();
if (facecount<6)
{
sb->faces[facecount] = TexMan[TexMan.GetTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable)];
}
facecount++;
}
if (facecount != 3 && facecount != 6)
{
sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->Name.GetChars());
}
sb->SetSize();
TexMan.AddTexture(sb);
}
//-----------------------------------------------------------------------------
//
// gl_ParseVavoomSkybox
//
//-----------------------------------------------------------------------------
void ParseVavoomSkybox()
{
int lump = Wads.CheckNumForName("SKYBOXES");
if (lump < 0) return;
FScanner sc(lump);
while (sc.GetString())
{
int facecount=0;
int maplump = -1;
bool error = false;
FSkyBox * sb = new FSkyBox;
sb->Name = sc.String;
sb->Name.ToUpper();
sb->fliptop = true;
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
if (facecount<6)
{
sc.MustGetStringName("{");
sc.MustGetStringName("map");
sc.MustGetString();
maplump = Wads.CheckNumForFullName(sc.String, true);
FTexture *tex = TexMan.FindTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny);
if (tex == NULL)
{
sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name.GetChars());
error = true;
}
sb->faces[facecount] = tex;
sc.MustGetStringName("}");
}
facecount++;
}
if (facecount != 6)
{
sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name.GetChars());
}
sb->SetSize();
if (!error) TexMan.AddTexture(sb);
}
}

View File

@ -44,6 +44,29 @@
#include "r_data/r_translate.h"
#include <vector>
enum MaterialShaderIndex
{
SHADER_Default,
SHADER_Warp1,
SHADER_Warp2,
SHADER_Brightmap,
SHADER_Specular,
SHADER_SpecularBrightmap,
SHADER_PBR,
SHADER_PBRBrightmap,
SHADER_NoTexture,
SHADER_BasicFuzz,
SHADER_SmoothFuzz,
SHADER_SwirlyFuzz,
SHADER_TranslucentFuzz,
SHADER_JaggedFuzz,
SHADER_NoiseFuzz,
SHADER_SmoothNoiseFuzz,
SHADER_SoftwareFuzz,
FIRST_USER_SHADER
};
struct FloatRect
{
float left,top;

View File

@ -1351,7 +1351,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n
_CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF);
// Use this to break at a specific allocation number.
//_crtBreakAlloc = 53039;
_crtBreakAlloc = 177312;
#endif
DoMain (hInstance);