summaryrefslogtreecommitdiff
blob: 70877b31e2080b28b8c475c838cbb3813755ae21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--- /trunk/lib/ivis_opengl/screen.c	2006/07/17 22:21:13	116
+++ trunk/lib/ivis_opengl/screen.c	2006/07/19 21:26:09	117
@@ -131,7 +131,7 @@
 	/* Store the screen information */
 	screenWidth = width;
 	screenHeight = height;
-	screenDepth = 24;
+	screenDepth = 32;
 
 	/* store vidmem flag */
 	g_bVidMem = bVidMem;
@@ -168,14 +168,42 @@
 				video_flags |= SDL_HWACCEL;
 			}
 
-			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, 16 );
-			SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
+			bpp = SDL_VideoModeOK(width, height, screenDepth, video_flags);
+			if (!bpp) {
+				debug( LOG_ERROR, "Error: Video mode %dx%d@%dbpp is not supported!\n", width, height, screenDepth );
+				return FALSE;
+			}
+			switch ( bpp )
+			{
+				case 32:
+				case 24:
+					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, 16 );
+					SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
+					break;
+				case 16:
+					debug( LOG_ERROR, "Warning: Using colour depth of %i instead of %i.", bpp, screenDepth );
+					debug( LOG_ERROR, "         You will experience graphics glitches!" );
+					SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
+					SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 6 );
+					SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
+					SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+					SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
+					break;
+				case 8:
+					debug( LOG_ERROR, "Error: You don't want to play Warzone with a bit depth of %i, do you?", bpp );
+					exit( 1 );
+					break;
+				default:
+					debug( LOG_ERROR, "Error: Weird bit depth: %i", bpp );
+					exit( 1 );
+					break;
+			}
 
-    			// Set the double buffer OpenGL attribute.
+			// Set the double buffer OpenGL attribute.
 			SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
 		}
 
@@ -186,15 +214,6 @@
 			screenMode = SCREEN_WINDOWED;
 		}
 
-		bpp = SDL_VideoModeOK(width, height, screenDepth, video_flags);
-		if (!bpp) {
-			printf("Error: Video mode %dx%d@%dbpp is not supported!\n", width, height, screenDepth);
-			return FALSE;
-		}
-		if (bpp != screenDepth) {
-			debug(LOG_3D, "Warning: Using colour depth of %d instead of %d.",
-            bpp, screenDepth);
-		}
 		screen = SDL_SetVideoMode(width, height, bpp, video_flags);
 		if (!screen) {
 			printf("Error: SDL_SetVideoMode failed (%s).\n", SDL_GetError());