]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
try to notice uncompensated packet loss due to timeouts
[xonotic/darkplaces.git] / vid_wgl.c
index ed890e702baee9a57f2971632de73ea6bb0a1daf..0eebe7d098cf61cd1975c0e92cbb201b9e08f336 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -250,14 +250,14 @@ static void IN_StartupMouse (void);
 
 void VID_Finish (void)
 {
-       vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
-       if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
+       vid_usevsync = vid_vsync.integer && !cls.timedemo && qwglSwapIntervalEXT;
+       if (vid_usingvsync != vid_usevsync)
        {
                vid_usingvsync = vid_usevsync;
                qwglSwapIntervalEXT (vid_usevsync);
        }
 
-       if (r_render.integer && !vid_hidden)
+       if (!vid_hidden)
        {
                CHECKGLERROR
                if (r_speeds.integer == 2 || gl_finish.integer)
@@ -395,8 +395,8 @@ void AppActivate(BOOL fActive, BOOL minimize)
 {
        static qboolean sound_active = false;  // initially blocked by Sys_InitConsole()
 
-       vid_activewindow = fActive;
-       vid_hidden = minimize;
+       vid_activewindow = fActive != FALSE;
+       vid_hidden = minimize != FALSE;
 
        // enable/disable sound on focus gain/loss
        if ((!vid_hidden && vid_activewindow) || !snd_mutewhenidle.integer)
@@ -787,7 +787,7 @@ void VID_Init(void)
        IN_Init();
 }
 
-int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
+qboolean VID_InitMode(viddef_mode_t *mode)
 {
        int i;
        HDC hdc;
@@ -827,6 +827,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        float *af;
        int attribs[128];
        float attribsf[16];
+       int bpp = mode->bitsperpixel;
+       int width = mode->width;
+       int height = mode->height;
+       int refreshrate = (int)floor(mode->refreshrate+0.5);
+       int stereobuffer = mode->stereobuffer;
+       int samples = mode->samples;
+       int fullscreen = mode->fullscreen;
 
        if (vid_initialized)
                Sys_Error("VID_InitMode called when video is already initialised");
@@ -928,8 +935,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                        foundmode = true;
                        gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
                        gdevmode.dmBitsPerPel = bpp;
-                       gdevmode.dmPelsWidth = *width;
-                       gdevmode.dmPelsHeight = *height;
+                       gdevmode.dmPelsWidth = width;
+                       gdevmode.dmPelsHeight = height;
                        gdevmode.dmSize = sizeof (gdevmode);
                        if(refreshrate)
                        {
@@ -962,13 +969,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                                                Con_Printf("wrong bpp\n");
                                        continue;
                                }
-                               if(thismode.dmPelsWidth != (DWORD)*width)
+                               if(thismode.dmPelsWidth != (DWORD)width)
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong width\n");
                                        continue;
                                }
-                               if(thismode.dmPelsHeight != (DWORD)*height)
+                               if(thismode.dmPelsHeight != (DWORD)height)
                                {
                                        if(developer.integer >= 100)
                                                Con_Printf("wrong height\n");
@@ -1020,13 +1027,13 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
                if (!foundmode)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", *width, *height, bpp);
+                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", width, height, bpp);
                        return false;
                }
                else if(ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", *width, *height, bpp);
+                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp);
                        return false;
                }
 
@@ -1059,8 +1066,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
 
        rect.top = 0;
        rect.left = 0;
-       rect.right = *width;
-       rect.bottom = *height;
+       rect.right = width;
+       rect.bottom = height;
        AdjustWindowRectEx(&rect, WindowStyle, false, 0);
 
        if (fullscreen)
@@ -1215,10 +1222,8 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        // fix the leftover Alt from any Alt-Tab or the like that switched us away
        ClearAllStates ();
 
-       gl_videosyncavailable = false;
-
 // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control
-       gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);
+       GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);
 
        GL_Init ();
 
@@ -1233,10 +1238,10 @@ int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshr
        IN_StartupMouse ();
        IN_StartupJoystick ();
 
-       if (gl_videosyncavailable)
+       if (qwglSwapIntervalEXT)
        {
-               vid_usevsync = vid_vsync.integer;
-               vid_usingvsync = vid_vsync.integer;
+               vid_usevsync = vid_vsync.integer != 0;
+               vid_usingvsync = vid_vsync.integer != 0;
                qwglSwapIntervalEXT (vid_usevsync);
        }
 
@@ -1308,7 +1313,7 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
                                        newmouseparms[0] = 0; // threshold to double movement (only if accel level is >= 1)
                                        newmouseparms[1] = 0; // threshold to quadruple movement (only if accel level is >= 2)
                                        newmouseparms[2] = 0; // maximum level of acceleration (0 = off)
-                                       restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
+                                       restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0) != FALSE;
                                }
                                else
                                        restore_spi = false;
@@ -1384,7 +1389,7 @@ static qboolean IN_InitDInput (void)
 
        if (!pDirectInputCreate)
        {
-               pDirectInputCreate = (void *)GetProcAddress(hInstDI,"DirectInputCreateA");
+               pDirectInputCreate = (HRESULT (__stdcall *)(HINSTANCE,DWORD,LPDIRECTINPUT *,LPUNKNOWN))GetProcAddress(hInstDI,"DirectInputCreateA");
 
                if (!pDirectInputCreate)
                {
@@ -1402,7 +1407,11 @@ static qboolean IN_InitDInput (void)
        }
 
 // obtain an interface to the system mouse device.
+#ifdef __cplusplus
+       hr = IDirectInput_CreateDevice(g_pdi, GUID_SysMouse, &g_pMouse, NULL);
+#else
        hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
+#endif
 
        if (FAILED(hr))
        {
@@ -1658,7 +1667,7 @@ static void IN_StartupJoystick (void)
 
        // save the joystick's number of buttons and POV status
        joy_numbuttons = jc.wNumButtons;
-       joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
+       joy_haspov = (jc.wCaps & JOYCAPS_HASPOV) != 0;
 
        // old button and POV states default to no buttons pressed
        joy_oldbuttonstate = joy_oldpovstate = 0;