Module glium::draw_parameters
[−]
[src]
Describes miscellaneous parameters to be used when drawing.
Example
let params = glium::DrawParameters { depth_test: glium::draw_parameters::DepthTest::IfLess, depth_write: true, scissor: Some(glium::Rect { bottom: 0, left: 100, width: 100, height: 200 }), .. Default::default() };
The new API
A new API is currently in construction. Example:
let params = glium::DrawParameters::new(&display) .with_rasterizer_discard_if_supported().unwrap() .With_scissor(glium::Rect { bottom: 0, left: 100, width: 100, height: 200 });
Instead of the draw command generating errors because of non-supported parameters, the errors will be generated directly when creating the parameters.
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 retreive 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. |
| ConditionalRendering |
Condition whether to render or not. |
| DrawParameters |
Represents the parameters to use when drawing. |
| DrawParametersBuilder |
This is what the new API of |
| PrimitivesGeneratedQuery |
Query that allows you to know the number of primitives generated by the geometry shader.
Will stay at |
| 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. |
| 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 |
| BlendingFunction |
Function that the GPU will use for blending. |
| 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. |
| 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 |
Functions
| validate |
Checks parameters and panics if something is wrong. |