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.

171 lines
4.3 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 GLAPP_H
  14. #define GLAPP_H
  15. #pragma once
  16. class CSysModule;
  17. // Mouse button identifiers.
  18. #define MSA_BUTTON_LEFT 0
  19. #define MSA_BUTTON_RIGHT 1
  20. typedef struct
  21. {
  22. int width;
  23. int height;
  24. int bpp;
  25. int flags;
  26. int frequency;
  27. } screen_res_t;
  28. typedef struct
  29. {
  30. int width;
  31. int height;
  32. int bpp;
  33. } devinfo_t;
  34. class MaterialSystemApp
  35. {
  36. public:
  37. MaterialSystemApp();
  38. ~MaterialSystemApp();
  39. void Term();
  40. void QuitNextFrame();
  41. // Post a message to shutdown the app.
  42. void AppShutdown();
  43. int WinMain(void *hInstance, void *hPrevInstance, char *szCmdLine, int iCmdShow);
  44. long WndProc(void *hwnd, long iMsg, long wParam, long lParam);
  45. int FindNumParameter(const char *s, int defaultVal=-1);
  46. bool FindParameter(const char *s);
  47. const char* FindParameterArg(const char *s);
  48. void SetTitleText(PRINTF_FORMAT_STRING const char *fmt, ...);
  49. // Make the matsysapp window the top window.
  50. void MakeWindowTopmost();
  51. void MouseCapture();
  52. void MouseRelease();
  53. private:
  54. bool InitMaterialSystem();
  55. void Clear();
  56. bool CreateMainWindow(int width, int height, int bpp, bool fullscreen);
  57. void RenderScene();
  58. void GetParameters();
  59. public:
  60. IMaterialSystem *m_pMaterialSystem;
  61. void *m_hMaterialSystemInst;
  62. devinfo_t m_DevInfo;
  63. void *m_hInstance;
  64. int m_iCmdShow;
  65. void *m_hWnd;
  66. void *m_hDC;
  67. bool m_bActive;
  68. bool m_bFullScreen;
  69. int m_width;
  70. int m_height;
  71. int m_centerx; // for mouse offset calculations
  72. int m_centery;
  73. int m_bpp;
  74. bool m_bChangeBPP;
  75. bool m_bAllowSoft;
  76. char *m_szCmdLine;
  77. int m_argc;
  78. char **m_argv;
  79. int m_glnWidth;
  80. int m_glnHeight;
  81. float m_gldAspect;
  82. float m_NearClip;
  83. float m_FarClip;
  84. float m_fov;
  85. screen_res_t *m_pResolutions;
  86. int m_iResCount;
  87. int m_iVidMode;
  88. };
  89. // ---------------------------------------------------------------------------------------- //
  90. // The app needs to define these symbols.
  91. // ---------------------------------------------------------------------------------------- //
  92. // g_szAppName[] -- char array applicaton name
  93. // void AppInit( void ) -- Called at init time
  94. // void AppRender( void ) -- Called each frame (as often as possible)
  95. // void AppExit( void ) -- Called to shut down
  96. // void AppKey( int key, int down ); -- called on each key up/down
  97. // void AppChar( int key ); -- key was pressed & released
  98. extern "C" char g_szAppName[];
  99. extern "C" void AppInit( void );
  100. extern "C" void AppRender( float frametime, float mouseDeltaX, float mouseDeltaY );
  101. extern "C" void AppExit( void );
  102. extern "C" void AppKey( int key, int down );
  103. extern "C" void AppChar( int key );
  104. extern bool g_bCaptureOnFocus; // The app needs to define this to control how matsysapp handles mouse cursor hiding.
  105. // If it's set to true, the mouse is captured and hidden when the app gets focus.
  106. // If false, the mouse is only captured and hidden while the left button is down.
  107. // ---------------------------------------------------------------------------------------- //
  108. // Global functions (MSA stands for Material System App)..
  109. // ---------------------------------------------------------------------------------------- //
  110. // Show an error dialog and quit.
  111. bool Sys_Error(PRINTF_FORMAT_STRING const char *pMsg, ...);
  112. // Print to the trace window.
  113. void con_Printf(PRINTF_FORMAT_STRING const char *pMsg, ...);
  114. // Returns true if the key is down.
  115. bool MSA_IsKeyDown(char key);
  116. // Sleep for the specified number of milliseconds... passing 0 does nothing.
  117. void MSA_Sleep(unsigned long countMS);
  118. // Returns true if the specified button is down.
  119. // button should be one of the MSA_BUTTON identifiers.
  120. bool MSA_IsMouseButtonDown( int button );
  121. extern MaterialSystemApp g_MaterialSystemApp;
  122. extern unsigned int g_Time;
  123. #endif // GLAPP_H