Struct glium::draw_parameters::DrawParameters [] [src]

pub struct DrawParameters<'a> {
    pub depth_test: DepthTest,
    pub depth_write: bool,
    pub depth_range: (f32, f32),
    pub stencil_test_clockwise: StencilTest,
    pub stencil_reference_value_clockwise: i32,
    pub stencil_write_mask_clockwise: u32,
    pub stencil_fail_operation_clockwise: StencilOperation,
    pub stencil_pass_depth_fail_operation_clockwise: StencilOperation,
    pub stencil_depth_pass_operation_clockwise: StencilOperation,
    pub stencil_test_counter_clockwise: StencilTest,
    pub stencil_reference_value_counter_clockwise: i32,
    pub stencil_write_mask_counter_clockwise: u32,
    pub stencil_fail_operation_counter_clockwise: StencilOperation,
    pub stencil_pass_depth_fail_operation_counter_clockwise: StencilOperation,
    pub stencil_depth_pass_operation_counter_clockwise: StencilOperation,
    pub blending_function: Option<BlendingFunction>,
    pub color_mask: (bool, bool, bool, bool),
    pub line_width: Option<f32>,
    pub point_size: Option<f32>,
    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>,
}

Represents the parameters to use when drawing.

Example:

let params = glium::DrawParameters {
    depth_test: glium::DepthTest::IfLess,
    depth_write: true,
    .. Default::default()
};

Fields

depth_test

The function that the GPU will use to determine whether to write over an existing pixel on the target. Don't forget to set depth_write appropriately if you use a depth test.

See the DepthTest documentation for more details.

The default is Overwrite.

depth_write

Sets whether the GPU will write the depth values on the depth buffer if they pass the depth test.

The default is false. You most likely want true if you're doing depth testing.

If you pass true but don't have a depth buffer available, drawing will produce a NoDepthBuffer error.

depth_range

The range of possible Z values in surface coordinates.

Just like OpenGL turns X and Y coordinates between -1.0 and 1.0 into surface coordinates, it will also map your Z coordinates to a certain range which you can specify here.

The two values must be between 0.0 and 1.0, anything outside this range will result in a panic. By default the depth range is (0.0, 1.0).

The first value of the tuple must be the "near" value, where -1.0 will be mapped. The second value must be the "far" value, where 1.0 will be mapped. It is possible for the "near" value to be greater than the "far" value.

stencil_test_clockwise

A comparaison against the existing value in the stencil buffer.

Only relevant for faces that are clockwise on the target surface. Other faces, points and lines use stencil_test_counter_clockwise instead.

The default value is AlwaysPass.

stencil_reference_value_clockwise

Reference value that is used by stencil_test_clockwise, stencil_fail_operation_clockwise, stencil_pass_depth_fail_operation_clockwise and stencil_depth_pass_operation_clockwise.

stencil_write_mask_clockwise

Allows specifying a mask when writing data on the stencil buffer.

Only relevant for faces that are clockwise on the target surface. Other faces, points and lines use stencil_write_mask_counter_clockwise instead.

The default value is 0xffffffff.

stencil_fail_operation_clockwise

Specifies the operation to do when a fragment fails the stencil test.

The stencil test is the test specified by stencil_test_clockwise.

Only relevant for faces that are clockwise on the target surface. Other faces, points and lines use stencil_fail_operation_counter_clockwise instead.

The default value is Keep.

stencil_pass_depth_fail_operation_clockwise

Specifies the operation to do when a fragment passes the stencil test but fails the depth test.

The stencil test is the test specified by stencil_test_clockwise.

Only relevant for faces that are clockwise on the target surface. Other faces, points and lines use stencil_pass_depth_fail_operation_counter_clockwise instead.

The default value is Keep.

stencil_depth_pass_operation_clockwise

Specifies the operation to do when a fragment passes both the stencil and depth tests.

The stencil test is the test specified by stencil_test_clockwise.

Only relevant for faces that are clockwise on the target surface. Other faces, points and lines use stencil_depth_pass_operation_counter_clockwise instead.

The default value is Keep.

stencil_test_counter_clockwise

A comparaison against the existing value in the stencil buffer.

Only relevant for points, lines and faces that are counter-clockwise on the target surface. Other faces use stencil_test_counter_clockwise instead.

The default value is AlwaysPass.

stencil_reference_value_counter_clockwise

Reference value that is used by stencil_test_counter_clockwise, stencil_fail_operation_counter_clockwise, stencil_pass_depth_fail_operation_counter_clockwise and stencil_depth_pass_operation_counter_clockwise.

stencil_write_mask_counter_clockwise

Allows specifying a mask when writing data on the stencil buffer.

Only relevant for points, lines and faces that are counter-clockwise on the target surface. Other faces use stencil_write_mask_clockwise instead.

The default value is 0xffffffff.

stencil_fail_operation_counter_clockwise

Specifies the operation to do when a fragment fails the stencil test.

The stencil test is the test specified by stencil_test_counter_clockwise.

Only relevant for faces that are counter-clockwise on the target surface. Other faces use stencil_fail_operation_clockwise instead.

The default value is Keep.

stencil_pass_depth_fail_operation_counter_clockwise

Specifies the operation to do when a fragment passes the stencil test but fails the depth test.

The stencil test is the test specified by stencil_test_counter_clockwise.

Only relevant for faces that are counter-clockwise on the target surface. Other faces use stencil_pass_depth_fail_operation_clockwise instead.

The default value is Keep.

stencil_depth_pass_operation_counter_clockwise

Specifies the operation to do when a fragment passes both the stencil and depth tests.

The stencil test is the test specified by stencil_test_counter_clockwise.

Only relevant for faces that are counter-clockwise on the target surface. Other faces use stencil_depth_pass_operation_clockwise instead.

The default value is Keep.

blending_function

The function that the GPU will use to merge the existing pixel with the pixel that is being written.

None means "don't care" (usually when you know that the alpha is always 1).

color_mask

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

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

Diameter in pixels of the points to draw when drawing points.

None means "don't care". Use this when you don't draw points.

backface_culling

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

How to render polygons. The default value is Fill.

See the documentation of PolygonMode for more infos.

multisampling

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

Whether dithering is activated. Default value is true.

Dithering will smoothen the transition between colors in your color buffer.

viewport

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

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

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

If set, each sample (ie. usually each pixel) written to the output adds one to the counter of the SamplesPassedQuery.

time_elapsed_query

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

If set, the number of primitives generated is added to the total stored inside the query.

transform_feedback_primitives_written_query

If set, the number of vertices written by transform feedback.

condition

If set, the commands will only be executed if the specified query contains true or a number different than 0.

transform_feedback

If set, then the generated primitives will be written back to a buffer.

smooth

If set, then the generated primitives will be smoothed.

Note that blending needs to be enabled for this to work.

Methods

impl<'a> DrawParameters<'a>

fn new<F>(facade: &'a F) -> DrawParametersBuilder<'a> where F: Facade

Start building draw parameters.

Trait Implementations

impl<'a> Default for DrawParameters<'a>

fn default() -> DrawParameters<'a>

Derived Implementations

impl<'a> Debug for DrawParameters<'a>

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl<'a> Copy for DrawParameters<'a>

impl<'a> Clone for DrawParameters<'a>

fn clone(&self) -> DrawParameters<'a>

fn clone_from(&mut self, source: &Self)