]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
moved brushq3.submodel to brush, removed brushq3.data_thismodel (instead looking...
[xonotic/darkplaces.git] / vid_wgl.c
index ad17aa3eb8a24c961deac6a7a02f8bf958be64a9..1595e798afa9ec42efceb7b436cecaa3ab7142d4 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -73,12 +73,13 @@ static dllfunction_t wglswapintervalfuncs[] =
        {NULL, NULL}
 };
 
-qboolean scr_skipupdate;
-
 static DEVMODE gdevmode;
 static qboolean vid_initialized = false;
 static qboolean vid_wassuspended = false;
-static int vid_usingmouse;
+static qboolean vid_usingmouse = false;
+static qboolean vid_usingvsync = false;
+static qboolean vid_usemouse = false;
+static qboolean vid_usevsync = false;
 static HICON hIcon;
 
 HWND mainwindow;
@@ -261,7 +262,7 @@ static DIDATAFORMAT df = {
 // forward-referenced functions
 void IN_StartupJoystick (void);
 void Joy_AdvancedUpdate_f (void);
-void IN_JoyMove (usercmd_t *cmd);
+void IN_JoyMove (void);
 void IN_StartupMouse (void);
 
 /*
@@ -304,22 +305,11 @@ void VID_GetWindowSize (int *x, int *y, int *width, int *height)
 
 void VID_Finish (void)
 {
-       int vid_usemouse;
-       static int      old_vsync       = -1;
-
-       if (old_vsync != vid_vsync.integer)
-       {
-               old_vsync = bound(0, vid_vsync.integer, 1);
-               Cvar_SetValueQuick(&vid_vsync, old_vsync);
-               if (gl_videosyncavailable)
-                       qwglSwapIntervalEXT (old_vsync);
-       }
-
-       if (r_render.integer && !scr_skipupdate)
+       vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
+       if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
        {
-               if (r_speeds.integer || gl_finish.integer)
-                       qglFinish();
-               SwapBuffers(baseDC);
+               vid_usingvsync = vid_usevsync;
+               qwglSwapIntervalEXT (vid_usevsync);
        }
 
 // handle the mouse state when windowed if that's changed
@@ -348,6 +338,13 @@ void VID_Finish (void)
                        IN_ShowMouse();
                }
        }
+
+       if (r_render.integer && !vid_hidden)
+       {
+               if (r_speeds.integer || gl_finish.integer)
+                       qglFinish();
+               SwapBuffers(baseDC);
+       }
 }
 
 //==========================================================================
@@ -523,9 +520,6 @@ void Sys_SendKeyEvents (void)
 
        while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
        {
-       // we always update if there are any event, even if we're paused
-               scr_skipupdate = 0;
-
                if (!GetMessage (&msg, NULL, 0, 0))
                        Sys_Quit ();
 
@@ -566,7 +560,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM lParam)
                        window_y = (int) HIWORD(lParam);
                        VID_UpdateWindowStatus ();
                        break;
-       
+
                case WM_KEYDOWN:
                case WM_SYSKEYDOWN:
                        down = true;
@@ -1006,6 +1000,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
 
        //vid_menudrawfn = VID_MenuDraw;
        //vid_menukeyfn = VID_MenuKey;
+       vid_usingmouse = false;
+       vid_usingvsync = false;
        vid_hidden = false;
        vid_initialized = true;
 
@@ -1182,7 +1178,7 @@ qboolean IN_InitDInput (void)
 
                if (hInstDI == NULL)
                {
-                       Con_SafePrint("Couldn't load dinput.dll\n");
+                       Con_Print("Couldn't load dinput.dll\n");
                        return false;
                }
        }
@@ -1193,7 +1189,7 @@ qboolean IN_InitDInput (void)
 
                if (!pDirectInputCreate)
                {
-                       Con_SafePrint("Couldn't get DI proc addr\n");
+                       Con_Print("Couldn't get DI proc addr\n");
                        return false;
                }
        }
@@ -1211,7 +1207,7 @@ qboolean IN_InitDInput (void)
 
        if (FAILED(hr))
        {
-               Con_SafePrint("Couldn't open DI mouse device\n");
+               Con_Print("Couldn't open DI mouse device\n");
                return false;
        }
 
@@ -1220,7 +1216,7 @@ qboolean IN_InitDInput (void)
 
        if (FAILED(hr))
        {
-               Con_SafePrint("Couldn't set DI mouse format\n");
+               Con_Print("Couldn't set DI mouse format\n");
                return false;
        }
 
@@ -1230,7 +1226,7 @@ qboolean IN_InitDInput (void)
 
        if (FAILED(hr))
        {
-               Con_SafePrint("Couldn't set DI coop level\n");
+               Con_Print("Couldn't set DI coop level\n");
                return false;
        }
 
@@ -1241,7 +1237,7 @@ qboolean IN_InitDInput (void)
 
        if (FAILED(hr))
        {
-               Con_SafePrint("Couldn't set DI buffersize\n");
+               Con_Print("Couldn't set DI buffersize\n");
                return false;
        }
 
@@ -1261,18 +1257,18 @@ void IN_StartupMouse (void)
 
        mouseinitialized = true;
 
-// COMMANDLINEOPTION: Windows Input: -dinput uses DirectInput (instead of GDI) for mouse/joystick input, may be more precise or responsive, but probably not
+// COMMANDLINEOPTION: Windows Input: -dinput enables DirectInput for mouse/joystick input
        if (COM_CheckParm ("-dinput"))
        {
                dinput = IN_InitDInput ();
 
                if (dinput)
                {
-                       Con_SafePrint("DirectInput initialized\n");
+                       Con_Print("DirectInput initialized\n");
                }
                else
                {
-                       Con_SafePrint("DirectInput not initialized\n");
+                       Con_Print("DirectInput not initialized\n");
                }
        }
 
@@ -1282,18 +1278,18 @@ void IN_StartupMouse (void)
 
                if (mouseparmsvalid)
                {
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemspd disables setting of mouse speed (ignored with -dinput, windows only)
+// COMMANDLINEOPTION: Windows GDI Input: -noforcemspd disables setting of mouse speed (not used with -dinput, windows only)
                        if ( COM_CheckParm ("-noforcemspd") )
                                newmouseparms[2] = originalmouseparms[2];
 
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemaccel disables setting of mouse acceleration (ignored with -dinput, windows only)
+// COMMANDLINEOPTION: Windows GDI Input: -noforcemaccel disables setting of mouse acceleration (not used with -dinput, windows only)
                        if ( COM_CheckParm ("-noforcemaccel") )
                        {
                                newmouseparms[0] = originalmouseparms[0];
                                newmouseparms[1] = originalmouseparms[1];
                        }
 
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemparms disables setting of mouse parameters (ignored with -dinput, windows only)
+// COMMANDLINEOPTION: Windows GDI Input: -noforcemparms disables setting of mouse parameters (not used with -dinput, windows only)
                        if ( COM_CheckParm ("-noforcemparms") )
                        {
                                newmouseparms[0] = originalmouseparms[0];
@@ -1349,7 +1345,7 @@ void IN_MouseEvent (int mstate)
 IN_MouseMove
 ===========
 */
-void IN_MouseMove (usercmd_t *cmd)
+void IN_MouseMove (void)
 {
        int                                     i, mx, my;
        DIDEVICEOBJECTDATA      od;
@@ -1360,7 +1356,7 @@ void IN_MouseMove (usercmd_t *cmd)
        {
                GetCursorPos (&current_pos);
                //ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
-               IN_Mouse( cmd, 0, 0 );
+               IN_Mouse( 0, 0 );
                return;
        }
 
@@ -1447,7 +1443,7 @@ void IN_MouseMove (usercmd_t *cmd)
                my = current_pos.y - window_center_y;
        }
 
-       IN_Mouse(cmd, mx, my);
+       IN_Mouse(mx, my);
 
        // if the mouse has moved, force it to the center, so there's room to move
        if (!dinput && (mx || my))
@@ -1460,12 +1456,12 @@ void IN_MouseMove (usercmd_t *cmd)
 IN_Move
 ===========
 */
-void IN_Move (usercmd_t *cmd)
+void IN_Move (void)
 {
        if (vid_activewindow && !vid_hidden)
        {
-               IN_MouseMove (cmd);
-               IN_JoyMove (cmd);
+               IN_MouseMove ();
+               IN_JoyMove ();
        }
 }
 
@@ -1758,7 +1754,7 @@ qboolean IN_ReadJoystick (void)
 IN_JoyMove
 ===========
 */
-void IN_JoyMove (usercmd_t *cmd)
+void IN_JoyMove (void)
 {
        float   speed, aspeed;
        float   fAxisValue, fTemp;
@@ -1853,7 +1849,7 @@ void IN_JoyMove (usercmd_t *cmd)
                                // user wants forward control to be forward control
                                if (fabs(fAxisValue) > joy_forwardthreshold.value)
                                {
-                                       cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
+                                       cl.cmd.forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
                                }
                        }
                        break;
@@ -1861,7 +1857,7 @@ void IN_JoyMove (usercmd_t *cmd)
                case AxisSide:
                        if (fabs(fAxisValue) > joy_sidethreshold.value)
                        {
-                               cmd->sidemove += (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
+                               cl.cmd.sidemove += (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
                        }
                        break;
 
@@ -1871,7 +1867,7 @@ void IN_JoyMove (usercmd_t *cmd)
                                // user wants turn control to become side control
                                if (fabs(fAxisValue) > joy_sidethreshold.value)
                                {
-                                       cmd->sidemove -= (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
+                                       cl.cmd.sidemove -= (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
                                }
                        }
                        else