]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
playvideo and cd loop/cd play commands now call Host_StartVideo (this fixes a crash...
[xonotic/darkplaces.git] / vid_wgl.c
index c6e0ff7404ecb9b4686385284611c67ff919e861..46589db67637c0c2c5c0b1430ec736e860e63039 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -76,7 +76,10 @@ static dllfunction_t wglswapintervalfuncs[] =
 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;
@@ -85,7 +88,7 @@ static HGLRC baseRC;
 
 //HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
 
-static int vid_isfullscreen;
+static qboolean vid_isfullscreen;
 
 //void VID_MenuDraw (void);
 //void VID_MenuKey (int key);
@@ -302,27 +305,16 @@ 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 && !vid_hidden)
+       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
        vid_usemouse = false;
-       if (vid_mouse.integer && !key_consoleactive)
+       if (vid_mouse.integer && !key_consoleactive && !cls.demoplayback)
                vid_usemouse = true;
        if (vid_isfullscreen)
                vid_usemouse = true;
@@ -346,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);
+       }
 }
 
 //==========================================================================
@@ -453,8 +452,6 @@ void ClearAllStates (void)
        IN_ClearStates ();
 }
 
-extern qboolean host_loopactive;
-
 void AppActivate(BOOL fActive, BOOL minimize)
 /****************************************************************************
 *
@@ -561,7 +558,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;
@@ -694,7 +691,18 @@ int VID_GetGamma(unsigned short *ramps)
 
 static HINSTANCE gldll;
 
-int GL_OpenLibrary(const char *name)
+static void GL_CloseLibrary(void)
+{
+       FreeLibrary(gldll);
+       gldll = 0;
+       gl_driver[0] = 0;
+       qwglGetProcAddress = NULL;
+       gl_extensions = "";
+       gl_platform = "";
+       gl_platformextensions = "";
+}
+
+static int GL_OpenLibrary(const char *name)
 {
        Con_Printf("Loading OpenGL driver %s\n", name);
        GL_CloseLibrary();
@@ -707,17 +715,6 @@ int GL_OpenLibrary(const char *name)
        return true;
 }
 
-void GL_CloseLibrary(void)
-{
-       FreeLibrary(gldll);
-       gldll = 0;
-       gl_driver[0] = 0;
-       qwglGetProcAddress = NULL;
-       gl_extensions = "";
-       gl_platform = "";
-       gl_platformextensions = "";
-}
-
 void *GL_GetProcAddress(const char *name)
 {
        void *p = NULL;
@@ -1001,6 +998,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;
 
@@ -1177,7 +1176,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;
                }
        }
@@ -1188,7 +1187,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;
                }
        }
@@ -1206,7 +1205,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;
        }
 
@@ -1215,7 +1214,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;
        }
 
@@ -1225,7 +1224,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;
        }
 
@@ -1236,7 +1235,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;
        }
 
@@ -1256,18 +1255,18 @@ void IN_StartupMouse (void)
 
        mouseinitialized = true;
 
-// COMMANDLINEOPTION: Windows Input: -nodinput disables DirectInput for mouse/joystick input, gl_finish 1 mode recommended if this option is used as otherwise it tends to stutter due to input backlog.
-       if (!COM_CheckParm ("-nodinput"))
+// 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");
                }
        }
 
@@ -1277,18 +1276,18 @@ void IN_StartupMouse (void)
 
                if (mouseparmsvalid)
                {
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemspd disables setting of mouse speed (-nodinput only, 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 (-nodinput only, 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 (-nodinput only, 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];