changeset 54:25e69f085ad9 trunk

[svn] This commit does the following: - Changes out static timings for a dynamic implementation which works via actively detecting how long it takes to render a frame - Cleans up a few warnings.
author nenolod
date Thu, 27 Oct 2005 16:49:50 -0700
parents 710d8b266d7e
children c0a32c66e928
files Visualization/libvisual-proxy/main.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Visualization/libvisual-proxy/main.c	Thu Oct 27 12:54:05 2005 -0700
+++ b/Visualization/libvisual-proxy/main.c	Thu Oct 27 16:49:50 2005 -0700
@@ -434,7 +434,7 @@
 {
 	visual_running = 1;
 	visual_stopped = 0;
-        long render_time, now;
+        static long render_time, now;
         long frame_length;
         long idle_time;
 	long frames;
@@ -472,6 +472,8 @@
 			if (SDL_MUSTLOCK (screen) == SDL_TRUE)
 				SDL_UnlockSurface (screen);
 		}
+
+		render_time = SDL_GetTicks();
                        
 		if (gl_plug == 1) {
 			visual_bin_run (bin);
@@ -492,7 +494,11 @@
 			sdl_draw (screen);
 		}
 
-		usleep(10000);
+		now = SDL_GetTicks();
+		idle_time = now - render_time;
+
+		if (idle_time < frame_length)
+			usleep(frame_length);
 
 		sdl_event_handle ();