Created
July 19, 2025 21:47
-
-
Save izzyreal/ba4bfdb810a570ffc1cbd47004e10d12 to your computer and use it in GitHub Desktop.
SDL draws over border
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define SDL_MAIN_USE_CALLBACKS | |
| #include <SDL3/SDL.h> | |
| #include <SDL3/SDL_main.h> | |
| static SDL_Window *window = NULL; | |
| static SDL_Renderer *renderer = NULL; | |
| SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) | |
| { | |
| if (!SDL_Init(SDL_INIT_VIDEO)) | |
| { | |
| SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError()); | |
| return SDL_APP_FAILURE; | |
| } | |
| if (!SDL_CreateWindowAndRenderer( | |
| "", | |
| 640, | |
| 480, | |
| 0, | |
| &window, | |
| &renderer) | |
| ) | |
| { | |
| SDL_Log("SDL_CreateWindowAndRenderer() failed: %s", SDL_GetError()); | |
| return SDL_APP_FAILURE; | |
| } | |
| return SDL_APP_CONTINUE; | |
| } | |
| SDL_AppResult SDL_AppIterate(void *appstate) | |
| { | |
| SDL_SetRenderTarget(renderer, NULL); | |
| SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); | |
| SDL_RenderClear(renderer); | |
| SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); | |
| SDL_FRect rect {0.f, 50.f, 100.f, 51.f}; | |
| SDL_RenderFillRect(renderer, &rect); | |
| SDL_RenderPresent(renderer); | |
| SDL_Delay(16); | |
| return SDL_APP_CONTINUE; | |
| } | |
| SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) | |
| { | |
| switch (event->type) | |
| { | |
| case SDL_EVENT_QUIT: | |
| return SDL_APP_SUCCESS; | |
| } | |
| return SDL_APP_CONTINUE; | |
| } | |
| void SDL_AppQuit(void *appstate, SDL_AppResult result) | |
| { | |
| SDL_DestroyRenderer(renderer); | |
| SDL_DestroyWindow(window); | |
| SDL_Quit(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment