forked from ejowerks/wfb-stabilizer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cairo.c
46 lines (36 loc) · 1.24 KB
/
cairo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <SDL2/SDL.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow(
"SDL2 Floating Glyph",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
400, 200,
SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP
);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
// Main loop flag
int running = 1;
SDL_Event event;
while (running) {
while (SDL_PollEvent(&event) != 0) {
if (event.type == SDL_QUIT) {
running = 0;
}
}
// Clear the screen with transparent black
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
SDL_RenderClear(renderer);
// Draw semi-transparent text using SDL_ttf or SDL's rendering
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 200); // Green with 80% opacity
SDL_Rect rect = {50, 50, 300, 100};
SDL_RenderFillRect(renderer, &rect);
SDL_RenderPresent(renderer);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}