Changed time measurements for FPS display
authorslack <slack@codemaniacs.com>
Thu, 19 Aug 2010 03:04:57 +0000 (05:04 +0200)
committerslack <slack@codemaniacs.com>
Thu, 19 Aug 2010 03:05:56 +0000 (05:05 +0200)
from clock_gettime to QTime. Now builds on windows again :)

qtboi/QtBoiMainWindow.cc
qtboi/QtBoiMainWindow.h

index fd696314c3b98a21ce31502e4981abd4cb5cdbd8..bdfd9eefd293d35af0bf1dbc8f06588b6b60da39 100644 (file)
 #include <QVBoxLayout>
 #include <QFile>
 #include <QTextStream>
+#include <QTime>
 
 #include <iostream>
+#include <cassert>
 
 #include "QtBoiMainWindow.h"
 #include "../core/GameBoy.h"
@@ -83,9 +85,8 @@ QtBoiMainWindow::QtBoiMainWindow(QWidget *parent)
 
        last_FPS_update=0.0f;
        frames_since_last_FPS_update=0;
-       struct timespec tp;
-       clock_gettime(CLOCK_REALTIME, &tp);
-       init_seconds = tp.tv_sec;
+       time = QTime::currentTime();
+    time.start();
 }
 
 QtBoiMainWindow::~QtBoiMainWindow()
@@ -555,9 +556,7 @@ void QtBoiMainWindow::saveTags()
 
 double QtBoiMainWindow::now()
 {
-       struct timespec tp;
-       clock_gettime(CLOCK_REALTIME, &tp);
-       return (tp.tv_sec-init_seconds) + (tp.tv_nsec*1e-9);
+       return time.elapsed()/1000.0;
 }
 
 
index 75d0a6e5aa526d9837b5108b6424a9ce612ad6f2..0293277a46aada333a4ba08eb3c2ce8588246b23 100644 (file)
@@ -13,6 +13,7 @@
 #include <QString>
 #include <QUrl>
 #include <QHash>
+#include <QTime>
 
 #include "QtBoiEmuThread.h"
 #include "QtBoiDisassemblyWindow.h"
@@ -99,6 +100,8 @@ class QtBoiMainWindow: public QMainWindow
         QAction *debugVideoDrawBackground;
         QAction *debugVideoDrawWindow;
         QAction *debugVideoDrawSprites;
+
+        QTime time;
 };