projects
/
dosdemo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- added blur in gfxutil
[dosdemo]
/
src
/
sdl
/
main.c
diff --git
a/src/sdl/main.c
b/src/sdl/main.c
index
05744e8
..
c00bf7d
100644
(file)
--- a/
src/sdl/main.c
+++ b/
src/sdl/main.c
@@
-4,12
+4,13
@@
#include <SDL/SDL.h>
#include "demo.h"
#include "tinyfps.h"
#include <SDL/SDL.h>
#include "demo.h"
#include "tinyfps.h"
+#include "timer.h"
+#include "cfgopt.h"
static void handle_event(SDL_Event *ev);
static void toggle_fullscreen(void);
static int quit;
static void handle_event(SDL_Event *ev);
static void toggle_fullscreen(void);
static int quit;
-static long start_time;
static SDL_Surface *fbsurf;
static int fbscale = 2;
static SDL_Surface *fbsurf;
static int fbscale = 2;
@@
-30,7
+31,8
@@
int main(int argc, char **argv)
xsz = fb_width * fbscale;
ysz = fb_height * fbscale;
xsz = fb_width * fbscale;
ysz = fb_height * fbscale;
- if(!(fb_pixels = malloc(fb_width * fb_height * fb_bpp / CHAR_BIT))) {
+ /* allocate 1 extra row as a guard band, until we fucking fix the rasterizer */
+ if(!(fb_pixels = malloc(fb_width * (fb_height + 1) * fb_bpp / CHAR_BIT))) {
fprintf(stderr, "failed to allocate virtual framebuffer\n");
return 1;
}
fprintf(stderr, "failed to allocate virtual framebuffer\n");
return 1;
}
@@
-51,7
+53,7
@@
int main(int argc, char **argv)
SDL_Quit();
return 1;
}
SDL_Quit();
return 1;
}
- start_time = SDL_GetTicks();
+ reset_timer();
while(!quit) {
SDL_Event ev;
while(!quit) {
SDL_Event ev;
@@
-60,7
+62,7
@@
int main(int argc, char **argv)
if(quit) goto break_evloop;
}
if(quit) goto break_evloop;
}
- time_msec = SDL_GetTicks() - start_time;
+ time_msec = get_msec();
demo_draw();
drawFps(fb_pixels);
demo_draw();
drawFps(fb_pixels);
@@
-102,9
+104,19
@@
void demo_quit(void)
quit = 1;
}
quit = 1;
}
+void wait_vsync(void)
+{
+ unsigned long start = SDL_GetTicks();
+ unsigned long until = (start | 0xf) + 1;
+ while(SDL_GetTicks() <= until);
+}
+
void swap_buffers(void *pixels)
{
/* do nothing, all pointers point to the same buffer */
void swap_buffers(void *pixels)
{
/* do nothing, all pointers point to the same buffer */
+ if(opt.vsync) {
+ wait_vsync();
+ }
}
static void handle_event(SDL_Event *ev)
}
static void handle_event(SDL_Event *ev)