Commit 86a9c9aa authored by nanahira's avatar nanahira

screenshot time

parent cff90c93
...@@ -2188,17 +2188,33 @@ void Game::FlashWindow() { ...@@ -2188,17 +2188,33 @@ void Game::FlashWindow() {
FlashWindowEx(&fi); FlashWindowEx(&fi);
#endif #endif
} }
void printTimeDiff(timeval tv1, timeval tv2, const char* prefix) {
const time_t time1 = tv1.tv_sec * 1000000 + tv1.tv_usec;
const time_t time2 = tv2.tv_sec * 1000000 + tv2.tv_usec;
printf("%s: %d\n", prefix, time2 - time1);
}
void Game::takeScreenshot() { void Game::takeScreenshot() {
if(!FileSystem::IsDirExists(L"./screenshots") && !FileSystem::MakeDir(L"./screenshots")) if(!FileSystem::IsDirExists(L"./screenshots") && !FileSystem::MakeDir(L"./screenshots"))
return; return;
irr::video::IImage* const image = driver->createScreenShot(); timeval t1;
if(image) { timeval t2;
timeval t3;
gettimeofday(&t1, NULL);
irr::video::IImage *const image = driver->createScreenShot();
gettimeofday(&t2, NULL);
printTimeDiff(t1, t2, "Screenshot time");
if (image)
{
irr::c8 filename[64]; irr::c8 filename[64];
snprintf(filename, 64, "screenshots/ygopro_%u.png", device->getTimer()->getRealTime()); snprintf(filename, 64, "screenshots/ygopro_%u.bmp", device->getTimer()->getRealTime());
if (!driver->writeImageToFile(image, filename)) if (!driver->writeImageToFile(image, filename))
device->getLogger()->log(L"Failed to take screenshot.", irr::ELL_WARNING); device->getLogger()->log(L"Failed to take screenshot.", irr::ELL_WARNING);
image->drop(); image->drop();
} else gettimeofday(&t3, NULL);
printTimeDiff(t2, t3, "Save time");
printTimeDiff(t1, t3, "Total time");
}
else
device->getLogger()->log(L"Failed to take screenshot.", irr::ELL_WARNING); device->getLogger()->log(L"Failed to take screenshot.", irr::ELL_WARNING);
} }
bool Game::CheckRegEx(const std::wstring& text, const std::wstring& exp, bool exact) { bool Game::CheckRegEx(const std::wstring& text, const std::wstring& exp, bool exact) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment