From 3e5a38dbf6bc785e73ce127dbd2d9566b2dbf1c2 Mon Sep 17 00:00:00 2001 From: kkard2 Date: Mon, 1 Sep 2025 20:21:40 +0200 Subject: rename to sponge --- platform_win32.c | 16 ++++++++-------- softrender.h | 35 ----------------------------------- sponge.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 43 deletions(-) delete mode 100644 softrender.h create mode 100644 sponge.h diff --git a/platform_win32.c b/platform_win32.c index 7ebd16c..06680e7 100644 --- a/platform_win32.c +++ b/platform_win32.c @@ -1,8 +1,8 @@ #define UNICODE #include -#define SOFTRENDER_IMPLEMENTATION -#include "softrender.h" +#define SPONGE_IMPLEMENTATION +#include "sponge.h" // TODO(kard): ofc some resizing stuff #define WIDTH 256 @@ -27,7 +27,7 @@ int WinMain( LPSTR lpCmdLine, int nShowCmd ) { - const wchar_t CLASS_NAME[] = L"softrender"; + const wchar_t CLASS_NAME[] = L"sponge"; WNDCLASS wc = { 0 }; @@ -40,7 +40,7 @@ int WinMain( HWND hwnd = CreateWindowEx( 0, CLASS_NAME, - L"softrender", + L"sponge", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, // bla bla you can't resize window basically CW_USEDEFAULT, CW_USEDEFAULT, WIDTH, HEIGHT, NULL, @@ -63,7 +63,7 @@ int WinMain( bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; - soft_Canvas canvas = { + sponge_Canvas canvas = { .pixels = pixel_buffer, .width = WIDTH, .height = HEIGHT, @@ -88,9 +88,9 @@ int WinMain( // NOTE(kard): ACTUAL RENDERING CODE HERE !!! - soft_clear(canvas, 0xFF000000); - soft_draw_rect(canvas, 80, 70, 80 + 20, 70 + 40, 0xFFFF00FF); - soft_draw_rect(canvas, 140, 70, 140 + 20, 70 + 40, 0xFFFF00FF); + sponge_clear(canvas, 0xFF000000); + sponge_draw_rect(canvas, 80, 70, 80 + 20, 70 + 40, 0xFFFF00FF); + sponge_draw_rect(canvas, 140, 70, 140 + 20, 70 + 40, 0xFFFF00FF); HDC hdc = GetDC(hwnd); diff --git a/softrender.h b/softrender.h deleted file mode 100644 index e417ab2..0000000 --- a/softrender.h +++ /dev/null @@ -1,35 +0,0 @@ -#include - -typedef struct { - // TODO(kard): define byte order - uint32_t *pixels; - uint32_t width; - uint32_t height; - uint32_t stride; -} soft_Canvas; - -void soft_clear(soft_Canvas c, uint32_t color); -void soft_draw_rect(soft_Canvas c, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t color); - -// TODO(kard): prefix stripping - -#ifdef SOFTRENDER_IMPLEMENTATION - -void soft_clear(soft_Canvas c, uint32_t color) { - soft_draw_rect(c, 0, 0, c.width - 1, c.height - 1, color); -} - -// TODO(kard): probably bounds checking -// TODO(kard): alpha blending maybe -void soft_draw_rect(soft_Canvas c, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t color) { - uint32_t *row = c.pixels + (y0 * c.stride); - - for (uint32_t y = y0; y <= y1; y++, row += c.stride) { - for (uint32_t x = x0; x <= x1; x++) { - row[x] = color; - } - } -} - -#endif // SOFTRENDER_IMPLEMENTATION - diff --git a/sponge.h b/sponge.h new file mode 100644 index 0000000..dc50693 --- /dev/null +++ b/sponge.h @@ -0,0 +1,35 @@ +#include + +typedef struct { + // TODO(kard): define byte order + uint32_t *pixels; + uint32_t width; + uint32_t height; + uint32_t stride; +} sponge_Canvas; + +void sponge_clear(sponge_Canvas c, uint32_t color); +void sponge_draw_rect(sponge_Canvas c, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t color); + +// TODO(kard): prefix stripping + +#ifdef SPONGE_IMPLEMENTATION + +void sponge_clear(sponge_Canvas c, uint32_t color) { + sponge_draw_rect(c, 0, 0, c.width - 1, c.height - 1, color); +} + +// TODO(kard): probably bounds checking +// TODO(kard): alpha blending maybe +void sponge_draw_rect(sponge_Canvas c, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t color) { + uint32_t *row = c.pixels + (y0 * c.stride); + + for (uint32_t y = y0; y <= y1; y++, row += c.stride) { + for (uint32_t x = x0; x <= x1; x++) { + row[x] = color; + } + } +} + +#endif // SPONGE_IMPLEMENTATION + -- cgit v1.3.1