comparison blittest.c @ 58:76a7d469eab9

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 01 Oct 2012 07:09:37 +0300
parents 187f50f02f17
children daeb5d4f6bad
comparison
equal deleted inserted replaced
57:2edda27f951c 58:76a7d469eab9
15 { 0, '?', "help", "Show this help", OPT_NONE }, 15 { 0, '?', "help", "Show this help", OPT_NONE },
16 { 2, 'v', "verbose", "Be more verbose", OPT_NONE }, 16 { 2, 'v', "verbose", "Be more verbose", OPT_NONE },
17 { 3, 'f', "full", "Fullscreen", OPT_NONE }, 17 { 3, 'f', "full", "Fullscreen", OPT_NONE },
18 { 4, 'h', "hw", "Use SDL hardware surface", OPT_NONE }, 18 { 4, 'h', "hw", "Use SDL hardware surface", OPT_NONE },
19 { 5, 's', "size", "Initial window size/resolution -s 640x480", OPT_ARGREQ }, 19 { 5, 's', "size", "Initial window size/resolution -s 640x480", OPT_ARGREQ },
20 { 6, 'd', "depth", "Color depth of mode/window in bits (8/15/16/32)", OPT_ARGREQ }, 20 { 6, 'd', "depth", "Color depth of mode/window in bits (8/32)", OPT_ARGREQ },
21 { 7, 'b', "bench", "Run in benchmark mode", OPT_NONE }, 21 { 7, 'b', "bench", "Run in benchmark mode", OPT_NONE },
22 }; 22 };
23 23
24 const int optListN = sizeof(optList) / sizeof(optList[0]); 24 const int optListN = sizeof(optList) / sizeof(optList[0]);
25 25
298 int main(int argc, char *argv[]) 298 int main(int argc, char *argv[])
299 { 299 {
300 SDL_Surface *screen = NULL, *bmap = NULL; 300 SDL_Surface *screen = NULL, *bmap = NULL;
301 TTF_Font *font = NULL; 301 TTF_Font *font = NULL;
302 SDL_Color fontcol={255,155,155,0}; 302 SDL_Color fontcol={255,155,155,0};
303 Uint32 lcol;
304 SDL_Event event; 303 SDL_Event event;
305 int mouseX, mouseY; 304 int mouseX, mouseY;
306 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag, showMap = FALSE; 305 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag, showMap = FALSE;
307 306
308 dmInitProg("blittest", "dmlib blittest", "0.2", NULL, NULL); 307 dmInitProg("blittest", "dmlib blittest", "0.2", NULL, NULL);
364 light.x = light.y = 128; 363 light.x = light.y = 128;
365 light.z = 128; 364 light.z = 128;
366 dmMakeBumpMap(heightMap, 0.06, 254); 365 dmMakeBumpMap(heightMap, 0.06, 254);
367 366
368 367
369
370 lcol = dmMapRGB(screen, 255,100,100);
371 368
372 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0; 369 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0;
373 exitFlag = FALSE; 370 exitFlag = FALSE;
374 371
375 if (optBenchmark) 372 if (optBenchmark)
424 dmError("Can't lock surface.\n"); 421 dmError("Can't lock surface.\n");
425 goto error_exit; 422 goto error_exit;
426 } 423 }
427 424
428 425
429 float f = SDL_GetTicks() / 250.0f;
430
431 #if 1
432 if (showMap) 426 if (showMap)
433 memcpy(bmap->pixels, heightMap, QWIDTH * QHEIGHT); 427 memcpy(bmap->pixels, heightMap, QWIDTH * QHEIGHT);
434 else 428 else
435 dmShadowTraceHeightMap(bmap->pixels, heightMap, &light); 429 dmShadowTraceHeightMap(bmap->pixels, heightMap, &light);
436 430
437 dmScaledBlitSurfaceAny(bmap, 0, 0, screen->w, screen->h, screen, DMD_NONE); 431 dmScaledBlitSurfaceAny(bmap, 0, 0, screen->w, screen->h, screen, DMD_NONE);
438 #else
439 dmScaledBlitSurfaceAny(bmap,
440 100 + sin(f) * 50,
441 100 + cos(f) * 50,
442 screen->w - 200 + 50 * cos(f),
443 screen->h - 200 + 50 * sin(f),
444 screen, DMD_NONE);
445
446 dmScaledBlitSurfaceAny(bmap,
447 200 + sin(f) * 50,
448 200 + cos(f) * 50,
449 50 + 50 * cos(f),
450 50 + 50 * sin(f),
451 screen, DMD_NONE);
452
453 dmScaledBlitSurfaceAny(bmap,
454 400,
455 200,
456 50 + 50 * cos(f),
457 50 + 50 * sin(f),
458 screen, DMD_NONE);
459
460 /*
461 dmDrawLineAny(screen, 30, 30, 600 + 200 * sin(f), 250 , lcol, DMD_NONE);
462 dmDrawLineAny(screen, 20, 30, 100 , 250 + 100 * sin(f), lcol, DMD_NONE);
463 dmDrawLineAny(screen, 100, 100, 100 + cos(f) * 50, 100 + sin(f) * 50, lcol, DMD_NONE);
464 */
465 #endif
466 432
467 if (!optBenchmark) 433 if (!optBenchmark)
468 { 434 {
469 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS", 435 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS",
470 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); 436 (float) (numFrames * 1000.0f) / (float) (endTime - startTime));