Search
lxdream.org :: lxdream/src/gui/gtkui.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/gtkui.c
changeset 437:2c259474b474
prev435:7a5d71e8560b
next447:3e095bfcb476
author nkeynes
date Thu Oct 11 08:22:03 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Add speed meter to main window
Add sunken border around video area
Add debugger menu item
Move logging out to util.c
file annotate diff log raw
1.1 --- a/src/gui/gtkui.c Wed Oct 10 11:02:04 2007 +0000
1.2 +++ b/src/gui/gtkui.c Thu Oct 11 08:22:03 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gtkui.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
1.6 + * $Id: gtkui.c,v 1.2 2007-10-11 08:22:03 nkeynes Exp $
1.7 *
1.8 * Core GTK-based user interface
1.9 *
1.10 @@ -16,6 +16,8 @@
1.11 * GNU General Public License for more details.
1.12 */
1.13
1.14 +#include <sys/time.h>
1.15 +#include <time.h>
1.16 #include "dream.h"
1.17 #include "dreamcast.h"
1.18 #include "gui/gtkui.h"
1.19 @@ -45,7 +47,7 @@
1.20 * Count of running nanoseconds - used to cut back on the GUI runtime
1.21 */
1.22 static uint32_t gtk_gui_nanos = 0;
1.23 -
1.24 +static struct timeval gtk_gui_lasttv;
1.25
1.26 gboolean gui_parse_cmdline( int *argc, char **argv[] )
1.27 {
1.28 @@ -97,6 +99,8 @@
1.29 if( debug_win != NULL ) {
1.30 debug_window_set_running( debug_win, TRUE );
1.31 }
1.32 + gtk_gui_nanos = 0;
1.33 + gettimeofday(&gtk_gui_lasttv,NULL);
1.34 }
1.35
1.36 /**
1.37 @@ -129,10 +133,18 @@
1.38 {
1.39 gtk_gui_nanos += nanosecs;
1.40 if( gtk_gui_nanos > 100000000 ) {
1.41 - gtk_gui_nanos = 0;
1.42 + struct timeval tv;
1.43 while( gtk_events_pending() )
1.44 gtk_main_iteration();
1.45 - // main_window_set_framerate( main_win, pvr2_get_frame_rate() );
1.46 +
1.47 + gettimeofday(&tv,NULL);
1.48 + double ns = ((tv.tv_sec - gtk_gui_lasttv.tv_sec) * 1000000000.0) +
1.49 + ((tv.tv_usec - gtk_gui_lasttv.tv_usec)*1000.0);
1.50 + double speed = (float)( (double)gtk_gui_nanos * 100.0 / ns );
1.51 + gtk_gui_lasttv.tv_sec = tv.tv_sec;
1.52 + gtk_gui_lasttv.tv_usec = tv.tv_usec;
1.53 + main_window_set_speed( main_win, speed );
1.54 + gtk_gui_nanos = 0;
1.55 }
1.56 return nanosecs;
1.57 }
.