about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2009-01-11 12:13:18 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2009-01-11 12:13:18 +0000
commitd0bcf50ef5ad0b5c615f937e3754d35045d35c80 (patch)
treecfc4686e20abf5d1502ec2c84e63b95df7702981 /src/engine
parent2a7402dd6c78e5b0e41bae57bfdd8aec57545f0d (diff)
downloadzcatch-d0bcf50ef5ad0b5c615f937e3754d35045d35c80.tar.gz
zcatch-d0bcf50ef5ad0b5c615f937e3754d35045d35c80.zip
fixed fsaa sampling and reduction of fsaa if gfx init fails
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/ec_gfx.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index 36e9e9fa..888963ba 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -209,6 +209,41 @@ static int try_init()
 	return 0;
 }
 
+static int gfx_init_window()
+{
+	if(try_init() == 0)
+		return 0;
+	
+	/* try disabling fsaa */
+	while(config.gfx_fsaa_samples)
+	{
+		config.gfx_fsaa_samples--;
+		
+		if(config.gfx_fsaa_samples)
+			dbg_msg("gfx", "lowering FSAA to %d and trying again", config.gfx_fsaa_samples);
+		else
+			dbg_msg("gfx", "disabling FSAA and trying again");
+
+		if(try_init() == 0)
+			return 0;
+	}
+
+	/* try lowering the resolution */
+	if(config.gfx_screen_width != 640 || config.gfx_screen_height != 480)
+	{
+		dbg_msg("gfx", "setting resolution to 640x480 and trying again");
+		config.gfx_screen_width = 640;
+		config.gfx_screen_height = 480;
+
+		if(try_init() == 0)
+			return 0;
+	}
+
+	dbg_msg("gfx", "out of ideas. failed to init graphics");
+					
+	return -1;		
+}
+
 int gfx_init()
 {
 	int i;
@@ -230,36 +265,9 @@ int gfx_init()
 			if(!getenv("SDL_VIDEO_WINDOW_POS") && !getenv("SDL_VIDEO_CENTERED"))
 				putenv("SDL_VIDEO_WINDOW_POS=8,27");
 		#endif
-		do
-		{
-			if(try_init() == 0)
-				break;
-			
-			/* try disabling fsaa */
-			if(config.gfx_fsaa_samples)
-			{
-				dbg_msg("gfx", "disabling FSAA and trying again");
-				config.gfx_fsaa_samples = 0;
-
-				if(try_init() == 0)
-					break;
-			}
-
-			/* try lowering the resolution */
-			if(config.gfx_screen_width != 640 || config.gfx_screen_height != 480)
-			{
-				dbg_msg("gfx", "setting resolution to 640x480 and trying again");
-				config.gfx_screen_width = 640;
-				config.gfx_screen_height = 480;
-
-				if(try_init() == 0)
-					break;
-			}
-
-			dbg_msg("gfx", "out of ideas. failed to init graphics");
-							
-			return -1;			
-		} while(0);
+		
+		if(gfx_init_window() != 0)
+			return -1;
 	}
 	
 	/* Init vertices */