Mercurial > sdl-ios-xcode
comparison test/testsprite2.c @ 1907:06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 15 Jul 2006 09:46:36 +0000 |
parents | 1a713f9d1f71 |
children | 051df511279c |
comparison
equal
deleted
inserted
replaced
1906:0c49855a7a3e | 1907:06c27a737b7a |
---|---|
1 /* Simple program: Move N sprites around on the screen as fast as possible */ | 1 /* Simple program: Move N sprites around on the screen as fast as possible */ |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 #include <stdio.h> | |
4 #include <time.h> | 5 #include <time.h> |
5 | 6 |
6 #include "SDL.h" | 7 #include "SDL.h" |
7 | 8 |
8 #define NUM_WINDOWS 4 | 9 #define NUM_WINDOWS 4 |
124 int | 125 int |
125 main(int argc, char *argv[]) | 126 main(int argc, char *argv[]) |
126 { | 127 { |
127 int window_w, window_h; | 128 int window_w, window_h; |
128 Uint32 window_flags = SDL_WINDOW_SHOWN; | 129 Uint32 window_flags = SDL_WINDOW_SHOWN; |
130 Uint32 render_flags = 0; | |
129 SDL_DisplayMode *mode, fullscreen_mode; | 131 SDL_DisplayMode *mode, fullscreen_mode; |
130 int i, done; | 132 int i, done; |
131 SDL_Event event; | 133 SDL_Event event; |
132 Uint32 then, now, frames; | 134 Uint32 then, now, frames; |
133 | 135 |
150 num_windows = atoi(argv[++i]); | 152 num_windows = atoi(argv[++i]); |
151 window_flags &= ~SDL_WINDOW_FULLSCREEN; | 153 window_flags &= ~SDL_WINDOW_FULLSCREEN; |
152 } else if (strcmp(argv[i], "-fullscreen") == 0) { | 154 } else if (strcmp(argv[i], "-fullscreen") == 0) { |
153 num_windows = 1; | 155 num_windows = 1; |
154 window_flags |= SDL_WINDOW_FULLSCREEN; | 156 window_flags |= SDL_WINDOW_FULLSCREEN; |
157 } else if (strcmp(argv[i], "-sync") == 0) { | |
158 render_flags |= SDL_Renderer_PresentVSync; | |
155 } else if (isdigit(argv[i][0])) { | 159 } else if (isdigit(argv[i][0])) { |
156 num_sprites = atoi(argv[i]); | 160 num_sprites = atoi(argv[i]); |
157 } else { | 161 } else { |
158 fprintf(stderr, | 162 fprintf(stderr, |
159 "Usage: %s [-width N] [-height N] [-windows N] [-fullscreen] [numsprites]\n", | 163 "Usage: %s [-width N] [-height N] [-windows N] [-fullscreen] [-sync] [numsprites]\n", |
160 argv[0]); | 164 argv[0]); |
161 quit(1); | 165 quit(1); |
162 } | 166 } |
163 } | 167 } |
164 | 168 |
187 if (!windows[i]) { | 191 if (!windows[i]) { |
188 fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); | 192 fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); |
189 quit(2); | 193 quit(2); |
190 } | 194 } |
191 | 195 |
192 if (SDL_CreateRenderer(windows[i], -1, 0) < 0) { | 196 if (SDL_CreateRenderer(windows[i], -1, render_flags) < 0) { |
193 fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); | 197 fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); |
194 quit(2); | 198 quit(2); |
195 } | 199 } |
196 SDL_RenderFill(NULL, BACKGROUND); | 200 SDL_RenderFill(NULL, BACKGROUND); |
197 } | 201 } |