本文整理汇总了C++中Timer::GetMSec方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetMSec方法的具体用法?C++ Timer::GetMSec怎么用?C++ Timer::GetMSec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetMSec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAsyncLoading
void Scene::UpdateAsyncLoading()
{
PROFILE(UpdateAsyncLoading);
Timer asyncLoadTimer;
for (;;)
{
if (asyncProgress_.loadedNodes_ >= asyncProgress_.totalNodes_)
{
FinishAsyncLoading();
return;
}
// Read one child node with its full sub-hierarchy either from binary or XML
if (!asyncProgress_.xmlFile_)
{
unsigned nodeID = asyncProgress_.file_->ReadUInt();
Node* newNode = CreateChild(nodeID, nodeID < FIRST_LOCAL_ID ? REPLICATED : LOCAL);
resolver_.AddNode(nodeID, newNode);
newNode->Load(*asyncProgress_.file_, resolver_);
}
else
{
unsigned nodeID = asyncProgress_.xmlElement_.GetInt("id");
Node* newNode = CreateChild(nodeID, nodeID < FIRST_LOCAL_ID ? REPLICATED : LOCAL);
resolver_.AddNode(nodeID, newNode);
newNode->LoadXML(asyncProgress_.xmlElement_, resolver_);
asyncProgress_.xmlElement_ = asyncProgress_.xmlElement_.GetNext("node");
}
++asyncProgress_.loadedNodes_;
// Break if time limit exceeded, so that we keep sufficient FPS
if (asyncLoadTimer.GetMSec(false) >= ASYNC_LOAD_MAX_MSEC)
break;
}
using namespace AsyncLoadProgress;
VariantMap eventData;
eventData[P_SCENE] = (void*)this;
eventData[P_PROGRESS] = (float)asyncProgress_.loadedNodes_ / (float)asyncProgress_.totalNodes_;
eventData[P_LOADEDNODES] = asyncProgress_.loadedNodes_;
eventData[P_TOTALNODES] = asyncProgress_.totalNodes_;
SendEvent(E_ASYNCLOADPROGRESS, eventData);
}
示例2: WindowsMain
int WindowsMain(int argc, char** argv, IApp* app)
{
pApp = app;
//Used for automated testing, if enabled app will exit after 120 frames
bool testing = false;
uint32_t testingFrameCount = 0;
const uint32_t testingDesiredFrameCount = 120;
//search for --test in command line arguments
if (argc > 1)
{
for(int i = 0 ; i < argc ; i++)
{
if (strcmp(argv[i], "--testing"))
testing = true;
}
}
FileSystem::SetCurrentDir(FileSystem::GetProgramDir());
IApp::Settings* pSettings = &pApp->mSettings;
WindowsDesc window = {};
Timer deltaTimer;
if (pSettings->mWidth == -1 || pSettings->mHeight == -1)
{
RectDesc rect = {};
getRecommendedResolution(&rect);
pSettings->mWidth = getRectWidth(rect);
pSettings->mHeight = getRectHeight(rect);
}
window.windowedRect = { 0, 0, (int)pSettings->mWidth, (int)pSettings->mHeight };
window.fullScreen = pSettings->mFullScreen;
window.maximized = false;
openWindow(pApp->GetName(), &window);
pSettings->mWidth = window.fullScreen ? getRectWidth(window.fullscreenRect) : getRectWidth(window.windowedRect);
pSettings->mHeight = window.fullScreen ? getRectHeight(window.fullscreenRect) : getRectHeight(window.windowedRect);
pApp->pWindow = &window;
pApp->mCommandLine = GetCommandLineA();
if (!pApp->Init())
return EXIT_FAILURE;
registerWindowResizeEvent(onResize);
while (isRunning())
{
float deltaTime = deltaTimer.GetMSec(true) / 1000.0f;
// if framerate appears to drop below about 6, assume we're at a breakpoint and simulate 20fps.
if (deltaTime > 0.15f)
deltaTime = 0.05f;
handleMessages();
pApp->Update(deltaTime);
pApp->Draw();
//used in automated tests only.
if (testing)
{
testingFrameCount++;
if (testingFrameCount >= testingDesiredFrameCount)
break;
}
}
pApp->Exit();
return 0;
}