//! ---------------------------------------------------- //! ---------------------------------------------------- const std = @import("std"); const sdl = @import("sdl"); const sdl_glue = @import("sdl_glue"); const wgpu = @import("wgpu"); const App = @import("app"); const Window = @import("../../window/resource/window.zig"); const Resized = @import("../../window/event/resized.zig"); const WGPUInstance = @import("../../platform/resource/wgpu_instance.zig"); const WGPUDevice = @import("../../device/resource/wgpu_device.zig"); /// ---------------------------------------------------- /// ---------------------------------------------------- pub fn pollEvents(app: *App) !void { // --- # --- const res = try app.resources.getMany(struct { instance: *WGPUInstance, window: *Window, device: *WGPUDevice, }); var event: sdl.SDL_Event = undefined; while (sdl.SDL_PollEvent(&event)) { switch (event.type) { sdl.SDL_EVENT_QUIT => try app.events.send(App.event.AppExit{}), sdl.SDL_EVENT_WINDOW_RESIZED => { // --- # --- try app.events.send(Resized{ .width = @intCast(event.window.data1), .height = @intCast(event.window.data2), }); // --- RELEASE --- sdl_glue.wgpuSurfaceUnconfigure(res.window.surface); // --- CONFIGURE SURFACE --- sdl_glue.wgpuSurfaceConfigure( res.window.surface, &sdl_glue.WGPUSurfaceConfiguration{ .device = @ptrCast(res.device.raw), .format = 28, // TODO: Get format properly, idk, store it somewhere .width = @intCast(event.window.data1), .height = @intCast(event.window.data2), .usage = sdl_glue.WGPUTextureUsage_RenderAttachment, }, ); }, else => {}, } } }