19

You may remember a super long time ago I double-buffered the Windows cmd.exe using c++

tl;dr, here it is in c!

Anyways, I was still learning c++ back then. It wasn't my first project in c++ but it was close and I ran into a lot of issues. The thing worked... but only if you didn't touch it.

Here's the same project (With a lot less bells'n'whistles) written in c. I used a different approach this time, and other than my function naming convention (Which, I honestly don't even know if it's bad or not!), I think this is some pretty solid code!

In the image you see the header file (I used as a summary of the code) and then three x's in a terminal. To do this, the code:

-Creates a ConsoleScreenBuffer handle
-Creates two CHAR_INFO buffers for drawing & displaying
-Draws three x's to the draw buffer
-Copies the draw buffer to the display buffer
-Copies the display buffer to the ConsoleScreenBuffer handle

I'm thinking about cutting out the middle man and removing the display buffer (which holds what is currently displayed) but I think it may actually be useful, and I don't know.

Anyways, I have no friends that understand this stuff so that's why it's here. Cheers.

Comments
Add Comment