CF_RenderState¶
Category: graphics
GitHub: cute_graphics.h
A bag of rendering related settings.
| Struct Members | Description |
|---|---|
CF_PrimitiveType primitive_type |
The type of primitive to draw, as in triangles or lines (triangle list by default). See CF_PrimitiveType. |
CF_CullMode cull_mode |
Controls whether or not to cull triangles based on their winding order. See CF_CullMode. |
union |
Controls how the GPU blends pixels together during compositing. blend aliases |
blends[0], so single-target code reads and writes exactly as before. For a multiple- |
|
render-target canvas, set blend_count to the canvas's target_count and fill |
|
blends[1] onward to give each color target its own blend and write mask -- e.g. a |
|
| deferred light-accumulation pass blending additively into target 0 while write-masking | |
| a material target off. See CF_BlendState. | |
int blend_count |
How many entries of blends are meaningful. Zero or one means every color target |
shares blends[0] (exactly the old behavior, so zero-initialized state is unchanged). |
|
| Per-target blend is SDL_GPU-only: the GLES backend has no indexed blend (ES 3.0) and | |
applies blends[0] to every target. |
|
CF_CompareFunction depth_compare |
Defines how to perform depth-testing. Depth testing runs when this is anything other |
than CF_COMPARE_FUNCTION_ALWAYS (the default) or when depth_write_enabled is true -- but |
|
| only if the canvas has a depth buffer. See CF_CompareFunction. | |
bool depth_write_enabled |
True to write depth values into the depth buffer. This alone does not reject anything: |
with the default depth_compare of CF_COMPARE_FUNCTION_ALWAYS you get a depth buffer that |
|
records but never occludes, so set depth_compare (usually CF_COMPARE_FUNCTION_LESS_THAN) |
|
as well. Both are ignored unless the canvas was made with depth_stencil_enable set to true. |
|
| cf_render_state_3d_defaults sets all of this up. | |
CF_StencilParams stencil |
Sets up how to perform (if at all) stencil testing. See CF_StencilParams. |
float depth_bias_constant_factor |
A scalar factor controlling the depth value added to each fragment. |
float depth_bias_clamp |
The maximum depth bias of a fragment. |
float depth_bias_slope_factor |
A scalar factor applied to a fragment's slope in depth calculations. |
bool enable_depth_bias |
True to bias fragment depth values. |
bool enable_depth_clip |
True to enable depth clip, false to enable depth clamp. Clipping discards fragments |
| outside the near/far planes; clamping keeps them, pinned to the nearest plane, which is how | |
| shadow casters are usually kept from being clipped away. Only implemented on the SDL_GPU | |
backend -- GLES has no equivalent of GL_DEPTH_CLAMP and silently ignores this. |
Remarks¶
The CF_RenderState is a big collection of various rendering settings, such as culling mode, blending operations, depth and stencil settings, etc. Altering these on a material always means increasing your draw call count. It's best to try and set these once and leave them alone, though this is not always possible.
Related Pages¶
CF_BlendState
CF_CullMode
CF_StencilParams
cf_material_set_render_state