|
|
@ -55,12 +55,20 @@ pub fn main() !void {
|
|
55
|
55
|
|
|
56
|
56
|
var window_width = glyph_width * 100;
|
|
57
|
57
|
var window_height = glyph_height * 20;
|
|
58
|
|
const screen = c.SDL_CreateWindow("hello fonts", c.SDL_WINDOWPOS_CENTERED, c.SDL_WINDOWPOS_CENTERED, window_width, window_height, c.SDL_WINDOW_BORDERLESS) orelse {
|
|
|
58
|
const screen = c.SDL_CreateWindow("hello fonts", c.SDL_WINDOWPOS_CENTERED, c.SDL_WINDOWPOS_CENTERED, window_width, window_height, c.SDL_WINDOW_BORDERLESS | c.SDL_WINDOW_OPENGL) orelse {
|
|
59
|
59
|
c.SDL_Log("Unable to create window: %s", c.SDL_GetError());
|
|
60
|
60
|
return error.SDLInitializationFailed;
|
|
61
|
61
|
};
|
|
62
|
62
|
defer c.SDL_DestroyWindow(screen);
|
|
63
|
63
|
|
|
|
64
|
const op: f32 = 0.5;
|
|
|
65
|
if (c.SDL_SetWindowOpacity(screen, op) != 0) {
|
|
|
66
|
c.SDL_Log("Unable to make window transparent: %s", c.SDL_GetError());
|
|
|
67
|
}
|
|
|
68
|
var opacity: f32 = 10.0;
|
|
|
69
|
_ = c.SDL_GetWindowOpacity(screen, &opacity);
|
|
|
70
|
c.SDL_Log("opacity: %f", opacity);
|
|
|
71
|
|
|
64
|
72
|
const renderer = c.SDL_CreateRenderer(screen, -1, c.SDL_RENDERER_ACCELERATED);
|
|
65
|
73
|
|
|
66
|
74
|
var msg = " ".*;
|
|
|
@ -200,11 +208,13 @@ pub fn main() !void {
|
|
200
|
208
|
}
|
|
201
|
209
|
}
|
|
202
|
210
|
|
|
|
211
|
_ = c.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 100);
|
|
|
212
|
//_ = c.SDL_SetRenderDrawBlendMode(renderer, c.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
|
203
|
213
|
_ = c.SDL_RenderClear(renderer);
|
|
204
|
214
|
|
|
205
|
215
|
// thanks to https://stackoverflow.com/questions/22886500/how-to-render-text-in-sdl2 for some actually useful code here
|
|
206
|
216
|
const white: c.SDL_Color = c.SDL_Color{ .r = 255, .g = 255, .b = 255, .a = 255 };
|
|
207
|
|
const black: c.SDL_Color = c.SDL_Color{ .r = 0, .g = 0, .b = 0, .a = 255 };
|
|
|
217
|
const black: c.SDL_Color = c.SDL_Color{ .r = 0, .g = 0, .b = 0, .a = 100 };
|
|
208
|
218
|
// Shaded vs Solid gives a nicer output, with solid the output
|
|
209
|
219
|
// was squiggly and not aligned with a baseline.
|
|
210
|
220
|
const text = c.TTF_RenderUTF8_Shaded(font, &msg, white, black);
|