]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed crash on startup and shutdown
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 22 Sep 2002 00:29:49 +0000 (00:29 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 22 Sep 2002 00:29:49 +0000 (00:29 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2414 d7cf8633-e32d-0410-b094-e92efae38249

vid_wgl.c

index 0e9b29443b48c94ce98e4741b7cdee1eef2fb638..7287e2c16daaa3f7e2e338ede4f7ec61b0546543 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -57,6 +57,8 @@ static gl_extensionfunctionlist_t wglfuncs[] =
        {"wglDeleteContext", (void **) &qwglDeleteContext},
        {"wglGetProcAddress", (void **) &qwglGetProcAddress},
        {"wglMakeCurrent", (void **) &qwglMakeCurrent},
        {"wglDeleteContext", (void **) &qwglDeleteContext},
        {"wglGetProcAddress", (void **) &qwglGetProcAddress},
        {"wglMakeCurrent", (void **) &qwglMakeCurrent},
+       {"wglGetCurrentContext", (void **) &qwglGetCurrentContext},
+       {"wglGetCurrentDC", (void **) &qwglGetCurrentDC},
        {NULL, NULL}
 };
 
        {NULL, NULL}
 };
 
@@ -107,7 +109,6 @@ static vmode_t badmode;
 static DEVMODE gdevmode;
 static qboolean vid_initialized = false;
 static qboolean windowed, leavecurrentmode;
 static DEVMODE gdevmode;
 static qboolean vid_initialized = false;
 static qboolean windowed, leavecurrentmode;
-static qboolean vid_canalttab = false;
 static qboolean vid_wassuspended = false;
 static int vid_usingmouse;
 extern qboolean mouseactive;  // from in_win.c
 static qboolean vid_wassuspended = false;
 static int vid_usingmouse;
 extern qboolean mouseactive;  // from in_win.c
@@ -413,23 +414,18 @@ void VID_Shutdown (void)
 {
        HGLRC hRC;
        HDC hDC;
 {
        HGLRC hRC;
        HDC hDC;
-       int i;
-       GLuint temp[8192];
 
        if (vid_initialized)
        {
 
        if (vid_initialized)
        {
-               vid_canalttab = false;
-               hRC = qwglGetCurrentContext();
-               hDC = qwglGetCurrentDC();
-
-               qwglMakeCurrent(NULL, NULL);
+               if (qwglGetCurrentContext)
+                       hRC = qwglGetCurrentContext();
+               if (qwglGetCurrentDC)
+                       hDC = qwglGetCurrentDC();
 
 
-               // LordHavoc: free textures before closing (may help NVIDIA)
-               for (i = 0;i < 8192;i++)
-                       temp[i] = i+1;
-               qglDeleteTextures(8192, temp);
+               if (qwglMakeCurrent)
+                       qwglMakeCurrent(NULL, NULL);
 
 
-               if (hRC)
+               if (hRC && qwglDeleteContext)
                        qwglDeleteContext(hRC);
 
                // close the library before we get rid of the window
                        qwglDeleteContext(hRC);
 
                // close the library before we get rid of the window
@@ -589,7 +585,7 @@ void AppActivate(BOOL fActive, BOOL minimize)
        {
                if (modestate == MS_FULLDIB)
                {
        {
                if (modestate == MS_FULLDIB)
                {
-                       if (vid_canalttab && vid_wassuspended)
+                       if (vid_wassuspended)
                        {
                                vid_wassuspended = false;
                                ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
                        {
                                vid_wassuspended = false;
                                ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
@@ -608,7 +604,7 @@ void AppActivate(BOOL fActive, BOOL minimize)
                vid_usingmouse = false;
                IN_DeactivateMouse ();
                IN_ShowMouse ();
                vid_usingmouse = false;
                IN_DeactivateMouse ();
                IN_ShowMouse ();
-               if (modestate == MS_FULLDIB && vid_canalttab)
+               if (modestate == MS_FULLDIB)
                {
                        ChangeDisplaySettings (NULL, 0);
                        vid_wassuspended = true;
                {
                        ChangeDisplaySettings (NULL, 0);
                        vid_wassuspended = true;
@@ -1314,6 +1310,9 @@ void VID_Init (int fullscreen, int width, int height, int bpp)
        if (!qwglMakeCurrent( maindc, baseRC ))
                Sys_Error ("wglMakeCurrent failed");
 
        if (!qwglMakeCurrent( maindc, baseRC ))
                Sys_Error ("wglMakeCurrent failed");
 
+       qglGetString = GL_GetProcAddress("glGetString");
+       if (qglGetString == NULL)
+               Sys_Error ("glGetString does not exist");
        gl_renderer = qglGetString(GL_RENDERER);
        gl_vendor = qglGetString(GL_VENDOR);
        gl_version = qglGetString(GL_VERSION);
        gl_renderer = qglGetString(GL_RENDERER);
        gl_vendor = qglGetString(GL_VENDOR);
        gl_version = qglGetString(GL_VERSION);
@@ -1343,7 +1342,6 @@ void VID_Init (int fullscreen, int width, int height, int bpp)
        vid_menukeyfn = VID_MenuKey;
 
        strcpy (badmode.modedesc, "Bad mode");
        vid_menukeyfn = VID_MenuKey;
 
        strcpy (badmode.modedesc, "Bad mode");
-       vid_canalttab = true;
 
        vid_hidden = false;
 }
 
        vid_hidden = false;
 }