Merge pull request #211 from lachlansneff/bevy-render-draw-command

Add Draw command to RenderCommand
This commit is contained in:
Carter Anderson 2020-08-17 19:15:41 -07:00 committed by GitHub
commit 6e4c959e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -43,6 +43,10 @@ pub enum RenderCommand {
base_vertex: i32,
instances: Range<u32>,
},
Draw {
vertices: Range<u32>,
instances: Range<u32>,
},
}
/// A component that indicates how to draw an entity.

View File

@ -245,6 +245,13 @@ impl<Q: HecsQuery + Send + Sync + 'static> Node for PassNode<Q> {
log::info!("Could not draw indexed because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline);
}
}
RenderCommand::Draw { vertices, instances } => {
if draw_state.can_draw() {
render_pass.draw(vertices.clone(), instances.clone());
} else {
log::info!("Could not draw because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline);
}
}
RenderCommand::SetVertexBuffer {
buffer,
offset,
@ -306,10 +313,13 @@ impl DrawState {
self.index_buffer = Some(buffer);
}
pub fn can_draw_indexed(&self) -> bool {
pub fn can_draw(&self) -> bool {
self.bind_groups.iter().all(|b| b.is_some())
&& self.vertex_buffers.iter().all(|v| v.is_some())
&& self.index_buffer.is_some()
}
pub fn can_draw_indexed(&self) -> bool {
self.can_draw() && self.index_buffer.is_some()
}
pub fn set_pipeline(