Documentation Index
Fetch the complete documentation index at: https://mintlify.com/adi3120/Fazen2d/llms.txt
Use this file to discover all available pages before exploring further.
ConsoleHandler sets up the Windows console, allocates the CHAR_INFO back-buffer, and exposes static accessors used by shapes and the renderer throughout the engine. Every member variable is stored as static storage, meaning all parts of the engine read from and write to the same shared state regardless of where they access it.
Header
Fazen.h — you do not need to add it separately in most projects.
Constructor
CHAR_INFO* back-buffer of size s_width * s_height, acquires the standard output and input handles, sets the console screen buffer size, configures the console window rectangle, and calls make2DConsole(8, 8) to set an 8×8 pixel font.
Width of the console in character columns. Stored in the static field
console_width and used as the stride for all buffer index calculations.Height of the console in character rows. Stored in the static field
console_height and used to compute the total buffer element count.make2DConsole(int fontw, int fonth)
Configures the console font size, resizes the console window to match the buffer rectangle, and enables mouse and window input on the input handle. Called automatically by the constructor with fontw = 8 and fonth = 8; call it again only if you need a different cell size after construction.
Pixel width of each character cell. Passed to
CONSOLE_FONT_INFOEX::dwFontSize.X.
Defaults to 8 when called from the constructor.Pixel height of each character cell. Passed to
CONSOLE_FONT_INFOEX::dwFontSize.Y.
Defaults to 8 when called from the constructor.Static Methods — Buffer Access
These methods return the core Win32 objects thatGraphicsRenderer::display() passes directly to WriteConsoleOutputW.
| Method | Return Type | Description |
|---|---|---|
GetBuffScreen() | CHAR_INFO* | Returns the back-buffer array. Each element holds a Unicode character and a Windows color attribute for one console cell. |
GetBufferSize() | COORD | Returns {console_width, console_height} as a COORD, used as the buffer dimensions argument for WriteConsoleOutputW. |
GetCharacterPos() | COORD | Returns the write origin {0, 0} — the top-left cell within the back-buffer from which output begins. |
GetRectWin() | SMALL_RECT* | Returns a pointer to the destination rectangle {0, 0, width-1, height-1} passed to WriteConsoleOutputW. |
GetOutHandle() | HANDLE | Standard output handle (STD_OUTPUT_HANDLE). Used for all console write and font configuration calls. |
GetInHandle() | HANDLE | Standard input handle (STD_INPUT_HANDLE). Used by MouseHandler and KeyboardHandler to read input events. |
Static Methods — Dimensions
| Method | Return Type | Description |
|---|---|---|
GetConsoleWidth() | int | Returns the number of character columns in the console buffer. |
GetConsoleHeight() | int | Returns the number of character rows in the console buffer. |
GetFontWidth() | int | Returns the pixel width of each character cell as set during make2DConsole. Defaults to 8. |
GetFontHeight() | int | Returns the pixel height of each character cell as set during make2DConsole. Defaults to 8. |
Static Methods — Window Position
These methods are used byMouseHandler to convert raw screen pixel coordinates into console cell coordinates.
| Method | Return Type | Description |
|---|---|---|
GetWindowPos() | void | Calls GetWindowRect on the console window and stores the resulting top-left pixel position in the static fields consoleRangeStartx and consoleRangeStarty. Call this before mapping mouse coordinates each frame. |
GetconsoleRangeStartx() | int | Returns the cached horizontal pixel offset of the console window’s top-left corner on the screen. |
GetconsoleRangeStarty() | int | Returns the cached vertical pixel offset of the console window’s top-left corner on the screen. |
Getpoint() | POINT | Returns the internally stored POINT struct used during window position tracking. |
Buffer Indexing
The back-buffer is a flat, row-major array. To access the cell at columnx, row y, use:
CHAR_INFO element has two fields you will typically write: