comparison vptest.c @ 248:e6303e0c62cb

Radial blur stuff.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 09 Oct 2012 17:47:40 +0300
parents cfde1deedd62
children 4b4123143b9e
comparison
equal deleted inserted replaced
247:cfde1deedd62 248:e6303e0c62cb
8 #include <math.h> 8 #include <math.h>
9 9
10 #define DM_COLORS (256) 10 #define DM_COLORS (256)
11 11
12 char *optFontFile = "font.ttf", 12 char *optFontFile = "font.ttf",
13 *optBitmapFilename = "map.png"; 13 *optBitmapFilename = "blurri.png";
14 BOOL optBenchmark = FALSE; 14 BOOL optBenchmark = FALSE;
15 int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; 15 int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE;
16 int optScrWidth = 640, optScrHeight = 480, optFontSize = 20, optScrDepth = 32; 16 int optScrWidth = 640, optScrHeight = 480, optFontSize = 20, optScrDepth = 32;
17 int optBenchmarkLen = 20; 17 int optBenchmarkLen = 20;
18 18
194 194
195 195
196 196
197 int main(int argc, char *argv[]) 197 int main(int argc, char *argv[])
198 { 198 {
199 SDL_Surface *screen = NULL, *bmap = NULL, *fbmap = NULL; 199 SDL_Surface *screen = NULL, *bmap = NULL, *fbmap = NULL, *screen2 = NULL;
200 SDL_Color fontcol = { 255, 155, 155, 0 }; 200 SDL_Color fontcol = { 255, 155, 155, 0 };
201 SDL_Event event; 201 SDL_Event event;
202 TTF_Font *font = NULL; 202 TTF_Font *font = NULL;
203 int mouseX, mouseY, bx, by; 203 int mouseX, mouseY, bx, by;
204 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag; 204 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag;
289 goto error_exit; 289 goto error_exit;
290 290
291 SDL_WM_SetCaption("Halleluja", "DMT"); 291 SDL_WM_SetCaption("Halleluja", "DMT");
292 } 292 }
293 293
294 screen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0);
294 Uint32 lcol = dmMapRGB(screen, 255,255,255); 295 Uint32 lcol = dmMapRGB(screen, 255,255,255);
295 296
296 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0; 297 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0;
297 exitFlag = FALSE; 298 exitFlag = FALSE;
298 299
351 352
352 353
353 dmClearSurface(screen, 0); 354 dmClearSurface(screen, 0);
354 355
355 float f = SDL_GetTicks() / 150.0f, 356 float f = SDL_GetTicks() / 150.0f,
356 qw = (float) 32.0 * (1.0 + sin(f) * 0.1),
357 qh = (float) 32.0 * (1.0 + sin(f) * 0.1),
358 qw2 = (float) 132.0 * (1.0 + sin(f) * 0.1), 357 qw2 = (float) 132.0 * (1.0 + sin(f) * 0.1),
359 qh2 = (float) 132.0 * (1.0 + sin(f) * 0.1); 358 qh2 = (float) 132.0 * (1.0 + sin(f) * 0.1);
360 359
361 #if 1 360 #if 1
362 dmScaledBlitSurfaceAny(bmap, bx-qw2, by-qh2, bmap->w+qw2, bmap->h+qh2, screen, 361 dmScaledBlitSurfaceAny(bmap, bx-qw2, by-qh2, bmap->w+qw2, bmap->h+qh2, screen,
362 DMD_TRANSPARENT
363 // DMD_SATURATE
363 // DMD_NONE 364 // DMD_NONE
364 DMD_TRANSPARENT
365 ); 365 );
366 #endif 366 #endif
367 #if 0 367 #if 0
368 float qw = (float) 32.0 * (1.0 + sin(f) * 0.1), 368 float qw = (float) 32.0 * (1.0 + sin(f) * 0.1),
369 qh = (float) 32.0 * (1.0 + sin(f) * 0.1), 369 qh = (float) 32.0 * (1.0 + sin(f) * 0.1),
382 dm_matrix_rot_a(&mat, 0, 0, f*0.1); 382 dm_matrix_rot_a(&mat, 0, 0, f*0.1);
383 383
384 dmDraw3DLineSpriteModel(screen, model, &pos, &mat, fbmap, lcol); 384 dmDraw3DLineSpriteModel(screen, model, &pos, &mat, fbmap, lcol);
385 #endif 385 #endif
386 386
387 #if 0
388 int np;
389 dmClearSurface(screen2, 0);
390 for (np = 1; np <= 4; np++)
391 {
392 float n = ((np + 1) * (np + 1) * np) * 0.6;
393 dmScaledBlitSurface32to32TransparentGA(screen, -n, -n, screen->w + n*2.0f, screen->h + n*2.0f, screen2,
394 200 - np * 5
395 );
396 dmDirectBlitSurface(screen2, screen);
397 }
398
399 dmDraw3DLineSpriteModel(screen, &model, &pos, &mat, fbmap, lcol);
400
401 dmRadialBlur(screen, 320, 240, 0.010);
402 dmRadialBlur(screen, 325, 245, 0.016);
403 #endif
387 404
388 if (!optBenchmark) 405 if (!optBenchmark)
389 { 406 {
390 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS", 407 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS",
391 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); 408 (float) (numFrames * 1000.0f) / (float) (endTime - startTime));