[quake3-commits] r2145 - in trunk/code: q3_ui renderer sdl

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Aug 11 01:14:43 EDT 2011


Author: ztm
Date: 2011-08-11 01:14:42 -0400 (Thu, 11 Aug 2011)
New Revision: 2145

Modified:
   trunk/code/q3_ui/ui_video.c
   trunk/code/renderer/tr_init.c
   trunk/code/sdl/sdl_glimp.c
Log:
- Added r_mode -2 for using display resolution.
- Changed q3_ui's very high video settings use display resolution.

Modified: trunk/code/q3_ui/ui_video.c
===================================================================
--- trunk/code/q3_ui/ui_video.c	2011-08-11 03:57:23 UTC (rev 2144)
+++ trunk/code/q3_ui/ui_video.c	2011-08-11 05:14:42 UTC (rev 2145)
@@ -297,7 +297,7 @@
 static InitialVideoOptions_s s_ivo_templates[] =
 {
 	{
-		6, qtrue, 3, 0, 2, 2, 1, 0, qtrue
+		6, qtrue, 3, 0, 2, 2, 1, 0, qtrue	// Note: If r_availableModes is found, mode is changed to -2.
 	},
 	{
 		4, qtrue, 2, 0, 2, 1, 1, 0, qtrue	// JDC: this was tq 3
@@ -372,6 +372,10 @@
 	if( !resolutionsDetected )
 		return mode;
 
+	// Display resolution
+	if( mode == 0 )
+		return -2;
+
 	if( mode < 0 )
 		return -1;
 
@@ -396,6 +400,10 @@
 	if( !resolutionsDetected )
 		return mode;
 
+	// Display resolution
+	if( mode == -2 )
+		return 0;
+
 	if( mode < 0 )
 		return -1;
 
@@ -425,11 +433,16 @@
 		char str[ sizeof(ratioBuf[0]) ];
 
 		// calculate resolution's aspect ratio
-		x = strchr( resolutions[r], 'x' ) + 1;
-		Q_strncpyz( str, resolutions[r], x-resolutions[r] );
-		w = atoi( str );
-		h = atoi( x );
-		Com_sprintf( str, sizeof(str), "%.2f:1", (float)w / (float)h );
+		x = strchr( resolutions[r], 'x' );
+		if (x) {
+			x++;
+			Q_strncpyz( str, resolutions[r], x-resolutions[r] );
+			w = atoi( str );
+			h = atoi( x );
+			Com_sprintf( str, sizeof(str), "%.2f:1", (float)w / (float)h );
+		} else {
+			Q_strncpyz(str, "Unknown", sizeof(str));
+		}
 
 		// rename common ratios ("1.33:1" -> "4:3")
 		for( i = 0; knownRatios[i][0]; i++ ) {
@@ -489,6 +502,13 @@
 	{
 		char* s = resbuf;
 		unsigned int i = 0;
+
+		// Add display resolution video mode
+		detectedResolutions[i++] = "Display Resolution";
+
+		// Use display resolution in "Very High Quality" template
+		s_ivo_templates[0].mode = -2;
+
 		while( s && i < ARRAY_LEN(detectedResolutions)-1 )
 		{
 			detectedResolutions[i++] = s;

Modified: trunk/code/renderer/tr_init.c
===================================================================
--- trunk/code/renderer/tr_init.c	2011-08-11 03:57:23 UTC (rev 2144)
+++ trunk/code/renderer/tr_init.c	2011-08-11 05:14:42 UTC (rev 2145)
@@ -292,14 +292,17 @@
 	vidmode_t	*vm;
 	float			pixelAspect;
 
-	if ( mode < -1 ) {
+	if ( mode < -2 ) {
 		return qfalse;
 	}
 	if ( mode >= s_numVidModes ) {
 		return qfalse;
 	}
 
-	if ( mode == -1 ) {
+	if ( mode == -2 ) {
+		// Must set width and height to display size before calling this function!
+		pixelAspect = 1.0f;
+	} else if ( mode == -1 ) {
 		*width = r_customwidth->integer;
 		*height = r_customheight->integer;
 		pixelAspect = r_customPixelAspect->value;

Modified: trunk/code/sdl/sdl_glimp.c
===================================================================
--- trunk/code/sdl/sdl_glimp.c	2011-08-11 03:57:23 UTC (rev 2144)
+++ trunk/code/sdl/sdl_glimp.c	2011-08-11 05:14:42 UTC (rev 2145)
@@ -248,6 +248,16 @@
 		}
 	}
 
+	if( videoInfo->current_h > 0 ) {
+		glConfig.vidWidth = videoInfo->current_w;
+		glConfig.vidHeight = videoInfo->current_h;
+	} else {
+		glConfig.vidWidth = 480;
+		glConfig.vidHeight = 640;
+		ri.Printf( PRINT_ALL,
+				"Cannot determine display resolution, assuming 640x480\n" );
+	}
+
 	ri.Printf (PRINT_ALL, "...setting mode %d:", mode );
 
 	if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )



More information about the quake3-commits mailing list