# HG changeset patch # User nenolod # Date 1163952762 28800 # Node ID a1be19f8de1f0e6ee4fce6557b0f7b42fc036ca1 # Parent 89e1003e5e84fddafb2842b8b1c077521bcd5ae7 [svn] - calculate FPS for frame limiter - avoid math overflows when drawing lines diff -r 89e1003e5e84 -r a1be19f8de1f ChangeLog --- 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 + 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 revision [560] - make sure the alphachannel is always full diff -r 89e1003e5e84 -r a1be19f8de1f src/paranormal/drawing.c --- 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; } diff -r 89e1003e5e84 -r a1be19f8de1f src/paranormal/plugin.c --- 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