platformWin32.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _PLATFORMWIN32_H_
  23. #define _PLATFORMWIN32_H_
  24. // Sanity check for UNICODE
  25. #ifdef TORQUE_UNICODE
  26. # ifndef UNICODE
  27. # error "ERROR: You must have UNICODE defined in your preprocessor settings (ie, /DUNICODE) if you have TORQUE_UNICODE enabled in torqueConfig.h!"
  28. # endif
  29. #endif
  30. //Luma: add WINVER definition if it doesn't exist.. Is that our bad that it isn't on our systems already?
  31. #ifndef WINVER
  32. #define WINVER 0x0500 /* version 5.0 */
  33. #endif //!WINVER
  34. // define this so that we can use WM_MOUSEWHEEL messages...
  35. #ifndef _WIN32_WINNT
  36. #define _WIN32_WINNT 0x0400
  37. #endif
  38. #include <windows.h>
  39. #ifndef _PLATFORM_H_
  40. #include "platform/platform.h"
  41. #endif
  42. #if defined(TORQUE_COMPILER_CODEWARRIOR)
  43. # include <ansi_prefix.win32.h>
  44. # include <stdio.h>
  45. # include <string.h>
  46. #else
  47. # include <stdio.h>
  48. # include <string.h>
  49. #endif
  50. #if defined(TORQUE_COMPILER_VISUALC) || defined(TORQUE_COMPILER_GCC2)
  51. #define vsnprintf _vsnprintf
  52. #define stricmp _stricmp
  53. #define strnicmp _strnicmp
  54. #define strupr _strupr
  55. #define strlwr _strlwr
  56. #endif
  57. #define NOMINMAX
  58. struct Win32PlatState
  59. {
  60. FILE *log_fp;
  61. HINSTANCE hinstOpenGL;
  62. HINSTANCE hinstGLU;
  63. HINSTANCE hinstOpenAL;
  64. HWND appWindow;
  65. HDC appDC;
  66. HINSTANCE appInstance;
  67. HGLRC hGLRC;
  68. DWORD processId;
  69. bool renderThreadBlocked;
  70. S32 nMessagesPerFrame; // The max number of messages to dispatch per frame
  71. HMENU appMenu; //*** DAW: The menu bar for the window
  72. #ifdef UNICODE
  73. HIMC imeHandle;
  74. #endif
  75. S32 desktopBitsPixel;
  76. S32 desktopWidth;
  77. S32 desktopHeight;
  78. S32 desktopClientWidth;
  79. S32 desktopClientHeight;
  80. U32 currentTime;
  81. // minimum time per frame
  82. U32 sleepTicks;
  83. // are we in the background?
  84. bool backgrounded;
  85. Win32PlatState();
  86. };
  87. extern Win32PlatState winState;
  88. extern bool GL_Init( const char *dllname_gl, const char *dllname_glu );
  89. extern bool GL_EXT_Init();
  90. extern void GL_Shutdown();
  91. extern HWND CreateOpenGLWindow( U32 width, U32 height, bool fullScreen, bool allowSizing = true );
  92. extern HWND CreateCurtain( U32 width, U32 height );
  93. extern void CreatePixelFormat( PIXELFORMATDESCRIPTOR *pPFD, S32 colorBits, S32 depthBits, S32 stencilBits, bool stereo );
  94. extern S32 ChooseBestPixelFormat( HDC hDC, PIXELFORMATDESCRIPTOR *pPFD );
  95. extern void setModifierKeys( S32 modKeys );
  96. #define WGLD3D_FUNCTION(fn_type, fn_name, fn_args, fn_value) extern fn_type (__stdcall *dwgl##fn_name)fn_args;
  97. #define WGL_FUNCTION(fn_type, fn_name, fn_args, fn_value) extern fn_type (__stdcall *d##fn_name)fn_args;
  98. #include "platformWin32/GLWinFunc.h"
  99. #undef WGL_FUNCTION
  100. #undef WGLD3D_FUNCTION
  101. #define WGLEXT_FUNCTION(fn_type, fn_name, fn_args, fn_value) extern fn_type (__stdcall *d##fn_name)fn_args;
  102. #include "platformWin32/GLWinExtFunc.h"
  103. #undef WGLEXT_FUNCTION
  104. #endif //_PLATFORMWIN32_H_