comparison test/testsprite2.c @ 1725:98a3207ddde8 SDL-1.3

Implemented Win32 video mode support
author Sam Lantinga <slouken@libsdl.org>
date Fri, 07 Jul 2006 08:05:39 +0000
parents 6c63fc2bd986
children 0b1070f2f94d
comparison
equal deleted inserted replaced
1724:6c63fc2bd986 1725:98a3207ddde8
120 120
121 int 121 int
122 main(int argc, char *argv[]) 122 main(int argc, char *argv[])
123 { 123 {
124 int window_w, window_h; 124 int window_w, window_h;
125 Uint32 window_flags = SDL_WINDOW_SHOWN;
126 SDL_DisplayMode *mode, fullscreen_mode;
125 int i, done; 127 int i, done;
126 SDL_Event event; 128 SDL_Event event;
127 Uint32 then, now, frames; 129 Uint32 then, now, frames;
128 130
129 /* Initialize SDL */ 131 /* Initialize SDL */
135 num_windows = NUM_WINDOWS; 137 num_windows = NUM_WINDOWS;
136 num_sprites = NUM_SPRITES; 138 num_sprites = NUM_SPRITES;
137 window_w = WINDOW_W; 139 window_w = WINDOW_W;
138 window_h = WINDOW_H; 140 window_h = WINDOW_H;
139 while (argc > 1) { 141 while (argc > 1) {
140 --argc;
141 if (strcmp(argv[argc - 1], "-width") == 0) { 142 if (strcmp(argv[argc - 1], "-width") == 0) {
142 window_w = atoi(argv[argc]); 143 window_w = atoi(argv[argc]);
143 --argc; 144 --argc;
144 } else if (strcmp(argv[argc - 1], "-height") == 0) { 145 } else if (strcmp(argv[argc - 1], "-height") == 0) {
145 window_h = atoi(argv[argc]); 146 window_h = atoi(argv[argc]);
147 --argc;
148 } else if (strcmp(argv[argc - 1], "-fullscreen") == 0) {
149 num_windows = 1;
150 window_flags |= SDL_WINDOW_FULLSCREEN;
146 --argc; 151 --argc;
147 } else if (isdigit(argv[argc][0])) { 152 } else if (isdigit(argv[argc][0])) {
148 num_sprites = atoi(argv[argc]); 153 num_sprites = atoi(argv[argc]);
149 } else { 154 } else {
150 fprintf(stderr, 155 fprintf(stderr,
151 "Usage: %s [-width] [-height] [numsprites]\n", argv[0]); 156 "Usage: %s [-width] [-height] [numsprites]\n", argv[0]);
152 quit(1); 157 quit(1);
153 } 158 }
154 } 159 }
155 160
156 /* Set the desktop mode, we don't care what it is */ 161 if (window_flags & SDL_WINDOW_FULLSCREEN) {
157 if (SDL_SetDisplayMode(NULL) < 0) { 162 SDL_zero(fullscreen_mode);
163 fullscreen_mode.w = window_w;
164 fullscreen_mode.h = window_h;
165 mode = &fullscreen_mode;
166 } else {
167 /* Set the desktop mode, we don't care what it is */
168 mode = NULL;
169 }
170 if (SDL_SetDisplayMode(mode) < 0) {
158 fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError()); 171 fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError());
159 quit(2); 172 quit(2);
160 } 173 }
161 174
162 /* Create the windows, initialize the renderers, and load the textures */ 175 /* Create the windows, initialize the renderers, and load the textures */
171 184
172 SDL_snprintf(title, sizeof(title), "testsprite %d", i + 1); 185 SDL_snprintf(title, sizeof(title), "testsprite %d", i + 1);
173 windows[i] = 186 windows[i] =
174 SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, 187 SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED,
175 SDL_WINDOWPOS_UNDEFINED, window_w, window_h, 188 SDL_WINDOWPOS_UNDEFINED, window_w, window_h,
176 SDL_WINDOW_SHOWN); 189 window_flags);
177 if (!windows[i]) { 190 if (!windows[i]) {
178 fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); 191 fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
179 quit(2); 192 quit(2);
180 } 193 }
181 194