]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
- Removed Con_SafePrint and Con_SafePrintf since they now does the same things as...
[xonotic/darkplaces.git] / vid_wgl.c
index 2200c87e0c22d5dbd7964a3063bd0d46a017707a..4726150ced845d16d9b6b7f2f2f4eecf03860949 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -73,8 +73,6 @@ static dllfunction_t wglswapintervalfuncs[] =
        {NULL, NULL}
 };
 
-qboolean scr_skipupdate;
-
 static DEVMODE gdevmode;
 static qboolean vid_initialized = false;
 static qboolean vid_wassuspended = false;
@@ -82,6 +80,8 @@ static int vid_usingmouse;
 static HICON hIcon;
 
 HWND mainwindow;
+static HDC      baseDC;
+static HGLRC baseRC;
 
 //HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
 
@@ -259,7 +259,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);
 
 /*
@@ -302,7 +302,6 @@ void VID_GetWindowSize (int *x, int *y, int *width, int *height)
 
 void VID_Finish (void)
 {
-       HDC hdc;
        int vid_usemouse;
        static int      old_vsync       = -1;
 
@@ -314,13 +313,11 @@ void VID_Finish (void)
                        qwglSwapIntervalEXT (old_vsync);
        }
 
-       if (r_render.integer && !scr_skipupdate)
+       if (r_render.integer && !vid_hidden)
        {
                if (r_speeds.integer || gl_finish.integer)
                        qglFinish();
-               hdc = GetDC(mainwindow);
-               SwapBuffers(hdc);
-               ReleaseDC(mainwindow, hdc);
+               SwapBuffers(baseDC);
        }
 
 // handle the mouse state when windowed if that's changed
@@ -524,9 +521,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 ();
 
@@ -789,7 +783,6 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        };
        int pixelformat;
        DWORD WindowStyle, ExWindowStyle;
-       HGLRC baseRC;
        int CenterX, CenterY;
        const char *gldrivername;
        int depth;
@@ -934,19 +927,19 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        // fix the leftover Alt from any Alt-Tab or the like that switched us away
        ClearAllStates ();
 
-       hdc = GetDC(mainwindow);
+       baseDC = GetDC(mainwindow);
 
-       if ((pixelformat = ChoosePixelFormat(hdc, &pfd)) == 0)
+       if ((pixelformat = ChoosePixelFormat(baseDC, &pfd)) == 0)
        {
                VID_Shutdown();
-               Con_Printf("ChoosePixelFormat(%d, %p) failed\n", hdc, &pfd);
+               Con_Printf("ChoosePixelFormat(%d, %p) failed\n", baseDC, &pfd);
                return false;
        }
 
-       if (SetPixelFormat(hdc, pixelformat, &pfd) == false)
+       if (SetPixelFormat(baseDC, pixelformat, &pfd) == false)
        {
                VID_Shutdown();
-               Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", hdc, pixelformat, &pfd);
+               Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", baseDC, pixelformat, &pfd);
                return false;
        }
 
@@ -957,17 +950,17 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
                return false;
        }
 
-       baseRC = qwglCreateContext(hdc);
+       baseRC = qwglCreateContext(baseDC);
        if (!baseRC)
        {
                VID_Shutdown();
                Con_Print("Could not initialize GL (wglCreateContext failed).\n\nMake sure you are in 65536 color mode, and try running -window.\n");
                return false;
        }
-       if (!qwglMakeCurrent(hdc, baseRC))
+       if (!qwglMakeCurrent(baseDC, baseRC))
        {
                VID_Shutdown();
-               Con_Printf("wglMakeCurrent(%d, %d) failed\n", hdc, baseRC);
+               Con_Printf("wglMakeCurrent(%d, %d) failed\n", baseDC, baseRC);
                return false;
        }
 
@@ -989,11 +982,11 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        gl_videosyncavailable = false;
 
        if (qwglGetExtensionsStringARB)
-               gl_platformextensions = qwglGetExtensionsStringARB(hdc);
+               gl_platformextensions = qwglGetExtensionsStringARB(baseDC);
 
 // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control
        gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);
-       ReleaseDC(mainwindow, hdc);
+       //ReleaseDC(mainwindow, hdc);
 
        GL_Init ();
 
@@ -1020,9 +1013,6 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
 static void IN_Shutdown(void);
 void VID_Shutdown (void)
 {
-       HGLRC hRC = 0;
-       HDC hDC = 0;
-
        if(vid_initialized == false)
                return;
 
@@ -1030,18 +1020,14 @@ void VID_Shutdown (void)
 
        vid_initialized = false;
        IN_Shutdown();
-       if (qwglGetCurrentContext)
-               hRC = qwglGetCurrentContext();
-       if (qwglGetCurrentDC)
-               hDC = qwglGetCurrentDC();
        if (qwglMakeCurrent)
                qwglMakeCurrent(NULL, NULL);
-       if (hRC && qwglDeleteContext)
-               qwglDeleteContext(hRC);
+       if (baseRC && qwglDeleteContext)
+               qwglDeleteContext(baseRC);
        // close the library before we get rid of the window
        GL_CloseLibrary();
-       if (hDC && mainwindow)
-               ReleaseDC(mainwindow, hDC);
+       if (baseDC && mainwindow)
+               ReleaseDC(mainwindow, baseDC);
        AppActivate(false, false);
        if (mainwindow)
                DestroyWindow(mainwindow);
@@ -1191,7 +1177,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;
                }
        }
@@ -1202,7 +1188,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;
                }
        }
@@ -1220,7 +1206,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;
        }
 
@@ -1229,7 +1215,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;
        }
 
@@ -1239,7 +1225,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;
        }
 
@@ -1250,7 +1236,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;
        }
 
@@ -1270,18 +1256,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");
                }
        }
 
@@ -1291,18 +1277,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];
@@ -1358,7 +1344,7 @@ void IN_MouseEvent (int mstate)
 IN_MouseMove
 ===========
 */
-void IN_MouseMove (usercmd_t *cmd)
+void IN_MouseMove (void)
 {
        int                                     i, mx, my;
        DIDEVICEOBJECTDATA      od;
@@ -1369,7 +1355,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;
        }
 
@@ -1456,7 +1442,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))
@@ -1469,12 +1455,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 ();
        }
 }
 
@@ -1767,7 +1753,7 @@ qboolean IN_ReadJoystick (void)
 IN_JoyMove
 ===========
 */
-void IN_JoyMove (usercmd_t *cmd)
+void IN_JoyMove (void)
 {
        float   speed, aspeed;
        float   fAxisValue, fTemp;
@@ -1862,7 +1848,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;
@@ -1870,7 +1856,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;
 
@@ -1880,7 +1866,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