SDXFrameWork 0.09 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Timer.h
1 #pragma once
2 #include <Multimedia/Color.h>
3 #include <chrono>
4
5 namespace SDX
6 {
9 class Time
10 {
11 private:
12 double fps;
13 std::chrono::system_clock::time_point reset;
14 std::chrono::system_clock::time_point fpsCounter;
15 std::chrono::system_clock::time_point watch;
16
17 Time(void)
18 {
19 this->ResetCount();
20 }
21
22 ~Time(void){};
23
24 static Time singleton;
25
26 static Time& Single()
27 {
28 return singleton;
29 }
30
31 public:
33 static void ResetCount()
34 {
35 Single().reset = std::chrono::system_clock::now();
36 }
37
39 static double GetNowCount()
40 {
41 auto diff = std::chrono::system_clock::now() - Single().reset;
42 return (double)std::chrono::duration_cast<std::chrono::microseconds>(diff).count()/ 1000;
43 }
44
46 static void GetDate(tm *現在時刻)
47 {
48 time_t timer;
49
50 time( &timer);
51
52 localtime_s( 現在時刻 , &timer);
53 }
54
56 static double GetFPS()
57 {
58 return Single().fps;
59 }
60
62 static void ResetFPS()
63 {
64 Single().fpsCounter = std::chrono::system_clock::now();
65 }
66
68 static void CheckFPS()
69 {
70 auto diff = std::chrono::system_clock::now() - Single().fpsCounter;
71 Single().fps = 1000000.0 / (double)std::chrono::duration_cast<std::chrono::microseconds>(diff).count();
72 Single().fpsCounter = std::chrono::system_clock::now();
73 }
74
76 static void StartWatch()
77 {
78 Single().watch = std::chrono::system_clock::now();
79 }
80
84 static void DrawWatch(const Point &座標, const char* 描画文字列)
85 {
86 std::string buf = 描画文字列;
87 buf += " = ";
88
89 auto diff = std::chrono::system_clock::now() - Single().watch;
90 Drawing::String(座標, Color(255, 255, 255), { buf , (double)std::chrono::duration_cast<std::chrono::microseconds>(diff).count() / 1000 });
91 Single().watch = std::chrono::system_clock::now();
92 }
93 };
94
95 }
SDX::Time::GetFPS
static double GetFPS()
FPSを取得.
Definition: Timer.h:56
SDX::Time::DrawWatch
static void DrawWatch(const Point &座標, const char *描画文字列)
処理時間計測終了.
Definition: Timer.h:84
SDX::Point
点を表す図形クラス.
Definition: Shape.h:129
SDX::Time::StartWatch
static void StartWatch()
処理時間計測開始.
Definition: Timer.h:76
SDX::Time::GetNowCount
static double GetNowCount()
リセット後の経過時間のミリ秒で取得(小数点以下).
Definition: Timer.h:39
SDX::Color
色を表すクラス.
Definition: Color.h:7
SDX::Time
時間と日付を取得する関数群.
Definition: Timer.h:9
SDX::Time::CheckFPS
static void CheckFPS()
FPS計測を更新.
Definition: Timer.h:68
SDX::Time::ResetCount
static void ResetCount()
時間の初期化.
Definition: Timer.h:33
SDX::Time::ResetFPS
static void ResetFPS()
FPSの計測開始.
Definition: Timer.h:62
SDX::Drawing::String
static void String(const Point &座標, Color 色, VariadicStream 描画する文字列)
文字を描画.
Definition: Drawing.h:155
SDX::Time::GetDate
static void GetDate(tm *現在時刻)
日付を取得.
Definition: Timer.h:46