Przeglądaj źródła

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 lat temu
rodzic
commit
ad5a6141bc
1 zmienionych plików z 9 dodań i 1 usunięć
  1. 9 1
      zig/sdl/hello_sdl.zig

+ 9 - 1
zig/sdl/hello_sdl.zig

48
    };
48
    };
49
    defer c.SDL_DestroyWindow(screen);
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
    // assume monospace font
53
    // assume monospace font
54
    var glyph_width: c_int = 0;
54
    var glyph_width: c_int = 0;
70
                c.SDL_QUIT => {
70
                c.SDL_QUIT => {
71
                    quit = true;
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
                c.SDL_KEYDOWN => {
81
                c.SDL_KEYDOWN => {
74
                    switch (event.key.keysym.sym) {
82
                    switch (event.key.keysym.sym) {
75
                        c.SDLK_ESCAPE => {
83
                        c.SDLK_ESCAPE => {