mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
draw methods
This commit is contained in:
parent
bb7fee796d
commit
64fb727bad
@ -110,3 +110,45 @@ pub extern "C" fn wgpu_render_pass_set_vertex_buffers(
|
||||
pass.raw.bind_vertex_buffers(0, buffers);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_draw(
|
||||
pass_id: RenderPassId,
|
||||
vertex_count: u32,
|
||||
instance_count: u32,
|
||||
first_vertex: u32,
|
||||
first_instance: u32,
|
||||
) {
|
||||
unsafe {
|
||||
HUB.render_passes
|
||||
.write()
|
||||
.get_mut(pass_id)
|
||||
.raw
|
||||
.draw(
|
||||
first_vertex .. first_vertex + vertex_count,
|
||||
first_instance .. first_instance + instance_count,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_draw_indexed(
|
||||
pass_id: RenderPassId,
|
||||
index_count: u32,
|
||||
instance_count: u32,
|
||||
first_index: u32,
|
||||
base_vertex: i32,
|
||||
first_instance: u32,
|
||||
) {
|
||||
unsafe {
|
||||
HUB.render_passes
|
||||
.write()
|
||||
.get_mut(pass_id)
|
||||
.raw
|
||||
.draw_indexed(
|
||||
first_index .. first_index + index_count,
|
||||
base_vertex,
|
||||
first_instance .. first_instance + instance_count,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ extern crate wgpu_native as wgn;
|
||||
use arrayvec::ArrayVec;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::ops::Range;
|
||||
use std::ptr;
|
||||
|
||||
pub use wgn::{
|
||||
@ -353,6 +354,31 @@ impl<'a> RenderPass<'a> {
|
||||
wgn::wgpu_render_pass_end_pass(self.id);
|
||||
self.parent
|
||||
}
|
||||
|
||||
pub fn draw(
|
||||
&self, vertices: Range<u32>, instances: Range<u32>
|
||||
) {
|
||||
wgn::wgpu_render_pass_draw(
|
||||
self.id,
|
||||
vertices.end - vertices.start,
|
||||
instances.end - instances.start,
|
||||
vertices.start,
|
||||
instances.start,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn draw_indexed(
|
||||
&self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>
|
||||
) {
|
||||
wgn::wgpu_render_pass_draw_indexed(
|
||||
self.id,
|
||||
indices.end - indices.start,
|
||||
instances.end - instances.start,
|
||||
indices.start,
|
||||
base_vertex,
|
||||
instances.start,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ComputePass<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user