Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop overflow of timer on long running machines. #666

Open
wants to merge 1 commit into
base: goodbye_cmake
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/polycode/core/PolyWinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ class Gamepad_devicePrivate {

// frequency of the windows performance counter
double pcFreq;
// Initial Value of the performance counter
int PerfInitial;

// Tracks whether the system supports multitouch at runtime
bool hasMultiTouch;
Expand Down
3 changes: 3 additions & 0 deletions src/core/PolyWinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScre
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
pcFreq = double(li.QuadPart)/1000.0;
PerfInitial = 0;

setVSync(vSync);

Expand Down Expand Up @@ -206,6 +207,8 @@ void Win32Core::warpCursor(int x, int y) {
unsigned int Win32Core::getTicks() {
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
if (PerfInitial == 0)
PerfInitial = li.QuadPart;
return (unsigned int)(li.QuadPart / pcFreq);
}

Expand Down