add gl_wireframe and gl_wireframecolor

This commit is contained in:
Ricardo Luís Vaz Silva 2025-01-09 09:25:52 -03:00 committed by Magnus Norddahl
commit c72bad053f
14 changed files with 151 additions and 64 deletions

View file

@ -159,4 +159,7 @@ CUSTOM_CVAR(Int, gl_shadowmap_quality, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
}
}
CVAR(Bool, gl_strict_gldefs, true, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVAR(Bool, gl_strict_gldefs, true, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVAR(Int, gl_wireframe, 0, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVAR(Color, gl_wireframecolor, -1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)

View file

@ -59,4 +59,6 @@ EXTERN_CVAR(Bool, gl_notexturefill)
EXTERN_CVAR(Bool, r_radarclipper)
EXTERN_CVAR(Bool, r_dithertransparency)
EXTERN_CVAR(Bool, gl_strict_gldefs)
EXTERN_CVAR(Bool, gl_strict_gldefs)
EXTERN_CVAR(Int, gl_wireframe)
EXTERN_CVAR(Color, gl_wireframecolor)

View file

@ -24,7 +24,7 @@ void MeshBuilder::SetShadowData(const TArray<FFlatVertex>& vertices, const TArra
mIndexes = indexes;
}
void MeshBuilder::Draw(int dt, int index, int count, bool apply)
void MeshBuilder::DoDraw(int dt, int index, int count, bool apply)
{
if (apply)
Apply();
@ -37,7 +37,7 @@ void MeshBuilder::Draw(int dt, int index, int count, bool apply)
mDrawLists->mDraws.Push(command);
}
void MeshBuilder::DrawIndexed(int dt, int index, int count, bool apply)
void MeshBuilder::DoDrawIndexed(int dt, int index, int count, bool apply)
{
if (apply)
Apply();

View file

@ -83,8 +83,8 @@ public:
int UploadFogballs(const TArray<Fogball>& balls) override { return -1; }
// Draw commands
void Draw(int dt, int index, int count, bool apply = true) override;
void DrawIndexed(int dt, int index, int count, bool apply = true) override;
void DoDraw(int dt, int index, int count, bool apply = true) override;
void DoDrawIndexed(int dt, int index, int count, bool apply = true) override;
// Immediate render state change commands. These only change infrequently and should not clutter the render state.
void SetDepthFunc(int func) override;

View file

@ -138,6 +138,10 @@ protected:
uint8_t mGradientEnabled : 1;
uint8_t mSplitEnabled : 1;
uint8_t mBrightmapEnabled : 1;
uint8_t mWireframe : 2;
FVector4 mWireframeColor;
FVector4 uObjectColor;
int mLightIndex;
int mBoneIndexBase;
@ -166,12 +170,16 @@ protected:
EPassType mPassType = NORMAL_PASS;
virtual void DoDraw(int dt, int index, int count, bool apply) = 0;
virtual void DoDrawIndexed(int dt, int index, int count, bool apply) = 0;
public:
uint64_t firstFrame = 0;
void Reset()
{
mWireframe = 0;
mWireframeColor = toFVector4(PalEntry(0xffffffff));
mTextureEnabled = true;
mBrightmapEnabled = mGradientEnabled = mFogEnabled = mGlowEnabled = false;
mFogColor = 0xffffffff;
@ -183,7 +191,7 @@ public:
mSurfaceUniforms.uAlphaThreshold = 0.5f;
mSplitEnabled = false;
mSurfaceUniforms.uAddColor = toFVector4(PalEntry(0));
mSurfaceUniforms.uObjectColor = toFVector4(PalEntry(0xffffffff));
uObjectColor = toFVector4(PalEntry(0xffffffff));
mSurfaceUniforms.uObjectColor2 = toFVector4(PalEntry(0));
mSurfaceUniforms.uTextureBlendColor = toFVector4(PalEntry(0));
mSurfaceUniforms.uTextureAddColor = toFVector4(PalEntry(0));
@ -233,6 +241,12 @@ public:
mSurfaceUniforms.uVertexNormal = { norm.X, norm.Y, norm.Z, 0.f };
}
void SetWireframe(int mode, FVector4 color)
{
mWireframe = mode;
mWireframeColor = color;
}
void SetNormal(float x, float y, float z)
{
mSurfaceUniforms.uVertexNormal = { x, y, z, 0.f };
@ -409,7 +423,7 @@ public:
void SetObjectColor(PalEntry pe)
{
mSurfaceUniforms.uObjectColor = toFVector4(pe);
uObjectColor = toFVector4(pe);
}
void SetObjectColor2(PalEntry pe)
@ -672,8 +686,59 @@ public:
// Draw commands
virtual void ClearScreen() = 0;
virtual void Draw(int dt, int index, int count, bool apply = true) = 0;
virtual void DrawIndexed(int dt, int index, int count, bool apply = true) = 0;
void Draw(int dt, int index, int count, bool apply = true)
{
if(mWireframe == 0)
{
mSurfaceUniforms.uObjectColor = uObjectColor;
DoDraw(dt, index, count, apply);
}
else if(mWireframe == 1)
{
mSurfaceUniforms.uObjectColor = mWireframeColor;
DoDraw(dt, index, count, apply);
}
else //if(mWireframe == 2)
{
mWireframe = 0;
mSurfaceUniforms.uObjectColor = uObjectColor;
DoDraw(dt, index, count, true);
mWireframe = 1;
mSurfaceUniforms.uObjectColor = mWireframeColor;
DoDraw(dt, index, count, true);
mWireframe = 2;
}
}
void DrawIndexed(int dt, int index, int count, bool apply = true)
{
if(mWireframe == 0)
{
mSurfaceUniforms.uObjectColor = uObjectColor;
DoDrawIndexed(dt, index, count, apply);
}
else if(mWireframe == 1)
{
mSurfaceUniforms.uObjectColor = mWireframeColor;
DoDrawIndexed(dt, index, count, apply);
}
else //if(mWireframe == 2)
{
mWireframe = 0;
mSurfaceUniforms.uObjectColor = uObjectColor;
DoDrawIndexed(dt, index, count, true);
mWireframe = 1;
mSurfaceUniforms.uObjectColor = mWireframeColor;
DoDrawIndexed(dt, index, count, true);
mWireframe = 2;
}
}
// Immediate render state change commands. These only change infrequently and should not clutter the render state.
virtual bool SetDepthClamp(bool on) = 0; // Deactivated only by skyboxes.