Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend should respect idx and vtx offsets given by ImGui #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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