Skip to content

Commit

Permalink
gfx: fix window resizing weirdness by updating display swapchain
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Oct 16, 2024
1 parent 83ed459 commit 652d61a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/gfx.b.v
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,13 @@ fn (mut c Context) sokol_gl_init() ! {
c.offscreen = offscreen
}

fn (mut c Context) offscreen_reinit(width int, height int) ! {
fn (mut c Context) on_resize(width int, height int) ! {
mut swapchain := c.display.swapchain
swapchain.width = width
swapchain.height = height

c.display.swapchain = swapchain

offscreen_sample_count := 1

gfx.destroy_attachments(c.offscreen.attachments)
Expand Down Expand Up @@ -373,7 +379,7 @@ pub fn (mut g GFX) begin_easy_frame() {
w, h := win.canvas().wh()
if off.width != w || off.height != h {
mut mc := unsafe { g.get_active_context() }
mc.offscreen_reinit(w, h) or { panic(err) }
mc.on_resize(w, h) or { panic(err) }
}
}

Expand Down

0 comments on commit 652d61a

Please sign in to comment.