diff options
-rw-r--r-- | example/3d.cpp | 2 | ||||
-rw-r--r-- | example/collision.cpp | 2 | ||||
-rw-r--r-- | example/pong.cpp | 4 | ||||
-rw-r--r-- | example/test.cpp | 2 | ||||
-rw-r--r-- | src/cRender.cpp | 36 | ||||
-rw-r--r-- | src/cRender.h | 7 |
6 files changed, 18 insertions, 35 deletions
diff --git a/example/3d.cpp b/example/3d.cpp index 11a2d3d..e488da1 100644 --- a/example/3d.cpp +++ b/example/3d.cpp @@ -39,7 +39,7 @@ private: int main(int argc, char* argv[]) { - cRender render(' ', _COL_DEFAULT, 30,30); + cRender render(' ', _COL_DEFAULT); cObjectHandler handler(&render); cObject ver(45,1); cWiremesh obj; diff --git a/example/collision.cpp b/example/collision.cpp index 4084809..e46c423 100644 --- a/example/collision.cpp +++ b/example/collision.cpp @@ -47,7 +47,7 @@ private: int main(int argc, char* argv[]) { - cRender render(' ', _COL_DEFAULT, 30,30); + cRender render(' ', _COL_DEFAULT); cObjectHandler handler(&render); cObject ver(45,1); testobject obj2; diff --git a/example/pong.cpp b/example/pong.cpp index a42bb55..4524869 100644 --- a/example/pong.cpp +++ b/example/pong.cpp @@ -22,7 +22,6 @@ public: sPos getV() { return v; } private: sPos v; - }; class bar : public cObject @@ -50,7 +49,7 @@ public: int main() { - cRender render(' ', _COL_DEFAULT, 10,10); + cRender render(' ', _COL_DEFAULT); cObjectHandler screen(&render); cInput input; @@ -91,7 +90,6 @@ int main() while(1) { - sInputEvent ie = input.poll(); if(ie.type != _EVENT_NULL) diff --git a/example/test.cpp b/example/test.cpp index ca6f38e..7c1e3a0 100644 --- a/example/test.cpp +++ b/example/test.cpp @@ -39,7 +39,7 @@ public: int main() { - cRender render(' ', _COL_DEFAULT, 10,10); + cRender render(' ', _COL_DEFAULT); cObjectHandler screen(&render); cInput input; diff --git a/src/cRender.cpp b/src/cRender.cpp index 3b4573a..148be91 100644 --- a/src/cRender.cpp +++ b/src/cRender.cpp @@ -1,7 +1,7 @@ #include "cRender.h" -cRender::cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy) +cRender::cRender(char _backound, WORD _color) { bBlockRender = false; //If this Constructor is used, this instance is not inherited, thus render() doesn't need to be blocked iLastError = _OK_; @@ -26,11 +26,6 @@ cRender::cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy setAlternateBufferScreen(true); setConsoleCursor(false); - //setBufferSize( getConsoleWindowSize() ); - - if(sizeX < _sx || sizeY < _sy) //Notify Program tha screen is too small for desired Size - iLastError = _ERR_SCREEN_TOO_SMALL_; - #elif _WIN32 //Windows Specific Code hstdout = GetStdHandle(STD_OUTPUT_HANDLE); //get handle @@ -43,8 +38,6 @@ cRender::cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy #endif //_WIN32 setConsoleEcho(false); - //clear(true); //Init backround array - }//render() @@ -214,7 +207,8 @@ int cRender::render(void) gotoxy(o,i); SetConsoleTextAttribute(hstdout, wColor[o][i] | _COL_INTENSITY); - printf("%c", cScreen[o][i]); + if(!bMute) + printf("%c", cScreen[o][i]); #elif __linux__ @@ -289,6 +283,10 @@ int cRender::clear() return clear(false); } +int cRender::getLastError() +{ + return iLastError; +} #ifdef _WIN32 //Source: http://www.cplusplus.com/forum/windows/121444/ @@ -328,14 +326,7 @@ int cRender::SetConsoleWindowSize(int x, int y) if (!SetConsoleWindowInfo(h, TRUE, &info)) return 1; } -#endif //_WIN32 -int cRender::getLastError() -{ - return iLastError; -} - -#ifdef _WIN32 void cRender::gotoxy( int x, int y ) { COORD p = { x, y }; @@ -436,15 +427,6 @@ void cRender::setConsoleEcho(bool _enable) SetConsoleMode(hStdin, mode ); #elif __linux__ - /*struct termios tty; - tcgetattr(STDIN_FILENO, &tty); - if( !_enable ) - tty.c_lflag &= ~ECHO; - else - tty.c_lflag |= ECHO; - - (void) tcsetattr(STDIN_FILENO, TCSANOW, &tty);*/ - _enable ? write (STDOUT_FILENO, "\e[?8h", 5) : write (STDOUT_FILENO, "\e[?8l", 5); #endif //__linux__ } @@ -486,13 +468,11 @@ void cRender::waitForFrametime() left = (1/(double)uTargetFPS) - elapsed - (((double)lastRenderTime) / CLOCKS_PER_SEC); std::this_thread::sleep_for(std::chrono::milliseconds(int (left * 1000))); - - } void cRender::forceScreenSize(sPos _size) { - if(_size.x || _size.y) + if(!(_size.x < 1 || _size.y < 1)) { setBufferSize(_size); bLockScreenSize = true; diff --git a/src/cRender.h b/src/cRender.h index 6aa4cce..41dd0c6 100644 --- a/src/cRender.h +++ b/src/cRender.h @@ -16,6 +16,7 @@ typedef uint32_t WORD; #elif _WIN32 + #error "Not ported" #include <Windows.h> #else #error "Platforn not supported" @@ -92,7 +93,7 @@ public: * Resizes console window for Windows * Sets Size to Console Window Size for Linux. Writes Error for _sx or _sy smaller than Screen. Get by getLastError() */ - cRender(char _backound, WORD _color, unsigned int _sx, unsigned int _sy); + cRender(char _backound, WORD _color); virtual ~cRender(); @@ -142,8 +143,12 @@ public: */ void setTargetFPS(unsigned int _fps); + /** Deactivates automatic screen size detection and forces screen size to _size + */ void forceScreenSize(sPos _size); + /** Disable Output + */ void mute(bool _mute); protected: |