Skip to content

Commit

Permalink
Enable vsync to avoid tearing
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Sep 12, 2024
1 parent 387e824 commit 5120b4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vm/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn window_create(thread: &mut Thread, width: Value, height: Value, title: Va
.build()
.unwrap();

let mut canvas = window.into_canvas().build().unwrap();
let mut canvas = window.into_canvas().present_vsync().build().unwrap();

canvas.set_draw_color(Color::RGB(0, 0, 0));
canvas.clear();
Expand Down Expand Up @@ -140,6 +140,9 @@ pub fn window_draw_frame(thread: &mut Thread, window_id: Value, src_addr: Value)
window.canvas.window_mut().raise();
}

// Clear the canvas
window.canvas.clear();

// Update the texture
let pitch = 4 * window.width as usize;
let pixel_slice = unsafe { std::slice::from_raw_parts(data_ptr, data_len) };
Expand Down

0 comments on commit 5120b4f

Please sign in to comment.