1 /**
2 * Benchmark to check new SDL_gfx resize algorithms
3
4 * Copyright (C) 2008 Sylvain Beucler
5
6 * This file is part of GNU FreeDink
7
8 * GNU FreeDink is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 3 of the
11 * License, or (at your option) any later version.
12
13 * GNU FreeDink is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23 #include <stdio.h>
24 #include "SDL.h"
25 #include "SDL_rotozoom.h"
26
main(void)27 int main(void)
28 {
29 SDL_Init(SDL_INIT_VIDEO);
30 SDL_Surface *screen = SDL_SetVideoMode(640, 480, 16, SDL_NOFRAME);
31 SDL_Surface *trick2 = SDL_DisplayFormat(screen);
32
33 SDL_Surface *pic = SDL_LoadBMP("pic.bmp");
34 if (pic == NULL)
35 {
36 fprintf(stderr, "Failed to load image: %s\n", SDL_GetError());
37 exit(1);
38 }
39
40 int resize_lasttick = SDL_GetTicks();
41 double resize_brightness = 256;
42
43 int fps = 0;
44 int fps_lasttick = SDL_GetTicks();
45
46 int pos_x = 0;
47 int pos_y = 0;
48
49
50 int quit = 0;
51 while (!quit)
52 {
53 SDL_Event event;
54 SDL_PollEvent(&event);
55 {
56 switch(event.type)
57 {
58 case SDL_KEYDOWN:
59 switch (event.key.keysym.sym)
60 {
61 case 'q':
62 case SDLK_ESCAPE:
63 quit = 1;
64 break;
65 case 'f':
66 SDL_WM_ToggleFullScreen(screen);
67 break;
68 default:
69 break;
70 }
71 break;
72
73 case SDL_QUIT:
74 quit = 1;
75 break;
76 }
77 }
78
79
80
81 int delta = SDL_GetTicks() - resize_lasttick;
82 resize_lasttick = SDL_GetTicks();
83 //double incr = delta * 256 / 1000.0;
84
85 //SDL_Flip(screen);
86 SDL_Surface *scaled = zoomSurface(pic, 3, 3, SMOOTHING_OFF);
87 SDL_FreeSurface(scaled);
88
89 fps++;
90 if ((SDL_GetTicks() - fps_lasttick) > 1000)
91 {
92 printf("FPS: %d\n", fps);
93 fps_lasttick = SDL_GetTicks();
94 fps = 0;
95 }
96 }
97
98 SDL_Quit();
99 return 1;
100 }
101
102 /**
103 * Local Variables:
104 * compile-command: "gcc -O0 sdlgfx_resize.c -o sdlgfx_resize `sdl-config --cflags --libs` -lSDL_gfx"
105 * End:
106 */
107