draw methods

This commit is contained in:
Dzmitry Malyshau 2019-01-18 12:04:36 -05:00
parent bb7fee796d
commit 64fb727bad
2 changed files with 68 additions and 0 deletions

View File

@ -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,
);
}
}

View File

@ -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> {