Hey. I'm using WriteConsoleOutput() to write a buffer of text/colour to a console application. I've made a Buffer class which is below, along with my main(). The problem IS, that it's displaying question marks instead of periods.. the line where I tried to do this is highlighted in red... I've tried stepping through it with the debugger but the Buffer instance's buffer variable (which is a CHAR_INFO struct declared in the blue line) has {UnicodeChar=L'쳌' AsciiChar='Ì' } for all of it's elements... that's where it should be a period. Can anyone tell me why this is playing up?
Code:int main() { Buffer buffer; buffer.draw_intro(); _getch(); return 0; }Code:#include "Buffer.h" Buffer::Buffer(ushort BUFFER_WIDTH, ushort BUFFER_HEIGHT) { buffer_size.X = BUFFER_WIDTH; buffer_size.Y = BUFFER_HEIGHT; output_handle = GetStdHandle(STD_OUTPUT_HANDLE); rect_info.X = 0; rect_info.Y = 0; } bool Buffer::is_valid_draw(const COORD buffer_size) { if(buffer_size.X < SCREEN_WIDTH && buffer_size.Y < SCREEN_HEIGHT) return true; else return false; } void Buffer::fill_buffer(const COORD buffer_size) { for(int y = 0; y < buffer_size.Y; y++) { for(int x = 0; x < buffer_size.X; x++) { buffer[x + y * SCREEN_WIDTH].Char.AsciiChar = '.'; buffer[x + y * SCREEN_WIDTH].Attributes = FOREGROUND_GREEN; } } } void Buffer::draw_intro() { SMALL_RECT draw_rect = {rect_info.X, rect_info.Y, rect_info.X + (SCREEN_WIDTH - 1), rect_info.Y + (SCREEN_HEIGHT - 1)}; COORD buffer_size = {SCREEN_WIDTH, SCREEN_HEIGHT}; COORD zero_zero = {0, 0}; fill_buffer(buffer_size); WriteConsoleOutput(output_handle, buffer, buffer_size, zero_zero, &draw_rect); _getch(); }




Reply With Quote