diff options
Diffstat (limited to 'src/wgpuctx')
| -rw-r--r-- | src/wgpuctx/pipeline.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/wgpuctx/pipeline.rs b/src/wgpuctx/pipeline.rs index 0811800..d698ac4 100644 --- a/src/wgpuctx/pipeline.rs +++ b/src/wgpuctx/pipeline.rs @@ -14,7 +14,8 @@ pub struct RenderPipelineBuilder<'a> vertex_buffer_layouts: Vec<wgpu::VertexBufferLayout<'a>>, - cull_mode: Option<wgpu::Face> + cull_mode: Option<wgpu::Face>, + primitive_topology: wgpu::PrimitiveTopology } impl<'a> RenderPipelineBuilder<'a> @@ -34,7 +35,8 @@ impl<'a> RenderPipelineBuilder<'a> vertex_buffer_layouts: Vec::new(), - cull_mode: Some(wgpu::Face::Back) + cull_mode: Some(wgpu::Face::Back), + primitive_topology: wgpu::PrimitiveTopology::TriangleList } } @@ -61,6 +63,13 @@ impl<'a> RenderPipelineBuilder<'a> self.cull_mode = mode; self } + pub fn primitive_topology( + mut self, + topology: wgpu::PrimitiveTopology + ) -> Self { + self.primitive_topology = topology; self + } + pub fn build( self, label: Option<&'static str>, @@ -109,8 +118,10 @@ impl<'a> RenderPipelineBuilder<'a> })], }), primitive: wgpu::PrimitiveState { - topology: wgpu::PrimitiveTopology::TriangleList, - strip_index_format: None, + topology: self.primitive_topology, + strip_index_format: if self.primitive_topology.is_strip() { + Some(wgpu::IndexFormat::Uint32) } else { + None }, front_face: wgpu::FrontFace::Ccw, cull_mode: self.cull_mode, polygon_mode: wgpu::PolygonMode::Fill, |
