doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
win_local.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 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 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 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.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __WIN_LOCAL_H__
30 #define __WIN_LOCAL_H__
31 
32 #include <windows.h>
33 #include "../../renderer/wglext.h" // windows OpenGL extensions
34 
35 // WGL_ARB_extensions_string
37 
38 // WGL_EXT_swap_interval
39 extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
40 
41 // WGL_ARB_pixel_format
42 extern PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB;
43 extern PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB;
44 extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
45 
46 // WGL_ARB_pbuffer
47 extern PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB;
48 extern PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB;
49 extern PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB;
50 extern PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB;
51 extern PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB;
52 
53 // WGL_ARB_render_texture
54 extern PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB;
55 extern PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB;
56 extern PFNWGLSETPBUFFERATTRIBARBPROC wglSetPbufferAttribARB;
57 
58 
59 #define MAX_OSPATH 256
60 
61 #define WINDOW_STYLE (WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE | WS_THICKFRAME)
62 
63 void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );
64 
65 void Sys_CreateConsole( void );
66 void Sys_DestroyConsole( void );
67 
68 char *Sys_ConsoleInput (void);
69 char *Sys_GetCurrentUser( void );
70 
71 void Win_SetErrorText( const char *text );
72 
73 cpuid_t Sys_GetCPUId( void );
74 
75 int MapKey (int key);
76 
77 
78 // Input subsystem
79 
80 void IN_Init (void);
81 void IN_Shutdown (void);
82 // add additional non keyboard / non mouse movement on top of the keyboard move cmd
83 
84 void IN_DeactivateMouseIfWindowed( void );
85 void IN_DeactivateMouse( void );
86 void IN_ActivateMouse( void );
87 
88 void IN_Frame( void );
89 
90 int IN_DIMapKey( int key );
91 
92 void DisableTaskKeys( BOOL bDisable, BOOL bBeep, BOOL bTaskMgr );
93 
94 
95 // window procedure
96 LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
97 
98 void Conbuf_AppendText( const char *msg );
99 
100 typedef struct {
101  HWND hWnd;
102  HINSTANCE hInstance;
103 
104  bool activeApp; // changed with WM_ACTIVATE messages
105  bool mouseReleased; // when the game has the console down or is doing a long operation
106  bool movingWindow; // inhibit mouse grab when dragging the window
107  bool mouseGrabbed; // current state of grab and hide
108 
109  OSVERSIONINFOEX osversion;
110 
112 
113  // when we get a windows message, we store the time off so keyboard processing
114  // can know the exact time of an event (not really needed now that we use async direct input)
116 
118 
119  WNDPROC wndproc;
120 
121  HDC hDC; // handle to device context
122  HGLRC hGLRC; // handle to GL rendering context
123  PIXELFORMATDESCRIPTOR pfd;
125 
126  HINSTANCE hinstOpenGL; // HINSTANCE for the OpenGL library
127 
129  int desktopWidth, desktopHeight;
130 
132 
133  FILE *log_fp;
134 
135  unsigned short oldHardwareGamma[3][256];
136  // desktop gamma is saved here for restoration at exit
137 
138  static idCVar sys_arch;
140  static idCVar in_mouse;
144  static idCVar win_xpos; // archived X coordinate of window position
145  static idCVar win_ypos; // archived Y coordinate of window position
151 
152  CRITICAL_SECTION criticalSections[MAX_CRITICAL_SECTIONS];
154 
155  HINSTANCE hInstDI; // direct input
156 
157  LPDIRECTINPUT8 g_pdi;
158  LPDIRECTINPUTDEVICE8 g_pMouse;
159  LPDIRECTINPUTDEVICE8 g_pKeyboard;
160 
165  unsigned long renderThreadId;
166  void (*glimpRenderThread)( void );
167  void *smpData;
169  // SMP acceleration vars
170 
171 } Win32Vars_t;
172 
173 extern Win32Vars_t win32;
174 
175 #endif /* !__WIN_LOCAL_H__ */
void IN_Shutdown(void)
GLsizei const GLfloat * value
Definition: glext.h:3614
HANDLE backgroundDownloadSemaphore
Definition: win_local.h:153
void Sys_CreateConsole(void)
Definition: win_syscon.cpp:283
int IN_DIMapKey(int key)
Definition: win_input.cpp:391
bool activeApp
Definition: win_local.h:104
static idCVar in_mouse
Definition: win_local.h:140
bool windowClassRegistered
Definition: win_local.h:117
static idCVar win_outputEditString
Definition: win_local.h:147
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB
Definition: win_glimp.cpp:61
HGLRC hGLRC
Definition: win_local.h:122
void IN_DeactivateMouseIfWindowed(void)
Definition: win_input.cpp:649
cpuid_t cpuid
Definition: win_local.h:111
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC
void Conbuf_AppendText(const char *msg)
Definition: win_syscon.cpp:474
static idCVar win_username
Definition: win_local.h:143
void * smpData
Definition: win_local.h:167
const int MAX_CRITICAL_SECTIONS
Definition: sys_public.h:505
#define WINAPI
Definition: qgl.h:64
OSVERSIONINFOEX osversion
Definition: win_local.h:109
char * Sys_ConsoleInput(void)
Definition: win_syscon.cpp:459
void Win_SetErrorText(const char *text)
Definition: win_syscon.cpp:543
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
#define BOOL
Definition: mprintf.c:71
static idCVar win_ypos
Definition: win_local.h:145
static idCVar win_viewlog
Definition: win_local.h:148
int sysMsgTime
Definition: win_local.h:115
bool cdsFullscreen
Definition: win_local.h:131
PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB
Definition: win_glimp.cpp:66
void Sys_DestroyConsole(void)
Definition: win_syscon.cpp:419
static idCVar sys_arch
Definition: win_local.h:138
PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB
Definition: win_glimp.cpp:62
LONG WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HANDLE renderActiveEvent
Definition: win_local.h:163
PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB
Definition: win_glimp.cpp:69
sysEventType_t
Definition: sys_public.h:192
LPDIRECTINPUTDEVICE8 g_pMouse
Definition: win_local.h:158
HANDLE renderCompletedEvent
Definition: win_local.h:162
FILE * log_fp
Definition: win_local.h:133
void IN_DeactivateMouse(void)
static idCVar win_xpos
Definition: win_local.h:144
int wglErrors
Definition: win_local.h:168
PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB
Definition: win_glimp.cpp:70
static idCVar win_allowAltTab
Definition: win_local.h:141
cpuid_t
Definition: sys_public.h:142
void Sys_QueEvent(int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr)
Definition: win_main.cpp:731
static idCVar win_allowMultipleInstances
Definition: win_local.h:150
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT
Definition: win_glimp.cpp:58
char * Sys_GetCurrentUser(void)
Definition: win_shared.cpp:239
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
int desktopWidth
Definition: win_local.h:129
void IN_ActivateMouse(void)
static idCVar win_outputDebugString
Definition: win_local.h:146
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB
Definition: win_glimp.cpp:55
long LONG
LPDIRECTINPUTDEVICE8 g_pKeyboard
Definition: win_local.h:159
HGLRC
Definition: win_qgl.cpp:52
PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB
Definition: win_glimp.cpp:67
PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB
Definition: win_glimp.cpp:74
HINSTANCE hinstOpenGL
Definition: win_local.h:126
bool mouseGrabbed
Definition: win_local.h:107
HANDLE renderThreadHandle
Definition: win_local.h:164
WNDPROC wndproc
Definition: win_local.h:119
int MapKey(int key)
PIXELFORMATDESCRIPTOR pfd
Definition: win_local.h:123
static idCVar win_timerUpdate
Definition: win_local.h:149
PFNWGLSETPBUFFERATTRIBARBPROC wglSetPbufferAttribARB
Definition: win_glimp.cpp:75
void IN_Init(void)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB
Definition: win_glimp.cpp:68
int desktopBitsPixel
Definition: win_local.h:128
HANDLE renderCommandsEvent
Definition: win_local.h:161
PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB
Definition: win_glimp.cpp:73
HINSTANCE hInstance
Definition: win_local.h:102
void DisableTaskKeys(BOOL bDisable, BOOL bBeep, BOOL bTaskMgr)
unsigned long renderThreadId
Definition: win_local.h:165
Win32Vars_t win32
Definition: win_main.cpp:65
const char *WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC(HDC hdc)
Definition: wglext.h:347
LPDIRECTINPUT8 g_pdi
Definition: win_local.h:157
cpuid_t Sys_GetCPUId(void)
Definition: win_cpu.cpp:534
bool mouseReleased
Definition: win_local.h:105
static idCVar sys_cpustring
Definition: win_local.h:139
int pixelformat
Definition: win_local.h:124
bool movingWindow
Definition: win_local.h:106
void IN_Frame(void)
Definition: win_input.cpp:764
HINSTANCE hInstDI
Definition: win_local.h:155
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB
Definition: win_glimp.cpp:63
static idCVar win_notaskkeys
Definition: win_local.h:142