Skip to content

Commit

Permalink
Backend should respect idx and vtx offsets given by ImGui
Browse files Browse the repository at this point in the history
This fixes background dimming with modal popups and (probably) the CTRL+Tab box
  • Loading branch information
sarchar committed Sep 25, 2024
1 parent e2e6335 commit f00b29b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,6 @@ impl Renderer {
clip_scale: [f32; 2],
(vertex_base, index_base): (i32, u32),
) -> RendererResult<()> {
let mut start = index_base;

for cmd in draw_list.commands() {
if let Elements { count, cmd_params } = cmd {
let clip_rect = [
Expand All @@ -721,6 +719,7 @@ impl Renderer {
rpass.set_bind_group(1, &tex.bind_group, &[]);

// Set scissors on the renderpass.
let start = index_base + cmd_params.idx_offset as u32;
let end = start + count as u32;
if clip_rect[0] < fb_size[0]
&& clip_rect[1] < fb_size[1]
Expand All @@ -747,13 +746,12 @@ impl Renderer {
rpass.set_scissor_rect(scissors.0, scissors.1, scissors.2, scissors.3);

// Draw the current batch of vertices with the renderpass.
rpass.draw_indexed(start..end, vertex_base, 0..1);
rpass.draw_indexed(start..end, vertex_base + cmd_params.vtx_offset as i32, 0..1);
}
}

// Increment the index regardless of whether or not this batch
// of vertices was drawn.
start = end;
}
}
Ok(())
Expand Down

0 comments on commit f00b29b

Please sign in to comment.