msectimer.cpp

来自「c+++ game uploading now」· C++ 代码 · 共 29 行

CPP
29
字号
/**
 @file
 Code for a timer with a resolution of one milisecond.
*/
#include "MSecTimer.h"
#include "../lib/WinException.h"

using namespace Othello;

MSecTimer::MSecTimer()
{
    LARGE_INTEGER freq=_htimer.Frequency();
    if(freq.QuadPart<1000)
        throw Win::Exception("Hardware does not support a timer with resolution of atleast 1 ms");
}

unsigned int MSecTimer::Time()
{
    LARGE_INTEGER ticks=_htimer.Ticks();
    LARGE_INTEGER freq=_htimer.Frequency();
    return static_cast<unsigned int>(1000*(ticks.QuadPart/freq.QuadPart))+1;
}

void MSecTimer::ReInit()
{
    _htimer.InitBase();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?