-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderer.cpp
More file actions
32 lines (23 loc) · 834 Bytes
/
Copy pathRenderer.cpp
File metadata and controls
32 lines (23 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Renderer.hpp"
#include <Windows.h>
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
void Renderer::setcursorvisibility(bool hidden) {
CONSOLE_CURSOR_INFO cursorInfo;
GetConsoleCursorInfo(hConsole, &cursorInfo);
cursorInfo.bVisible = hidden ? FALSE : TRUE;
SetConsoleCursorInfo(hConsole, &cursorInfo);
}
void Renderer::draw(std::string& fb) {
// Set Cursor Position to top left
COORD pos = { 0,0 };
SetConsoleCursorPosition(hConsole, pos);
WriteConsoleA(hConsole, fb.c_str(), fb.size(), NULL, NULL);
}
Vec2 Renderer::getframesize() {
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
return Vec2{ csbi.srWindow.Bottom - csbi.srWindow.Top + 1, csbi.srWindow.Right - csbi.srWindow.Left + 1 };
}
void Renderer::sleep(double time) {
Sleep(time);
}