diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/cl_mat_stub.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/cl_mat_stub.cpp')
| -rw-r--r-- | game/client/cl_mat_stub.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/game/client/cl_mat_stub.cpp b/game/client/cl_mat_stub.cpp new file mode 100644 index 0000000..a0caec8 --- /dev/null +++ b/game/client/cl_mat_stub.cpp @@ -0,0 +1,74 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//===========================================================================// + +#include "cbase.h" +#include "bitmap/imageformat.h" +#include "cl_mat_stub.h" +#include "materialsystem/imaterialsystemstub.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +// Hook the engine's mat_stub cvar. +ConVar mat_stub( "mat_stub", "0", FCVAR_CHEAT ); +extern ConVar gl_clear; + + +IMaterialSystemStub* GetStubMaterialSystem() +{ + return materials_stub; +} + +// ---------------------------------------------------------------------------------------- // +// CMatStubHandler implementation. +// ---------------------------------------------------------------------------------------- // + +CMatStubHandler::CMatStubHandler() +{ + if ( mat_stub.GetInt() ) + { + m_pOldMaterialSystem = materials; + + // Replace all material system pointers with the stub. + GetStubMaterialSystem()->SetRealMaterialSystem( materials ); + materials->SetInStubMode( true ); + materials = GetStubMaterialSystem(); + engine->Mat_Stub( materials ); + } + else + { + m_pOldMaterialSystem = 0; + } +} + + +CMatStubHandler::~CMatStubHandler() +{ + End(); +} + + +void CMatStubHandler::End() +{ + // Put back the original material system pointer. + if ( m_pOldMaterialSystem ) + { + materials = m_pOldMaterialSystem; + materials->SetInStubMode( false ); + engine->Mat_Stub( materials ); + m_pOldMaterialSystem = 0; +// if( gl_clear.GetBool() ) + { + materials->ClearBuffers( true, true ); + } + } +} + + +bool IsMatStubEnabled() +{ + return mat_stub.GetBool(); +} |