Mercurial > audlegacy-plugins
changeset 268:a1be19f8de1f trunk
[svn] - calculate FPS for frame limiter
- avoid math overflows when drawing lines
author | nenolod |
---|---|
date | Sun, 19 Nov 2006 08:12:42 -0800 |
parents | 89e1003e5e84 |
children | 69f309c8bd71 |
files | ChangeLog src/paranormal/drawing.c src/paranormal/plugin.c |
diffstat | 3 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Nov 19 07:36:02 2006 -0800 +++ b/ChangeLog Sun Nov 19 08:12:42 2006 -0800 @@ -1,3 +1,10 @@ +2006-11-19 15:36:02 +0000 Tony Vroon <chainsaw@gentoo.org> + revision [562] + gtk_file_selection_get_filename wanted a const char, but was afraid to ask. + trunk/src/paranormal/cfg.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + + 2006-11-19 05:02:55 +0000 William Pitcock <nenolod@nenolod.net> revision [560] - make sure the alphachannel is always full
--- a/src/paranormal/drawing.c Sun Nov 19 07:36:02 2006 -0800 +++ b/src/paranormal/drawing.c Sun Nov 19 08:12:42 2006 -0800 @@ -28,7 +28,7 @@ while (x0 != x1) { x0 += dx; - y0 = round(m * x0 + b); + y0 = m * x0 + b; pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value; }
--- a/src/paranormal/plugin.c Sun Nov 19 07:36:02 2006 -0800 +++ b/src/paranormal/plugin.c Sun Nov 19 08:12:42 2006 -0800 @@ -126,6 +126,9 @@ static int draw_thread_fn (gpointer data) { + gfloat fps = 0.0; + guint last_time = 0, last_second = 0; + guint this_time; pn_init (); /* Used when pn_quit is called from this thread */ @@ -152,6 +155,17 @@ pn_render (); SDL_mutexV (config_mutex); + /* Compute the FPS */ + this_time = SDL_GetTicks (); + + fps = fps * .95 + (1000. / (gfloat) (this_time - last_time)) * .05; + if (this_time > 2000 + last_second) + { + last_second = this_time; + g_print ("FPS: %f\n", fps); + } + last_time = this_time; + #ifdef _POSIX_PRIORITY_SCHEDULING sched_yield(); #endif