diff options
| author | kkard2 <[email protected]> | 2025-09-06 15:59:51 +0200 |
|---|---|---|
| committer | kkard2 <[email protected]> | 2025-09-06 15:59:51 +0200 |
| commit | c451018c17ce4953a7011fce6cafa55e362e0005 (patch) | |
| tree | c2140b4e8a68ef0607f18d5c868698ae8e1e97d4 /platform_win32.c | |
| parent | ee158180231bafb2d41bd1c6aa5de545556faed8 (diff) | |
rainbow
Diffstat (limited to 'platform_win32.c')
| -rw-r--r-- | platform_win32.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/platform_win32.c b/platform_win32.c index 1d7ff57..620b8a2 100644 --- a/platform_win32.c +++ b/platform_win32.c @@ -1,13 +1,16 @@ #define UNICODE #include <windows.h> #include <assert.h> +#include <stdio.h> +#include <io.h> + +#include <fcntl.h> #define SPONGE_IMPLEMENTATION #include "sponge.h" #include "example.h" -// TODO(kard): ofc some resizing stuff #define DEFAULT_WIDTH 256 #define DEFAULT_HEIGHT 256 @@ -36,6 +39,22 @@ int update_canvas(sponge_Texture *canvas, uint32_t new_width, uint32_t new_heigh bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; + return 1; +} + +// TODO(kard): MSVC complains about freopen (should be freopen_s apparently) +void redirect_io_to_console() { + AllocConsole(); + FILE *fp; + + fp = freopen("CONOUT$", "w", stdout); + setvbuf(stdout, NULL, _IONBF, 0); + + fp = freopen("CONOUT$", "w", stderr); + setvbuf(stderr, NULL, _IONBF, 0); + + fp = freopen("CONIN$", "r", stdin); + setvbuf(stdin, NULL, _IONBF, 0); } LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -61,6 +80,8 @@ int WinMain( LPSTR lpCmdLine, int nShowCmd ) { + redirect_io_to_console(); + const wchar_t CLASS_NAME[] = L"sponge"; WNDCLASS wc = { 0 }; |
