]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_sdl.c
changed drivername to NULL, as SDL knows best
[xonotic/darkplaces.git] / vid_sdl.c
index d4519854f8ffeccfd53ffc5a6bd6a1af3f8e6e74..3acdc478265534ab55c8aacfe588c7160c3bad39 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -195,7 +195,7 @@ static unsigned int tbl_sdltoquake[] =
 #undef fiftyoh
 #undef hundredoh
 
-static int MapKey( int sdlkey )
+static int MapKey( unsigned int sdlkey )
 {
        if( sdlkey > sizeof(tbl_sdltoquake)/ sizeof(int) )
                return 0;
@@ -281,10 +281,12 @@ void Sys_SendKeyEvents( void )
                                break;
                        case SDL_ACTIVEEVENT:
                                if( event.active.state == SDL_APPACTIVE ) 
+                               {
                                        if( event.active.gain )
                                                vid_hidden = false;
                                        else
                                                vid_hidden = true;
+                               }
                                break;
                        case SDL_MOUSEBUTTONDOWN:
                                if( event.button.button == SDL_BUTTON_MIDDLE ) 
@@ -335,16 +337,16 @@ static void VID_SetCaption()
        HICON                   icon;
 
        // set the caption
-       //SDL_WM_SetCaption( gamename, NULL );
+       SDL_WM_SetCaption( gamename, NULL );
 
        // get the HWND handle 
     SDL_VERSION( &info.version );
        if( !SDL_GetWMInfo( &info ) )
                return;
 
-       icon = LoadIcon( GetModuleHandle( NULL ), MAKEINTRESOURCE( IDI_ICON1 ) );
-       //icon = LoadIcon( NULL, IDI_ERROR );
-       SetClassLong( info.window, GCL_HICONSM, (LONG) icon );
+       //icon = LoadIcon( GetModuleHandle( NULL ), MAKEINTRESOURCE( IDI_ICON1 ) );
+       icon = LoadIcon( NULL, IDI_ERROR );
+       SetClassLong( info.window, GCL_HICON, (LONG) icon );
 }
 #else
 static void VID_SetCaption()
@@ -378,14 +380,10 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        */
        SDL_SetVideoMode( 0, 0, 0, 0 );
 
-#ifdef WIN32
-       drivername = "opengl32.dll";
-#elif defined(__APPLE__) && defined(__MACH__)
-       drivername = "OpenGL.framework";
-#else
-       drivername = "libGL.so.1";
-#endif
+       // SDL usually knows best
+       drivername = NULL;
 
+// COMMANDLINEOPTION: SDL GL: -gl_driver <drivername> selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
        i = COM_CheckParm("-gl_driver");
        if (i && i < com_argc - 1)
                drivername = com_argv[i + 1];
@@ -412,11 +410,23 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
                vid_isfullscreen = true;
        }
 
-       SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 1);
-       SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 1);
-       SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 1);
-       SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
        SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
+       if (bpp >= 32)
+       {
+               SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
+               SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8);
+               SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8);
+               SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 8);
+               SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 24);
+               SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 8);
+       }
+       else
+       {
+               SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 1);
+               SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 1);
+               SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 1);
+               SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
+       }
 
        screen = SDL_SetVideoMode(width, height, bpp, flags);
        if (screen == NULL)
@@ -425,7 +435,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
                VID_Shutdown();
                return false;
        }
-
+       VID_SetCaption();
        
        gl_renderer = qglGetString(GL_RENDERER);
        gl_vendor = qglGetString(GL_VENDOR);
@@ -443,7 +453,6 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        vid_activewindow = false;
        vid_usingmouse = false;
        IN_Init();
-       VID_SetCaption();
        return true;
 }
 
@@ -475,7 +484,8 @@ void VID_Finish (void)
        Uint8 appstate;
        int vid_usemouse;
 
-       qglFinish();
+       if (r_speeds.integer || gl_finish.integer)
+               qglFinish();
        SDL_GL_SwapBuffers();
 
        //react on appstate changes