From 9918f45d60b85a325dd74003ff5b08d8bfab0e4f Mon Sep 17 00:00:00 2001 From: makefunstuff Date: Wed, 3 Jul 2024 01:27:18 +0300 Subject: works --- src/sdl-window.zig | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sdl-window.zig b/src/sdl-window.zig index 2e292ed..50d3f0c 100644 --- a/src/sdl-window.zig +++ b/src/sdl-window.zig @@ -23,9 +23,6 @@ pub fn present_sdl_window() !void { }; defer c.SDL_DestroyRenderer(renderer); - const color = c.SDL_Color{ .r = 255, .g = 255, .b = 255, .a = 255 }; - _ = c.SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a); - const rect_height = 100; const rect_width = 100; @@ -40,16 +37,21 @@ pub fn present_sdl_window() !void { while (c.SDL_PollEvent(&event) != 0) { switch (event.type) { - c.SDL_Quit => { + c.SDL_QUIT => { quit = true; }, else => {}, } } - _ = c.SDL_RenderFillRect(renderer, &rect); + const bg_color = c.SDL_Color{ .r = 255, .g = 255, .b = 255, .a = 255 }; + _ = c.SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b, bg_color.a); + _ = c.SDL_RenderClear(renderer); - _ = c.SDL_RenderPresent(renderer); - _ = c.SDL_Delay(20); + const rect_color = c.SDL_Color{ .r = 0, .g = 0, .b = 255, .a = 255 }; + _ = c.SDL_SetRenderDrawColor(renderer, rect_color.r, rect_color.g, rect_color.b, rect_color.a); + + _ = c.SDL_RenderFillRect(renderer, &rect); + _ = c.SDL_RenderPresent(renderer); } } -- cgit 1.4.1-2-gfad0