Skip to content
modkitv0.2

state.h

#include <modkit/state.h>1 functions · 1 enums · 1 typedefs · 85 macros

Render state and transform helpers.

Provides MK_ prefixed render state constants with hardcoded values matching the GPU backend's stable ABI.

Functions

mk_blend_mode_statefunction

uint64_t mk_blend_mode_state(mk_blend_mode_t mode)

Return the render state for a high-level 2D blend mode.

Invalid values are treated as MK_BLEND_NORMAL.

ParameterTypeDescription
modemk_blend_mode_tValue for mode.

Returns The resulting value.

Enums

mk_blend_modeenum

High-level blend mode presets for 2D drawing.

(Low-level blend is the MK_STATE_BLEND_* flags above.)

ValueDescription
MK_BLEND_NORMALStandard alpha blending.
MK_BLEND_ADDITIVEAdditive blending (good for glow).
MK_BLEND_MULTIPLYMultiply blending.
MK_BLEND_SCREENScreen blending.
MK_BLEND_PREMULTIPLIEDPremultiplied alpha.

Typedefs

mk_blend_mode_ttypedef

typedef enum mk_blend_mode mk_blend_mode_t

High-level blend mode presets for 2D drawing.

(Low-level blend is the MK_STATE_BLEND_* flags above.)

Macros

MK_DISCARD_ALLdefine

MK_DISCARD_ALL

Constant for discard all.

MK_DISCARD_BINDINGSdefine

MK_DISCARD_BINDINGS

Constant for discard bindings.

MK_DISCARD_INDEX_BUFFERdefine

MK_DISCARD_INDEX_BUFFER

Constant for discard index buffer.

MK_DISCARD_INSTANCE_DATAdefine

MK_DISCARD_INSTANCE_DATA

Constant for discard instance data.

MK_DISCARD_NONEdefine

MK_DISCARD_NONE

Constant for discard none.

MK_DISCARD_STATEdefine

MK_DISCARD_STATE

Constant for discard state.

MK_DISCARD_TRANSFORMdefine

MK_DISCARD_TRANSFORM

Constant for discard transform.

MK_DISCARD_VERTEX_STREAMSdefine

MK_DISCARD_VERTEX_STREAMS

Constant for discard vertex streams.

MK_STATE_BLEND_ADDdefine

MK_STATE_BLEND_ADD

Constant for state blend add.

MK_STATE_BLEND_ALPHAdefine

MK_STATE_BLEND_ALPHA

Constant for state blend alpha.

MK_STATE_BLEND_DST_ALPHAdefine

MK_STATE_BLEND_DST_ALPHA

Constant for state blend dst alpha.

MK_STATE_BLEND_DST_COLORdefine

MK_STATE_BLEND_DST_COLOR

Constant for state blend dst color.

MK_STATE_BLEND_FUNCdefine

MK_STATE_BLEND_FUNC(src, dst)

Constant for state blend func.

MK_STATE_BLEND_FUNC_SEPARATEdefine

MK_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)

Constant for state blend func separate.

MK_STATE_BLEND_INV_DST_ALPHAdefine

MK_STATE_BLEND_INV_DST_ALPHA

Constant for state blend inv dst alpha.

MK_STATE_BLEND_INV_DST_COLORdefine

MK_STATE_BLEND_INV_DST_COLOR

Constant for state blend inv dst color.

MK_STATE_BLEND_INV_SRC_ALPHAdefine

MK_STATE_BLEND_INV_SRC_ALPHA

Constant for state blend inv src alpha.

MK_STATE_BLEND_INV_SRC_COLORdefine

MK_STATE_BLEND_INV_SRC_COLOR

Constant for state blend inv src color.

MK_STATE_BLEND_ONEdefine

MK_STATE_BLEND_ONE

Constant for state blend one.

MK_STATE_BLEND_SRC_ALPHAdefine

MK_STATE_BLEND_SRC_ALPHA

Constant for state blend src alpha.

MK_STATE_BLEND_SRC_ALPHA_SATdefine

MK_STATE_BLEND_SRC_ALPHA_SAT

Constant for state blend src alpha sat.

MK_STATE_BLEND_SRC_COLORdefine

MK_STATE_BLEND_SRC_COLOR

Constant for state blend src color.

MK_STATE_BLEND_ZEROdefine

MK_STATE_BLEND_ZERO

Constant for state blend zero.

MK_STATE_CULL_CCWdefine

MK_STATE_CULL_CCW

Constant for state cull ccw.

