diff --git a/crates/notan_glow/src/pipeline.rs b/crates/notan_glow/src/pipeline.rs index 574d4b77..aefa6147 100644 --- a/crates/notan_glow/src/pipeline.rs +++ b/crates/notan_glow/src/pipeline.rs @@ -88,6 +88,7 @@ impl InnerPipeline { set_blend_mode(gl, options); #[cfg(not(target_arch = "wasm32"))] set_srgb_space(gl, options); + set_point_size_available(gl, options); } } } @@ -257,6 +258,17 @@ fn set_srgb_space(gl: &Context, opts: &PipelineOptions) { } } +#[inline(always)] +fn set_point_size_available(gl: &Context, opts: &PipelineOptions) { + unsafe { + if opts.point_size_available { + gl.enable(glow::VERTEX_PROGRAM_POINT_SIZE); + } else { + gl.disable(glow::VERTEX_PROGRAM_POINT_SIZE); + } + } +} + #[inline(always)] fn clean_pipeline(gl: &Context, pip: InnerPipeline) { let InnerPipeline { diff --git a/crates/notan_glow/src/to_glow.rs b/crates/notan_glow/src/to_glow.rs index 2b4aa629..873fe1ae 100644 --- a/crates/notan_glow/src/to_glow.rs +++ b/crates/notan_glow/src/to_glow.rs @@ -136,6 +136,7 @@ impl ToGlow for TextureFilter { impl ToGlow for DrawPrimitive { fn to_glow(&self) -> u32 { match self { + DrawPrimitive::Points => glow::POINTS, DrawPrimitive::Triangles => glow::TRIANGLES, DrawPrimitive::TriangleStrip => glow::TRIANGLE_STRIP, DrawPrimitive::Lines => glow::LINES, diff --git a/crates/notan_graphics/src/pipeline.rs b/crates/notan_graphics/src/pipeline.rs index 6a1ef20d..bb63d2ac 100644 --- a/crates/notan_graphics/src/pipeline.rs +++ b/crates/notan_graphics/src/pipeline.rs @@ -162,6 +162,12 @@ impl<'a, 'b> PipelineBuilder<'a, 'b> { self } + /// Enable the availability of gl_PointSize in the vertex shader + pub fn with_point_size_available(mut self, enabled: bool) -> Self { + self.options.point_size_available = enabled; + self + } + /// Build the pipeline with the data set on the builder pub fn build(self) -> Result { match self.shaders { @@ -358,6 +364,7 @@ pub struct PipelineOptions { pub color_mask: ColorMask, pub stencil: Option, pub srgb_space: bool, + pub point_size_available: bool, } impl Default for PipelineOptions { @@ -370,6 +377,7 @@ impl Default for PipelineOptions { color_mask: Default::default(), stencil: None, srgb_space: false, + point_size_available: true, } } } @@ -444,6 +452,7 @@ impl Default for StencilOptions { #[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] pub enum DrawPrimitive { + Points, Lines, LineStrip, #[default]