diff options
Diffstat (limited to '')
-rw-r--r-- | src/Utility.cpp | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/src/Utility.cpp b/src/Utility.cpp index 0fb10cf..848ee02 100644 --- a/src/Utility.cpp +++ b/src/Utility.cpp @@ -5,40 +5,41 @@ #include <easylogging++.h> GLenum glCheckError_(const char *file, int line) { - GLenum errorCode; - while ((errorCode = glGetError()) != GL_NO_ERROR) { - std::string error; - switch (errorCode) { - case GL_INVALID_ENUM: - error = "INVALID_ENUM"; - break; - case GL_INVALID_VALUE: - error = "INVALID_VALUE"; - break; - case GL_INVALID_OPERATION: - error = "INVALID_OPERATION"; - break; - case GL_STACK_OVERFLOW: - error = "STACK_OVERFLOW"; - break; - case GL_STACK_UNDERFLOW: - error = "STACK_UNDERFLOW"; - break; - case GL_OUT_OF_MEMORY: - error = "OUT_OF_MEMORY"; - break; - case GL_INVALID_FRAMEBUFFER_OPERATION: - error = "INVALID_FRAMEBUFFER_OPERATION"; - break; - } - static int t = 0; - LOG(ERROR) << "OpenGL error: " << error << " at " << file << ":" << line; - } - return errorCode; + GLenum errorCode; + while ((errorCode = glGetError()) != GL_NO_ERROR) { + std::string error; + switch (errorCode) { + case GL_INVALID_ENUM: + error = "INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + error = "INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + error = "INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + error = "STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + error = "STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + error = "OUT_OF_MEMORY"; + break; + case GL_INVALID_FRAMEBUFFER_OPERATION: + error = "INVALID_FRAMEBUFFER_OPERATION"; + break; + } + static int t = 0; + LOG(ERROR) << "OpenGL error: " << error << " at " << file << ":" << line; + } + return errorCode; } -LoopExecutionTimeController::LoopExecutionTimeController(duration delayLength) : delayLength(delayLength) { - previousUpdate = clock::now(); +LoopExecutionTimeController::LoopExecutionTimeController(duration delayLength) + : delayLength(delayLength) { + previousUpdate = clock::now(); } LoopExecutionTimeController::~LoopExecutionTimeController() { @@ -46,16 +47,16 @@ LoopExecutionTimeController::~LoopExecutionTimeController() { } void LoopExecutionTimeController::SetDelayLength(duration length) { - delayLength = length; + delayLength = length; } unsigned long long LoopExecutionTimeController::GetIterations() { - return iterations; + return iterations; } void LoopExecutionTimeController::Update() { - iterations++; - auto timeToSleep = delayLength - GetDelta(); + iterations++; + auto timeToSleep = delayLength - GetDelta(); if (timeToSleep.count() > 0) std::this_thread::sleep_for(timeToSleep); previousPreviousUpdate = previousUpdate; @@ -68,8 +69,8 @@ double LoopExecutionTimeController::GetDeltaMs() { } LoopExecutionTimeController::duration LoopExecutionTimeController::GetDelta() { - auto now = clock::now(); - return duration(now-previousUpdate); + auto now = clock::now(); + return duration(now-previousUpdate); } double LoopExecutionTimeController::GetDeltaS() { @@ -77,13 +78,11 @@ double LoopExecutionTimeController::GetDeltaS() { return delta.count(); } -double LoopExecutionTimeController::GetRealDeltaS() -{ +double LoopExecutionTimeController::GetRealDeltaS() { return std::chrono::duration<double,std::ratio<1,1>>(previousUpdate - previousPreviousUpdate).count(); } -double LoopExecutionTimeController::RemainTimeMs() -{ +double LoopExecutionTimeController::RemainTimeMs() { auto remain = delayLength - GetDelta(); return remain.count(); } |