natiny_material_set_state

C
typedef struct {
    uint32_t blend;   /* NATINY_BLEND_*  */
    uint32_t cull;    /* NATINY_CULL_*   */
    uint32_t depth;   /* NATINY_DEPTH_*  */
} NatinyMaterialState;

void natiny_material_set_state(NatinyMaterial material, const NatinyMaterialState* state);

Sets the material's blend, face-culling and depth-test state.

Parameters

Name Type Description
material NatinyMaterial Material handle
state const NatinyMaterialState* The whole state; every field is read

Blend defines

Define Value Meaning
NATINY_BLEND_ALPHA 0 straight alpha - the default
NATINY_BLEND_NONE 1 overwrite
NATINY_BLEND_ADD 2 additive blending

Cull defines

Define Value Meaning
NATINY_CULL_DEFAULT 0 2D keeps both faces, 3D drops the back
NATINY_CULL_NONE 1 keep both
NATINY_CULL_BACK 2 drop back faces
NATINY_CULL_FRONT 3 drop front faces

Depth defines

Define Value Meaning
NATINY_DEPTH_DEFAULT 0 2D draws ignore depth, 3D draws use it
NATINY_DEPTH_OFF 1 no test, no write
NATINY_DEPTH_ON 2 test and write
NATINY_DEPTH_TEST 3 test, but leave the buffer alone

Example

C
NatinyMaterialState state = {
    NATINY_BLEND_NONE, NATINY_CULL_DEFAULT, NATINY_DEPTH_OFF
};
natiny_material_set_state(material, &state);

Notes

  • A newly created material uses NATINY_BLEND_ALPHA, NATINY_CULL_DEFAULT and NATINY_DEPTH_DEFAULT.
  • Changing the state invalidates the material's pipelines; they are rebuilt on the next draw. Reapplying the same state is a no-op.
  • One blend mode applies to every target written by the shader.