Team Fortress 2 Source Code as on 22/4/2020
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.

210 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef MATSYSWIN_H
  14. #define MATSYSWIN_H
  15. #pragma once
  16. #include <mxtk/mxMatSysWindow.h>
  17. #include "materialsystem/imaterialsystem.h"
  18. #include "faceposertoolwindow.h"
  19. #include "interface.h"
  20. class MatSysWindow : public mxMatSysWindow, public IFacePoserToolWindow
  21. {
  22. typedef mxMatSysWindow BaseClass;
  23. public:
  24. // CREATORS
  25. MatSysWindow( mxWindow *parent, int x, int y, int w, int h, const char *label, int style );
  26. ~MatSysWindow( );
  27. // MANIPULATORS
  28. virtual int handleEvent( mxEvent *event );
  29. virtual void draw( );
  30. virtual void redraw();
  31. void EnableStickySnapshotMode( void );
  32. void DisableStickySnapshotMode( void );
  33. void PushSnapshotMode( int nSnapShotSize );
  34. void PopSnapshotMode( void );
  35. void TakeSnapshotRect( const char *pFilename, int x, int y, int w, int h );
  36. bool IsSuppressingResize( void );
  37. void SuppressResize( bool suppress );
  38. void TakeScreenShot(const char *filename);
  39. void Frame( void );
  40. void DrawFrame( void );
  41. void SuppressBufferSwap( bool bSuppress );
  42. void *m_hWnd;
  43. private:
  44. bool m_bSuppressResize;
  45. bool m_bSuppressSwap;
  46. // stack and sticky window mode
  47. int m_stickyDepth;
  48. bool m_bIsSticky;
  49. int m_snapshotDepth;
  50. WINDOWPLACEMENT m_wp;
  51. HCURSOR m_hPrevCursor;
  52. };
  53. extern MatSysWindow *g_pMatSysWindow;
  54. extern IMaterialSystem *g_pMaterialSystem;
  55. extern IMaterial *g_materialBackground;
  56. extern IMaterial *g_materialWireframe;
  57. extern IMaterial *g_materialWireframe;
  58. extern IMaterial *g_materialWireframeVertexColor;
  59. extern IMaterial *g_materialWireframeVertexColorNoCull;
  60. extern IMaterial *g_materialDebugCopyBaseTexture;
  61. extern IMaterial *g_materialFlatshaded;
  62. extern IMaterial *g_materialSmoothshaded;
  63. extern IMaterial *g_materialBones;
  64. extern IMaterial *g_materialLines;
  65. extern IMaterial *g_materialFloor;
  66. #if 0
  67. typedef struct
  68. {
  69. int width;
  70. int height;
  71. int bpp;
  72. int flags;
  73. int frequency;
  74. } screen_res_t;
  75. typedef struct
  76. {
  77. int width;
  78. int height;
  79. int bpp;
  80. } devinfo_t;
  81. class MaterialSystemApp
  82. {
  83. public:
  84. MaterialSystemApp();
  85. ~MaterialSystemApp();
  86. void Term();
  87. // Post a message to shutdown the app.
  88. void AppShutdown();
  89. int WinMain(void *hInstance, void *hPrevInstance, char *szCmdLine, int iCmdShow);
  90. long WndProc(void *hwnd, long iMsg, long wParam, long lParam);
  91. int FindNumParameter(const char *s, int defaultVal=-1);
  92. bool FindParameter(const char *s);
  93. const char* FindParameterArg(const char *s);
  94. void SetTitleText(PRINTF_FORMAT_STRING const char *fmt, ...);
  95. private:
  96. bool InitMaterialSystem();
  97. void Clear();
  98. bool CreateMainWindow(int width, int height, int bpp, bool fullscreen);
  99. void RenderScene();
  100. void MouseCapture();
  101. void MouseRelease();
  102. void GetParameters();
  103. public:
  104. IMaterialSystem *m_pMaterialSystem;
  105. void *m_hMaterialSystemInst;
  106. devinfo_t m_DevInfo;
  107. void *m_hInstance;
  108. int m_iCmdShow;
  109. void *m_hWnd;
  110. void *m_hDC;
  111. bool m_bActive;
  112. bool m_bFullScreen;
  113. int m_width;
  114. int m_height;
  115. int m_centerx; // for mouse offset calculations
  116. int m_centery;
  117. int m_bpp;
  118. BOOL m_bChangeBPP;
  119. BOOL m_bAllowSoft;
  120. BOOL m_bPaused;
  121. int m_glnWidth;
  122. int m_glnHeight;
  123. float m_gldAspect;
  124. float m_NearClip;
  125. float m_FarClip;
  126. float m_fov;
  127. screen_res_t *m_pResolutions;
  128. int m_iResCount;
  129. int m_iVidMode;
  130. };
  131. // ---------------------------------------------------------------------------------------- //
  132. // Global functions
  133. // ---------------------------------------------------------------------------------------- //
  134. // Show an error dialog and quit.
  135. bool Sys_Error(PRINTF_FORMAT_STRING const char *pMsg, ...);
  136. // Print to the trace window.
  137. void con_Printf(PRINTF_FORMAT_STRING const char *pMsg, ...);
  138. // Returns true if the key is down.
  139. bool IsKeyDown(char key);
  140. extern MaterialSystemApp g_MaterialSystemApp;
  141. #ifdef __cplusplus
  142. extern "C" {
  143. #endif
  144. extern unsigned int g_Time;
  145. #ifdef __cplusplus
  146. };
  147. #endif
  148. #endif
  149. #endif // GLAPP_H