Created
May 1, 2025 16:40
-
-
Save Quackdoc/bacea267f25a856bcdc628af0312e68f to your computer and use it in GitHub Desktop.
test translucent window
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
#include <SDL3/SDL.h> | |
#include <SDL3/SDL_render.h> | |
int main(int argc, char* argv[]) { | |
if (SDL_Init(SDL_INIT_VIDEO) < 0) { | |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL: %s", SDL_GetError()); | |
return 3; | |
} | |
SDL_Window* window = SDL_CreateWindow( | |
"Translucent Window", | |
600, | |
600, | |
f SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_TRANSPARENT | |
); | |
if (!window) { | |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create window: %s", SDL_GetError()); | |
SDL_Quit(); | |
return 3; | |
} | |
SDL_Renderer* renderer = SDL_CreateRenderer(window, NULL); | |
if (!renderer) { | |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create renderer: %s", SDL_GetError()); | |
SDL_DestroyWindow(window); | |
SDL_Quit(); | |
return 3; | |
} | |
int running = 1; | |
SDL_Event event; | |
while (running) { | |
while (SDL_PollEvent(&event)) { | |
if (event.type == SDL_EVENT_QUIT) { | |
running = 0; | |
break; | |
} | |
} | |
SDL_SetRenderDrawColor(renderer, 155, 0, 155, 0); | |
SDL_RenderClear(renderer); | |
SDL_RenderPresent(renderer); | |
SDL_Delay(16); | |
} | |
SDL_DestroyRenderer(renderer); | |
SDL_DestroyWindow(window); | |
SDL_Quit(); | |
return 0; | |
} | |
// gcc -o colored_square colored_square-sdl3.c -I../include -L../build/lib -lSDL3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment