Package: rrootage / 0.23a-12

06_rrootage_highres.patch Patch series | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Index: rrootage-0.23a/src/rr.c
===================================================================
--- rrootage-0.23a.orig/src/rr.c	2007-08-29 19:48:31.000000000 +0000
+++ rrootage-0.23a/src/rr.c	2007-08-29 19:50:14.000000000 +0000
@@ -195,14 +195,18 @@
 static int accframe = 0;
 
 static void usage(char *argv0) {
-  fprintf(stderr, "Usage: %s [-lowres] [-nosound] [-window] [-reverse] [-nowait] [-accframe]\n", argv0);
+  fprintf(stderr, "Usage: %s [-lowres|-mediumres|-highres] [-nosound] [-window] [-reverse] [-nowait] [-accframe]\n", argv0);
 }
 
 static void parseArgs(int argc, char *argv[]) {
   int i;
   for ( i=1 ; i<argc ; i++ ) {
     if ( strcmp(argv[i], "-lowres") == 0 ) {
-      lowres = 1;
+      resolution = LOW_RESOLUTION;
+    } else if ( strcmp(argv[i], "-mediumres") == 0 ) {
+      resolution = MEDIUM_RESOLUTION;
+    } else if ( strcmp(argv[i], "-highres") == 0 ) {
+      resolution = HIGH_RESOLUTION;
     } else if ( strcmp(argv[i], "-nosound") == 0 ) {
       noSound = 1;
     } else if ( strcmp(argv[i], "-window") == 0 ) {
@@ -249,6 +253,10 @@
 
   while ( !done ) {
     SDL_PollEvent(&event);
+
+    if ( event.type == SDL_VIDEORESIZE )
+      resized(event.resize.w, event.resize.h);
+
     keys = SDL_GetKeyState(NULL);
     if ( keys[SDLK_ESCAPE] == SDL_PRESSED || event.type == SDL_QUIT ) done = 1;
     if ( keys[SDLK_p] == SDL_PRESSED ) {
Index: rrootage-0.23a/src/screen.c
===================================================================
--- rrootage-0.23a.orig/src/screen.c	2007-08-29 19:50:13.000000000 +0000
+++ rrootage-0.23a/src/screen.c	2007-08-29 19:55:05.000000000 +0000
@@ -33,19 +33,37 @@
 #define LOWRES_SCREEN_HEIGHT 240
 #define SHARE_LOC "/usr/share/games/rrootage/"
 
+static Uint32 videoFlags;
 static int screenWidth, screenHeight;
 
 // Reset viewport when the screen is resized.
 static void screenResized() {
-  glViewport(0, 0, screenWidth, screenHeight);
+  int viewWidth, viewHeight;
+  if ( screenWidth * SCREEN_HEIGHT > screenHeight * SCREEN_WIDTH ) {
+    viewWidth = screenHeight * SCREEN_WIDTH / SCREEN_HEIGHT;
+    viewHeight = screenHeight;
+  } else if ( screenWidth * SCREEN_HEIGHT < screenHeight * SCREEN_WIDTH ) {
+    viewWidth = screenWidth;
+    viewHeight = screenWidth * SCREEN_HEIGHT / SCREEN_WIDTH;
+  } else {
+    viewWidth = screenWidth;
+    viewHeight = screenHeight;
+  }
+
+  glViewport((screenWidth - viewWidth) / 2, screenHeight - viewHeight, viewWidth, viewHeight);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
-  gluPerspective(45.0f, (GLfloat)screenWidth/(GLfloat)screenHeight, 0.1f, FAR_PLANE);
+  gluPerspective(45.0f, (GLfloat)viewWidth/(GLfloat)viewHeight, 0.1f, FAR_PLANE);
   glMatrixMode(GL_MODELVIEW);
 }
 
 void resized(int width, int height) {
   screenWidth = width; screenHeight = height;
+  if ( SDL_SetVideoMode(width, height, 0, videoFlags) == NULL ) {
+    fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
+    SDL_Quit();
+    exit(2);
+  }
   screenResized();
 }
 
@@ -110,7 +128,7 @@
 static GLuint titleTexture;
 #define TITLE_BMP "title.bmp"
 
-int lowres = 0;
+int resolution = MEDIUM_RESOLUTION;
 int windowMode = 0;
 int brightness = DEFAULT_BRIGHTNESS;
 Uint8 *keys;
@@ -118,11 +136,13 @@
 int joystickMode = 1;
 
 void initSDL() {
-  Uint32 videoFlags;
-
-  if ( lowres ) {
+  if ( resolution == LOW_RESOLUTION ) {
     screenWidth  = LOWRES_SCREEN_WIDTH;
     screenHeight = LOWRES_SCREEN_HEIGHT;
+  } else if ( resolution == HIGH_RESOLUTION ) {
+    /* SDL will pick the desktop resolution, which should be the highest possible */
+    screenWidth = 0;
+    screenHeight = 0;
   } else {
     screenWidth  = SCREEN_WIDTH;
     screenHeight = SCREEN_HEIGHT;
@@ -144,11 +164,14 @@
   } else {
     videoFlags = SDL_OPENGL | SDL_FULLSCREEN;
   }
-  if ( SDL_SetVideoMode(screenWidth, screenHeight, 0, videoFlags) == NULL ) {
+  SDL_Surface * screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, videoFlags);
+  if ( screen == NULL ) {
     fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
     SDL_Quit();
     exit(2);
   }
+  screenWidth = screen->w;
+  screenHeight = screen->h;
 
   if (joystickMode == 1) {
     stick = SDL_JoystickOpen(0);
Index: rrootage-0.23a/src/screen.h
===================================================================
--- rrootage-0.23a.orig/src/screen.h	2007-08-29 19:48:31.000000000 +0000
+++ rrootage-0.23a/src/screen.h	2007-08-29 19:50:14.000000000 +0000
@@ -23,13 +23,17 @@
 
 #define DEFAULT_BRIGHTNESS 224
 
+#define MEDIUM_RESOLUTION 0
+#define LOW_RESOLUTION 1
+#define HIGH_RESOLUTION 2
+
 extern float eyeX, eyeY, eyeZ;
 extern float pitch, roll;
 extern float zoom;
 extern Uint8 *keys;
 extern SDL_Joystick *stick;
 extern int buttonReversed;
-extern int lowres;
+extern int resolution;
 extern int windowMode;
 extern int brightness;