aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/cl_mat_stub.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/client/cl_mat_stub.cpp
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/client/cl_mat_stub.cpp')
-rw-r--r--mp/src/game/client/cl_mat_stub.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/mp/src/game/client/cl_mat_stub.cpp b/mp/src/game/client/cl_mat_stub.cpp
new file mode 100644
index 00000000..e1f4ed82
--- /dev/null
+++ b/mp/src/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();
+}