Module draw_parameters

Source
Expand description

Describes miscellaneous parameters to be used when drawing.

§Example

let params = glium::DrawParameters {
    depth: glium::Depth {
        test: glium::draw_parameters::DepthTest::IfLess,
        write: true,
        .. Default::default()
    },
    scissor: Some(glium::Rect { bottom: 0, left: 100, width: 100, height: 200 }),
    .. Default::default()
};

§Queries

Query objects allow you to obtain information about the rendering process. For example, a SamplesPassedQuery allows you to know the number of samples that have been drawn.

let query = glium::draw_parameters::SamplesPassedQuery::new(&display).unwrap();
let params = glium::DrawParameters {
    samples_passed_query: Some((&query).into()),
    .. Default::default()
};

After drawing with these parameters, you can retrieve the value inside the query:

let value = query.get();

This operation will consume the query and block until the GPU has finished drawing. Instead, you can also use the query as a condition for drawing:

let params = glium::DrawParameters {
    condition: Some(glium::draw_parameters::ConditionalRendering {
        query: (&query).into(),
        wait: true,
        per_region: true,
    }),
    .. Default::default()
};

If you use conditional rendering, glium will submit the draw command but the GPU will execute it only if the query contains a value different from 0.

§WrongQueryOperation errors

OpenGL puts some restrictions about the usage of queries. If you draw one or several times with a query, then draw without that query, then the query cannot be used again. Trying to draw with it results in a WrongQueryOperation error returned by the draw function.

For the same reasons, as soon as you call is_ready on a query it will stop being usable.

Structs§

AnySamplesPassedQuery
A query type that allows you to know whether any sample has been written to the output during the operations executed with this query.
Blend
Blend effect that the GPU will use for blending.
ConditionalRendering
Condition whether to render or not.
Depth
Represents the depth parameters of a draw command.
DrawParameters
Represents the parameters to use when drawing.
PrimitivesGeneratedQuery
Query that allows you to know the number of primitives generated by the geometry shader. Will stay at 0 if you use it without any active geometry shader.
SamplesPassedQuery
A query that allows you to know the number of samples written to the output during the draw operations where this query was active.
Stencil
Describes the parameters that must be used for the stencil operations when drawing.
TimeElapsedQuery
A query that allows you to know the number of nanoseconds that have elapsed during the draw operations.
TransformFeedbackPrimitivesWrittenQuery
Query that allows you to know the number of primitives generated by transform feedback.

Enums§

BackfaceCullingMode
Describes how triangles should be filtered before the fragment processing. Backface culling is purely an optimization. If you don’t know what this does, just use CullingDisabled.
BlendingFunction
Function that the GPU will use for blending.
DepthClamp
Specifies whether the depth value of samples should be clamped to 0.0 or 1.0.
DepthTest
The function that the GPU will use to determine whether to write over an existing pixel on the target.
LinearBlendingFactor
Indicates which value to multiply each component with.
PolygonMode
Defines how the device should render polygons.
ProvokingVertex
The vertex to use for flat shading.
QueryCreationError
Error that can happen when creating a query object.
SamplesQueryParam
The query to use for samples counting.
Smooth
Specifies a hint for the smoothing.
StencilOperation
Specificies which operation the GPU will do depending on the result of the stencil test.
StencilTest
Specifies which comparison the GPU will do to determine whether a sample passes the stencil test. The general equation is (ref & mask) CMP (stencil & mask), where ref is the reference value (stencil_reference_value_clockwise or stencil_reference_value_counter_clockwise), CMP is the comparison chosen, and stencil is the current value in the stencil buffer.

Functions§

validate
DEPRECATED. Checks parameters and returns an error if something is wrong.