Mercurial > hg > dmlib
annotate vptest.c @ 313:a89500f26dde
Cleanup the pattern decoder a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 12 Oct 2012 13:45:33 +0300 |
parents | a759a52d4829 |
children | a4a6082a9055 |
rev | line source |
---|---|
0 | 1 #include "dmlib.h" |
2 #include "dmargs.h" | |
3 #include "dmres.h" | |
4 #include "dmimage.h" | |
62
daeb5d4f6bad
Do include "dmtext.h" where necessary.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
5 #include "dmtext.h" |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
6 #include "dmq3d.h" |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
7 #include "dmvecmat.h" |
0 | 8 #include <math.h> |
9 | |
10 #define DM_COLORS (256) | |
11 | |
12 char *optFontFile = "font.ttf", | |
248 | 13 *optBitmapFilename = "blurri.png"; |
0 | 14 BOOL optBenchmark = FALSE; |
15 int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; | |
16 int optScrWidth = 640, optScrHeight = 480, optFontSize = 20, optScrDepth = 32; | |
17 int optBenchmarkLen = 20; | |
18 | |
19 DMOptArg optList[] = { | |
20 { 0, '?', "help", "Show this help", OPT_NONE }, | |
21 { 2, 'v', "verbose", "Be more verbose", OPT_NONE }, | |
22 { 3, 'f', "full", "Fullscreen", OPT_NONE }, | |
23 { 4, 'h', "hw", "Use SDL hardware surface", OPT_NONE }, | |
24 { 5, 's', "size", "Initial window size/resolution -s 640x480", OPT_ARGREQ }, | |
25 { 6, 'd', "depth", "Color depth of mode/window in bits (8/15/16/32)", OPT_ARGREQ }, | |
26 { 7, 'b', "bench", "Run in benchmark mode", OPT_NONE }, | |
27 }; | |
28 | |
29 const int optListN = sizeof(optList) / sizeof(optList[0]); | |
30 | |
31 | |
32 void argShowHelp() | |
33 { | |
34 dmArgsPrintHelp(stdout, optList, optListN); | |
35 } | |
36 | |
37 | |
38 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | |
39 { | |
40 switch (optN) { | |
41 case 0: | |
42 argShowHelp(); | |
43 exit(0); | |
44 break; | |
45 | |
46 case 2: | |
47 dmVerbosity++; | |
48 break; | |
49 | |
50 case 3: | |
51 optVFlags |= SDL_FULLSCREEN; | |
52 break; | |
53 | |
54 case 6: | |
55 if (optArg) | |
56 optScrDepth = atoi(optArg); | |
57 break; | |
58 | |
59 case 5: | |
60 { | |
61 int w, h; | |
62 if (sscanf(optArg, "%dx%d", &w, &h) == 2) | |
63 { | |
64 if (w < 320 || h < 200 || w > 3200 || h > 3200) | |
65 { | |
66 dmError("Invalid width or height: %d x %d\n", w, h); | |
67 return FALSE; | |
68 } | |
69 optScrWidth = w; | |
70 optScrHeight = h; | |
71 } | |
72 else | |
73 { | |
74 dmError("Invalid size argument '%s'.\n", optArg); | |
75 return FALSE; | |
76 } | |
77 } | |
78 break; | |
79 | |
80 case 7: | |
81 optBenchmark = TRUE; | |
82 break; | |
83 | |
84 default: | |
85 dmError("Unknown option '%s'.\n", currArg); | |
86 return FALSE; | |
87 } | |
88 | |
89 return TRUE; | |
90 } | |
91 | |
92 | |
93 void DM_PrintRect(FILE *f, SDL_Rect *r) | |
94 { | |
95 fprintf(f, "SDL_Rect <%d, %d : %d, %d>\n", | |
96 r->x, r->y, r->w, r->h); | |
97 } | |
98 | |
306 | 99 |
0 | 100 BOOL DM_InitializeVideo(SDL_Surface **screen) |
101 { | |
102 *screen = SDL_SetVideoMode(optScrWidth, optScrHeight, optScrDepth, optVFlags | SDL_RESIZABLE); | |
103 if (*screen == NULL) | |
104 { | |
105 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError()); | |
106 return FALSE; | |
107 } | |
108 return TRUE; | |
109 } | |
110 | |
111 | |
247 | 112 #define DM_RADIAL_BLUR(YC, XC) \ |
113 DMVector p1 = { xc, yc, 0, 0 }, p2 = { cx, cy, 0, 0 }, v; \ | |
114 dm_vector_sub_r(&v, &p2, &p1); \ | |
115 dm_vector_scale(&v, scale); \ | |
116 dm_vector_add(&v, &p1); \ | |
117 if (v.y YC || v.x XC) continue; \ | |
118 DMRGBA32 *dp = pix + xc, \ | |
119 *q = ((DMRGBA32 *)img->pixels) + ((int)(v.y) * pitch) + (int)v.x; \ | |
120 dp->r = (q->r + dp->r) / 2; \ | |
121 dp->g = (q->g + dp->g) / 2; \ | |
122 dp->b = (q->b + dp->b) / 2; | |
123 | |
124 /* | |
125 asm("movq %2, %%xmm1\n" \ | |
126 "movq %1, %%xmm2\n" \ | |
127 "paddusb %%xmm2, %%xmm1\n" \ | |
128 "movq %%xmm1, %0\n" \ | |
129 : "=m" (*c) \ | |
130 : "m" (*c), "m" (*px) \ | |
131 : "memory", "%xmm1", "%xmm2"); | |
132 */ | |
133 | |
134 const Uint64 qpmask[2] = { 0xffffffff, 0 }; | |
135 const Uint64 *qmask = qpmask; | |
136 | |
137 | |
138 void dmRadialBlur(SDL_Surface *img, int cx, int cy, DMFloat scale) | |
139 { | |
140 int pitch = img->pitch / sizeof(DMRGBA32); | |
141 int xc, yc; | |
142 | |
143 for (yc = cy; yc >= 0; yc--) | |
144 { | |
145 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
146 for (xc = cx + 1; xc < img->w; xc++) | |
147 { | |
148 DM_RADIAL_BLUR(< 0, >= img->w) | |
149 } | |
150 } | |
151 | |
152 for (yc = cy; yc >= 0; yc--) | |
153 { | |
154 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
155 for (xc = cx; xc > 0; xc--) | |
156 { | |
157 DM_RADIAL_BLUR(< 0, < 0) | |
158 } | |
159 } | |
160 | |
161 for (yc = cy + 1; yc < img->h; yc++) | |
162 { | |
163 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
164 for (xc = cx; xc > 0; xc--) | |
165 { | |
166 DM_RADIAL_BLUR(>= img->h, < 0) | |
167 } | |
168 } | |
169 | |
170 for (yc = cy + 1; yc < img->h; yc++) | |
171 { | |
172 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
173 for (xc = cx + 1; xc < img->w; xc++) | |
174 { | |
175 DM_RADIAL_BLUR(>= img->h, >= img->w) | |
176 } | |
177 } | |
178 } | |
179 | |
180 | |
181 | |
0 | 182 int main(int argc, char *argv[]) |
183 { | |
248 | 184 SDL_Surface *screen = NULL, *bmap = NULL, *fbmap = NULL, *screen2 = NULL; |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
185 SDL_Color fontcol = { 255, 155, 155, 0 }; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
186 SDL_Event event; |
0 | 187 TTF_Font *font = NULL; |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
188 int mouseX, mouseY, bx, by, err; |
0 | 189 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag; |
268 | 190 DM3DVectorSpriteModel *model, *model2; |
0 | 191 |
192 dmVerbosity = 5; | |
193 if (!dmArgsProcess(argc, argv, optList, optListN, | |
194 argHandleOpt, NULL, FALSE)) | |
195 exit(1); | |
196 | |
197 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) | |
198 { | |
199 dmError("Could not initialize SDL: %s\n", SDL_GetError()); | |
200 goto error_exit; | |
201 } | |
202 initSDL = TRUE; | |
203 | |
204 | |
205 if (TTF_Init() < 0) | |
206 { | |
207 dmError("Could not initialize FreeType/TTF: %s\n", SDL_GetError()); | |
208 goto error_exit; | |
209 } | |
210 initTTF = TRUE; | |
211 | |
212 font = TTF_OpenFont(optFontFile, optFontSize); | |
213 if (font == NULL) | |
214 { | |
215 dmError("Could not load TTF font '%s' (%d): %s\n", | |
216 optFontFile, optFontSize, SDL_GetError()); | |
217 goto error_exit; | |
218 } | |
219 TTF_SetFontStyle(font, TTF_STYLE_NORMAL); | |
220 | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
221 DMResource *res = dmf_create_stdio(optBitmapFilename, "rb"); |
0 | 222 if (res == NULL) |
223 { | |
224 dmError("Could not open resource file '%s'.\n", optBitmapFilename); | |
225 goto error_exit; | |
226 } | |
227 bmap = dmLoadImage(res); | |
228 dmf_close(res); | |
229 if (bmap == NULL) | |
230 { | |
231 dmError("Could not load image file '%s'.\n", optBitmapFilename); | |
232 goto error_exit; | |
233 } | |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
234 |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
235 res = dmf_create_stdio("trans6x6.png", "rb"); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
236 if (res == NULL) |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
237 { |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
238 dmError("Could not open resource file '%s'.\n", optBitmapFilename); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
239 goto error_exit; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
240 } |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
241 fbmap = dmLoadImage(res); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
242 dmf_close(res); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
243 if (fbmap == NULL) |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
244 { |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
245 dmError("Could not load image file '%s'.\n", optBitmapFilename); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
246 goto error_exit; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
247 } |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
248 |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
249 |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
250 res = dmf_create_stdio("mole.3d", "r"); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
251 if (res == NULL) |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
252 { |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
253 dmError("Could not open resource file '%s'.\n", optBitmapFilename); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
254 goto error_exit; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
255 } |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
256 err = dmRead3DVectorSpriteModel(res, &model); |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
257 dmf_close(res); |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
258 dmMsg(0, "Loaded, %d: %s\n", err, dmErrorStr(err)); |
268 | 259 |
260 res = dmf_create_stdio("roto.3d", "r"); | |
261 if (res == NULL) | |
262 { | |
263 dmError("Could not open resource file '%s'.\n", optBitmapFilename); | |
264 goto error_exit; | |
265 } | |
266 err = dmRead3DVectorSpriteModel(res, &model2); | |
267 dmf_close(res); | |
268 dmMsg(0, "Loaded, %d: %s\n", err, dmErrorStr(err)); | |
0 | 269 |
270 if (optBenchmark) | |
271 { | |
272 screen = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); | |
273 if (screen == NULL) | |
274 { | |
275 dmError("Could not create screen surface.\n"); | |
276 goto error_exit; | |
277 } | |
278 | |
279 dmMsg(0, "Benchmark mode, not opening window.\n"); | |
280 } | |
281 else | |
282 { | |
283 if (!DM_InitializeVideo(&screen)) | |
284 goto error_exit; | |
285 | |
286 SDL_WM_SetCaption("Halleluja", "DMT"); | |
287 } | |
288 | |
248 | 289 screen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); |
23 | 290 Uint32 lcol = dmMapRGB(screen, 255,255,255); |
291 | |
0 | 292 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0; |
293 exitFlag = FALSE; | |
294 | |
295 if (optBenchmark) | |
296 dmMsg(0, "Starting benchmark, running for %d seconds.\n", optBenchmarkLen); | |
297 | |
298 while (!exitFlag) | |
299 { | |
300 if (!optBenchmark) | |
301 { | |
302 while (SDL_PollEvent(&event)) | |
303 switch (event.type) | |
304 { | |
305 case SDL_KEYDOWN: | |
306 switch (event.key.keysym.sym) | |
307 { | |
308 case SDLK_ESCAPE: exitFlag = TRUE; break; | |
309 | |
310 default: | |
311 break; | |
312 } | |
313 | |
314 break; | |
315 | |
316 case SDL_VIDEORESIZE: | |
317 optScrWidth = event.resize.w; | |
318 optScrHeight = event.resize.h; | |
319 | |
320 if (!DM_InitializeVideo(&screen)) | |
321 goto error_exit; | |
322 | |
323 break; | |
324 | |
325 case SDL_VIDEOEXPOSE: | |
326 break; | |
327 | |
328 case SDL_QUIT: | |
329 exit(0); | |
330 } | |
331 | |
332 SDL_GetMouseState(&mouseX, &mouseY); | |
333 bx = 300 - ((DMFloat) mouseX * 500.0f ) / (DMFloat) optScrWidth; | |
334 by = 300 - ((DMFloat) mouseY * 500.0f ) / (DMFloat) optScrHeight; | |
335 } | |
11 | 336 else |
337 { | |
338 bx = 0; | |
339 by = 0; | |
340 } | |
0 | 341 |
342 if (!optBenchmark && SDL_MUSTLOCK(screen) != 0 && SDL_LockSurface(screen) != 0) | |
343 { | |
344 dmError("Can't lock surface.\n"); | |
345 goto error_exit; | |
346 } | |
347 | |
348 | |
349 dmClearSurface(screen, 0); | |
350 | |
11 | 351 float f = SDL_GetTicks() / 150.0f, |
0 | 352 qw2 = (float) 132.0 * (1.0 + sin(f) * 0.1), |
353 qh2 = (float) 132.0 * (1.0 + sin(f) * 0.1); | |
354 | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
355 #if 1 |
0 | 356 dmScaledBlitSurfaceAny(bmap, bx-qw2, by-qh2, bmap->w+qw2, bmap->h+qh2, screen, |
248 | 357 DMD_TRANSPARENT |
358 // DMD_SATURATE | |
0 | 359 // DMD_NONE |
360 ); | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
361 #endif |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
362 #if 0 |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
363 float qw = (float) 32.0 * (1.0 + sin(f) * 0.1), |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
364 qh = (float) 32.0 * (1.0 + sin(f) * 0.1), |
20 | 365 dmScaledBlitSurface32to32TransparentGA(bmap, bx*2-qw, by*2-qh, bmap->w+qw, bmap->h+qh, screen, |
366 128 + sin(f*0.1) * 120.0f); | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
367 #endif |
0 | 368 |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
369 #if 1 |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
370 DMVector pos; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
371 |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
372 DMMatrix mat; |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
373 // dm_matrix_rot_a(&mat, f*0.1, 0, (3.1415926535f * 2.0f * ((DMFloat) mouseX + (DMFloat) mouseY) ) / 500.0f); |
257 | 374 // dm_matrix_rot_a(&mat, f*0.1, f*0.1, f*0.1); |
375 dm_matrix_rot_a(&mat, 0, 0, f*0.1); | |
268 | 376 |
377 pos.x = -118; | |
378 pos.y = 0; | |
379 pos.z = 100; | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
380 |
268 | 381 dmDraw3DVectorSpriteModel(screen, model2, &pos, &mat, fbmap, lcol); |
382 | |
383 pos.x = 118; | |
384 pos.y = 0; | |
385 pos.z = 100; | |
386 | |
387 dm_matrix_rot_a(&mat, 0, 0, -f*0.1+0.125); | |
388 dmDraw3DVectorSpriteModel(screen, model2, &pos, &mat, fbmap, lcol); | |
389 | |
390 | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
391 #endif |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
392 |
248 | 393 #if 0 |
394 int np; | |
395 dmClearSurface(screen2, 0); | |
257 | 396 for (np = 1; np <= 5; np++) |
248 | 397 { |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
398 float n = ((float) np - 0.5f) * np; |
248 | 399 dmScaledBlitSurface32to32TransparentGA(screen, -n, -n, screen->w + n*2.0f, screen->h + n*2.0f, screen2, |
257 | 400 210 - np * 10 |
248 | 401 ); |
402 dmDirectBlitSurface(screen2, screen); | |
403 } | |
404 | |
257 | 405 // dmRadialBlur(screen, 320, 240, 0.010); |
406 // dmRadialBlur(screen, 325, 245, 0.016); | |
407 | |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
408 dmDraw3DVectorSpriteModel(screen, model, &pos, &mat, fbmap, lcol); |
248 | 409 |
257 | 410 for (np = 1; np <= 5; np++) |
411 { | |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
412 float n = ((float) np - 0.5f) / 2.0f; |
257 | 413 dmScaledBlitSurface32to32TransparentGA(screen, -n, -n, screen->w + n*2.0f, screen->h + n*2.0f, screen2, |
414 210 - np * 10 | |
415 ); | |
416 dmDirectBlitSurface(screen2, screen); | |
417 } | |
418 | |
419 // dmRadialBlur(screen, 320, 240, 0.010); | |
420 // dmRadialBlur(screen, 325, 245, 0.016); | |
248 | 421 #endif |
23 | 422 |
0 | 423 if (!optBenchmark) |
424 { | |
425 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS", | |
426 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); | |
427 | |
428 if (SDL_MUSTLOCK(screen) != 0) | |
429 SDL_UnlockSurface(screen); | |
430 | |
431 SDL_Flip(screen); | |
432 SDL_Delay(25); | |
433 } | |
434 | |
435 endTime = SDL_GetTicks(); | |
436 numFrames++; | |
437 | |
438 if (optBenchmark) | |
439 { | |
440 if (endTime - startTime > optBenchmarkLen * 1000) | |
441 exitFlag = TRUE; | |
442 } | |
443 } | |
444 | |
445 // Print benchmark results | |
446 dmMsg(0, "%d frames in %d ms, fps = %1.3f\n", | |
447 numFrames, endTime - startTime, | |
448 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); | |
449 | |
450 | |
451 error_exit: | |
452 dmMsg(0, "Shutting down dmlib.\n"); | |
453 if (screen) | |
454 SDL_FreeSurface(screen); | |
455 | |
456 if (bmap) | |
457 SDL_FreeSurface(bmap); | |
458 | |
459 if (font) | |
460 TTF_CloseFont(font); | |
461 | |
462 if (initSDL) | |
463 SDL_Quit(); | |
464 | |
465 if (initTTF) | |
466 TTF_Quit(); | |
467 | |
468 return 0; | |
469 } |