Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Something {
- private:
- // Console window, console stream handles.
- HDC cwd;
- HANDLE chd;
- HWND cwn;
- // ... //
- // Rendering
- uint32_t* frontBuf;
- uint32_t* backBuf;
- size_t gbufSize;
- // ... //
- public:
- // ... //
- // Intiailizes/prepares the application.
- void Initialize() {
- // get handles
- cwd = GetDC(GetConsoleWindow());
- chd = GetStdHandle(STD_OUTPUT_HANDLE);
- cwn = GetConsoleWindow();
- // prepare for rendering
- gbufSize = sizeof(uint32_t) * w * h;
- backBuf = (uint32_t*)malloc(gbufSize);
- frontBuf = (uint32_t*)malloc(gbufSize);
- // ... //
- }
- // ... //
- // Swaps front and back buffers and
- // displays the new front buffer on the screen.
- void GSwap() {
- // swap pointers
- uint32_t* frontTmp = frontBuf;
- frontBuf = backBuf;
- backBuf = frontTmp;
- // clear new back buffer
- memset(backBuf, 0, gbufSize);
- // draw on screen
- /* ??? */
- }
- size_t GFlatten(int x, int y) {
- return y * h + x;
- }
- void GSetPixel(int x, int y, uint32_t color) {
- backBuf[GFlatten(x, y)] = color;
- }
- void GFillRect(int x, int y, int w, int h, uint32_t color) {
- for (int ix = x; ix < x + w; ix++) {
- for (int iy = y; iy < y + h; iy++) {
- GSetPixel(ix, iy, color);
- }
- }
- }
- void GFillScreen(uint32_t color) {
- memset(backBuf, color, gbufSize);
- }
- };
Add Comment
Please, Sign In to add comment