Mercurial > hg > dmlib
annotate 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 |
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; |
203 int mouseX, mouseY, bx, by; | |
204 BOOL initSDL = FALSE, initTTF = FALSE, exitFlag; | |
245 | 205 DM3DLineSpriteModel *model; |
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 } |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
271 dmRead3DLineSpriteModel(res, &model); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
272 dmf_close(res); |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
273 |
0 | 274 |
275 if (optBenchmark) | |
276 { | |
277 screen = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); | |
278 if (screen == NULL) | |
279 { | |
280 dmError("Could not create screen surface.\n"); | |
281 goto error_exit; | |
282 } | |
283 | |
284 dmMsg(0, "Benchmark mode, not opening window.\n"); | |
285 } | |
286 else | |
287 { | |
288 if (!DM_InitializeVideo(&screen)) | |
289 goto error_exit; | |
290 | |
291 SDL_WM_SetCaption("Halleluja", "DMT"); | |
292 } | |
293 | |
248 | 294 screen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, optScrWidth, optScrHeight, optScrDepth, 0, 0, 0, 0); |
23 | 295 Uint32 lcol = dmMapRGB(screen, 255,255,255); |
296 | |
0 | 297 int numFrames = 0, startTime = SDL_GetTicks(), endTime = 0; |
298 exitFlag = FALSE; | |
299 | |
300 if (optBenchmark) | |
301 dmMsg(0, "Starting benchmark, running for %d seconds.\n", optBenchmarkLen); | |
302 | |
303 while (!exitFlag) | |
304 { | |
305 if (!optBenchmark) | |
306 { | |
307 while (SDL_PollEvent(&event)) | |
308 switch (event.type) | |
309 { | |
310 case SDL_KEYDOWN: | |
311 switch (event.key.keysym.sym) | |
312 { | |
313 case SDLK_ESCAPE: exitFlag = TRUE; break; | |
314 | |
315 default: | |
316 break; | |
317 } | |
318 | |
319 break; | |
320 | |
321 case SDL_VIDEORESIZE: | |
322 optScrWidth = event.resize.w; | |
323 optScrHeight = event.resize.h; | |
324 | |
325 if (!DM_InitializeVideo(&screen)) | |
326 goto error_exit; | |
327 | |
328 break; | |
329 | |
330 case SDL_VIDEOEXPOSE: | |
331 break; | |
332 | |
333 case SDL_QUIT: | |
334 exit(0); | |
335 } | |
336 | |
337 SDL_GetMouseState(&mouseX, &mouseY); | |
338 bx = 300 - ((DMFloat) mouseX * 500.0f ) / (DMFloat) optScrWidth; | |
339 by = 300 - ((DMFloat) mouseY * 500.0f ) / (DMFloat) optScrHeight; | |
340 } | |
11 | 341 else |
342 { | |
343 bx = 0; | |
344 by = 0; | |
345 } | |
0 | 346 |
347 if (!optBenchmark && SDL_MUSTLOCK(screen) != 0 && SDL_LockSurface(screen) != 0) | |
348 { | |
349 dmError("Can't lock surface.\n"); | |
350 goto error_exit; | |
351 } | |
352 | |
353 | |
354 dmClearSurface(screen, 0); | |
355 | |
11 | 356 float f = SDL_GetTicks() / 150.0f, |
0 | 357 qw2 = (float) 132.0 * (1.0 + sin(f) * 0.1), |
358 qh2 = (float) 132.0 * (1.0 + sin(f) * 0.1); | |
359 | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
360 #if 1 |
0 | 361 dmScaledBlitSurfaceAny(bmap, bx-qw2, by-qh2, bmap->w+qw2, bmap->h+qh2, screen, |
248 | 362 DMD_TRANSPARENT |
363 // DMD_SATURATE | |
0 | 364 // DMD_NONE |
365 ); | |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
366 #endif |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
367 #if 0 |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
368 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
|
369 qh = (float) 32.0 * (1.0 + sin(f) * 0.1), |
20 | 370 dmScaledBlitSurface32to32TransparentGA(bmap, bx*2-qw, by*2-qh, bmap->w+qw, bmap->h+qh, screen, |
371 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
|
372 #endif |
0 | 373 |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
374 #if 1 |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
375 DMVector pos; |
245 | 376 pos.x = -100; |
377 pos.y = -100; | |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
378 pos.z = 0; |
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
379 |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
380 DMMatrix mat; |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
381 // dm_matrix_rot_a(&mat, f*0.1, 0, (3.1415926535f * 2.0f * ((DMFloat) mouseX + (DMFloat) mouseY) ) / 500.0f); |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
382 dm_matrix_rot_a(&mat, 0, 0, f*0.1); |
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
383 |
245 | 384 dmDraw3DLineSpriteModel(screen, model, &pos, &mat, fbmap, lcol); |
241
3bff024a91be
Move 3D line/sprite renderer to separate module.
Matti Hamalainen <ccr@tnsp.org>
parents:
240
diff
changeset
|
385 #endif |
238
9643c517967d
Beginnings of a lines + sprites "3D" "model" renderer.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
386 |
248 | 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 | |
23 | 404 |
0 | 405 if (!optBenchmark) |
406 { | |
407 dmDrawTTFText(screen, font, fontcol, 0, 0, "%3.1f FPS", | |
408 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); | |
409 | |
410 if (SDL_MUSTLOCK(screen) != 0) | |
411 SDL_UnlockSurface(screen); | |
412 | |
413 SDL_Flip(screen); | |
414 SDL_Delay(25); | |
415 } | |
416 | |
417 endTime = SDL_GetTicks(); | |
418 numFrames++; | |
419 | |
420 if (optBenchmark) | |
421 { | |
422 if (endTime - startTime > optBenchmarkLen * 1000) | |
423 exitFlag = TRUE; | |
424 } | |
425 } | |
426 | |
427 // Print benchmark results | |
428 dmMsg(0, "%d frames in %d ms, fps = %1.3f\n", | |
429 numFrames, endTime - startTime, | |
430 (float) (numFrames * 1000.0f) / (float) (endTime - startTime)); | |
431 | |
432 | |
433 error_exit: | |
434 dmMsg(0, "Shutting down dmlib.\n"); | |
435 if (screen) | |
436 SDL_FreeSurface(screen); | |
437 | |
438 if (bmap) | |
439 SDL_FreeSurface(bmap); | |
440 | |
441 if (font) | |
442 TTF_CloseFont(font); | |
443 | |
444 if (initSDL) | |
445 SDL_Quit(); | |
446 | |
447 if (initTTF) | |
448 TTF_Quit(); | |
449 | |
450 return 0; | |
451 } |