📄 timer.h
字号:
/////////////////////////////////////////////////////
// TIMER.H //
// This is the timer class used mostly to get //
// a constante movement speed independet on //
// FPS and to calculate the FPS //
// Based on NeHe's timer code //
/////////////////////////////////////////////////////
#ifndef TIMERH
#define TIMERH
#include <windows.h>
class GcTimer
{
public:
// Cponstructor / Destructor
GcTimer();
~GcTimer();
// Returns the time since the program started
float GetTime();
// Return the FPS (as a string)
char *FPS();
// The timing function, StartTimer is caled
// before the main loop and DoTimer inside the loop
void StartTimer();
void DoTimer();
// Return the movements constante (for constant movement speed on all computers)
float CalcMove(float desDistance) { return desDistance * secsPerFrame; }
private:
__int64 frequency; // Timer Frequency
float resolution; // Timer Resolution
unsigned long mm_timer_start; // Multimedia Timer Start Value
unsigned long mm_timer_elapsed; // Multimedia Timer Elapsed Time
bool performance_timer; // Using The Performance Timer?
__int64 performance_timer_start; // Performance Timer Start Value
__int64 performance_timer_elapsed; // Performance Timer Elapsed Time
float time; // Used to check the current time
float timeDiff; // Used to determine the time elapsed
float secsPerFrame; // Used to hold the value for how many seconds have elapsed between frames
float lastTime; // Used to see if it's time to update the FPS
char buffer[20]; // Used for printing
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -