- Create a popup window with the size (in characters per width and per height, ex: 80x24 which is the normal console width*heighr in characters) of your console, since it's going to be invisible, we have no need to implement a WindowProc function nor a MSG loop, since the user will never interact with this window, so in the WNDCLASSEX we put DefWindowProc as our WNDPROC function or we create and get the hDC from a edit control.
- Create a OpenGL context for this window.
- Create a char buffer which will represent the console screen, make it the same size of the window and console (in this case 80x24)
- Create a intencity/shades table which will contain special characters such as a "block" or a "chess block" to represent the different shades of gray
- Clear the Window and draw what ever you want (in this case a sphere)
- Using glGetPixels copy the image on the window to a temp_buffer where you will convert the colors to indexes in your intencity table to a final buffer which is made of chars.
- Print the char buffer to console
Clear the console screen (cls) and SwapBuffers in the window Set the cursor to position 0,0 (which is faster) and SwapBuffers
- goto 5
The code is made with C and it's compiled using Visual C++ 2010 and Linked under Crinkler to a final size of 1kb.
The sphere is made using Glu's gluSphere, haters gonna hate.
You are permited to copy, use and reuse this code, as long you put my name in the greetings section
This code is licensed under the human rights.
Not really a demo, just a test anyway haha, source code included