pub struct GlRenderState { /* private fields */ }Expand description
The whole fixed-function state of one draw, as a single Copy value.
The point of bundling these six fields into one struct is that it can
be diffed field by field against the state currently bound, so
WebGl2Backend::apply_state
issues a GL call only for what actually changed. A renderer that
calls enable, depthFunc, depthMask, blendFunc,
blendEquation, cullFace, frontFace, colorMask, scissor, and
viewport unconditionally pays for a dozen redundant calls per draw,
each one a validation check inside the driver.
Implementations§
Source§impl GlRenderState
Implements default construction for the fixed-function state shadow.
impl GlRenderState
Implements default construction for the fixed-function state shadow.
Sourcepub fn context_defaults(width: i32, height: i32) -> GlRenderState
pub fn context_defaults(width: i32, height: i32) -> GlRenderState
Builds the state a freshly created WebGL 2 context is actually in.
Every value here is one the driver has already set up, not a zero
placeholder, and that is the point: seeding the diffing shadow
with the real defaults means the first
WebGl2Backend::apply_state
emits only the calls that genuinely differ from what the driver
already did, rather than a dozen redundant re-assertions. Getting
a single default wrong would instead leave one field permanently
un-applied, because the diff would consider it unchanged forever.
Depth test off, depth write on, LEQUAL once enabled; blending
off; culling off with counter-clockwise front faces; all four
color channels writable; scissor off; viewport covering the given
size.
§Arguments
i32- The viewport width in pixels.i32- The viewport height in pixels.
§Returns
GlRenderState- The state a new context starts in.