r1446 - trunk/code/sdl

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Aug 13 15:39:38 EDT 2008


Author: tma
Date: 2008-08-13 15:39:38 -0400 (Wed, 13 Aug 2008)
New Revision: 1446

Modified:
   trunk/code/sdl/sdl_glimp.c
Log:
* Pass the "best" SDL_PixelFormat (as returned by the initial call to
  SDL_GetVideoInfo) to SDL_ListModes; this fixes said function returning an
  empty list when using the "windib" driver


Modified: trunk/code/sdl/sdl_glimp.c
===================================================================
--- trunk/code/sdl/sdl_glimp.c	2008-08-12 19:34:43 UTC (rev 1445)
+++ trunk/code/sdl/sdl_glimp.c	2008-08-13 19:39:38 UTC (rev 1446)
@@ -76,6 +76,7 @@
 } rserr_t;
 
 static SDL_Surface *screen = NULL;
+static const SDL_VideoInfo *videoInfo = NULL;
 
 cvar_t *r_allowSoftwareGL; // Don't abort out if a hardware visual can't be obtained
 cvar_t *r_sdlDriver;
@@ -150,9 +151,17 @@
 	SDL_Rect **modes;
 	int numModes;
 	int i;
+	SDL_PixelFormat *format = NULL;
 
-	modes = SDL_ListModes( NULL, SDL_OPENGL | SDL_FULLSCREEN );
+#if SDL_VERSION_ATLEAST(1, 2, 10)
+	format = videoInfo->vfmt;
+#	if MINSDL_PATCH >= 10
+#		error Ifdeffery no longer necessary, please remove
+#	endif
+#endif
 
+	modes = SDL_ListModes( format, SDL_OPENGL | SDL_FULLSCREEN );
+
 	if( !modes )
 	{
 		ri.Printf( PRINT_WARNING, "Can't get list of available modes\n" );
@@ -202,22 +211,32 @@
 	int i = 0;
 	SDL_Surface *vidscreen = NULL;
 	Uint32 flags = SDL_OPENGL;
-	const SDL_VideoInfo *videoInfo;
 
 	ri.Printf( PRINT_ALL, "Initializing OpenGL display\n");
 
-	if( displayAspect == 0.0f )
-	{
 #if !SDL_VERSION_ATLEAST(1, 2, 10)
-		// 1.2.10 is needed to get the desktop resolution
-		displayAspect = 4.0f / 3.0f;
+	// 1.2.10 is needed to get the desktop resolution
+	displayAspect = 4.0f / 3.0f;
 #elif MINSDL_PATCH >= 10
 #	error Ifdeffery no longer necessary, please remove
 #else
+	if( videoInfo == NULL )
+	{
+		static SDL_VideoInfo sVideoInfo;
+		static SDL_PixelFormat sPixelFormat;
+
+		videoInfo = SDL_GetVideoInfo( );
+
+		// Take a copy of the videoInfo
+		Com_Memcpy( &sPixelFormat, videoInfo->vfmt, sizeof( SDL_PixelFormat ) );
+		sPixelFormat.palette = NULL; // Should already be the case
+		Com_Memcpy( &sVideoInfo, videoInfo, sizeof( SDL_VideoInfo ) );
+		sVideoInfo.vfmt = &sPixelFormat;
+		videoInfo = &sVideoInfo;
+
 		// Guess the display aspect ratio through the desktop resolution
 		// by assuming (relatively safely) that it is set at or close to
 		// the display's native aspect ratio
-		videoInfo = SDL_GetVideoInfo( );
 		displayAspect = (float)videoInfo->current_w / (float)videoInfo->current_h;
 #endif
 




More information about the quake3-commits mailing list