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

Scrissor rect should be clamped #1447

Open
andraantariksa opened this issue Dec 22, 2021 · 0 comments
Open

Scrissor rect should be clamped #1447

andraantariksa opened this issue Dec 22, 2021 · 0 comments

Comments

@andraantariksa
Copy link

I was following this example, but I always encounter an error about invalid scissor. I just found out the problem was the rect was overflowing the surface bound. I guess the example need to be updated so no one will stumble upon my same exact problem.

https://github.com/PistonDevelopers/conrod/blob/master/backends/conrod_wgpu/examples/all_winit_wgpu.rs#L247

more or less, it can be rewritten into

conrod_wgpu::RenderPassCommand::SetScissor {
    top_left: [x, y],
    dimensions: [w, h],
} => {
    render_pass.set_scissor_rect(x, y, w, h);
}

It should be clamped to the surface size

conrod_wgpu::RenderPassCommand::SetScissor {
    top_left: [x, y],
    dimensions: [mut w, mut h],
} => {
    if w + x > surface_config.surface.width { // Surface width
        w = surface_config.surface.width - x;
    }
    if h + y > surface_config.surface.height { // Surface height
        h = surface_config.surface.height - y;
    }
    render_pass.set_scissor_rect(x, y, w, h);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant