mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Scissor test
This commit is contained in:
@@ -805,6 +805,12 @@ void wgpu_render_pass_set_index_buffer(WGPURenderPassId pass_id,
|
||||
|
||||
void wgpu_render_pass_set_pipeline(WGPURenderPassId pass_id, WGPURenderPipelineId pipeline_id);
|
||||
|
||||
void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t w,
|
||||
uint32_t h);
|
||||
|
||||
void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
|
||||
const WGPUBufferId *buffer_ptr,
|
||||
const uint32_t *offset_ptr,
|
||||
|
||||
@@ -343,3 +343,30 @@ pub extern "C" fn wgpu_render_pass_set_blend_color(pass_id: RenderPassId, color:
|
||||
pass.raw.set_blend_constants(conv::map_color(color));
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_scissor_rect(
|
||||
pass_id: RenderPassId,
|
||||
x: u32,
|
||||
y: u32,
|
||||
w: u32,
|
||||
h: u32,
|
||||
) {
|
||||
let mut pass_guard = HUB.render_passes.write();
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
|
||||
unsafe {
|
||||
use std::convert::TryFrom;
|
||||
use std::i16;
|
||||
|
||||
pass.raw.set_scissors(
|
||||
0,
|
||||
&[hal::pso::Rect {
|
||||
x: i16::try_from(x).unwrap_or(0),
|
||||
y: i16::try_from(y).unwrap_or(0),
|
||||
w: i16::try_from(w).unwrap_or(i16::MAX),
|
||||
h: i16::try_from(h).unwrap_or(i16::MAX),
|
||||
}],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,6 +869,10 @@ impl<'a> RenderPass<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn set_scissor_rect(&mut self, x: u32, y: u32, w: u32, h: u32) {
|
||||
wgn::wgpu_render_pass_set_scissor_rect(self.id, x, y, w, h)
|
||||
}
|
||||
|
||||
pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {
|
||||
wgn::wgpu_render_pass_draw(
|
||||
self.id,
|
||||
|
||||
Reference in New Issue
Block a user