From 2187b2dbd6107835868f2b464dac076792545b9a Mon Sep 17 00:00:00 2001 From: jonas Date: Tue, 26 Mar 2019 13:38:14 +0100 Subject: cRender: Added enableDebugInfo() to print debug info --- src/cRender.cpp | 13 +++++++++++-- src/cRender.h | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cRender.cpp b/src/cRender.cpp index ddc52df..818b11b 100644 --- a/src/cRender.cpp +++ b/src/cRender.cpp @@ -17,6 +17,7 @@ cRender::cRender(char _backound, WORD _color) bMute = false; bLockScreenSize = false; + bPrintDebugInfo = false; #ifdef __linux__ //In Linux, setting Console size is not supported, so it gets Size of Console (Window) instead. @@ -443,12 +444,15 @@ void cRender::setTargetFPS(unsigned int _fps) void cRender::printDebugInfo() { + if(!bPrintDebugInfo) + return; + char dbgtxt[30]; double lrt = (double)lastFrameTime / CLOCKS_PER_SEC; - double fps = getFrametime()? 1/getFrametime():0; + double fps = getFrametime() ? 1/getFrametime() : 0; - sprintf(dbgtxt, "R: %f F: %f", lrt, fps); + sprintf(dbgtxt, "R: %f F: %f ", lrt, fps); drawText(dbgtxt, {0,0}, _COL_BLACK | _COL_WHITE_BG); } @@ -490,3 +494,8 @@ void cRender::mute(bool _mute) { bMute = _mute; } + +void cRender::enableDebugInfo(bool _enable) +{ + bPrintDebugInfo = _enable; +} diff --git a/src/cRender.h b/src/cRender.h index 41dd0c6..4aa2c4d 100644 --- a/src/cRender.h +++ b/src/cRender.h @@ -151,6 +151,10 @@ public: */ void mute(bool _mute); + /** Enables Debug info Printing to screen + */ + void enableDebugInfo(bool _enable); + protected: /** Empty Constructor for being inheritable */ @@ -166,6 +170,7 @@ protected: bool bMute; bool bLockScreenSize; + bool bPrintDebugInfo; char **cScreen; //* Pixel Map -- cgit v1.2.3