comparison test/testvidinfo.c @ 886:05c551e5bc64

Date: Sat, 24 Apr 2004 15:13:32 +0300 From: "Mike Gorchak" Subject: SDL updates for the QNX6 1. Updated the README.QNX 2. Updated libtool scripts, which are shipped with SDL for QNX6 support. 3. Added some code to support the new QNX 6.3.0, which is in beta now. 4. Added code to detect the hw features, which driver supports. 5. Added hw alpha blits code. 6. Fixed bug when application switches to fullscreen more the 2 times. (afte\ r that window becames always stay on top). 7. Updated a bit README for the tests. 8. Added information about acceleration show in the testalpha.c test. 9. Added small fixes to the testoverlay2.c test. 10. Added alpha and cc+alpha blits benchmarks to the testvidinfo.c test.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 06 May 2004 15:55:06 +0000
parents 30168104389f
children 8d9bb0cf2c2a
comparison
equal deleted inserted replaced
885:9f6ad2286011 886:05c551e5bc64
9 #include "SDL.h" 9 #include "SDL.h"
10 10
11 #define NUM_BLITS 10 11 #define NUM_BLITS 10
12 #define NUM_UPDATES 500 12 #define NUM_UPDATES 500
13 13
14 #define FLAG_MASK (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF) 14 #define FLAG_MASK (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | \
15 SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCEL | \
16 SDL_RLEACCELOK)
15 17
16 void PrintFlags(Uint32 flags) 18 void PrintFlags(Uint32 flags)
17 { 19 {
18 printf("0x%8.8x", (flags & FLAG_MASK)); 20 printf("0x%8.8x", (flags & FLAG_MASK));
19 if ( flags & SDL_HWSURFACE ) { 21 if ( flags & SDL_HWSURFACE ) {
28 printf(" | SDL_DOUBLEBUF"); 30 printf(" | SDL_DOUBLEBUF");
29 } 31 }
30 if ( flags & SDL_SRCCOLORKEY ) { 32 if ( flags & SDL_SRCCOLORKEY ) {
31 printf(" | SDL_SRCCOLORKEY"); 33 printf(" | SDL_SRCCOLORKEY");
32 } 34 }
35 if ( flags & SDL_SRCALPHA ) {
36 printf(" | SDL_SRCALPHA");
37 }
33 if ( flags & SDL_RLEACCEL ) { 38 if ( flags & SDL_RLEACCEL ) {
34 printf(" | SDL_RLEACCEL"); 39 printf(" | SDL_RLEACCEL");
40 }
41 if ( flags & SDL_RLEACCELOK ) {
42 printf(" | SDL_RLEACCELOK");
35 } 43 }
36 } 44 }
37 45
38 int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount) 46 int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount)
39 { 47 {
115 printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, seconds, (float)frames / seconds); 123 printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, seconds, (float)frames / seconds);
116 } else { 124 } else {
117 printf("%d fills and flips in zero seconds!n", frames); 125 printf("%d fills and flips in zero seconds!n", frames);
118 } 126 }
119 127
128 /* clear the screen after fill test */
129 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
130 SDL_Flip(screen);
131
120 while ( SDL_PollEvent(&event) ) { 132 while ( SDL_PollEvent(&event) ) {
121 if ( event.type == SDL_KEYDOWN ) 133 if ( event.type == SDL_KEYDOWN )
122 return 0; 134 return 0;
123 } 135 }
124 136
140 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 152 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
141 } else { 153 } else {
142 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 154 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
143 } 155 }
144 156
157 /* clear the screen after blit test */
158 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
159 SDL_Flip(screen);
160
161 while ( SDL_PollEvent(&event) ) {
162 if ( event.type == SDL_KEYDOWN )
163 return 0;
164 }
165
145 /* run the colorkeyed blit test */ 166 /* run the colorkeyed blit test */
146 bmpcc = SDL_LoadBMP("sample.bmp"); 167 bmpcc = SDL_LoadBMP("sample.bmp");
147 if ( ! bmpcc ) { 168 if ( ! bmpcc ) {
148 printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); 169 printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
149 return 0; 170 return 0;
160 seconds = (float)(now - then) / 1000.0f; 181 seconds = (float)(now - then) / 1000.0f;
161 if ( seconds > 0.0f ) { 182 if ( seconds > 0.0f ) {
162 printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 183 printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
163 } else { 184 } else {
164 printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 185 printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
186 }
187
188 /* clear the screen after cc blit test */
189 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
190 SDL_Flip(screen);
191
192 while ( SDL_PollEvent(&event) ) {
193 if ( event.type == SDL_KEYDOWN )
194 return 0;
165 } 195 }
166 196
167 /* run the generic blit test */ 197 /* run the generic blit test */
168 tmp = bmp; 198 tmp = bmp;
169 bmp = SDL_DisplayFormat(bmp); 199 bmp = SDL_DisplayFormat(bmp);
184 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 214 printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
185 } else { 215 } else {
186 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 216 printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
187 } 217 }
188 218
219 /* clear the screen after blit test */
220 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
221 SDL_Flip(screen);
222
223 while ( SDL_PollEvent(&event) ) {
224 if ( event.type == SDL_KEYDOWN )
225 return 0;
226 }
227
189 /* run the colorkeyed blit test */ 228 /* run the colorkeyed blit test */
190 tmp = bmpcc; 229 tmp = bmpcc;
191 bmpcc = SDL_DisplayFormat(bmpcc); 230 bmpcc = SDL_DisplayFormat(bmpcc);
192 SDL_FreeSurface(tmp); 231 SDL_FreeSurface(tmp);
193 if ( ! bmpcc ) { 232 if ( ! bmpcc ) {
204 seconds = (float)(now - then) / 1000.0f; 243 seconds = (float)(now - then) / 1000.0f;
205 if ( seconds > 0.0f ) { 244 if ( seconds > 0.0f ) {
206 printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds); 245 printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
207 } else { 246 } else {
208 printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames); 247 printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
248 }
249
250 /* clear the screen after cc blit test */
251 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
252 SDL_Flip(screen);
253
254 while ( SDL_PollEvent(&event) ) {
255 if ( event.type == SDL_KEYDOWN )
256 return 0;
257 }
258
259 /* run the alpha blit test only if screen bpp>8 */
260 if (bmp->format->BitsPerPixel>8)
261 {
262 SDL_FreeSurface(bmp);
263 bmp = SDL_LoadBMP("sample.bmp");
264 SDL_SetAlpha(bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */
265 tmp = bmp;
266 bmp = SDL_DisplayFormat(bmp);
267 SDL_FreeSurface(tmp);
268 if ( ! bmp ) {
269 printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
270 return 0;
271 }
272 printf("Running display format alpha blit test: %dx%d at %d bpp, flags: ",
273 bmp->w, bmp->h, bmp->format->BitsPerPixel);
274 PrintFlags(bmp->flags);
275 printf("\n");
276 then = SDL_GetTicks();
277 frames = RunBlitTests(screen, bmp, NUM_BLITS);
278 now = SDL_GetTicks();
279 seconds = (float)(now - then) / 1000.0f;
280 if ( seconds > 0.0f ) {
281 printf("%d alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
282 } else {
283 printf("%d alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
284 }
285 }
286
287 /* clear the screen after alpha blit test */
288 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
289 SDL_Flip(screen);
290
291 while ( SDL_PollEvent(&event) ) {
292 if ( event.type == SDL_KEYDOWN )
293 return 0;
294 }
295
296 /* run the cc+alpha blit test only if screen bpp>8 */
297 if (bmp->format->BitsPerPixel>8)
298 {
299 SDL_FreeSurface(bmpcc);
300 bmpcc = SDL_LoadBMP("sample.bmp");
301 SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */
302 SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels);
303 tmp = bmpcc;
304 bmpcc = SDL_DisplayFormat(bmpcc);
305 SDL_FreeSurface(tmp);
306 if ( ! bmpcc ) {
307 printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
308 return 0;
309 }
310 printf("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ",
311 bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
312 PrintFlags(bmpcc->flags);
313 printf("\n");
314 then = SDL_GetTicks();
315 frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
316 now = SDL_GetTicks();
317 seconds = (float)(now - then) / 1000.0f;
318 if ( seconds > 0.0f ) {
319 printf("%d cc+alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
320 } else {
321 printf("%d cc+alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
322 }
209 } 323 }
210 324
211 SDL_FreeSurface(bmpcc); 325 SDL_FreeSurface(bmpcc);
212 SDL_FreeSurface(bmp); 326 SDL_FreeSurface(bmp);
213 327