Add Draw command to RenderCommand
This commit is contained in:
parent
77ebb461f9
commit
e24aaf3dd3
@ -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.
|
||||
|
@ -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,6 +313,11 @@ impl DrawState {
|
||||
self.index_buffer = Some(buffer);
|
||||
}
|
||||
|
||||
pub fn can_draw(&self) -> bool {
|
||||
self.bind_groups.iter().all(|b| b.is_some())
|
||||
&& self.vertex_buffers.iter().all(|v| v.is_some())
|
||||
}
|
||||
|
||||
pub fn can_draw_indexed(&self) -> bool {
|
||||
self.bind_groups.iter().all(|b| b.is_some())
|
||||
&& self.vertex_buffers.iter().all(|v| v.is_some())
|
||||
|
Loading…
Reference in New Issue
Block a user