Module glium::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

  • 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 effect that the GPU will use for blending.
  • Condition whether to render or not.
  • Represents the depth parameters of a draw command.
  • Represents the parameters to use when drawing.
  • 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.
  • A query that allows you to know the number of samples written to the output during the draw operations where this query was active.
  • Describes the parameters that must be used for the stencil operations when drawing.
  • A query that allows you to know the number of nanoseconds that have elapsed during the draw operations.
  • Query that allows you to know the number of primitives generated by transform feedback.

Enums

  • 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.
  • Function that the GPU will use for blending.
  • Specifies whether the depth value of samples should be clamped to 0.0 or 1.0.
  • The function that the GPU will use to determine whether to write over an existing pixel on the target.
  • Indicates which value to multiply each component with.
  • Defines how the device should render polygons.
  • The vertex to use for flat shading.
  • Error that can happen when creating a query object.
  • The query to use for samples counting.
  • Specifies a hint for the smoothing.
  • Specificies which operation the GPU will do depending on the result of the stencil test.
  • 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

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