Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.6 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #include "cbase.h"
  7. #include "bitmap/imageformat.h"
  8. #include "cl_mat_stub.h"
  9. #include "materialsystem/imaterialsystemstub.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. // Hook the engine's mat_stub cvar.
  13. ConVar mat_stub( "mat_stub", "0", FCVAR_CHEAT );
  14. extern ConVar gl_clear;
  15. IMaterialSystemStub* GetStubMaterialSystem()
  16. {
  17. return materials_stub;
  18. }
  19. // ---------------------------------------------------------------------------------------- //
  20. // CMatStubHandler implementation.
  21. // ---------------------------------------------------------------------------------------- //
  22. CMatStubHandler::CMatStubHandler()
  23. {
  24. if ( mat_stub.GetInt() )
  25. {
  26. m_pOldMaterialSystem = materials;
  27. // Replace all material system pointers with the stub.
  28. GetStubMaterialSystem()->SetRealMaterialSystem( materials );
  29. materials->SetInStubMode( true );
  30. materials = GetStubMaterialSystem();
  31. engine->Mat_Stub( materials );
  32. }
  33. else
  34. {
  35. m_pOldMaterialSystem = 0;
  36. }
  37. }
  38. CMatStubHandler::~CMatStubHandler()
  39. {
  40. End();
  41. }
  42. void CMatStubHandler::End()
  43. {
  44. // Put back the original material system pointer.
  45. if ( m_pOldMaterialSystem )
  46. {
  47. materials = m_pOldMaterialSystem;
  48. materials->SetInStubMode( false );
  49. engine->Mat_Stub( materials );
  50. m_pOldMaterialSystem = 0;
  51. // if( gl_clear.GetBool() )
  52. {
  53. materials->ClearBuffers( true, true );
  54. }
  55. }
  56. }
  57. bool IsMatStubEnabled()
  58. {
  59. return mat_stub.GetBool();
  60. }