rendering rectangles

This commit is contained in:
Josh Lyon
2025-08-12 20:02:48 -06:00
parent 256781587b
commit 4e3e4f9aab

View File

@@ -9,8 +9,11 @@
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely. freely.
*/ */
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_render.h>
#include <string> #include <string>
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */ #define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> #include <SDL3/SDL_main.h>
@@ -52,9 +55,19 @@ SDL_AppResult SDL_AppIterate(void *appstate)
x = ((w / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * message.length()) / 2; x = ((w / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * message.length()) / 2;
y = ((h / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2; y = ((h / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2;
SDL_FRect rect {
.x = 30,
.y = 30,
.w = 100,
.h = 100
};
/* Draw the message */ /* Draw the message */
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 200, 255);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
SDL_RenderFillRect(renderer, &rect);
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderDebugText(renderer, x, y, message.c_str()); SDL_RenderDebugText(renderer, x, y, message.c_str());
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);