Merge pull request #211 from lachlansneff/bevy-render-draw-command
Add Draw command to RenderCommand
This commit is contained in:
commit
6e4c959e93
@ -43,6 +43,10 @@ pub enum RenderCommand {
|
|||||||
base_vertex: i32,
|
base_vertex: i32,
|
||||||
instances: Range<u32>,
|
instances: Range<u32>,
|
||||||
},
|
},
|
||||||
|
Draw {
|
||||||
|
vertices: Range<u32>,
|
||||||
|
instances: Range<u32>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A component that indicates how to draw an entity.
|
/// 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);
|
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 {
|
RenderCommand::SetVertexBuffer {
|
||||||
buffer,
|
buffer,
|
||||||
offset,
|
offset,
|
||||||
@ -306,10 +313,13 @@ impl DrawState {
|
|||||||
self.index_buffer = Some(buffer);
|
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.bind_groups.iter().all(|b| b.is_some())
|
||||||
&& self.vertex_buffers.iter().all(|v| v.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(
|
pub fn set_pipeline(
|
||||||
|
Loading…
Reference in New Issue
Block a user