Mercurial > hg > dmlib
annotate vptest.c @ 300:4972ca91d062
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 11 Oct 2012 17:55:15 +0300 |
parents | f07ddc4982c6 |
children | a759a52d4829 |
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_MakePalette(SDL_Surface *scr) | |
94 { | |
95 SDL_Color pal[DM_COLORS]; | |
96 int n; | |
97 | |
98 for (n = 0; n < 256; n++) | |
99 { | |
100 pal[n].r = n; | |
101 pal[n].g = n; | |
102 pal[n].b = n; | |
103 } | |
104 | |
105 SDL_SetColors(scr, pal, 0, DM_COLORS); | |
106 } | |
107 | |
108 | |
109 void DM_PrintRect(FILE *f, SDL_Rect *r) | |
110 { | |
111 fprintf(f, "SDL_Rect <%d, %d : %d, %d>\n", | |
112 r->x, r->y, r->w, r->h); | |
113 } | |
114 | |
115 BOOL DM_InitializeVideo(SDL_Surface **screen) | |
116 { | |
117 *screen = SDL_SetVideoMode(optScrWidth, optScrHeight, optScrDepth, optVFlags | SDL_RESIZABLE); | |
118 if (*screen == NULL) | |
119 { | |
120 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError()); | |
121 return FALSE; | |
122 } | |
123 return TRUE; | |
124 } | |
125 | |
126 | |
247 | 127 #define DM_RADIAL_BLUR(YC, XC) \ |
128 DMVector p1 = { xc, yc, 0, 0 }, p2 = { cx, cy, 0, 0 }, v; \ | |
129 dm_vector_sub_r(&v, &p2, &p1); \ | |
130 dm_vector_scale(&v, scale); \ | |
131 dm_vector_add(&v, &p1); \ | |
132 if (v.y YC || v.x XC) continue; \ | |
133 DMRGBA32 *dp = pix + xc, \ | |
134 *q = ((DMRGBA32 *)img->pixels) + ((int)(v.y) * pitch) + (int)v.x; \ | |
135 dp->r = (q->r + dp->r) / 2; \ | |
136 dp->g = (q->g + dp->g) / 2; \ | |
137 dp->b = (q->b + dp->b) / 2; | |
138 | |
139 /* | |
140 asm("movq %2, %%xmm1\n" \ | |
141 "movq %1, %%xmm2\n" \ | |
142 "paddusb %%xmm2, %%xmm1\n" \ | |
143 "movq %%xmm1, %0\n" \ | |
144 : "=m" (*c) \ | |
145 : "m" (*c), "m" (*px) \ | |
146 : "memory", "%xmm1", "%xmm2"); | |
147 */ | |
148 | |
149 const Uint64 qpmask[2] = { 0xffffffff, 0 }; | |
150 const Uint64 *qmask = qpmask; | |
151 | |
152 | |
153 void dmRadialBlur(SDL_Surface *img, int cx, int cy, DMFloat scale) | |
154 { | |
155 int pitch = img->pitch / sizeof(DMRGBA32); | |
156 int xc, yc; | |
157 | |
158 for (yc = cy; yc >= 0; yc--) | |
159 { | |
160 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
161 for (xc = cx + 1; xc < img->w; xc++) | |
162 { | |
163 DM_RADIAL_BLUR(< 0, >= img->w) | |
164 } | |
165 } | |
166 | |
167 for (yc = cy; yc >= 0; yc--) | |
168 { | |
169 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
170 for (xc = cx; xc > 0; xc--) | |
171 { | |
172 DM_RADIAL_BLUR(< 0, < 0) | |
173 } | |
174 } | |
175 | |
176 for (yc = cy + 1; yc < img->h; yc++) | |
177 { | |
178 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
179 for (xc = cx; xc > 0; xc--) | |
180 { | |
181 DM_RADIAL_BLUR(>= img->h, < 0) | |
182 } | |
183 } | |
184 | |
185 for (yc = cy + 1; yc < img->h; yc++) | |
186 { | |
187 DMRGBA32 *pix = ((DMRGBA32 *)img->pixels) + yc * pitch; | |
188 for (xc = cx + 1; xc < img->w; xc++) | |
189 { | |
190 DM_RADIAL_BLUR(>= img->h, >= img->w) | |
191 } | |
192 } | |
193 } | |
194 | |
195 | |
196 | |
0 | 197 int main(int argc, char *argv[]) |
198 { | |
248 | 199 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
|
200 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
|
201 SDL_Event event; |
0 | 202 TTF_Font *font = NULL; |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
203 int mouseX, mouseY, bx, by, err; |
0 | 204 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag; |
268 | 205 DM3DVectorSpriteModel *model, *model2; |
0 | 206 |
207 dmVerbosity = 5; | |
208 if (!dmArgsProcess(argc, argv, optList, optListN, | |
209 argHandleOpt, NULL, FALSE)) | |
210 exit(1); | |
211 | |
212 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) | |
213 { | |
214 dmError("Could not initialize SDL: %s\n", SDL_GetError()); | |
215 goto error_exit; | |
216 } | |
217 initSDL = TRUE; | |
218 | |
219 | |
220 if (TTF_Init() < 0) | |
221 { | |
222 dmError("Could not initialize FreeType/TTF: %s\n", SDL_GetError()); | |
223 goto error_exit; | |
224 } | |
225 initTTF = TRUE; | |
226 | |
227 font = TTF_OpenFont(optFontFile, optFontSize); | |
228 if (font == NULL) | |
229 { | |
230 dmError("Could not load TTF font '%s' (%d): %s\n", | |
231 optFontFile, optFontSize, SDL_GetError()); | |
232 goto error_exit; | |
233 } | |
234 TTF_SetFontStyle(font, TTF_STYLE_NORMAL); | |
235 | |
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
|
236 DMResource *res = dmf_create_stdio(optBitmapFilename, "rb"); |
0 | 237 if (res == NULL) |
238 { | |
239 dmError("Could not open resource file '%s'.\n", optBitmapFilename); | |
240 goto error_exit; | |
241 } | |
242 bmap = dmLoadImage(res); | |
243 dmf_close(res); | |
244 if (bmap == NULL) | |
245 { | |
246 dmError("Could not load image file '%s'.\n", optBitmapFilename); | |
247 goto error_exit; | |
248 } | |
238
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("trans6x6.png", "rb"); |
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 } |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
256 fbmap = dmLoadImage(res); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
257 dmf_close(res); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
258 if (fbmap == NULL) |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
259 { |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
260 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
|
261 goto error_exit; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
262 } |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
263 |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
264 |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
265 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
|
266 if (res == NULL) |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
267 { |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
268 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
|
269 goto error_exit; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
270 } |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
271 err = dmRead3DVectorSpriteModel(res, &model); |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
272 dmf_close(res); |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
273 dmMsg(0, "Loaded, %d: %s\n", err, dmErrorStr(err)); |
268 | 274 |
275 res = dmf_create_stdio("roto.3d", "r"); | |
276 if (res == NULL) | |
277 { | |
278 dmError("Could not open resource file '%s'.\n", optBitmapFilename); | |
279 goto error_exit; | |
280 } | |
281 err = dmRead3DVectorSpriteModel(res, &model2); | |
282 dmf_close(res); | |
283 dmMsg(0, "Loaded, %d: %s\n", err, dmErrorStr(err)); | |
0 | 284 |
285 if (optBenchmark) | |
286 { | |
287 screen = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); | |
288 if (screen == NULL) | |
289 { | |
290 dmError("Could not create screen surface.\n"); | |
291 goto error_exit; | |
292 } | |
293 | |
294 dmMsg(0, "Benchmark mode, not opening window.\n"); | |
295 } | |
296 else | |
297 { | |
298 if (!DM_InitializeVideo(&screen)) | |
299 goto error_exit; | |
300 | |
301 SDL_WM_SetCaption("Halleluja", "DMT"); | |
302 } | |
303 | |
248 | 304 screen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); |
23 | 305 Uint32 lcol = dmMapRGB(screen, 255,255,255); |
306 | |
0 | 307 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0; |
308 exitFlag = FALSE; | |
309 | |
310 if (optBenchmark) | |
311 dmMsg(0, "Starting benchmark, running for %d seconds.\n", optBenchmarkLen); | |
312 | |
313 while (!exitFlag) | |
314 { | |
315 if (!optBenchmark) | |
316 { | |
317 while (SDL_PollEvent(&event)) | |
318 switch (event.type) | |
319 { | |
320 case SDL_KEYDOWN: | |
321 switch (event.key.keysym.sym) | |
322 { | |
323 case SDLK_ESCAPE: exitFlag = TRUE; break; | |
324 | |
325 default: | |
326 break; | |
327 } | |
328 | |
329 break; | |
330 | |
331 case SDL_VIDEORESIZE: | |
332 optScrWidth = event.resize.w; | |
333 optScrHeight = event.resize.h; | |
334 | |
335 if (!DM_InitializeVideo(&screen)) | |
336 goto error_exit; | |
337 | |
338 break; | |
339 | |
340 case SDL_VIDEOEXPOSE: | |
341 break; | |
342 | |
343 case SDL_QUIT: | |
344 exit(0); | |
345 } | |
346 | |
347 SDL_GetMouseState(&mouseX, &mouseY); | |
348 bx = 300 - ((DMFloat) mouseX * 500.0f ) / (DMFloat) optScrWidth; | |
349 by = 300 - ((DMFloat) mouseY * 500.0f ) / (DMFloat) optScrHeight; | |
350 } | |
11 | 351 else |
352 { | |
353 bx = 0; | |
354 by = 0; | |
355 } | |
0 | 356 |
357 if (!optBenchmark && SDL_MUSTLOCK(screen) != 0 && SDL_LockSurface(screen) != 0) | |
358 { | |
359 dmError("Can't lock surface.\n"); | |
360 goto error_exit; | |
361 } | |
362 | |
363 | |
364 dmClearSurface(screen, 0); | |
365 | |
11 | 366 float f = SDL_GetTicks() / 150.0f, |
0 | 367 qw2 = (float) 132.0 * (1.0 + sin(f) * 0.1), |
368 qh2 = (float) 132.0 * (1.0 + sin(f) * 0.1); | |
369 | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
370 #if 1 |
0 | 371 dmScaledBlitSurfaceAny(bmap, bx-qw2, by-qh2, bmap->w+qw2, bmap->h+qh2, screen, |
248 | 372 DMD_TRANSPARENT |
373 // DMD_SATURATE | |
0 | 374 // DMD_NONE |
375 ); | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
376 #endif |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
377 #if 0 |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
378 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
|
379 qh = (float) 32.0 * (1.0 + sin(f) * 0.1), |
20 | 380 dmScaledBlitSurface32to32TransparentGA(bmap, bx*2-qw, by*2-qh, bmap->w+qw, bmap->h+qh, screen, |
381 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
|
382 #endif |
0 | 383 |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
384 #if 1 |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
385 DMVector pos; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
386 |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
387 DMMatrix mat; |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
388 // dm_matrix_rot_a(&mat, f*0.1, 0, (3.1415926535f * 2.0f * ((DMFloat) mouseX + (DMFloat) mouseY) ) / 500.0f); |
257 | 389 // dm_matrix_rot_a(&mat, f*0.1, f*0.1, f*0.1); |
390 dm_matrix_rot_a(&mat, 0, 0, f*0.1); | |
268 | 391 |
392 pos.x = -118; | |
393 pos.y = 0; | |
394 pos.z = 100; | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
395 |
268 | 396 dmDraw3DVectorSpriteModel(screen, model2, &pos, &mat, fbmap, lcol); |
397 | |
398 pos.x = 118; | |
399 pos.y = 0; | |
400 pos.z = 100; | |
401 | |
402 dm_matrix_rot_a(&mat, 0, 0, -f*0.1+0.125); | |
403 dmDraw3DVectorSpriteModel(screen, model2, &pos, &mat, fbmap, lcol); | |
404 | |
405 | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
406 #endif |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
407 |
248 | 408 #if 0 |
409 int np; | |
410 dmClearSurface(screen2, 0); | |
257 | 411 for (np = 1; np <= 5; np++) |
248 | 412 { |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
413 float n = ((float) np - 0.5f) * np; |
248 | 414 dmScaledBlitSurface32to32TransparentGA(screen, -n, -n, screen->w + n*2.0f, screen->h + n*2.0f, screen2, |
257 | 415 210 - np * 10 |
248 | 416 ); |
417 dmDirectBlitSurface(screen2, screen); | |
418 } | |
419 | |
257 | 420 // dmRadialBlur(screen, 320, 240, 0.010); |
421 // dmRadialBlur(screen, 325, 245, 0.016); | |
422 | |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
423 dmDraw3DVectorSpriteModel(screen, model, &pos, &mat, fbmap, lcol); |
248 | 424 |
257 | 425 for (np = 1; np <= 5; np++) |
426 { | |
261
eb77496ab7b3
More work on the rendering test.
Matti Hamalainen <ccr@tnsp.org>
parents:
257
diff
changeset
|
427 float n = ((float) np - 0.5f) / 2.0f; |
257 | 428 dmScaledBlitSurface32to32TransparentGA(screen, -n, -n, screen->w + n*2.0f, screen->h + n*2.0f, screen2, |
429 210 - np * 10 | |
430 ); | |
431 dmDirectBlitSurface(screen2, screen); | |
432 } | |
433 | |
434 // dmRadialBlur(screen, 320, 240, 0.010); | |
435 // dmRadialBlur(screen, 325, 245, 0.016); | |
248 | 436 #endif |
23 | 437 |
0 | 438 if (!optBenchmark) |
439 { | |
440 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS", | |
441 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); | |
442 | |
443 if (SDL_MUSTLOCK(screen) != 0) | |
444 SDL_UnlockSurface(screen); | |
445 | |
446 SDL_Flip(screen); | |
447 SDL_Delay(25); | |
448 } | |
449 | |
450 endTime = SDL_GetTicks(); | |
451 numFrames++; | |
452 | |
453 if (optBenchmark) | |
454 { | |
455 if (endTime - startTime > optBenchmarkLen * 1000) | |
456 exitFlag = TRUE; | |
457 } | |
458 } | |
459 | |
460 // Print benchmark results | |
461 dmMsg(0, "%d frames in %d ms, fps = %1.3f\n", | |
462 numFrames, endTime - startTime, | |
463 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); | |
464 | |
465 | |
466 error_exit: | |
467 dmMsg(0, "Shutting down dmlib.\n"); | |
468 if (screen) | |
469 SDL_FreeSurface(screen); | |
470 | |
471 if (bmap) | |
472 SDL_FreeSurface(bmap); | |
473 | |
474 if (font) | |
475 TTF_CloseFont(font); | |
476 | |
477 if (initSDL) | |
478 SDL_Quit(); | |
479 | |
480 if (initTTF) | |
481 TTF_Quit(); | |
482 | |
483 return 0; | |
484 } |