linux support

This commit is contained in:
milek7
2017-07-31 00:25:19 +02:00
parent e7623fa18f
commit f7459f3434
64 changed files with 967 additions and 602 deletions

View File

@@ -75,12 +75,19 @@ void ResetTimers()
fSoundTimer = 0.0;
};
LONGLONG fr, count, oldCount;
// LARGE_INTEGER fr,count;
uint64_t fr, count, oldCount;
void UpdateTimers(bool pause)
{
#ifdef _WIN32
QueryPerformanceFrequency((LARGE_INTEGER *)&fr);
QueryPerformanceCounter((LARGE_INTEGER *)&count);
#elif __linux__
timespec ts;
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
count = (uint64_t)ts.tv_sec * 1000000000 + (uint64_t)ts.tv_nsec;
fr = 1000000000;
#endif
DeltaRenderTime = double(count - oldCount) / double(fr);
if (!pause)
{
@@ -88,11 +95,7 @@ void UpdateTimers(bool pause)
fSoundTimer += DeltaTime;
if (fSoundTimer > 0.1)
fSoundTimer = 0.0;
/*
double CurrentTime= double(count)/double(fr);//GetTickCount();
DeltaTime= (CurrentTime-OldTime);
OldTime= CurrentTime;
*/
if (DeltaTime > 1.0)
DeltaTime = 1.0;
}
@@ -101,9 +104,11 @@ void UpdateTimers(bool pause)
oldCount = count;
// Keep track of the time lapse and frame count
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
#if __linux__
double fTime = (double)(count / 1000000000);
#elif _WIN32_WINNT >= _WIN32_WINNT_VISTA
double fTime = ::GetTickCount64() * 0.001f; // Get current time in seconds
#else
#elif _WIN32
double fTime = ::GetTickCount() * 0.001f; // Get current time in seconds
#endif
++dwFrames; // licznik ramek