MK_STATE_CULL_CWdefine

MK_STATE_CULL_CW

Constant for state cull cw.

MK_STATE_DEFAULTdefine

MK_STATE_DEFAULT

Constant for state default.

MK_STATE_DEFAULT_2Ddefine

MK_STATE_DEFAULT_2D

Constant for state default 2D.

MK_STATE_DEFAULT_BLENDdefine

MK_STATE_DEFAULT_BLEND

Constant for state default blend.

MK_STATE_DEPTH_TEST_ALWAYSdefine

MK_STATE_DEPTH_TEST_ALWAYS

Constant for state depth test always.

MK_STATE_DEPTH_TEST_EQUALdefine

MK_STATE_DEPTH_TEST_EQUAL

Constant for state depth test equal.

MK_STATE_DEPTH_TEST_GEQUALdefine

MK_STATE_DEPTH_TEST_GEQUAL

Constant for state depth test gequal.

MK_STATE_DEPTH_TEST_GREATERdefine

MK_STATE_DEPTH_TEST_GREATER

Constant for state depth test greater.

MK_STATE_DEPTH_TEST_LEQUALdefine

MK_STATE_DEPTH_TEST_LEQUAL

Constant for state depth test lequal.

MK_STATE_DEPTH_TEST_LESSdefine

MK_STATE_DEPTH_TEST_LESS

Constant for state depth test less.

MK_STATE_DEPTH_TEST_NEVERdefine

MK_STATE_DEPTH_TEST_NEVER

Constant for state depth test never.

MK_STATE_DEPTH_TEST_NOTEQUALdefine

MK_STATE_DEPTH_TEST_NOTEQUAL

Constant for state depth test notequal.

MK_STATE_FRONT_CCWdefine

MK_STATE_FRONT_CCW

Constant for state front ccw.

MK_STATE_MSAAdefine

MK_STATE_MSAA

Constant for state msaa.

MK_STATE_PT_LINESdefine

MK_STATE_PT_LINES

Constant for state pt lines.

MK_STATE_PT_LINESTRIPdefine

MK_STATE_PT_LINESTRIP

Constant for state pt linestrip.

MK_STATE_PT_POINTSdefine

MK_STATE_PT_POINTS

Constant for state pt points.

MK_STATE_PT_TRISTRIPdefine

MK_STATE_PT_TRISTRIP

Constant for state pt tristrip.

MK_STATE_WRITE_Adefine

MK_STATE_WRITE_A

Constant for state write a.

MK_STATE_WRITE_Bdefine

MK_STATE_WRITE_B

Constant for state write b.

MK_STATE_WRITE_Gdefine

MK_STATE_WRITE_G

Constant for state write g.

MK_STATE_WRITE_MASKdefine

MK_STATE_WRITE_MASK

Constant for state write mask.

MK_STATE_WRITE_Rdefine

MK_STATE_WRITE_R

Constant for state write r.

MK_STATE_WRITE_RGBdefine

MK_STATE_WRITE_RGB

Constant for state write rgb.

MK_STATE_WRITE_Zdefine

MK_STATE_WRITE_Z

Constant for state write z.

MK_STENCIL_FUNC_REFdefine

MK_STENCIL_FUNC_REF(v)

Constant for stencil func ref.

MK_STENCIL_FUNC_RMASKdefine

MK_STENCIL_FUNC_RMASK(v)

Stencil read/compare mask.

Since bgfx 2026-07 this byte is also the stencil WRITE mask, so passing 0 disables stencil writes entirely. Use 0xff (or MK_STENCIL_NONE) when you only mean "compare against everything".

MK_STENCIL_FUNC_WMASKdefine

MK_STENCIL_FUNC_WMASK(v)

Alias making the dual read/write role of the mask byte explicit.

MK_STENCIL_NONEdefine

MK_STENCIL_NONE

Constant for stencil none.

MK_STENCIL_OP_FAIL_S_DECRdefine

MK_STENCIL_OP_FAIL_S_DECR

Constant for stencil op fail s decr.

MK_STENCIL_OP_FAIL_S_DECRSATdefine

MK_STENCIL_OP_FAIL_S_DECRSAT

Constant for stencil op fail s decrsat.

MK_STENCIL_OP_FAIL_S_INCRdefine

MK_STENCIL_OP_FAIL_S_INCR

Constant for stencil op fail s incr.

MK_STENCIL_OP_FAIL_S_INCRSATdefine

MK_STENCIL_OP_FAIL_S_INCRSAT

