OSDN Git Service

fix cmake/Macros.cmake
[moflib/moflib.git] / moflib-1.0 / moflib / moflib / mof / Timer.cpp
1 #include "mof/Timer.hpp"
2 #include <windows.h>
3
4 bool mof::Timer::initialized = false;
5
6
7
8 mof::Timer::Timer() : m_startTime(timeGetTime()){
9         if(!initialized){
10                 TIMECAPS caps;
11                 timeGetDevCaps(&caps, sizeof(TIMECAPS)); 
12                 timeBeginPeriod(caps.wPeriodMin);//\8dÅ\8d\82\90«\94\\82Å\8cv\91ª
13                 initialized = true;
14         }
15 }
16
17 void mof::Timer::reset(){
18         m_startTime = timeGetTime();
19 }
20
21 int mof::Timer::getTime() const{
22         return timeGetTime() - m_startTime;
23 }
24
25 unsigned long mof::Timer::getSystemTime()
26 {
27         return timeGetTime();
28 }
29
30 /*
31 //-----------------------------------------------
32 // Clock::Clock
33 // 
34 //-----------------------------------------------
35 mof::Clock::Clock()
36
37 {
38         
39         m_begintime = 0;
40         
41
42 }
43
44 //-----------------------------------------------
45 // Clock::SetTimer
46 // 
47 //-----------------------------------------------
48 void mof::Clock::setTimer(){
49         
50         m_begintime =  timeGetTime();
51         
52
53 }
54
55
56 //-----------------------------------------------
57 // Clock::GetBetweenTime
58 // 
59 //-----------------------------------------------
60 DWORD mof::Clock::getBetweenTime(){
61         DWORD temp_time = m_begintime;
62         m_begintime = timeGetTime();    
63         return m_begintime - temp_time;
64
65 }
66
67
68
69 //      void StopTimer();
70 //      DWORD GetAvgTime();
71
72
73 //-----------------------------------------------
74 // Clock::GetFPS
75 // \82 \82é\83t\83\8c\81[\83\80\90\94\82É\82©\82©\82Á\82½\8e\9e\8aÔ\82©\82ç\81AFPS\82ð\8eZ\8fo\82·\82é
76 //-----------------------------------------------
77 float mof::Clock::getFPS(DWORD in_time , UINT in_cnt_frame){
78         if(in_time == 0)return 0.0f;//\82O\82Å\8f\9c\8eZ\82ð\89ñ\94ð
79         return (float)in_cnt_frame / (float)in_time * 1000.0f;
80
81 }*/