pub struct DrawParameters<'a> {Show 27 fields
pub depth: Depth,
pub stencil: Stencil,
pub blend: Blend,
pub color_mask: (bool, bool, bool, bool),
pub line_width: Option<f32>,
pub point_size: Option<f32>,
pub clip_planes_bitmask: u32,
pub backface_culling: BackfaceCullingMode,
pub polygon_mode: PolygonMode,
pub multisampling: bool,
pub dithering: bool,
pub viewport: Option<Rect>,
pub scissor: Option<Rect>,
pub draw_primitives: bool,
pub samples_passed_query: Option<SamplesQueryParam<'a>>,
pub time_elapsed_query: Option<&'a TimeElapsedQuery>,
pub primitives_generated_query: Option<&'a PrimitivesGeneratedQuery>,
pub transform_feedback_primitives_written_query: Option<&'a TransformFeedbackPrimitivesWrittenQuery>,
pub condition: Option<ConditionalRendering<'a>>,
pub transform_feedback: Option<&'a TransformFeedbackSession<'a>>,
pub smooth: Option<Smooth>,
pub provoking_vertex: ProvokingVertex,
pub primitive_bounding_box: (Range<f32>, Range<f32>, Range<f32>, Range<f32>),
pub primitive_restart_index: bool,
pub polygon_offset: PolygonOffset,
pub clip_control_origin: ClipControlOrigin,
pub clip_control_depth: ClipControlDepth,
}
Expand description
Represents the parameters to use when drawing.
Example:
let params = glium::DrawParameters {
depth: glium::Depth {
test: glium::DepthTest::IfLess,
write: true,
.. Default::default()
},
.. Default::default()
};
Fields§
§depth: Depth
How the fragment will interact with the depth buffer.
stencil: Stencil
How the fragment will interact with the stencil buffer.
blend: Blend
The effect that the GPU will use to merge the existing pixel with the pixel that is being written.
color_mask: (bool, bool, bool, bool)
Allows you to disable some color components.
This affects all attachments to the framebuffer. It’s at the same level as the blending function.
The parameters are in order: red, green, blue, alpha. true
means that the given
component will be written, false
means that it will be ignored. The default value
is (true, true, true, true)
.
line_width: Option<f32>
Width in pixels of the lines to draw when drawing lines.
None
means “don’t care”. Use this when you don’t draw lines.
point_size: Option<f32>
Diameter in pixels of the points to draw when drawing points.
None
means “don’t care”. Use this when you don’t draw points.
clip_planes_bitmask: u32
If the bit corresponding to 2^i is 1 in the bitmask, then GL_CLIP_DISTANCEi is enabled.
The most common value for GL_MAX_CLIP_DISTANCES is 8, so 32 bits in the mask is plenty.
See https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_ClipDistance.xhtml
.
backface_culling: BackfaceCullingMode
Whether or not the GPU should filter out some faces.
After the vertex shader stage, the GPU will try to remove the faces that aren’t facing the camera.
See the BackfaceCullingMode
documentation for more infos.
polygon_mode: PolygonMode
How to render polygons. The default value is Fill
.
See the documentation of PolygonMode
for more infos.
multisampling: bool
Whether multisample antialiasing (MSAA) should be used. Default value is true
.
Note that you will need to set the appropriate option when creating the window.
The recommended way to do is to leave this to true
, and adjust the option when
creating the window.
dithering: bool
Whether dithering is activated. Default value is true
.
Dithering will smoothen the transition between colors in your color buffer.
viewport: Option<Rect>
The viewport to use when drawing.
The X and Y positions of your vertices are mapped to the viewport so that (-1, -1)
corresponds to the lower-left hand corner and (1, 1)
corresponds to the top-right
hand corner. Any pixel outside of the viewport is discarded.
You can specify a viewport greater than the target if you want to stretch the image.
None
means “use the whole surface”.
scissor: Option<Rect>
If specified, only pixels in this rect will be displayed. Default is None
.
This is different from a viewport. The image will stretch to fill the viewport, but not the scissor box.
draw_primitives: bool
If false
, the pipeline will stop after the primitives generation stage. The default
value is true
.
If false
, the fragment shader of your program won’t be executed.
If false
, drawing may return TransformFeedbackNotSupported
if the backend doesn’t
support this feature.
This parameter may seem pointless, but it can be useful when you use transform feedback or if you just use your shaders to write to a buffer.
samples_passed_query: Option<SamplesQueryParam<'a>>
If set, each sample (ie. usually each pixel) written to the output adds one to the
counter of the SamplesPassedQuery
.
time_elapsed_query: Option<&'a TimeElapsedQuery>
If set, the time it took for the GPU to execute this draw command is added to the total
stored inside the TimeElapsedQuery
.
primitives_generated_query: Option<&'a PrimitivesGeneratedQuery>
If set, the number of primitives generated is added to the total stored inside the query.
transform_feedback_primitives_written_query: Option<&'a TransformFeedbackPrimitivesWrittenQuery>
If set, the number of vertices written by transform feedback.
condition: Option<ConditionalRendering<'a>>
If set, the commands will only be executed if the specified query contains true
or
a number different than 0.
transform_feedback: Option<&'a TransformFeedbackSession<'a>>
If set, then the generated primitives will be written back to a buffer.
smooth: Option<Smooth>
If set, then the generated primitives will be smoothed.
Note that blending needs to be enabled for this to work.
provoking_vertex: ProvokingVertex
In your vertex shader or geometry shader, you have the possibility to mark some output
varyings as flat
. If this is the case, the value of one of the vertices will be used
for the whole primitive. This variable allows you to specify which vertex.
The default value is LastVertex
, as this is the default in OpenGL. Any other value can
potentially trigger a ProvokingVertexNotSupported
error. Most notably OpenGL ES doesn’t
support anything else but LastVertex
.
primitive_bounding_box: (Range<f32>, Range<f32>, Range<f32>, Range<f32>)
Hint for the GPU of the bounding box of the geometry.
If you’re using geometry shaders or tessellation shaders, it can be extremely advantageous
for the GPU to know where on the screen the primitive is. This field specifies the
bounding box (x
, y
, z
, w
) of the primitive and serves as a hint to the GPU.
The GPU is free not to draw samples outside of the bounding box. Whether the samples are drawn is implementation-specific.
This field is useless if you’re not using a geometry shader or tessellation shader.
Since this is purely an optimization, this parameter is ignored if the backend doesn’t support it.
primitive_restart_index: bool
If enabled, will split the index buffer (if any is used in the draw call)
at the MAX value of the IndexType (u8::MAX, u16::MAX or u32::MAX) and start a new primitive
of the same type (“primitive restarting”). Supported on > OpenGL 3.1 or OpenGL ES 3.0.
If the backend does not support GL_PRIMITIVE_RESTART_FIXED_INDEX, an Error
of type FixedIndexRestartingNotSupported
will be returned.
polygon_offset: PolygonOffset
If enabled, shifts the depth value of towards of away from the camera. This is useful for drawing decals and wireframes, for example.
clip_control_origin: ClipControlOrigin
Clip control origin. The default value is LowerLeft
.
clip_control_depth: ClipControlDepth
Clip control depth mode. The default value is NegativeOneToOne
.
Trait Implementations§
source§impl<'a> Clone for DrawParameters<'a>
impl<'a> Clone for DrawParameters<'a>
source§fn clone(&self) -> DrawParameters<'a>
fn clone(&self) -> DrawParameters<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for DrawParameters<'a>
impl<'a> Debug for DrawParameters<'a>
source§impl<'a> Default for DrawParameters<'a>
impl<'a> Default for DrawParameters<'a>
source§fn default() -> DrawParameters<'a>
fn default() -> DrawParameters<'a>
Auto Trait Implementations§
impl<'a> Freeze for DrawParameters<'a>
impl<'a> !RefUnwindSafe for DrawParameters<'a>
impl<'a> !Send for DrawParameters<'a>
impl<'a> !Sync for DrawParameters<'a>
impl<'a> Unpin for DrawParameters<'a>
impl<'a> !UnwindSafe for DrawParameters<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)