Constant for stencil op fail s incrsat.

MK_STENCIL_OP_FAIL_S_INVERTdefine

MK_STENCIL_OP_FAIL_S_INVERT

Constant for stencil op fail s invert.

MK_STENCIL_OP_FAIL_S_KEEPdefine

MK_STENCIL_OP_FAIL_S_KEEP

Constant for stencil op fail s keep.

MK_STENCIL_OP_FAIL_S_REPLACEdefine

MK_STENCIL_OP_FAIL_S_REPLACE

Constant for stencil op fail s replace.

MK_STENCIL_OP_FAIL_S_ZEROdefine

MK_STENCIL_OP_FAIL_S_ZERO

Constant for stencil op fail s zero.

MK_STENCIL_OP_FAIL_Z_DECRdefine

MK_STENCIL_OP_FAIL_Z_DECR

Constant for stencil op fail z decr.

MK_STENCIL_OP_FAIL_Z_DECRSATdefine

MK_STENCIL_OP_FAIL_Z_DECRSAT

Constant for stencil op fail z decrsat.

MK_STENCIL_OP_FAIL_Z_INCRdefine

MK_STENCIL_OP_FAIL_Z_INCR

Constant for stencil op fail z incr.

MK_STENCIL_OP_FAIL_Z_INCRSATdefine

MK_STENCIL_OP_FAIL_Z_INCRSAT

Constant for stencil op fail z incrsat.

MK_STENCIL_OP_FAIL_Z_INVERTdefine

MK_STENCIL_OP_FAIL_Z_INVERT

Constant for stencil op fail z invert.

MK_STENCIL_OP_FAIL_Z_KEEPdefine

MK_STENCIL_OP_FAIL_Z_KEEP

Constant for stencil op fail z keep.

MK_STENCIL_OP_FAIL_Z_REPLACEdefine

MK_STENCIL_OP_FAIL_Z_REPLACE

Constant for stencil op fail z replace.

MK_STENCIL_OP_FAIL_Z_ZEROdefine

MK_STENCIL_OP_FAIL_Z_ZERO

Constant for stencil op fail z zero.

MK_STENCIL_OP_PASS_Z_DECRdefine

MK_STENCIL_OP_PASS_Z_DECR

Constant for stencil op pass z decr.

MK_STENCIL_OP_PASS_Z_DECRSATdefine

MK_STENCIL_OP_PASS_Z_DECRSAT

Constant for stencil op pass z decrsat.

MK_STENCIL_OP_PASS_Z_INCRdefine

MK_STENCIL_OP_PASS_Z_INCR

Constant for stencil op pass z incr.

MK_STENCIL_OP_PASS_Z_INCRSATdefine

MK_STENCIL_OP_PASS_Z_INCRSAT

Constant for stencil op pass z incrsat.

MK_STENCIL_OP_PASS_Z_INVERTdefine

MK_STENCIL_OP_PASS_Z_INVERT

Constant for stencil op pass z invert.

MK_STENCIL_OP_PASS_Z_KEEPdefine

MK_STENCIL_OP_PASS_Z_KEEP

Constant for stencil op pass z keep.

MK_STENCIL_OP_PASS_Z_REPLACEdefine

MK_STENCIL_OP_PASS_Z_REPLACE

Constant for stencil op pass z replace.

MK_STENCIL_OP_PASS_Z_ZEROdefine

MK_STENCIL_OP_PASS_Z_ZERO

Constant for stencil op pass z zero.

MK_STENCIL_TEST_ALWAYSdefine

MK_STENCIL_TEST_ALWAYS

Constant for stencil test always.

MK_STENCIL_TEST_EQUALdefine

MK_STENCIL_TEST_EQUAL

Constant for stencil test equal.

MK_STENCIL_TEST_GEQUALdefine

MK_STENCIL_TEST_GEQUAL

Constant for stencil test gequal.

MK_STENCIL_TEST_GREATERdefine

MK_STENCIL_TEST_GREATER

Constant for stencil test greater.

MK_STENCIL_TEST_LEQUALdefine

MK_STENCIL_TEST_LEQUAL

Constant for stencil test lequal.

MK_STENCIL_TEST_LESSdefine

MK_STENCIL_TEST_LESS

Constant for stencil test less.

MK_STENCIL_TEST_NEVERdefine

MK_STENCIL_TEST_NEVER

Constant for stencil test never.

MK_STENCIL_TEST_NOTEQUALdefine

MK_STENCIL_TEST_NOTEQUAL

Constant for stencil test notequal.