X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=vid_wgl.c;h=d0954d01e4b4550da5611adc2a5bf0aefebb3cb2;hp=6f189c460a5bc62c04477577a84a422fb73dad92;hb=77f8bde166d6e0061eb25faf3c33cc24fce2caca;hpb=715bf430b1612f5a4527968b683db80de14f10f9 diff --git a/vid_wgl.c b/vid_wgl.c index 6f189c46..d0954d01 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -24,12 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" #include +#include #include #include "resource.h" #include +#include -extern void S_BlockSound (void); -extern void S_UnblockSound (void); extern HINSTANCE global_hInstance; @@ -115,8 +115,6 @@ static qboolean dinput; // input code -#include - #define DINPUT_BUFFERSIZE 16 #define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d) @@ -147,7 +145,7 @@ static int mouse_buttons; static int mouse_oldbuttonstate; static qboolean restore_spi; -static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; +static int originalmouseparms[3], newmouseparms[3] = {0, 0, 0}; static unsigned int uiWheelMessage; static qboolean mouseparmsvalid; @@ -186,25 +184,25 @@ static PDWORD pdwRawValue[JOY_MAX_AXES]; // each time. this avoids any problems with getting back to a default usage // or when changing from one controller to another. this way at least something // works. -static cvar_t in_joystick = {CVAR_SAVE, "joystick","0"}; -static cvar_t joy_name = {0, "joyname", "joystick"}; -static cvar_t joy_advanced = {0, "joyadvanced", "0"}; -static cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"}; -static cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"}; -static cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"}; -static cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"}; -static cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"}; -static cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"}; -static cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"}; -static cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"}; -static cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"}; -static cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"}; -static cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"}; -static cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"}; -static cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"}; -static cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"}; -static cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"}; -static cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"}; +static cvar_t in_joystick = {CVAR_SAVE, "joystick","0", "enables joysticks"}; +static cvar_t joy_name = {0, "joyname", "joystick", "name of joystick to use (informational only, used only by joyadvanced 1 mode)"}; +static cvar_t joy_advanced = {0, "joyadvanced", "0", "use more than 2 axis joysticks (configuring this is very technical)"}; +static cvar_t joy_advaxisx = {0, "joyadvaxisx", "0", "axis mapping for joyadvanced 1 mode"}; +static cvar_t joy_advaxisy = {0, "joyadvaxisy", "0", "axis mapping for joyadvanced 1 mode"}; +static cvar_t joy_advaxisz = {0, "joyadvaxisz", "0", "axis mapping for joyadvanced 1 mode"}; +static cvar_t joy_advaxisr = {0, "joyadvaxisr", "0", "axis mapping for joyadvanced 1 mode"}; +static cvar_t joy_advaxisu = {0, "joyadvaxisu", "0", "axis mapping for joyadvanced 1 mode"}; +static cvar_t joy_advaxisv = {0, "joyadvaxisv", "0", "axis mapping for joyadvanced 1 mode"}; +static cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15", "minimum joystick movement necessary to move forward"}; +static cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15", "minimum joystick movement necessary to move sideways (strafing)"}; +static cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15", "minimum joystick movement necessary to look up/down"}; +static cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15", "minimum joystick movement necessary to turn left/right"}; +static cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0", "how fast the joystick moves forward"}; +static cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0", "how fast the joystick moves sideways (strafing)"}; +static cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0", "how fast the joystick looks up/down"}; +static cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0", "how fast the joystick turns left/right"}; +static cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0", "special hack for wingman warrior"}; +static cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0", "special hack for wingman warrior"}; static qboolean joy_avail, joy_advancedinit, joy_haspov; static DWORD joy_oldbuttonstate, joy_oldpovstate; @@ -262,7 +260,7 @@ static void IN_StartupMouse (void); //==================================== -void VID_Finish (void) +void VID_Finish (qboolean allowmousegrab) { qboolean vid_usemouse; @@ -275,7 +273,7 @@ void VID_Finish (void) // handle the mouse state when windowed if that's changed vid_usemouse = false; - if (vid_mouse.integer && !key_consoleactive && !cls.demoplayback) + if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback)) vid_usemouse = true; if (vid_isfullscreen) vid_usemouse = true; @@ -285,10 +283,15 @@ void VID_Finish (void) if (r_render.integer && !vid_hidden) { + CHECKGLERROR if (r_speeds.integer || gl_finish.integer) - qglFinish(); + { + qglFinish();CHECKGLERROR + } SwapBuffers(baseDC); } + + VID_UpdateGamma(false, 256); } //========================================================================== @@ -409,7 +412,7 @@ void AppActivate(BOOL fActive, BOOL minimize) * ****************************************************************************/ { - static BOOL sound_active; + static qboolean sound_active = false; // initially blocked by Sys_InitConsole() vid_activewindow = fActive; vid_hidden = minimize; @@ -647,7 +650,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return lRet; } -int VID_SetGamma(unsigned short *ramps) +int VID_SetGamma(unsigned short *ramps, int rampsize) { HDC hdc = GetDC (NULL); int i = SetDeviceGammaRamp(hdc, ramps); @@ -655,7 +658,7 @@ int VID_SetGamma(unsigned short *ramps) return i; // return success or failure } -int VID_GetGamma(unsigned short *ramps) +int VID_GetGamma(unsigned short *ramps, int rampsize) { HDC hdc = GetDC (NULL); int i = GetDeviceGammaRamp(hdc, ramps); @@ -685,7 +688,7 @@ static int GL_OpenLibrary(const char *name) Con_Printf("Unable to LoadLibrary %s\n", name); return false; } - strcpy(gl_driver, name); + strlcpy(gl_driver, name, sizeof(gl_driver)); return true; } @@ -725,7 +728,7 @@ void VID_Init(void) IN_Init(); } -int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate) +int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer) { int i; HDC hdc; @@ -773,6 +776,9 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat pfd.cAlphaBits = 0; } + if (stereobuffer) + pfd.dwFlags |= PFD_STEREO; + gldrivername = "opengl32.dll"; // COMMANDLINEOPTION: Windows WGL: -gl_driver selects a GL driver library, default is opengl32.dll, useful only for 3dfxogl.dll or 3dfxvgl.dll, if you don't know what this is for, you don't need it i = COM_CheckParm("-gl_driver"); @@ -859,7 +865,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL); if (!mainwindow) { - Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL); + Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), NULL, NULL, (int)global_hInstance, NULL); VID_Shutdown(); return false; } @@ -900,14 +906,14 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat if ((pixelformat = ChoosePixelFormat(baseDC, &pfd)) == 0) { VID_Shutdown(); - Con_Printf("ChoosePixelFormat(%d, %p) failed\n", baseDC, &pfd); + Con_Printf("ChoosePixelFormat(%d, %p) failed\n", (int)baseDC, &pfd); return false; } if (SetPixelFormat(baseDC, pixelformat, &pfd) == false) { VID_Shutdown(); - Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", baseDC, pixelformat, &pfd); + Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", (int)baseDC, pixelformat, &pfd); return false; } @@ -928,7 +934,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat if (!qwglMakeCurrent(baseDC, baseRC)) { VID_Shutdown(); - Con_Printf("wglMakeCurrent(%d, %d) failed\n", baseDC, baseRC); + Con_Printf("wglMakeCurrent(%d, %d) failed\n", (int)baseDC, (int)baseRC); return false; } @@ -1623,7 +1629,7 @@ static void IN_JoyMove (void) else speed = 1; // LordHavoc: viewzoom affects sensitivity for sniping - aspeed = speed * host_realframetime * cl.viewzoom; + aspeed = speed * cl.realframetime * cl.viewzoom; // loop through the axes for (i = 0; i < JOY_MAX_AXES; i++) @@ -1784,7 +1790,7 @@ static void IN_Init(void) Cvar_RegisterVariable (&joy_yawsensitivity); Cvar_RegisterVariable (&joy_wwhack1); Cvar_RegisterVariable (&joy_wwhack2); - Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); + Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f, "applies current joyadv* cvar settings to the joystick driver"); } static void IN_Shutdown(void)