mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 16:19:53 +07:00
setup timers resolution for windows
This commit is contained in:
@@ -144,6 +144,11 @@ if(APPLE)
|
||||
${Foundation})
|
||||
endif(APPLE)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND E2D_LIBRARIES
|
||||
winmm.lib)
|
||||
endif(WIN32)
|
||||
|
||||
set(E2D_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/headers)
|
||||
|
||||
|
||||
@@ -8,14 +8,30 @@
|
||||
|
||||
#if defined(E2D_PLATFORM_MODE) && E2D_PLATFORM_MODE == E2D_PLATFORM_MODE_WINDOWS
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace e2d;
|
||||
|
||||
class platform_internal_state_impl_windows final : public platform_internal_state_impl {
|
||||
public:
|
||||
platform_internal_state_impl_windows() = default;
|
||||
~platform_internal_state_impl_windows() noexcept = default;
|
||||
platform_internal_state_impl_windows() {
|
||||
TIMECAPS tc;
|
||||
if ( MMSYSERR_NOERROR == ::timeGetDevCaps(&tc, sizeof(tc)) ) {
|
||||
if ( TIMERR_NOERROR == ::timeBeginPeriod(tc.wPeriodMin) ) {
|
||||
timers_resolution_ = tc.wPeriodMin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~platform_internal_state_impl_windows() noexcept {
|
||||
if ( timers_resolution_ > 0 ) {
|
||||
::timeEndPeriod(timers_resolution_);
|
||||
}
|
||||
}
|
||||
private:
|
||||
UINT timers_resolution_{0u};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user