win_local.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __WIN_LOCAL_H__
  21. #define __WIN_LOCAL_H__
  22. #include <windows.h>
  23. #include "../../renderer/OpenGL/wglext.h" // windows OpenGL extensions
  24. #include "win_input.h"
  25. // WGL_ARB_extensions_string
  26. extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
  27. // WGL_EXT_swap_interval
  28. extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
  29. // WGL_ARB_pixel_format
  30. extern PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB;
  31. extern PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB;
  32. extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
  33. // WGL_ARB_pbuffer
  34. extern PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB;
  35. extern PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB;
  36. extern PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB;
  37. extern PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB;
  38. extern PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB;
  39. // WGL_ARB_render_texture
  40. extern PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB;
  41. extern PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB;
  42. extern PFNWGLSETPBUFFERATTRIBARBPROC wglSetPbufferAttribARB;
  43. #define WINDOW_STYLE (WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE | WS_THICKFRAME)
  44. void Sys_QueEvent( sysEventType_t type, int value, int value2, int ptrLength, void *ptr, int inputDeviceNum );
  45. void Sys_CreateConsole();
  46. void Sys_DestroyConsole();
  47. char *Sys_ConsoleInput ();
  48. char *Sys_GetCurrentUser();
  49. void Win_SetErrorText( const char *text );
  50. cpuid_t Sys_GetCPUId();
  51. // Input subsystem
  52. void IN_Init ();
  53. void IN_Shutdown ();
  54. // add additional non keyboard / non mouse movement on top of the keyboard move cmd
  55. void IN_DeactivateMouseIfWindowed();
  56. void IN_DeactivateMouse();
  57. void IN_ActivateMouse();
  58. void IN_Frame();
  59. void DisableTaskKeys( BOOL bDisable, BOOL bBeep, BOOL bTaskMgr );
  60. uint64 Sys_Microseconds();
  61. // window procedure
  62. LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  63. void Conbuf_AppendText( const char *msg );
  64. typedef struct {
  65. HWND hWnd;
  66. HINSTANCE hInstance;
  67. bool activeApp; // changed with WM_ACTIVATE messages
  68. bool mouseReleased; // when the game has the console down or is doing a long operation
  69. bool movingWindow; // inhibit mouse grab when dragging the window
  70. bool mouseGrabbed; // current state of grab and hide
  71. OSVERSIONINFOEX osversion;
  72. cpuid_t cpuid;
  73. // when we get a windows message, we store the time off so keyboard processing
  74. // can know the exact time of an event (not really needed now that we use async direct input)
  75. int sysMsgTime;
  76. bool windowClassRegistered;
  77. WNDPROC wndproc;
  78. HDC hDC; // handle to device context
  79. HGLRC hGLRC; // handle to GL rendering context
  80. PIXELFORMATDESCRIPTOR pfd;
  81. int pixelformat;
  82. HINSTANCE hinstOpenGL; // HINSTANCE for the OpenGL library
  83. int desktopBitsPixel;
  84. int desktopWidth, desktopHeight;
  85. int cdsFullscreen; // 0 = not fullscreen, otherwise monitor number
  86. idFileHandle log_fp;
  87. unsigned short oldHardwareGamma[3][256];
  88. // desktop gamma is saved here for restoration at exit
  89. static idCVar sys_arch;
  90. static idCVar sys_cpustring;
  91. static idCVar in_mouse;
  92. static idCVar win_allowAltTab;
  93. static idCVar win_notaskkeys;
  94. static idCVar win_username;
  95. static idCVar win_outputEditString;
  96. static idCVar win_viewlog;
  97. static idCVar win_timerUpdate;
  98. static idCVar win_allowMultipleInstances;
  99. CRITICAL_SECTION criticalSections[MAX_CRITICAL_SECTIONS];
  100. HINSTANCE hInstDI; // direct input
  101. LPDIRECTINPUT8 g_pdi;
  102. LPDIRECTINPUTDEVICE8 g_pMouse;
  103. LPDIRECTINPUTDEVICE8 g_pKeyboard;
  104. idJoystickWin32 g_Joystick;
  105. HANDLE renderCommandsEvent;
  106. HANDLE renderCompletedEvent;
  107. HANDLE renderActiveEvent;
  108. HANDLE renderThreadHandle;
  109. unsigned long renderThreadId;
  110. void (*glimpRenderThread)();
  111. void *smpData;
  112. int wglErrors;
  113. // SMP acceleration vars
  114. } Win32Vars_t;
  115. extern Win32Vars_t win32;
  116. #endif /* !__WIN_LOCAL_H__ */