]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
fixed some dynamic lighting bugs related to glowing self
[xonotic/darkplaces.git] / vid_wgl.c
index d924b5e500ee9ad0e49e27cd79d163ac8f4c6731..969cfcc088ab38afbb0349332dc6dec8be9b82ac 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -234,6 +234,7 @@ static DIDATAFORMAT df = {
 void IN_StartupJoystick (void);
 void Joy_AdvancedUpdate_f (void);
 void IN_JoyMove (usercmd_t *cmd);
+void IN_StartupMouse (void);
 
 /*
 ================
@@ -538,14 +539,9 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM lParam)
 
                        break;
 
-               case WM_DESTROY:
-               {
-                       if (mainwindow)
-                               DestroyWindow (mainwindow);
-
-                       PostQuitMessage (0);
-               }
-               break;
+               //case WM_DESTROY:
+               //      PostQuitMessage (0);
+               //      break;
 
                case MM_MCINOTIFY:
                        lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
@@ -813,14 +809,21 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int stencil)
        HGLRC baseRC;
        int CenterX, CenterY;
        const char *gldrivername;
-       
+
        if (vid_initialized)
                Sys_Error("VID_InitMode called when video is already initialised\n");
 
+       // if stencil is enabled, ask for alpha too
        if (stencil)
+       {
                pfd.cStencilBits = 8;
+               pfd.cAlphaBits = 8;
+       }
        else
+       {
                pfd.cStencilBits = 0;
+               pfd.cAlphaBits = 0;
+       }
 
        gldrivername = "opengl32.dll";
        i = COM_CheckParm("-gl_driver");
@@ -903,8 +906,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int stencil)
        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);
                VID_Shutdown();
-               Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", ExWindowStyle, gamename, gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
                return false;
        }
 
@@ -1030,36 +1033,28 @@ void VID_Shutdown (void)
        HGLRC hRC = 0;
        HDC hDC = 0;
 
-       if (vid_initialized)
-       {
-               vid_initialized = false;
-               IN_Shutdown();
-
-               if (qwglGetCurrentContext)
-                       hRC = qwglGetCurrentContext();
-
-               if (qwglGetCurrentDC)
-                       hDC = qwglGetCurrentDC();
-
-               if (qwglMakeCurrent)
-                       qwglMakeCurrent(NULL, NULL);
-
-               if (hRC && qwglDeleteContext)
-                       qwglDeleteContext(hRC);
-
-               // close the library before we get rid of the window
-               GL_CloseLibrary();
-
-               if (hDC && mainwindow)
-                       ReleaseDC(mainwindow, hDC);
-
-               if (vid_isfullscreen)
-                       ChangeDisplaySettings (NULL, 0);
-
-               AppActivate(false, false);
-
-               VID_RestoreSystemGamma();
-       }
+       vid_initialized = false;
+       IN_Shutdown();
+       if (qwglGetCurrentContext)
+               hRC = qwglGetCurrentContext();
+       if (qwglGetCurrentDC)
+               hDC = qwglGetCurrentDC();
+       if (qwglMakeCurrent)
+               qwglMakeCurrent(NULL, NULL);
+       if (hRC && qwglDeleteContext)
+               qwglDeleteContext(hRC);
+       // close the library before we get rid of the window
+       GL_CloseLibrary();
+       if (hDC && mainwindow)
+               ReleaseDC(mainwindow, hDC);
+       if (vid_isfullscreen)
+               ChangeDisplaySettings (NULL, 0);
+       vid_isfullscreen = false;
+       AppActivate(false, false);
+       VID_RestoreSystemGamma();
+       if (mainwindow)
+               DestroyWindow(mainwindow);
+       mainwindow = 0;
 }