Ver Código Fonte

React to resize events

E.g. when forcing full-screen in Sway this now works!  Without this
change nothing would render after a resize.
Luna Stadler 4 anos atrás
pai
commit
ad5a6141bc
1 arquivos alterados com 9 adições e 1 exclusões
  1. 9 1
      zig/sdl/hello_sdl.zig

+ 9 - 1
zig/sdl/hello_sdl.zig

@ -48,7 +48,7 @@ pub fn main() !void {
48 48
    };
49 49
    defer c.SDL_DestroyWindow(screen);
50 50
51
    const surface = c.SDL_GetWindowSurface(screen);
51
    var surface = c.SDL_GetWindowSurface(screen);
52 52
53 53
    // assume monospace font
54 54
    var glyph_width: c_int = 0;
@ -70,6 +70,14 @@ pub fn main() !void {
70 70
                c.SDL_QUIT => {
71 71
                    quit = true;
72 72
                },
73
                c.SDL_WINDOWEVENT => {
74
                    switch (event.window.event) {
75
                        c.SDL_WINDOWEVENT_SIZE_CHANGED => {
76
                            surface = c.SDL_GetWindowSurface(screen);
77
                        },
78
                        else => {},
79
                    }
80
                },
73 81
                c.SDL_KEYDOWN => {
74 82
                    switch (event.key.keysym.sym) {
75 83
                        c.SDLK_ESCAPE => {