libogc  v2.9.0
Data Structures | Macros | Typedefs | Functions | Variables
gx.h File Reference

GX subsystem. More...

#include <gctypes.h>
#include "lwp.h"
#include "gx_struct.h"
#include "gu.h"

Data Structures

struct  _gx_color
 
struct  _gx_colors10
 
struct  _gx_litobj
 
struct  _gx_texobj
 
struct  _gx_texreg
 
struct  _gx_tlutobj
 
struct  _gx_tlutreg
 
struct  _vtx
 
union  _wgpipe
 
struct  GXFifoObj
 Object describing a graphics FIFO. More...
 
struct  GXFogAdjTbl
 Fog range adjustment parameter table. More...
 
struct  GXTexReg
 
struct  GXVtxAttrFmt
 Structure describing the attribute format for one attribute. More...
 
struct  GXVtxDesc
 Structure describing how a single vertex attribute will be referenced. More...
 

Macros

#define _GX_TF_CTF   0x20
 
#define _GX_TF_ZTF   0x10
 
#define GX_AF_NONE   2
 
#define GX_AF_SPEC   0
 
#define GX_AF_SPOT   1
 
#define GX_ALPHA0   2
 
#define GX_ALPHA1   3
 
#define GX_ALPHA_BUMP   7
 
#define GX_ALPHA_BUMPN   8
 
#define GX_ALWAYS   7
 
#define GX_ANISO_1   0
 
#define GX_ANISO_2   1
 
#define GX_ANISO_4   2
 
#define GX_AOP_AND   0
 
#define GX_AOP_OR   1
 
#define GX_AOP_XNOR   3
 
#define GX_AOP_XOR   2
 
#define GX_BIGTLUT0   16
 
#define GX_BIGTLUT1   17
 
#define GX_BIGTLUT2   18
 
#define GX_BIGTLUT3   19
 
#define GX_BL_DSTALPHA   6
 
#define GX_BL_DSTCLR   GX_BL_SRCCLR
 
#define GX_BL_INVDSTALPHA   7
 
#define GX_BL_INVDSTCLR   GX_BL_INVSRCCLR
 
#define GX_BL_INVSRCALPHA   5
 
#define GX_BL_INVSRCCLR   3
 
#define GX_BL_ONE   1
 
#define GX_BL_SRCALPHA   4
 
#define GX_BL_SRCCLR   2
 
#define GX_BL_ZERO   0
 
#define GX_BLEND   2
 
#define GX_BM_BLEND   1
 
#define GX_BM_LOGIC   2
 
#define GX_BM_NONE   0
 
#define GX_BM_SUBTRACT   3
 
#define GX_CA_A0   1
 
#define GX_CA_A1   2
 
#define GX_CA_A2   3
 
#define GX_CA_APREV   0
 
#define GX_CA_KONST   6
 
#define GX_CA_RASA   5
 
#define GX_CA_TEXA   4
 
#define GX_CA_ZERO   7
 
#define GX_CC_A0   3
 
#define GX_CC_A1   5
 
#define GX_CC_A2   7
 
#define GX_CC_APREV   1
 
#define GX_CC_C0   2
 
#define GX_CC_C1   4
 
#define GX_CC_C2   6
 
#define GX_CC_CPREV   0
 
#define GX_CC_HALF   13
 
#define GX_CC_KONST   14
 
#define GX_CC_ONE   12
 
#define GX_CC_RASA   11
 
#define GX_CC_RASC   10
 
#define GX_CC_TEXA   9
 
#define GX_CC_TEXC   8
 
#define GX_CC_ZERO   15
 
#define GX_CH_ALPHA   3
 
#define GX_CH_BLUE   2
 
#define GX_CH_GREEN   1
 
#define GX_CH_RED   0
 
#define GX_CLAMP   0
 
#define GX_CLAMP_BOTTOM   2
 
#define GX_CLAMP_NONE   0
 
#define GX_CLAMP_TOP   1
 
#define GX_CLIP_DISABLE   1
 
#define GX_CLIP_ENABLE   0
 
#define GX_CLR_RGB   0
 
#define GX_CLR_RGBA   1
 
#define GX_COLOR0   0
 
#define GX_COLOR0A0   4
 
#define GX_COLOR1   1
 
#define GX_COLOR1A1   5
 
#define GX_COLORNULL   0xff
 
#define GX_COLORZERO   6
 
#define GX_COPY_INTLC_EVEN   2
 
#define GX_COPY_INTLC_ODD   3
 
#define GX_COPY_PROGRESSIVE   0
 
#define GX_CS_DIVIDE_2   3
 
#define GX_CS_SCALE_1   0
 
#define GX_CS_SCALE_2   1
 
#define GX_CS_SCALE_4   2
 
#define GX_CTF_A8   (0x7|_GX_TF_CTF)
 
#define GX_CTF_B8   (0xA|_GX_TF_CTF)
 
#define GX_CTF_G8   (0x9|_GX_TF_CTF)
 
#define GX_CTF_GB8   (0xC|_GX_TF_CTF)
 
#define GX_CTF_R4   (0x0|_GX_TF_CTF)
 
#define GX_CTF_R8   (0x8|_GX_TF_CTF)
 
#define GX_CTF_RA4   (0x2|_GX_TF_CTF)
 
#define GX_CTF_RA8   (0x3|_GX_TF_CTF)
 
#define GX_CTF_RG8   (0xB|_GX_TF_CTF)
 
#define GX_CTF_YUVA8   (0x6|_GX_TF_CTF)
 
#define GX_CTF_Z16L   (0xC|_GX_TF_ZTF|_GX_TF_CTF)
 
#define GX_CTF_Z4   (0x0|_GX_TF_ZTF|_GX_TF_CTF)
 
#define GX_CTF_Z8L   (0xA|_GX_TF_ZTF|_GX_TF_CTF)
 
#define GX_CTF_Z8M   (0x9|_GX_TF_ZTF|_GX_TF_CTF)
 
#define GX_CULL_ALL   3
 
#define GX_CULL_BACK   2
 
#define GX_CULL_FRONT   1
 
#define GX_CULL_NONE   0
 
#define GX_DA_GENTLE   1
 
#define GX_DA_MEDIUM   2
 
#define GX_DA_OFF   0
 
#define GX_DA_STEEP   3
 
#define GX_DECAL   1
 
#define GX_DF_CLAMP   2
 
#define GX_DF_NONE   0
 
#define GX_DF_SIGNED   1
 
#define GX_DIRECT   1
 
#define GX_DISABLE   0
 
#define GX_DTTIDENTITY   125
 
#define GX_DTTMTX0   64
 
#define GX_DTTMTX1   67
 
#define GX_DTTMTX10   94
 
#define GX_DTTMTX11   97
 
#define GX_DTTMTX12   100
 
#define GX_DTTMTX13   103
 
#define GX_DTTMTX14   106
 
#define GX_DTTMTX15   109
 
#define GX_DTTMTX16   112
 
#define GX_DTTMTX17   115
 
#define GX_DTTMTX18   118
 
#define GX_DTTMTX19   121
 
#define GX_DTTMTX2   70
 
#define GX_DTTMTX3   73
 
#define GX_DTTMTX4   76
 
#define GX_DTTMTX5   79
 
#define GX_DTTMTX6   82
 
#define GX_DTTMTX7   85
 
#define GX_DTTMTX8   88
 
#define GX_DTTMTX9   91
 
#define GX_ENABLE   1
 
#define GX_EQUAL   2
 
#define GX_F32   4
 
#define GX_FALSE   0
 
#define GX_FIFO_HIWATERMARK   (16*1024)
 
#define GX_FIFO_MINSIZE   (64*1024)
 
#define GX_FIFO_OBJSIZE   128
 
#define GX_FOG_EXP   GX_FOG_PERSP_EXP
 
#define GX_FOG_EXP2   GX_FOG_PERSP_EXP2
 
#define GX_FOG_LIN   GX_FOG_PERSP_LIN
 
#define GX_FOG_NONE   0
 
#define GX_FOG_ORTHO_EXP   12
 
#define GX_FOG_ORTHO_EXP2   13
 
#define GX_FOG_ORTHO_LIN   10
 
#define GX_FOG_ORTHO_REVEXP   14
 
#define GX_FOG_ORTHO_REVEXP2   15
 
#define GX_FOG_PERSP_EXP   4
 
#define GX_FOG_PERSP_EXP2   5
 
#define GX_FOG_PERSP_LIN   2
 
#define GX_FOG_PERSP_REVEXP   6
 
#define GX_FOG_PERSP_REVEXP2   7
 
#define GX_FOG_REVEXP   GX_FOG_PERSP_REVEXP
 
#define GX_FOG_REVEXP2   GX_FOG_PERSP_REVEXP2
 
#define GX_GEQUAL   6
 
#define GX_GM_1_0   0
 
#define GX_GM_1_7   1
 
#define GX_GM_2_2   2
 
#define GX_GREATER   4
 
#define GX_IDENTITY   60
 
#define GX_INDEX16   3
 
#define GX_INDEX8   2
 
#define GX_INDTEXSTAGE0   0
 
#define GX_INDTEXSTAGE1   1
 
#define GX_INDTEXSTAGE2   2
 
#define GX_INDTEXSTAGE3   3
 
#define GX_InitLightDirv(lo, vec)    (GX_InitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
 Sets the direction of a light in the light object using a vector structure. More...
 
#define GX_InitLightPosv(lo, vec)    (GX_InitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
 Sets the position of the light in the light object using a vector structure. More...
 
#define GX_InitLightShininess(lobj, shininess)
 Sets shininess of a per-vertex specular light. More...
 
#define GX_InitSpecularDirHAv(lo, vec0, vec1)
 Sets the direction and half-angle vector of a specular light in the light object using a vector. More...
 
#define GX_InitSpecularDirv(lo, vec)    (GX_InitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
 Sets the direction of a specular light in the light object using a vector. More...
 
#define GX_ITB_NONE   0
 
#define GX_ITB_S   1
 
#define GX_ITB_ST   3
 
#define GX_ITB_STU   7
 
#define GX_ITB_SU   5
 
#define GX_ITB_T   2
 
#define GX_ITB_TU   6
 
#define GX_ITB_U   4
 
#define GX_ITBA_OFF   0
 
#define GX_ITBA_S   1
 
#define GX_ITBA_T   2
 
#define GX_ITBA_U   3
 
#define GX_ITF_3   3
 
#define GX_ITF_4   2
 
#define GX_ITF_5   1
 
#define GX_ITF_8   0
 
#define GX_ITM_0   1
 
#define GX_ITM_1   2
 
#define GX_ITM_2   3
 
#define GX_ITM_OFF   0
 
#define GX_ITM_S0   5
 
#define GX_ITM_S1   6
 
#define GX_ITM_S2   7
 
#define GX_ITM_T0   9
 
#define GX_ITM_T1   10
 
#define GX_ITM_T2   11
 
#define GX_ITS_1   0
 
#define GX_ITS_128   7
 
#define GX_ITS_16   4
 
#define GX_ITS_2   1
 
#define GX_ITS_256   8
 
#define GX_ITS_32   5
 
#define GX_ITS_4   2
 
#define GX_ITS_64   6
 
#define GX_ITS_8   3
 
#define GX_ITW_0   6
 
#define GX_ITW_128   2
 
#define GX_ITW_16   5
 
#define GX_ITW_256   1
 
#define GX_ITW_32   4
 
#define GX_ITW_64   3
 
#define GX_ITW_OFF   0
 
#define GX_KCOLOR0   0
 
#define GX_KCOLOR1   1
 
#define GX_KCOLOR2   2
 
#define GX_KCOLOR3   3
 
#define GX_KCOLOR_MAX   4
 
#define GX_LEQUAL   3
 
#define GX_LESS   1
 
#define GX_LIGHT0   0x001
 
#define GX_LIGHT1   0x002
 
#define GX_LIGHT2   0x004
 
#define GX_LIGHT3   0x008
 
#define GX_LIGHT4   0x010
 
#define GX_LIGHT5   0x020
 
#define GX_LIGHT6   0x040
 
#define GX_LIGHT7   0x080
 
#define GX_LIGHTARRAY   24
 
#define GX_LIGHTNULL   0x000
 
#define GX_LIN_MIP_LIN   5
 
#define GX_LIN_MIP_NEAR   3
 
#define GX_LINEAR   1
 
#define GX_LINES   0xA8
 
#define GX_LINESTRIP   0xB0
 
#define GX_LO_AND   1
 
#define GX_LO_CLEAR   0
 
#define GX_LO_COPY   3
 
#define GX_LO_EQUIV   9
 
#define GX_LO_INV   10
 
#define GX_LO_INVAND   4
 
#define GX_LO_INVCOPY   12
 
#define GX_LO_INVOR   13
 
#define GX_LO_NAND   14
 
#define GX_LO_NOOP   5
 
#define GX_LO_NOR   8
 
#define GX_LO_OR   7
 
#define GX_LO_REVAND   2
 
#define GX_LO_REVOR   11
 
#define GX_LO_SET   15
 
#define GX_LO_XOR   6
 
#define GX_MAX_ALPHAOP   4
 
#define GX_MAX_ANISOTROPY   3
 
#define GX_MAX_BLENDMODE   4
 
#define GX_MAX_INDTEXSTAGE   4
 
#define GX_MAX_ITBALPHA   4
 
#define GX_MAX_ITBIAS   8
 
#define GX_MAX_ITFORMAT   4
 
#define GX_MAX_ITSCALE   9
 
#define GX_MAX_ITWRAP   7
 
#define GX_MAX_TEVBIAS   3
 
#define GX_MAX_TEVCLAMPMODE   4
 
#define GX_MAX_TEVREG   4
 
#define GX_MAX_TEVSCALE   4
 
#define GX_MAX_TEVSTAGE   16
 
#define GX_MAX_TEVSWAP   4
 
#define GX_MAX_TEXMAP   8
 
#define GX_MAX_TEXOFFSET   6
 
#define GX_MAX_VTXATTRFMT   GX_VA_MAXATTR
 
#define GX_MAX_VTXATTRFMT_LISTSIZE   (GX_VA_MAXATTR+1)
 
#define GX_MAX_VTXDESC   GX_VA_MAXATTR
 
#define GX_MAX_VTXDESC_LISTSIZE   (GX_VA_MAXATTR+1)
 
#define GX_MAX_Z24   0x00ffffff
 
#define GX_MAX_ZTEXOP   3
 
#define GX_MAXCOORD   0x8
 
#define GX_MAXLIGHT   0x100
 
#define GX_MAXTEXWRAPMODE   3
 
#define GX_MAXVTXFMT   8
 
#define GX_MIRROR   2
 
#define GX_MODULATE   0
 
#define GX_MT_DL_SAVE_CTX   2
 
#define GX_MT_NULL   0
 
#define GX_MT_XF_FLUSH   1
 
#define GX_MTX2x4   1
 
#define GX_MTX3x4   0
 
#define GX_NEAR   0
 
#define GX_NEAR_MIP_LIN   4
 
#define GX_NEAR_MIP_NEAR   2
 
#define GX_NEQUAL   5
 
#define GX_NEVER   0
 
#define GX_NONE   0
 
#define GX_NRM_NBT   1
 
#define GX_NRM_NBT3   2
 
#define GX_NRM_XYZ   0
 
#define GX_NRMMTXARRAY   22
 
#define GX_ORTHOGRAPHIC   1
 
#define GX_PASSCLR   4
 
#define GX_PERF0_AVG_QUAD_CNT   33
 
#define GX_PERF0_CLIP_CLKS   2
 
#define GX_PERF0_CLIP_RATIO   10
 
#define GX_PERF0_CLIP_VTX   1
 
#define GX_PERF0_CLOCKS   34
 
#define GX_PERF0_NONE   35
 
#define GX_PERF0_QUAD_0CVG   27
 
#define GX_PERF0_QUAD_1CVG   29
 
#define GX_PERF0_QUAD_2CVG   30
 
#define GX_PERF0_QUAD_3CVG   31
 
#define GX_PERF0_QUAD_4CVG   32
 
#define GX_PERF0_QUAD_NON0CVG   28
 
#define GX_PERF0_TRIANGLES   11
 
#define GX_PERF0_TRIANGLES_0CLR   24
 
#define GX_PERF0_TRIANGLES_0TEX   15
 
#define GX_PERF0_TRIANGLES_1CLR   25
 
#define GX_PERF0_TRIANGLES_1TEX   16
 
#define GX_PERF0_TRIANGLES_2CLR   26
 
#define GX_PERF0_TRIANGLES_2TEX   17
 
#define GX_PERF0_TRIANGLES_3TEX   18
 
#define GX_PERF0_TRIANGLES_4TEX   19
 
#define GX_PERF0_TRIANGLES_5TEX   20
 
#define GX_PERF0_TRIANGLES_6TEX   21
 
#define GX_PERF0_TRIANGLES_7TEX   22
 
#define GX_PERF0_TRIANGLES_8TEX   23
 
#define GX_PERF0_TRIANGLES_CULLED   12
 
#define GX_PERF0_TRIANGLES_PASSED   13
 
#define GX_PERF0_TRIANGLES_SCISSORED   14
 
#define GX_PERF0_VERTICES   0
 
#define GX_PERF0_XF_BOT_CLKS   7
 
#define GX_PERF0_XF_LIT_CLKS   6
 
#define GX_PERF0_XF_REGLD_CLKS   8
 
#define GX_PERF0_XF_REGRD_CLKS   9
 
#define GX_PERF0_XF_WAIT_IN   3
 
#define GX_PERF0_XF_WAIT_OUT   4
 
#define GX_PERF0_XF_XFRM_CLKS   5
 
#define GX_PERF1_CALL_REQ   18
 
#define GX_PERF1_CLOCKS   21
 
#define GX_PERF1_CP_ALL_REQ   20
 
#define GX_PERF1_FIFO_REQ   17
 
#define GX_PERF1_NONE   22
 
#define GX_PERF1_TC_CHECK1_2   4
 
#define GX_PERF1_TC_CHECK3_4   5
 
#define GX_PERF1_TC_CHECK5_6   6
 
#define GX_PERF1_TC_CHECK7_8   7
 
#define GX_PERF1_TC_MISS   8
 
#define GX_PERF1_TEXELS   0
 
#define GX_PERF1_TX_IDLE   1
 
#define GX_PERF1_TX_MEMSTALL   3
 
#define GX_PERF1_TX_REGS   2
 
#define GX_PERF1_VC_ALL_STALLS   15
 
#define GX_PERF1_VC_ELEMQ_FULL   9
 
#define GX_PERF1_VC_MEMREQ_FULL   11
 
#define GX_PERF1_VC_MISS_REQ   19
 
#define GX_PERF1_VC_MISSQ_FULL   10
 
#define GX_PERF1_VC_MISSREP_FULL   13
 
#define GX_PERF1_VC_STATUS7   12
 
#define GX_PERF1_VC_STREAMBUF_LOW   14
 
#define GX_PERF1_VERTICES   16
 
#define GX_PERSPECTIVE   0
 
#define GX_PF_RGB565_Z16   2
 
#define GX_PF_RGB8_Z24   0
 
#define GX_PF_RGBA6_Z24   1
 
#define GX_PF_U8   5
 
#define GX_PF_V8   6
 
#define GX_PF_Y8   4
 
#define GX_PF_YUV420   7
 
#define GX_PF_Z24   3
 
#define GX_PNMTX0   0
 
#define GX_PNMTX1   3
 
#define GX_PNMTX2   6
 
#define GX_PNMTX3   9
 
#define GX_PNMTX4   12
 
#define GX_PNMTX5   15
 
#define GX_PNMTX6   18
 
#define GX_PNMTX7   21
 
#define GX_PNMTX8   24
 
#define GX_PNMTX9   27
 
#define GX_POINTS   0xB8
 
#define GX_POS_XY   0
 
#define GX_POS_XYZ   1
 
#define GX_POSMTXARRAY   21
 
#define GX_QUADS   0x80
 
#define GX_READ_00   0
 
#define GX_READ_FF   1
 
#define GX_READ_NONE   2
 
#define GX_REPEAT   1
 
#define GX_REPLACE   3
 
#define GX_RGB565   0
 
#define GX_RGB8   1
 
#define GX_RGBA4   3
 
#define GX_RGBA6   4
 
#define GX_RGBA8   5
 
#define GX_RGBX8   2
 
#define GX_S16   3
 
#define GX_S8   1
 
#define GX_SP_COS   2
 
#define GX_SP_COS2   3
 
#define GX_SP_FLAT   1
 
#define GX_SP_OFF   0
 
#define GX_SP_RING1   5
 
#define GX_SP_RING2   6
 
#define GX_SP_SHARP   4
 
#define GX_SRC_REG   0
 
#define GX_SRC_VTX   1
 
#define GX_TB_ADDHALF   1
 
#define GX_TB_SUBHALF   2
 
#define GX_TB_ZERO   0
 
#define GX_TC_EQ   2
 
#define GX_TC_GE   1
 
#define GX_TC_LE   3
 
#define GX_TC_LINEAR   0
 
#define GX_TEV_ADD   0
 
#define GX_TEV_COMP_A8_EQ   GX_TEV_COMP_RGB8_EQ
 
#define GX_TEV_COMP_A8_GT   GX_TEV_COMP_RGB8_GT
 
#define GX_TEV_COMP_BGR24_EQ   13
 
#define GX_TEV_COMP_BGR24_GT   12
 
#define GX_TEV_COMP_GR16_EQ   11
 
#define GX_TEV_COMP_GR16_GT   10
 
#define GX_TEV_COMP_R8_EQ   9
 
#define GX_TEV_COMP_R8_GT   8
 
#define GX_TEV_COMP_RGB8_EQ   15
 
#define GX_TEV_COMP_RGB8_GT   14
 
#define GX_TEV_KASEL_1   0x00
 
#define GX_TEV_KASEL_1_2   0x04
 
#define GX_TEV_KASEL_1_4   0x06
 
#define GX_TEV_KASEL_1_8   0x07
 
#define GX_TEV_KASEL_3_4   0x02
 
#define GX_TEV_KASEL_3_8   0x05
 
#define GX_TEV_KASEL_5_8   0x03
 
#define GX_TEV_KASEL_7_8   0x01
 
#define GX_TEV_KASEL_K0_A   0x1C
 
#define GX_TEV_KASEL_K0_B   0x18
 
#define GX_TEV_KASEL_K0_G   0x14
 
#define GX_TEV_KASEL_K0_R   0x10
 
#define GX_TEV_KASEL_K1_A   0x1D
 
#define GX_TEV_KASEL_K1_B   0x19
 
#define GX_TEV_KASEL_K1_G   0x15
 
#define GX_TEV_KASEL_K1_R   0x11
 
#define GX_TEV_KASEL_K2_A   0x1E
 
#define GX_TEV_KASEL_K2_B   0x1A
 
#define GX_TEV_KASEL_K2_G   0x16
 
#define GX_TEV_KASEL_K2_R   0x12
 
#define GX_TEV_KASEL_K3_A   0x1F
 
#define GX_TEV_KASEL_K3_B   0x1B
 
#define GX_TEV_KASEL_K3_G   0x17
 
#define GX_TEV_KASEL_K3_R   0x13
 
#define GX_TEV_KCSEL_1   0x00
 
#define GX_TEV_KCSEL_1_2   0x04
 
#define GX_TEV_KCSEL_1_4   0x06
 
#define GX_TEV_KCSEL_1_8   0x07
 
#define GX_TEV_KCSEL_3_4   0x02
 
#define GX_TEV_KCSEL_3_8   0x05
 
#define GX_TEV_KCSEL_5_8   0x03
 
#define GX_TEV_KCSEL_7_8   0x01
 
#define GX_TEV_KCSEL_K0   0x0C
 
#define GX_TEV_KCSEL_K0_A   0x1C
 
#define GX_TEV_KCSEL_K0_B   0x18
 
#define GX_TEV_KCSEL_K0_G   0x14
 
#define GX_TEV_KCSEL_K0_R   0x10
 
#define GX_TEV_KCSEL_K1   0x0D
 
#define GX_TEV_KCSEL_K1_A   0x1D
 
#define GX_TEV_KCSEL_K1_B   0x19
 
#define GX_TEV_KCSEL_K1_G   0x15
 
#define GX_TEV_KCSEL_K1_R   0x11
 
#define GX_TEV_KCSEL_K2   0x0E
 
#define GX_TEV_KCSEL_K2_A   0x1E
 
#define GX_TEV_KCSEL_K2_B   0x1A
 
#define GX_TEV_KCSEL_K2_G   0x16
 
#define GX_TEV_KCSEL_K2_R   0x12
 
#define GX_TEV_KCSEL_K3   0x0F
 
#define GX_TEV_KCSEL_K3_A   0x1F
 
#define GX_TEV_KCSEL_K3_B   0x1B
 
#define GX_TEV_KCSEL_K3_G   0x17
 
#define GX_TEV_KCSEL_K3_R   0x13
 
#define GX_TEV_SUB   1
 
#define GX_TEV_SWAP0   0
 
#define GX_TEV_SWAP1   1
 
#define GX_TEV_SWAP2   2
 
#define GX_TEV_SWAP3   3
 
#define GX_TEVPREV   0
 
#define GX_TEVREG0   1
 
#define GX_TEVREG1   2
 
#define GX_TEVREG2   3
 
#define GX_TEVSTAGE0   0
 
#define GX_TEVSTAGE1   1
 
#define GX_TEVSTAGE10   10
 
#define GX_TEVSTAGE11   11
 
#define GX_TEVSTAGE12   12
 
#define GX_TEVSTAGE13   13
 
#define GX_TEVSTAGE14   14
 
#define GX_TEVSTAGE15   15
 
#define GX_TEVSTAGE2   2
 
#define GX_TEVSTAGE3   3
 
#define GX_TEVSTAGE4   4
 
#define GX_TEVSTAGE5   5
 
#define GX_TEVSTAGE6   6
 
#define GX_TEVSTAGE7   7
 
#define GX_TEVSTAGE8   8
 
#define GX_TEVSTAGE9   9
 
#define GX_TEX_S   0
 
#define GX_TEX_ST   1
 
#define GX_TEXCACHE_128K   1
 
#define GX_TEXCACHE_32K   0
 
#define GX_TEXCACHE_512K   2
 
#define GX_TEXCACHE_NONE   3
 
#define GX_TEXCOORD0   0x0
 
#define GX_TEXCOORD1   0x1
 
#define GX_TEXCOORD2   0x2
 
#define GX_TEXCOORD3   0x3
 
#define GX_TEXCOORD4   0x4
 
#define GX_TEXCOORD5   0x5
 
#define GX_TEXCOORD6   0x6
 
#define GX_TEXCOORD7   0x7
 
#define GX_TEXCOORDNULL   0xff
 
#define GX_TEXMAP0   0
 
#define GX_TEXMAP1   1
 
#define GX_TEXMAP2   2
 
#define GX_TEXMAP3   3
 
#define GX_TEXMAP4   4
 
#define GX_TEXMAP5   5
 
#define GX_TEXMAP6   6
 
#define GX_TEXMAP7   7
 
#define GX_TEXMAP_DISABLE   0x100
 
#define GX_TEXMAP_NULL   0xff
 
#define GX_TEXMTX0   30
 
#define GX_TEXMTX1   33
 
#define GX_TEXMTX2   36
 
#define GX_TEXMTX3   39
 
#define GX_TEXMTX4   42
 
#define GX_TEXMTX5   45
 
#define GX_TEXMTX6   48
 
#define GX_TEXMTX7   51
 
#define GX_TEXMTX8   54
 
#define GX_TEXMTX9   57
 
#define GX_TEXMTXARRAY   23
 
#define GX_TF_A8   GX_CTF_A8
 
#define GX_TF_CI14   0xa
 
#define GX_TF_CI4   0x8
 
#define GX_TF_CI8   0x9
 
#define GX_TF_CMPR   0xE
 
#define GX_TF_I4   0x0
 
#define GX_TF_I8   0x1
 
#define GX_TF_IA4   0x2
 
#define GX_TF_IA8   0x3
 
#define GX_TF_RGB565   0x4
 
#define GX_TF_RGB5A3   0x5
 
#define GX_TF_RGBA8   0x6
 
#define GX_TF_Z16   (0x3|_GX_TF_ZTF)
 
#define GX_TF_Z24X8   (0x6|_GX_TF_ZTF)
 
#define GX_TF_Z8   (0x1|_GX_TF_ZTF)
 
#define GX_TG_BINRM   2
 
#define GX_TG_BUMP0   2
 
#define GX_TG_BUMP1   3
 
#define GX_TG_BUMP2   4
 
#define GX_TG_BUMP3   5
 
#define GX_TG_BUMP4   6
 
#define GX_TG_BUMP5   7
 
#define GX_TG_BUMP6   8
 
#define GX_TG_BUMP7   9
 
#define GX_TG_COLOR0   19
 
#define GX_TG_COLOR1   20
 
#define GX_TG_MTX2x4   1
 
#define GX_TG_MTX3x4   0
 
#define GX_TG_NRM   1
 
#define GX_TG_POS   0
 
#define GX_TG_SRTG   10
 
#define GX_TG_TANGENT   3
 
#define GX_TG_TEX0   4
 
#define GX_TG_TEX1   5
 
#define GX_TG_TEX2   6
 
#define GX_TG_TEX3   7
 
#define GX_TG_TEX4   8
 
#define GX_TG_TEX5   9
 
#define GX_TG_TEX6   10
 
#define GX_TG_TEX7   11
 
#define GX_TG_TEXCOORD0   12
 
#define GX_TG_TEXCOORD1   13
 
#define GX_TG_TEXCOORD2   14
 
#define GX_TG_TEXCOORD3   15
 
#define GX_TG_TEXCOORD4   16
 
#define GX_TG_TEXCOORD5   17
 
#define GX_TG_TEXCOORD6   18
 
#define GX_TL_IA8   0x00
 
#define GX_TL_RGB565   0x01
 
#define GX_TL_RGB5A3   0x02
 
#define GX_TLUT0   0
 
#define GX_TLUT1   1
 
#define GX_TLUT10   10
 
#define GX_TLUT11   11
 
#define GX_TLUT12   12
 
#define GX_TLUT13   13
 
#define GX_TLUT14   14
 
#define GX_TLUT15   15
 
#define GX_TLUT2   2
 
#define GX_TLUT3   3
 
#define GX_TLUT4   4
 
#define GX_TLUT5   5
 
#define GX_TLUT6   6
 
#define GX_TLUT7   7
 
#define GX_TLUT8   8
 
#define GX_TLUT9   9
 
#define GX_TLUT_128   8
 
#define GX_TLUT_16   1
 
#define GX_TLUT_16K   1024
 
#define GX_TLUT_1K   64
 
#define GX_TLUT_256   16
 
#define GX_TLUT_2K   128
 
#define GX_TLUT_32   2
 
#define GX_TLUT_4K   256
 
#define GX_TLUT_512   32
 
#define GX_TLUT_64   4
 
#define GX_TLUT_8K   512
 
#define GX_TO_EIGHTH   2
 
#define GX_TO_FOURTH   3
 
#define GX_TO_HALF   4
 
#define GX_TO_ONE   5
 
#define GX_TO_SIXTEENTH   1
 
#define GX_TO_ZERO   0
 
#define GX_TRIANGLEFAN   0xA0
 
#define GX_TRIANGLES   0x90
 
#define GX_TRIANGLESTRIP   0x98
 
#define GX_TRUE   1
 
#define GX_U16   2
 
#define GX_U8   0
 
#define GX_VA_CLR0   11
 
#define GX_VA_CLR1   12
 
#define GX_VA_MAXATTR   26
 
#define GX_VA_NBT   25
 
#define GX_VA_NRM   10
 
#define GX_VA_NULL   0xff
 
#define GX_VA_POS   9
 
#define GX_VA_PTNMTXIDX   0
 
#define GX_VA_TEX0   13
 
#define GX_VA_TEX0MTXIDX   1
 
#define GX_VA_TEX1   14
 
#define GX_VA_TEX1MTXIDX   2
 
#define GX_VA_TEX2   15
 
#define GX_VA_TEX2MTXIDX   3
 
#define GX_VA_TEX3   16
 
#define GX_VA_TEX3MTXIDX   4
 
#define GX_VA_TEX4   17
 
#define GX_VA_TEX4MTXIDX   5
 
#define GX_VA_TEX5   18
 
#define GX_VA_TEX5MTXIDX   6
 
#define GX_VA_TEX6   19
 
#define GX_VA_TEX6MTXIDX   7
 
#define GX_VA_TEX7   20
 
#define GX_VA_TEX7MTXIDX   8
 
#define GX_VC_ALL   15
 
#define GX_VC_CLR0   2
 
#define GX_VC_CLR1   3
 
#define GX_VC_NRM   1
 
#define GX_VC_POS   0
 
#define GX_VC_TEX0   4
 
#define GX_VC_TEX1   5
 
#define GX_VC_TEX2   6
 
#define GX_VC_TEX3   7
 
#define GX_VC_TEX4   8
 
#define GX_VC_TEX5   9
 
#define GX_VC_TEX6   10
 
#define GX_VC_TEX7   11
 
#define GX_VTXFMT0   0
 
#define GX_VTXFMT1   1
 
#define GX_VTXFMT2   2
 
#define GX_VTXFMT3   3
 
#define GX_VTXFMT4   4
 
#define GX_VTXFMT5   5
 
#define GX_VTXFMT6   6
 
#define GX_VTXFMT7   7
 
#define GX_XF_FLUSH_NONE   0
 
#define GX_XF_FLUSH_SAFE   1
 
#define GX_ZC_FAR   3
 
#define GX_ZC_LINEAR   0
 
#define GX_ZC_MID   2
 
#define GX_ZC_NEAR   1
 
#define GX_ZT_ADD   1
 
#define GX_ZT_DISABLE   0
 
#define GX_ZT_REPLACE   2
 

Typedefs

typedef void(* GXBreakPtCallback) (void)
 function pointer typedef for the GP breakpoint-token callback
 
typedef struct _gx_color GXColor
 Structure used to pass colors to some GX functions.
 
typedef struct _gx_colors10 GXColorS10
 Structure used to pass signed 10-bit colors to some GX functions.
 
typedef void(* GXDrawDoneCallback) (void)
 function pointer typedef for the GP drawdone-token callback
 
typedef void(* GXDrawSyncCallback) (u16 token)
 function pointer typedef for the drawsync-token callback More...
 
typedef struct _gx_litobj GXLightObj
 Object containing information on a light. More...
 
typedef struct _gx_texobj GXTexObj
 Object containing information about a texture. More...
 
typedef struct _gx_texreg GXTexRegion
 Object containing information on a texture cache region. More...
 
typedef GXTexRegion *(* GXTexRegionCallback) (GXTexObj *obj, u8 mapid)
 function pointer typedef for the texture region callback More...
 
typedef struct _gx_tlutobj GXTlutObj
 Object containing information on a TLUT. More...
 
typedef struct _gx_tlutreg GXTlutRegion
 Object containing information on a TLUT cache region. More...
 
typedef GXTlutRegion *(* GXTlutRegionCallback) (u32 tlut_name)
 function pointer typedef for the TLUT region callback More...
 
typedef struct _vtx Vtx
 
typedef union _wgpipe WGPipe
 

Functions

void GX_AbortFrame (void)
 Aborts the current frame. More...
 
void GX_AdjustForOverscan (GXRModeObj *rmin, GXRModeObj *rmout, u16 hor, u16 ver)
 Takes a given render mode and returns a version that is reduced in size to account for overscan. More...
 
void GX_Begin (u8 primitve, u8 vtxfmt, u16 vtxcnt)
 Begins drawing of a graphics primitive. More...
 
void GX_BeginDispList (void *list, u32 size)
 Begins a display list and disables writes to the FIFO currently attached to the CPU. More...
 
void GX_CallDispList (void *list, u32 nbytes)
 Causes the GP to execute graphics commands from the display list instead of from the GP FIFO. More...
 
void GX_ClearBoundingBox (void)
 Clears the bounding box values before a new image is drawn. More...
 
void GX_ClearGPMetric (void)
 Clears the two virtual GP performance counters to zero. More...
 
void GX_ClearVCacheMetric (void)
 Clears the Vertex Cache performance counter. More...
 
void GX_ClearVtxDesc (void)
 Clears all vertex attributes of the current vertex descriptor to GX_NONE. More...
 
void GX_CopyDisp (void *dest, u8 clear)
 Copies the embedded framebuffer (EFB) to the external framebuffer(XFB) in main memory. More...
 
void GX_CopyTex (void *dest, u8 clear)
 Copies the embedded framebuffer (EFB) to the texture image buffer dest in main memory. More...
 
void GX_DisableBreakPt (void)
 Allows reads from the FIFO currently attached to the Graphics Processor (GP) to resume. More...
 
void GX_DrawDone (void)
 Sends a DrawDone command to the GP and stalls until its subsequent execution. More...
 
void GX_EnableBreakPt (void *break_pt)
 Sets a breakpoint that causes the GP to halt when encountered. More...
 
void GX_EnableTexOffsets (u8 coord, u8 line_enable, u8 point_enable)
 Enables a special texture offset feature for points and lines. More...
 
u32 GX_EndDispList (void)
 Ends a display list and resumes writing graphics commands to the CPU FIFO. More...
 
void GX_Flush (void)
 Flushes all commands to the GP. More...
 
void GX_GetCPUFifo (GXFifoObj *fifo)
 Copies the information from the currently attached CPU FIFO into fifo. More...
 
lwp_t GX_GetCurrentGXThread (void)
 Returns the current GX thread. More...
 
u16 GX_GetDrawSync (void)
 Returns the value of the token register, which is written using the GX_SetDrawSync() function. More...
 
void * GX_GetFifoBase (const GXFifoObj *fifo)
 Get the base address for a given fifo. More...
 
u32 GX_GetFifoCount (const GXFifoObj *fifo)
 Returns number of cache lines in the FIFO. More...
 
void GX_GetFifoPtrs (const GXFifoObj *fifo, void **rd_ptr, void **wt_ptr)
 Returns the current value of the Graphics FIFO read and write pointers. More...
 
u32 GX_GetFifoSize (const GXFifoObj *fifo)
 Get the size of a given fifo. More...
 
u8 GX_GetFifoWrap (const GXFifoObj *fifo)
 Returns a non-zero value if the write pointer has passed the TOP of the FIFO. More...
 
void GX_GetGPFifo (GXFifoObj *fifo)
 Copies the information from the currently attached GP FIFO info fifo. More...
 
void GX_GetGPStatus (u8 *overhi, u8 *underlow, u8 *readIdle, u8 *cmdIdle, u8 *brkpt)
 Reads the current status of the GP. More...
 
u32 GX_GetOverflowCount (void)
 
u32 GX_GetTexBufferSize (u16 wd, u16 ht, u32 fmt, u8 mipmap, u8 maxlod)
 Returns the amount of memory in bytes needed to store a texture of the given size and fmt. More...
 
void GX_GetTexObjAll (const GXTexObj *obj, void **image_ptr, u16 *width, u16 *height, u8 *format, u8 *wrap_s, u8 *wrap_t, u8 *mipmap)
 Returns the parameters described by a texture object. Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes, etc. Texture objects are initialized using either GX_InitTexObj() or, for color index format textures, GX_InitTexObjCI(). More...
 
void * GX_GetTexObjData (const GXTexObj *obj)
 Used to get a pointer to texture data from the GXTexObj structure. More...
 
void GX_GetTexObjFilterMode (const GXTexObj *obj, u8 *minfilt, u8 *magfilt)
 Returns the filter mode for the texture object obj. More...
 
u32 GX_GetTexObjFmt (const GXTexObj *obj)
 Returns the texture format described by texture object obj. More...
 
u16 GX_GetTexObjHeight (const GXTexObj *obj)
 Returns the texture height described by texture object obj. More...
 
void GX_GetTexObjLOD (const GXTexObj *obj, f32 *minlod, f32 *maxlod)
 Returns the min and max LOD values for the texture object obj. More...
 
u32 GX_GetTexObjMipMap (const GXTexObj *obj)
 Returns the texture mipmap enable described by texture object obj. More...
 
void * GX_GetTexObjUserData (const GXTexObj *obj)
 Used to get a pointer to user data from the GXTexObj structure. More...
 
u16 GX_GetTexObjWidth (const GXTexObj *obj)
 Returns the texture width described by texture object obj. More...
 
u8 GX_GetTexObjWrapS (const GXTexObj *obj)
 Returns the texture wrap s mode described by texture object obj. More...
 
u8 GX_GetTexObjWrapT (const GXTexObj *obj)
 Returns the texture wrap t mode described by texture object obj. More...
 
void GX_GetVtxDescv (GXVtxDesc *attr_list)
 Gets the type of multiple attributes. More...
 
f32 GX_GetYScaleFactor (u16 efbHeight, u16 xfbHeight)
 Calculates an appropriate Y scale factor value for GX_SetDispCopyYScale() based on the height of the EFB and the height of the XFB. More...
 
GXFifoObjGX_Init (void *base, u32 size)
 Initializes the graphics processor to its initial state. More...
 
void GX_InitFifoBase (GXFifoObj *fifo, void *base, u32 size)
 Describes the area of main memory that will be used for this fifo. More...
 
void GX_InitFifoLimits (GXFifoObj *fifo, u32 hiwatermark, u32 lowatermark)
 Sets the high and low water mark for the fifo. More...
 
void GX_InitFifoPtrs (GXFifoObj *fifo, void *rd_ptr, void *wt_ptr)
 Sets the fifo read and write pointers. More...
 
void GX_InitFogAdjTable (GXFogAdjTbl *table, u16 width, f32 projmtx[4][4])
 Generates the standard range adjustment table and puts the results into table. More...
 
void GX_InitLightAttn (GXLightObj *lit_obj, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2)
 Sts coefficients used in the lighting attenuation calculation in a given light object. More...
 
void GX_InitLightAttnA (GXLightObj *lit_obj, f32 a0, f32 a1, f32 a2)
 Sets coefficients used in the lighting angle attenuation calculation in a given light object. More...
 
void GX_InitLightAttnK (GXLightObj *lit_obj, f32 k0, f32 k1, f32 k2)
 Sets coefficients used in the lighting distance attenuation calculation in a given light object. More...
 
void GX_InitLightColor (GXLightObj *lit_obj, GXColor col)
 Sets the color of the light in the light object. More...
 
void GX_InitLightDir (GXLightObj *lit_obj, f32 nx, f32 ny, f32 nz)
 Sets the direction of a light in the light object. More...
 
void GX_InitLightDistAttn (GXLightObj *lit_obj, f32 ref_dist, f32 ref_brite, u8 dist_fn)
 Sets coefficients for distance attenuation in a light object. More...
 
void GX_InitLightPos (GXLightObj *lit_obj, f32 x, f32 y, f32 z)
 Sets the position of the light in the light object. More...
 
void GX_InitLightSpot (GXLightObj *lit_obj, f32 cut_off, u8 spotfn)
 Sets coefficients for angular (spotlight) attenuation in light object. More...
 
void GX_InitSpecularDir (GXLightObj *lit_obj, f32 nx, f32 ny, f32 nz)
 Sets the direction of a specular light in the light object. More...
 
void GX_InitSpecularDirHA (GXLightObj *lit_obj, f32 nx, f32 ny, f32 nz, f32 hx, f32 hy, f32 hz)
 Sets the direction and half-angle vector of a specular light in the light object. More...
 
void GX_InitTexCacheRegion (GXTexRegion *region, u8 is32bmipmap, u32 tmem_even, u8 size_even, u32 tmem_odd, u8 size_odd)
 Initializes a texture memory (TMEM) region object for cache. More...
 
void GX_InitTexObj (GXTexObj *obj, void *img_ptr, u16 wd, u16 ht, u8 fmt, u8 wrap_s, u8 wrap_t, u8 mipmap)
 Used to initialize or change a texture object for non-color index textures. More...
 
void GX_InitTexObjBiasClamp (GXTexObj *obj, u8 biasclamp)
 Enables bias clamping for texture LOD. More...
 
void GX_InitTexObjCI (GXTexObj *obj, void *img_ptr, u16 wd, u16 ht, u8 fmt, u8 wrap_s, u8 wrap_t, u8 mipmap, u32 tlut_name)
 Used to initialize or change a texture object when the texture is color index format. More...
 
void GX_InitTexObjData (GXTexObj *obj, void *img_ptr)
 Allows one to modify the image data pointer for an existing texture object. More...
 
void GX_InitTexObjEdgeLOD (GXTexObj *obj, u8 edgelod)
 Changes LOD computing mode. More...
 
void GX_InitTexObjFilterMode (GXTexObj *obj, u8 minfilt, u8 magfilt)
 Sets the filter mode for a texture. More...
 
void GX_InitTexObjLOD (GXTexObj *obj, u8 minfilt, u8 magfilt, f32 minlod, f32 maxlod, f32 lodbias, u8 biasclamp, u8 edgelod, u8 maxaniso)
 Sets texture Level Of Detail (LOD) controls explicitly for a texture object. More...
 
void GX_InitTexObjLODBias (GXTexObj *obj, f32 lodbias)
 Sets the LOD bias for a given texture. More...
 
void GX_InitTexObjMaxAniso (GXTexObj *obj, u8 maxaniso)
 Sets the maximum anisotropic filter to use for a texture. More...
 
void GX_InitTexObjMaxLOD (GXTexObj *obj, f32 maxlod)
 Sets the maximum LOD for a given texture. More...
 
void GX_InitTexObjMinLOD (GXTexObj *obj, f32 minlod)
 Sets the minimum LOD for a given texture. More...
 
void GX_InitTexObjTlut (GXTexObj *obj, u32 tlut_name)
 Allows one to modify the TLUT that is associated with an existing texture object. More...
 
void GX_InitTexObjUserData (GXTexObj *obj, void *userdata)
 Used to set a pointer to user data in the GXTexObj structure. More...
 
void GX_InitTexObjWrapMode (GXTexObj *obj, u8 wrap_s, u8 wrap_t)
 Allows one to modify the texture coordinate wrap modes for an existing texture object. More...
 
void GX_InitTexPreloadRegion (GXTexRegion *region, u32 tmem_even, u32 size_even, u32 tmem_odd, u32 size_odd)
 Initializes a Texture Memory (TMEM) region object for preloading. More...
 
void GX_InitTlutObj (GXTlutObj *obj, void *lut, u8 fmt, u16 entries)
 Initializes a Texture Look-Up Table (TLUT) object. More...
 
void GX_InitTlutRegion (GXTlutRegion *region, u32 tmem_addr, u8 tlut_sz)
 Initializes a Texture Look-Up Table (TLUT) region object. More...
 
void GX_InitXfRasMetric (void)
 Initialize the transformation unit (XF) rasterizer unit (RAS) to take performance measurements. More...
 
void GX_InvalidateTexAll (void)
 Invalidates the current caches of the Texture Memory (TMEM). More...
 
void GX_InvalidateTexRegion (GXTexRegion *region)
 Invalidates the texture cache in Texture Memory (TMEM) described by region. More...
 
void GX_InvVtxCache (void)
 Invalidates the vertex cache. More...
 
void GX_LoadLightObj (const GXLightObj *lit_obj, u8 lit_id)
 Loads a light object into a set of hardware registers associated with a Light ID. More...
 
void GX_LoadLightObjIdx (u32 litobjidx, u8 litid)
 Instructs the GP to fetch the light object at ltobjindx from an array. More...
 
void GX_LoadNrmMtxIdx3x3 (u16 mtxidx, u32 pnidx)
 Loads a 3x3 normal matrix into matrix memory at location pnidx from a 3x3 matrix located at index mtxidx from the array in main memory. More...
 
void GX_LoadNrmMtxImm (Mtx mt, u32 pnidx)
 Used to load a normal transform matrix into matrix memory at location pnidx from the 4x3 matrix mt. More...
 
void GX_LoadNrmMtxImm3x3 (Mtx33 mt, u32 pnidx)
 Used to load a normal transform matrix into matrix memory at location pnidx from the 3x3 matrix mt. More...
 
void GX_LoadPosMtxIdx (u16 mtxidx, u32 pnidx)
 Loads a 3x4 modelview matrix at index mtxidx from the array in main memory. More...
 
void GX_LoadPosMtxImm (Mtx mt, u32 pnidx)
 Used to load a 3x4 modelview matrix mt into matrix memory at location pnidx. More...
 
void GX_LoadProjectionMtx (Mtx44 mt, u8 type)
 Sets the projection matrix. More...
 
void GX_LoadTexMtxIdx (u16 mtxidx, u32 texidx, u8 type)
 Loads a texture matrix at index mtxidx from the array in main memory. More...
 
void GX_LoadTexMtxImm (Mtx mt, u32 texidx, u8 type)
 Loads a texture matrix mt into the matrix memory at location texidx. More...
 
void GX_LoadTexObj (GXTexObj *obj, u8 mapid)
 Loads the state describing a texture into one of eight hardware register sets. More...
 
void GX_LoadTexObjPreloaded (GXTexObj *obj, GXTexRegion *region, u8 mapid)
 Loads the state describing a preloaded texture into one of eight hardware register sets. More...
 
void GX_LoadTlut (GXTlutObj *obj, u32 tlut_name)
 Copies a Texture Look-Up Table (TLUT) from main memory to Texture Memory (TMEM). More...
 
void GX_PeekARGB (u16 x, u16 y, GXColor *color)
 Allows the CPU to read a color value directly from the Embedded Frame Buffer (EFB) at position x,y. More...
 
void GX_PeekZ (u16 x, u16 y, u32 *z)
 Allows the CPU to read a z value directly from the Embedded Frame Buffer (EFB) at position x,y. More...
 
void GX_PixModeSync (void)
 Causes the GPU to wait for the pipe to flush. More...
 
void GX_PokeAlphaMode (u8 func, u8 threshold)
 Sets a threshold which is compared to the alpha of pixels written to the Embedded Frame Buffer (EFB) using the GX_Poke*() functions. More...
 
void GX_PokeAlphaRead (u8 mode)
 Determines what value of alpha will be read from the Embedded Frame Buffer (EFB). More...
 
void GX_PokeAlphaUpdate (u8 update_enable)
 Enables or disables alpha-buffer updates for GX_Poke*() functions. More...
 
void GX_PokeARGB (u16 x, u16 y, GXColor color)
 Allows the CPU to write color directly to the Embedded Frame Buffer (EFB) at position x,y. More...
 
void GX_PokeBlendMode (u8 type, u8 src_fact, u8 dst_fact, u8 op)
 Determines how the source image, is blended with the current Embedded Frame Buffer (EFB). More...
 
void GX_PokeColorUpdate (u8 update_enable)
 Enables or disables color-buffer updates when writing the Embedded Frame Buffer (EFB) using the GX_Poke*() functions. More...
 
void GX_PokeDither (u8 dither)
 Enables dithering when writing the Embedded Frame Buffer (EFB) using GX_Poke*() functions. More...
 
void GX_PokeDstAlpha (u8 enable, u8 a)
 Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB). More...
 
void GX_PokeZ (u16 x, u16 y, u32 z)
 Allows the CPU to write a z value directly to the Embedded Frame Buffer (EFB) at position x,y. More...
 
void GX_PokeZMode (u8 comp_enable, u8 func, u8 update_enable)
 Sets the Z-buffer compare mode when writing the Embedded Frame Buffer (EFB). More...
 
void GX_PreloadEntireTexture (GXTexObj *obj, GXTexRegion *region)
 Loads a given texture from DRAM into the texture memory. More...
 
void GX_ReadBoundingBox (u16 *top, u16 *bottom, u16 *left, u16 *right)
 Returns the bounding box of pixel coordinates that are drawn in the Embedded Framebuffer (EFB). More...
 
u32 GX_ReadClksPerVtx (void)
 
void GX_ReadGPMetric (u32 *cnt0, u32 *cnt1)
 Returns the count of the previously set performance metrics. More...
 
void GX_ReadVCacheMetric (u32 *check, u32 *miss, u32 *stall)
 Returns Vertex Cache performance counters. More...
 
void GX_ReadXfRasMetric (u32 *xfwaitin, u32 *xfwaitout, u32 *rasbusy, u32 *clks)
 Read performance metric values from the XF and RAS units. More...
 
volatile void * GX_RedirectWriteGatherPipe (void *ptr)
 Temporarily points the CPU's write-gather pipe at a new location. More...
 
u32 GX_ResetOverflowCount (void)
 
void GX_RestoreWriteGatherPipe (void)
 Restores the write-gather pipe. More...
 
void GX_SetAlphaCompare (u8 comp0, u8 ref0, u8 aop, u8 comp1, u8 ref1)
 Sets the parameters for the alpha compare function which uses the alpha output from the last active TEV stage. More...
 
void GX_SetAlphaUpdate (u8 enable)
 Enables or disables alpha-buffer updates of the Embedded Frame Buffer (EFB). More...
 
void GX_SetArray (u32 attr, void *ptr, u8 stride)
 Sets the array base pointer and stride for a single attribute. More...
 
void GX_SetBlendMode (u8 type, u8 src_fact, u8 dst_fact, u8 op)
 Determines how the source image, generated by the graphics processor, is blended with the Embedded Frame Buffer (EFB). More...
 
GXBreakPtCallback GX_SetBreakPtCallback (GXBreakPtCallback cb)
 Registers cb as a function to be invoked when a break point is encountered. More...
 
void GX_SetChanAmbColor (s32 channel, GXColor color)
 Sets the ambient color register for color channel chan. More...
 
void GX_SetChanCtrl (s32 channel, u8 enable, u8 ambsrc, u8 matsrc, u8 litmask, u8 diff_fn, u8 attn_fn)
 Sets the lighting controls for a particular color channel. More...
 
void GX_SetChanMatColor (s32 channel, GXColor color)
 Sets the material color register for color channel chan. More...
 
void GX_SetClipMode (u8 mode)
 Enables or disables clipping of geometry. More...
 
void GX_SetColorUpdate (u8 enable)
 Enables or disables color-buffer updates when rendering into the Embedded Frame Buffer (EFB). More...
 
void GX_SetCoPlanar (u8 enable)
 Enables or disables coplanar triangle processing. More...
 
void GX_SetCopyClamp (u8 clamp)
 Sets the vertical clamping mode to use during the EFB to XFB or texture copy. More...
 
void GX_SetCopyClear (GXColor color, u32 zvalue)
 Sets color and Z value to clear the EFB to during copy operations. More...
 
void GX_SetCopyFilter (u8 aa, u8 sample_pattern[12][2], u8 vf, u8 vfilter[7])
 Sets the subpixel sample patterns and vertical filter coefficients used to filter subpixels into pixels. More...
 
void GX_SetCPUFifo (GXFifoObj *fifo)
 Attaches a FIFO to the CPU. More...
 
void GX_SetCullMode (u8 mode)
 Enables or disables culling of geometry based on its orientation to the viewer. More...
 
lwp_t GX_SetCurrentGXThread (void)
 Sets the current GX thread to the calling thread. More...
 
void GX_SetCurrentMtx (u32 mtx)
 Selects a specific matrix to use for transformations. More...
 
void GX_SetDispCopyDst (u16 wd, u16 ht)
 Sets the witdth and height of the display buffer in pixels. More...
 
void GX_SetDispCopyFrame2Field (u8 mode)
 Determines which lines are read from the Embedded Frame Buffer (EFB) when using GX_CopyDisp(). More...
 
void GX_SetDispCopyGamma (u8 gamma)
 Sets the gamma correction applied to pixels during EFB to XFB copy operation. More...
 
void GX_SetDispCopySrc (u16 left, u16 top, u16 wd, u16 ht)
 Sets the source parameters for the EFB to XFB copy operation. More...
 
u32 GX_SetDispCopyYScale (f32 yscale)
 Sets the vertical scale factor for the EFB to XFB copy operation. More...
 
void GX_SetDither (u8 dither)
 Enables or disables dithering. More...
 
void GX_SetDrawDone (void)
 Sends a DrawDone command to the GP. More...
 
GXDrawDoneCallback GX_SetDrawDoneCallback (GXDrawDoneCallback cb)
 Installs a callback that is invoked whenever a DrawDone command is encountered by the GP. More...
 
void GX_SetDrawSync (u16 token)
 This function sends a token into the command stream. More...
 
GXDrawSyncCallback GX_SetDrawSyncCallback (GXDrawSyncCallback cb)
 Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline. More...
 
void GX_SetDstAlpha (u8 enable, u8 a)
 Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB). More...
 
void GX_SetFieldMask (u8 even_mask, u8 odd_mask)
 selectively enables and disables interlacing of the frame buffer image. More...
 
void GX_SetFieldMode (u8 field_mode, u8 half_aspect_ratio)
 Controls various rasterization and texturing parameters that relate to field-mode and double-strike rendering. More...
 
void GX_SetFog (u8 type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor col)
 Enables fog. More...
 
void GX_SetFogColor (GXColor color)
 Sets the fog color. More...
 
void GX_SetFogRangeAdj (u8 enable, u16 center, GXFogAdjTbl *table)
 Enables or disables horizontal fog-range adjustment. More...
 
void GX_SetGPFifo (GXFifoObj *fifo)
 Attaches fifo to the GP. More...
 
void GX_SetGPMetric (u32 perf0, u32 perf1)
 Sets two performance metrics to measure in the GP. More...
 
void GX_SetIndTexCoordScale (u8 indtexid, u8 scale_s, u8 scale_t)
 Allows the sharing of a texcoord between an indirect stage and a regular TEV stage. More...
 
void GX_SetIndTexMatrix (u8 indtexmtx, f32 offset_mtx[2][3], s8 scale_exp)
 Sets one of the three static indirect matrices and the associated scale factor. More...
 
void GX_SetIndTexOrder (u8 indtexstage, u8 texcoord, u8 texmap)
 Used to specify the texcoord and texmap to used with a given indirect lookup. More...
 
void GX_SetLineWidth (u8 width, u8 fmt)
 Sets the width of line primitives. More...
 
void GX_SetMisc (u32 token, u32 value)
 Sets miscellanous settings in the GP. More...
 
void GX_SetNumChans (u8 num)
 Sets the number of color channels that are output to the TEV stages. More...
 
void GX_SetNumIndStages (u8 nstages)
 Used to set how many indirect lookups will take place. More...
 
void GX_SetNumTevStages (u8 num)
 Enables a consecutive number of TEV stages. More...
 
void GX_SetNumTexGens (u32 nr)
 Sets the number of texture coordinates that are generated and available for use in the Texture Environment TEV stages. More...
 
void GX_SetPixelFmt (u8 pix_fmt, u8 z_fmt)
 Sets the format of pixels in the Embedded Frame Buffer (EFB). More...
 
void GX_SetPointSize (u8 width, u8 fmt)
 Sets the size of point primitives. More...
 
void GX_SetScissor (u32 xOrigin, u32 yOrigin, u32 wd, u32 ht)
 Sets the scissor rectangle. More...
 
void GX_SetScissorBoxOffset (s32 xoffset, s32 yoffset)
 Repositions the scissorbox rectangle within the Embedded Frame Buffer (EFB) memory space. More...
 
void GX_SetTevAlphaIn (u8 tevstage, u8 a, u8 b, u8 c, u8 d)
 Sets the alpha input sources for one tevstage of the Texture Environment (TEV) alpha combiner. More...
 
void GX_SetTevAlphaOp (u8 tevstage, u8 tevop, u8 tevbias, u8 tevscale, u8 clamp, u8 tevregid)
 Sets the tevop, tevbias, tevscale and clamp-mode operation for the alpha combiner for this tevstage of the TEV unit. More...
 
void GX_SetTevColor (u8 tev_regid, GXColor color)
 Used to set one of the primary color registers in the TEV unit. More...
 
void GX_SetTevColorIn (u8 tevstage, u8 a, u8 b, u8 c, u8 d)
 Sets the color input sources for one tevstage of the Texture Environment (TEV) color combiner. More...
 
void GX_SetTevColorOp (u8 tevstage, u8 tevop, u8 tevbias, u8 tevscale, u8 clamp, u8 tevregid)
 Sets the tevop, tevbias, tevscale and clamp-mode operation for the color combiner for this tevstage of the TEV unit. More...
 
void GX_SetTevColorS10 (u8 tev_regid, GXColorS10 color)
 Used to set one of the constant color registers in the TEV unit. More...
 
void GX_SetTevDirect (u8 tevstage)
 Used to turn off all indirect texture processing for the specified regular TEV stage. More...
 
void GX_SetTevIndBumpST (u8 tevstage, u8 indstage, u8 mtx_sel)
 Sets up an environment-mapped bump-mapped indirect lookup. More...
 
void GX_SetTevIndBumpXYZ (u8 tevstage, u8 indstage, u8 mtx_sel)
 Sets up an environment-mapped bump-mapped indirect lookup. More...
 
void GX_SetTevIndirect (u8 tevstage, u8 indtexid, u8 format, u8 bias, u8 mtxid, u8 wrap_s, u8 wrap_t, u8 addprev, u8 utclod, u8 a)
 Controls how the results from an indirect lookup will be used to modify a given regular TEV stage lookup. More...
 
void GX_SetTevIndRepeat (u8 tevstage)
 Set a given TEV stage to use the same texture coordinates as were computed in the previous stage. More...
 
void GX_SetTevIndTile (u8 tevstage, u8 indtexid, u16 tilesize_x, u16 tilesize_y, u16 tilespacing_x, u16 tilespacing_y, u8 indtexfmt, u8 indtexmtx, u8 bias_sel, u8 alpha_sel)
 Used to implement tiled texturing using indirect textures. More...
 
void GX_SetTevIndWarp (u8 tevstage, u8 indtexid, u8 bias_flag, u8 replace_tex, u8 mtxid)
 Used to warp a normal texture lookup using an indirect texture map with 8-bit offsets. More...
 
void GX_SetTevKAlphaSel (u8 tevstage, u8 sel)
 Selects a "konstant" alpha input to be used in a given TEV stage. More...
 
void GX_SetTevKColor (u8 sel, GXColor col)
 Sets one of the "konstant" color registers in the TEV unit. More...
 
void GX_SetTevKColorS10 (u8 sel, GXColorS10 col)
 Used to set one of the constant color registers in the Texture Environment (TEV) unit. More...
 
void GX_SetTevKColorSel (u8 tevstage, u8 sel)
 Selects a "konstant" color input to be used in a given TEV stage. More...
 
void GX_SetTevOp (u8 tevstage, u8 mode)
 Simplified function to set various TEV parameters for this tevstage based on a predefined combiner mode. More...
 
void GX_SetTevOrder (u8 tevstage, u8 texcoord, u32 texmap, u8 color)
 Specifies the texture and rasterized color that will be available as inputs to this TEV tevstage. More...
 
void GX_SetTevSwapMode (u8 tevstage, u8 ras_sel, u8 tex_sel)
 Selects a set of swap modes for the rasterized color and texture color for a given TEV stage. More...
 
void GX_SetTevSwapModeTable (u8 swapid, u8 r, u8 g, u8 b, u8 a)
 Sets up the TEV color swap table. More...
 
void GX_SetTexCoordBias (u8 texcoord, u8 s_enable, u8 t_enable)
 Sets the texture coordinate bias of a particular texture. More...
 
void GX_SetTexCoordCylWrap (u8 texcoord, u8 s_enable, u8 t_enable)
 
void GX_SetTexCoordGen (u16 texcoord, u32 tgen_typ, u32 tgen_src, u32 mtxsrc)
 Specifies how texture coordinates are generated. More...
 
void GX_SetTexCoordGen2 (u16 texcoord, u32 tgen_typ, u32 tgen_src, u32 mtxsrc, u32 normalize, u32 postmtx)
 An extension of GX_SetTexCoordGen(). It allows one to specify additional texgen options. More...
 
void GX_SetTexCoordScaleManually (u8 texcoord, u8 enable, u16 ss, u16 ts)
 Overrides the automatic texture coordinate scaling (based upon the associated map size) and lets one manually assign the scale values that are used for a given texcoord. More...
 
void GX_SetTexCopyDst (u16 wd, u16 ht, u32 fmt, u8 mipmap)
 This function sets the width and height of the destination texture buffer in texels. More...
 
void GX_SetTexCopySrc (u16 left, u16 top, u16 wd, u16 ht)
 Sets the source parameters for the Embedded Frame Buffer (EFB) to texture image copy. More...
 
GXTexRegionCallback GX_SetTexRegionCallback (GXTexRegionCallback cb)
 Sets the callback function called by GX_LoadTexObj() to obtain an available texture region. More...
 
GXTlutRegionCallback GX_SetTlutRegionCallback (GXTlutRegionCallback cb)
 Sets the callback function called by GX_LoadTlut() to find the region into which to load the TLUT. More...
 
void GX_SetVCacheMetric (u32 attr)
 Sets the metric the Vertex Cache performance counter will measure. More...
 
void GX_SetViewport (f32 xOrig, f32 yOrig, f32 wd, f32 ht, f32 nearZ, f32 farZ)
 Sets the viewport rectangle in screen coordinates. More...
 
void GX_SetViewportJitter (f32 xOrig, f32 yOrig, f32 wd, f32 ht, f32 nearZ, f32 farZ, u32 field)
 Sets the viewport and adjusts the viewport's line offset for interlaced field rendering. More...
 
void GX_SetVtxAttrFmt (u8 vtxfmt, u32 vtxattr, u32 comptype, u32 compsize, u32 frac)
 Sets the attribute format (vtxattr) for a single attribute in the Vertex Attribute Table (VAT). More...
 
void GX_SetVtxAttrFmtv (u8 vtxfmt, GXVtxAttrFmt *attr_list)
 Sets multiple attribute formats within a single vertex format. More...
 
void GX_SetVtxDesc (u8 attr, u8 type)
 Sets the type of a single attribute (attr) in the current vertex descriptor. More...
 
void GX_SetVtxDescv (GXVtxDesc *attr_list)
 Sets the type of multiple attributes. More...
 
void GX_SetZCompLoc (u8 before_tex)
 Sets whether Z buffering happens before or after texturing. More...
 
void GX_SetZMode (u8 enable, u8 func, u8 update_enable)
 Sets the Z-buffer compare mode. More...
 
void GX_SetZTexture (u8 op, u8 fmt, u32 bias)
 Controls Z texture operations. More...
 
void GX_TexModeSync (void)
 Inserts a synchronization command into the graphics FIFO. When the Graphics Processor sees this command, it will allow the texture pipeline to flush before continuing. More...
 
void GX_WaitDrawDone (void)
 Stalls until DrawDone is encountered by the GP. More...
 

Variables

WGPipe *const wgPipe
 

Detailed Description

GX subsystem.

Macro Definition Documentation

◆ GX_FIFO_HIWATERMARK

#define GX_FIFO_HIWATERMARK   (16*1024)

Default hi watermark for FIFO buffer control.

◆ GX_FIFO_MINSIZE

#define GX_FIFO_MINSIZE   (64*1024)

Smallest usable graphics FIFO size.

◆ GX_InitLightDirv

#define GX_InitLightDirv (   lo,
  vec 
)     (GX_InitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))

Sets the direction of a light in the light object using a vector structure.

This direction is used when the light object is used as a spotlight or a specular light, see the attn_fn parameter of GX_SetChanCtrl().

Note
The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().

The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be transformed to view space.

This function does not set the direction of parallel lights.
Parameters
[in]loptr to the light object
[in]vecstruct or array of three values for the direction
Returns
none

◆ GX_InitLightPosv

#define GX_InitLightPosv (   lo,
  vec 
)     (GX_InitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))

Sets the position of the light in the light object using a vector structure.

Note
The GameCube graphics hardware supports local diffuse lights. The position of the light should be in the same space as a transformed vertex position (i.e. view space).

The memory for the light object must be allocated by the application; this function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]loptr to the light object
[in]vecstruct or array of three values for the position
Returns
none

◆ GX_InitLightShininess

#define GX_InitLightShininess (   lobj,
  shininess 
)
Value:
(GX_InitLightAttn(lobj, 0.0F, 0.0F, 1.0F, \
(shininess)/2.0F, 0.0F, \
1.0F-(shininess)/2.0F ))
void GX_InitLightAttn(GXLightObj *lit_obj, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2)
Sts coefficients used in the lighting attenuation calculation in a given light object.

Sets shininess of a per-vertex specular light.

In reality, shininess is a property of the material being lit, not the light. However, in the Graphics Processor, the specular calculation is implemented by reusing the diffuse angle/distance attenuation function, so shininess is determined by the light attenuation parameters (see GX_InitLightAttn()). Note that the equation is attempting to approximate the function (N*H)^shininess. Since the attenuation equation is only a ratio of quadratics, a true exponential function is not possible. To enable the specular calculation, you must set the attenuation parameter of the lighting channel to GX_AF_SPEC using GX_SetChanCtrl().

Parameters
[in]lobjptr to the light object
[in]shininessshininess parameter
Returns
none

◆ GX_InitSpecularDirHAv

#define GX_InitSpecularDirHAv (   lo,
  vec0,
  vec1 
)
Value:
*(f32*)(vec0), *((f32*)(vec0)+1), *((f32*)(vec0)+2), \
*(f32*)(vec1), *((f32*)(vec1)+1), *((f32*)(vec1)+2)))
void GX_InitSpecularDirHA(GXLightObj *lit_obj, f32 nx, f32 ny, f32 nz, f32 hx, f32 hy, f32 hz)
Sets the direction and half-angle vector of a specular light in the light object.

Sets the direction and half-angle vector of a specular light in the light object using a vector.

These vectors are used when the light object is used only as specular light.

Note
The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().

In contrast to GX_InitSpecularDirv(), which caclulates half-angle vector automatically by assuming the view vector as (0,0,1), this function allows users to specify half-angle vector directly as input arguments. It is useful to do detailed control for orientation of highlights.

Other notes are similar to that described in GX_InitSpecularDirv().
Parameters
[in]loptr to the light object
[in]vec0struct or array of three values for the direction
[in]vec1struct or array of three values for the half-angle
Returns
none

◆ GX_InitSpecularDirv

#define GX_InitSpecularDirv (   lo,
  vec 
)     (GX_InitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))

Sets the direction of a specular light in the light object using a vector.

This direction is used when the light object is used only as specular light.

Note
The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().

The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be transformed to view space.
Warning
This function should be used if and only if the light object is used as specular light. One specifies a specular light in GX_SetChanCtrl() by setting attn_fn to GX_AF_SPEC. Furthermore, one must not use GX_InitLightDir() or GX_InitLightPos() to set up a light object which will be used as a specular light since these functions will destroy the information set by GX_InitSpecularDir(). In contrast to diffuse lights (including spotlights) that are considered local lights, a specular light is a parallel light (i.e. the specular light is infinitely far away such that all the rays of the light are parallel), and thus one can only specify directional information.
Parameters
[in]loptr to the light object
[in]vecstruct or array of three values for the direction
Returns
none

Typedef Documentation

◆ GXDrawSyncCallback

void(* GXDrawSyncCallback)(u16 token)

function pointer typedef for the drawsync-token callback

Parameters
[out]tokentokenvalue most recently encountered.

◆ GXLightObj

Object containing information on a light.

This structure contains precompiled register state setting commands and data. The application must use the GX_InitLight*() functions to initialize or change this object. The proper size of the object is returned by

sizeof(GXLightObj)
struct _gx_litobj GXLightObj
Object containing information on a light.

but the internal data representation is not visible to the application.

◆ GXTexObj

Object containing information about a texture.

This structure contains precompiled register state setting commands and data. The application must use the GX_InitTexObj*() function to initialize or change this object. The proper size of the object is returned by

sizeof(GXTexObj)
struct _gx_texobj GXTexObj
Object containing information about a texture.

but the internal data representation is not visible to the application.

◆ GXTexRegion

Object containing information on a texture cache region.

This structure contains precompiled register state setting commands and data. The application must use the GX_InitTexCacheRegion() function to initialize or change this object. The proper size of the object is returned by

sizeof(GXTexRegion)
struct _gx_texreg GXTexRegion
Object containing information on a texture cache region.

but the internal data representation is not visible to the application.

◆ GXTexRegionCallback

GXTexRegion *(* GXTexRegionCallback)(GXTexObj *obj, u8 mapid)

function pointer typedef for the texture region callback

Parameters
[out]tokentokenvalue most recently encountered.

◆ GXTlutObj

Object containing information on a TLUT.

This structure contains precompiled register state setting commands and data. The application must use the GX_InitTlutObj() function to initialize or change this object. The proper size of the object is returned by

sizeof(GXTlutObj)
struct _gx_tlutobj GXTlutObj
Object containing information on a TLUT.

but the internal data representation is not visible to the application.

◆ GXTlutRegion

Object containing information on a TLUT cache region.

This structure contains precompiled register state setting commands and data. The application must use the GX_InitTlutRegion() function to initialize or change this object. The proper size of the object is returned by

sizeof(GXTlutRegion)
struct _gx_tlutreg GXTlutRegion
Object containing information on a TLUT cache region.

but the internal data representation is not visible to the application.

◆ GXTlutRegionCallback

GXTlutRegion *(* GXTlutRegionCallback)(u32 tlut_name)

function pointer typedef for the TLUT region callback

Parameters
[out]tokentokenvalue most recently encountered.

Function Documentation

◆ GX_AbortFrame()

void GX_AbortFrame ( void  )

Aborts the current frame.

This command will reset the entire graphics pipeline, including any commands in the graphics FIFO.

Note
Texture memory will not be reset, so currently loaded textures will still be valid; however, when loading texture using GX_PreloadEntireTexture() or TLUTs using GX_LoadTlut(), you must make sure the command completed. You can use the draw sync mechanism to do this; see GX_SetDrawSync() and GX_GetDrawSync().
Returns
none

◆ GX_AdjustForOverscan()

void GX_AdjustForOverscan ( GXRModeObj rmin,
GXRModeObj rmout,
u16  hor,
u16  ver 
)

Takes a given render mode and returns a version that is reduced in size to account for overscan.

The number of pixels specified by hor is subtracted from each side of the screen, and the number of pixels specified by ver is subtracted from both the top and the bottom of the screen. The active screen area is centered within what the render mode specified before the adjustment.

Note
Due to the wide possibilities of how a render mode may be configured, this function may not work in all cases. For instance, if you use Y-scaling to create a size difference between the EFB and XFB, this function may not do the right thing. In such cases, you should configure the desired render mode manually (or else call this function and then fix up the results).
Parameters
[in]rminrmode that is being copied
[in]rmoutrmode to hold the adjusted version. Needs to be allocated but can be uninitialized.
[in]horpixels to trim from each side of the screen
[in]verpixels to tim from top and bottom of the screen
Returns
none

◆ GX_Begin()

void GX_Begin ( u8  primitve,
u8  vtxfmt,
u16  vtxcnt 
)

Begins drawing of a graphics primitive.

To draw a graphics primitive, a stream of vertex data matching the description of both GX_SetVtxDesc() and GX_SetVtxAttrFmt() is enclosed between GX_Begin()/GX_End() pairs. The number of vertices between GX_Begin() and GX_End() must match that specified by the vtxcnt parameter. The type of the primitive will determine the minimum number of vertices required. For example, a GX_TRIANGLES primitive must have at least 3 vertices.

Note
Primitives in which the vertex order is clockwise to the viewer are considered front-facing (for culling purposes).
Parameters
[in]primitvePrimitive type to draw
[in]vtxfmtVertex format index to use
[in]vtxcntnumber of vertices being drawn; maximum is 65536

◆ GX_BeginDispList()

void GX_BeginDispList ( void *  list,
u32  size 
)

Begins a display list and disables writes to the FIFO currently attached to the CPU.

After this function is called, GX API functions that normally send command or data into the CPU FIFO will send them to the display list buffer instead of the FIFO until GX_EndDispList() is called. Writes to the CPU FIFO will be re-enabled when the function GX_EndDispList() executes.

Basically you can put most of GX API commands into a display list. However, since the use of display list can bypass all state coherences controlled by GX API in run-time, sometimes it brings some state collisions or incoherences that may lead to unexpected behavior or even graphics pipeline hang. The most recommended safe way is putting only primitives (regions enclosed by GX_Begin() and GX_End()) that don't cause any state collisions.

Note
The application is expected to allocate the memory for the display list buffer. If the display list exceeds the maximum size of the buffer, GX_EndDispList() will return 0. The address of the buffer must be 32-byte aligned; memalign() can return 32-byte-aligned pointers. You can use the macro ATTRIBUTE_ALIGN(32) to align statically allocated buffers.

The CPU's write-gather pipe is used to write graphics commands to the display list. Therefore, the display list buffer must be forced out of the CPU cache prior to being filled. DCInvalidateRange() may be used for this purpose. In addition, due to the mechanics of flushing the write-gather pipe, the display list buffer should be at least 63 bytes larger than the maximum expected amount of data stored.

A display list cannot be nested; i.e., no display list functions (GX_BeginDispList(), GX_EndDispList() and GX_CallDispList()) can be called between a GX_BeginDispList() and GX_EndDispList() pair.

To execute a display list, use GX_CallDispList().
Parameters
[in]list32-byte aligned buffer to hold the list
[in]sizesize of the buffer, multiple of 32
Returns
none

◆ GX_CallDispList()

void GX_CallDispList ( void *  list,
u32  nbytes 
)

Causes the GP to execute graphics commands from the display list instead of from the GP FIFO.

When the number of bytes specified by nbytes have been read, the graphics processor will resume executing commands from the graphics FIFO. Graphics commands from a display list are prefetched into a separate 4KB FIFO. This prevents any data prefetched for the main graphics command stream from being lost during the display list call.

Note
A display list cannot call another display list.

The display list must be padded to a length of 32B. All the data in the display list is interpreted by the graphics processor, so any unused memory at the end of a display list should be set to GX_NOP. If you create the display list using GX_BeginDispList()/GX_EndDispList(), this padding will be inserted automatically.
Parameters
[in]list32-byte aligned pointer to the display list buffer
[in]nbytesnumber of bytes in the display list. Use the return value of GX_EndDispList() here.
Returns
none

◆ GX_ClearBoundingBox()

void GX_ClearBoundingBox ( void  )

Clears the bounding box values before a new image is drawn.

The graphics hardware keeps track of a bounding box of pixel coordinates that are drawn in the Embedded Frame Buffer (EFB).

Returns
none

◆ GX_ClearGPMetric()

void GX_ClearGPMetric ( void  )

Clears the two virtual GP performance counters to zero.

Note
The counter's function is set using GX_SetGPMetric(); the counter's value is read using GX_ReadGPMetric(). Consult these for more details.
Warning
This function resets CPU accessible counters, so it should not be used in a display list.
Returns
none

◆ GX_ClearVCacheMetric()

void GX_ClearVCacheMetric ( void  )

Clears the Vertex Cache performance counter.

This function clears the performance counter by sending a special clear token via the Graphics FIFO.

Note
To set the metric for the counter, call GX_SetVCacheMetric(); to read the counter value, call GX_ReadVCacheMetric().
Returns
none

◆ GX_ClearVtxDesc()

void GX_ClearVtxDesc ( void  )

Clears all vertex attributes of the current vertex descriptor to GX_NONE.

Note
The same functionality can be obtained using GX_SetVtxDescv(), however using GX_ClearVtxDesc() is much more efficient.
Returns
none

◆ GX_CopyDisp()

void GX_CopyDisp ( void *  dest,
u8  clear 
)

Copies the embedded framebuffer (EFB) to the external framebuffer(XFB) in main memory.

Note
The stride of the XFB is set using GX_SetDispCopyDst(). The source image in the EFB is described using GX_SetDispCopySrc().

The graphics processor will stall all graphics commands util the copy is complete.

If the clear flag is true, the color and Z buffers will be cleared during the copy. They will be cleared to the constant values set using GX_SetCopyClear().
Parameters
[in]destpointer to the external framebuffer. dest should be 32B aligned.
[in]clearflag that indicates framebuffer should be cleared if GX_TRUE.
Returns
none

◆ GX_CopyTex()

void GX_CopyTex ( void *  dest,
u8  clear 
)

Copies the embedded framebuffer (EFB) to the texture image buffer dest in main memory.

This is useful when creating textures using the Graphics Processor (GP). If the clear flag is set to GX_TRUE, the EFB will be cleared to the current color(see GX_SetCopyClear()) during the copy operation.

Parameters
[in]destpointer to the image buffer in main memory. dest should be 32B aligned.
[in]clearflag that indicates framebuffer should be cleared if GX_TRUE.
Returns
none

◆ GX_DisableBreakPt()

void GX_DisableBreakPt ( void  )

Allows reads from the FIFO currently attached to the Graphics Processor (GP) to resume.

See GX_EnableBreakPt() for an explanation of the FIFO break point feature.

Note
The breakpoint applies to the FIFO currently attached to the Graphics Processor (GP) (see GX_SetGPFifo()).
Returns
none

◆ GX_DrawDone()

void GX_DrawDone ( void  )

Sends a DrawDone command to the GP and stalls until its subsequent execution.

Note
This function is equivalent to calling GX_SetDrawDone() then GX_WaitDrawDone().
Returns
none

◆ GX_EnableBreakPt()

void GX_EnableBreakPt ( void *  break_pt)

Sets a breakpoint that causes the GP to halt when encountered.

Note
The break point feature allows the application to have two frames of graphics in the FIFO at the same time, overlapping one frame's processing by the graphics processor with another frame's processing by the CPU. For example, suppose you finish writing the graphics commands for one frame and are ready to start on the next. First, execute a GX_Flush() command to make sure all the data in the CPU write gatherer is flushed into the FIFO. This will also align the FIFO write pointer to a 32B boundary. Next, read the value of the current write pointer using GX_GetFifoPtrs(). Write the value of the write pointer as the break point address using GX_EnableBreakPt(). When the FIFO read pointer reaches the break point address the hardware will disable reads from the FIFO. The status brkpt, returned by GX_GetGPStatus(), can be polled to detect when the break point is reached. The application can then decide when to disable the break point, using GX_DisableBreakPt(), which will allow the FIFO to resume reading graphics commands.

FIFO reads will stall when the GP FIFO read pointer is equal to the break point address break_pt. To re-enable reads of the GP FIFO, use GX_DisableBreakPt().

Use GX_SetBreakPtCallback() to set what function runs when the breakpoint is encountered.
Parameters
[in]break_ptaddress for GP to break on when read.
Returns
none

◆ GX_EnableTexOffsets()

void GX_EnableTexOffsets ( u8  coord,
u8  line_enable,
u8  point_enable 
)

Enables a special texture offset feature for points and lines.

When a point's size is defined using GX_SetPointSize() or a line's width is described using GX_SetLineWidth(), you can also specify a second parameter. The parameter fmt is added to the texture coordinate(s), if any, to obtain texture coordinates at the other corners of a point or line. The fmts are added after the texture coordinate generation operation; see GX_SetTexCoordGen(). This function enables this operation for a particular texture coordinate. Offset operations for points and lines are enabled separately. If the enables are false, the same texture coordinate is used for every vertex of the line or point.

Parameters
[in]coordtexture coordinate slot
[in]line_enableenable or disable tex offset calculation for lines
[in]point_enableenable or disable tex offset calculation for points
Returns
none

◆ GX_EndDispList()

u32 GX_EndDispList ( void  )

Ends a display list and resumes writing graphics commands to the CPU FIFO.

This function returns the size of the display list written to the display list buffer since GX_BeginDispList() was called. If the display list size exceeds the size of the buffer allocated, a zero length size will be returned. The display list size is a multiple of 32B and any unsed commands in the last 32B will be padded with GX_NOP. The size returned should be passed to GX_CallDispList() when the display list needs to be executed.

Note
Due to the mechanics of flushing the write-gather pipe (which is used to create the display list), the display buffer should be at least 32 bytes larger than the maximum expected amount of data stored. This function calls GX_Flush(), and thus it is not necessary to call GX_Flush() explicitly after creating the display list.

A display list cannot be nested; i.e., no display list functions (GX_BeginDispList(), GX_EndDispList() and GX_CallDispList()) can be called between a GX_BeginDispList() and GX_EndDispList() pair.

To execute a display list, use GX_CallDispList().
Returns
0 if display list size exceeds buffer, otherwise gives list size in bytes
Bug:
Specifying a display list buffer size for GX_BeginDispList() the exact size that the display list will be (after padding) will cause this function to return a very large (and very incorrect) value.

◆ GX_Flush()

void GX_Flush ( void  )

Flushes all commands to the GP.

Specifically, it flushes the write-gather FIFO in the CPU to make sure that all commands are sent to the GP.

Returns
none

◆ GX_GetCPUFifo()

void GX_GetCPUFifo ( GXFifoObj fifo)

Copies the information from the currently attached CPU FIFO into fifo.

Parameters
[out]fifothe object to copy the current CPU FIFO object data into
Returns
none

◆ GX_GetCurrentGXThread()

lwp_t GX_GetCurrentGXThread ( void  )

Returns the current GX thread.

The current GX thread should be the thread that is currently responsible for generating graphics data. By default, the GX thread is the thread that invoked GX_Init(); however, it may be changed by calling GX_SetCurrentGXThread().

Note
When graphics data is being generated in immediate mode (that is, the CPU FIFO = GP FIFO, and the GP is actively consuming data), the high watermark may be triggered. When this happens, the high watermark interrupt handler will suspend the GX thread, thus preventing any further graphics data from being generated. The low watermark interrupt handler will resume the thread.
Returns
the current GX thread

◆ GX_GetDrawSync()

u16 GX_GetDrawSync ( void  )

Returns the value of the token register, which is written using the GX_SetDrawSync() function.

Returns
the value of the token register.

◆ GX_GetFifoBase()

void * GX_GetFifoBase ( const GXFifoObj fifo)

Get the base address for a given fifo.

Parameters
[in]fifothe object to get the address from
Returns
pointer to the base address of the FIFO in main memory.

◆ GX_GetFifoCount()

u32 GX_GetFifoCount ( const GXFifoObj fifo)

Returns number of cache lines in the FIFO.

Note
The count is incorrect if an overflow has occurred (i.e. you have written more data than the size of the fifo), as the hardware cannot detect an overflow in general.
Parameters
[in]fifothe FIFO to get the count from
Returns
number of cache lines in the FIFO

◆ GX_GetFifoPtrs()

void GX_GetFifoPtrs ( const GXFifoObj fifo,
void **  rd_ptr,
void **  wt_ptr 
)

Returns the current value of the Graphics FIFO read and write pointers.

Note
See GX_EnableBreakPt() for an example of why you would do this.
Parameters
[in]fifopointer to a FIFO struct
[out]rd_ptraddress of the FIFO read pointer
[out]wt_ptraddress of the FIFO write pointer
Returns
none

◆ GX_GetFifoSize()

u32 GX_GetFifoSize ( const GXFifoObj fifo)

Get the size of a given fifo.

Parameters
[in]fifothe object to get the size from
Returns
size of the FIFO, in bytes

◆ GX_GetFifoWrap()

u8 GX_GetFifoWrap ( const GXFifoObj fifo)

Returns a non-zero value if the write pointer has passed the TOP of the FIFO.

Returns true only if the FIFO is attached to the CPU and the FIFO write pointer has passed the top of the FIFO. Use the return value to detect whether or not an overflow has occured by initializing the FIFO's write pointer to the base of the FIFO before sending any commands to the FIFO.

Note
If the FIFO write pointer is not explicitly set to the base of the FIFO, you cannot rely on this function to detect overflows.
Parameters
[in]fifothe object to get the wrap status from
Returns
wrap value

◆ GX_GetGPFifo()

void GX_GetGPFifo ( GXFifoObj fifo)

Copies the information from the currently attached GP FIFO info fifo.

Parameters
[out]fifothe object to copy the current GP FIFO object data into
Returns
none

◆ GX_GetGPStatus()

void GX_GetGPStatus ( u8 overhi,
u8 underlow,
u8 readIdle,
u8 cmdIdle,
u8 brkpt 
)

Reads the current status of the GP.

overhi and underlow will indicate whether or not the watermarks have been reached. If the CPU and GP FIFOs are the same, then overhi will indicate whether or not the current GX thread is suspended. The value of brkpt can be used to determine if a breakpoint is in progress (i.e. GP reads are suspended; they are resumed by a call to GX_DisableBreakPt()). A callback can also be used to notify your application that the break point has been reached. (see GX_SetBreakPtCallback())

Parameters
[out]overhiGX_TRUE if high watermark has been passed
[out]underlowGX_TRUE if low watermark has been passed
[out]readIdleGX_TRUE if the GP read unit is idle
[out]cmdIdleGX_TRUE if all commands have been flushed to XF
[out]brkptGX_TRUE if FIFO has reached a breakpoint and GP reads have been stopped
Returns
none

◆ GX_GetTexBufferSize()

u32 GX_GetTexBufferSize ( u16  wd,
u16  ht,
u32  fmt,
u8  mipmap,
u8  maxlod 
)

Returns the amount of memory in bytes needed to store a texture of the given size and fmt.

If the mipmap flag is GX_TRUE, then the size of buffer needed for the mipmap pyramid up to maxlod will be returned. maxlod will be clamped to the number of LODs possible given the map wd and ht. For mipmaps, wd and ht must be a power of two.

Note
This function takes into account the tiling and padding requirements of the GameCube's native texture format. The resulting size can be used along with memalign() to allocate texture buffers (see GX_CopyTex()).
Parameters
[in]wdwidth of the texture in texels
[in]htheight of the texture in texels
[in]fmtformat of the texture; use GX_TexFmt() or GX_CITexFmt() to get it
[in]mipmapflag indicating whether or not the texture is a mipmap
[in]maxlodif mipmap is GX_TRUE, texture size will include mipmap pyramid up to this value
Returns
number of bytes needed for the texture, including tile padding

◆ GX_GetTexObjAll()

void GX_GetTexObjAll ( const GXTexObj obj,
void **  image_ptr,
u16 width,
u16 height,
u8 format,
u8 wrap_s,
u8 wrap_t,
u8 mipmap 
)

Returns the parameters described by a texture object. Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes, etc. Texture objects are initialized using either GX_InitTexObj() or, for color index format textures, GX_InitTexObjCI().

Parameters
[in]objptr to a texture object
[out]image_ptrReturns a physical pointer to the image data for a texture.
[out]widthReturns the width of the texture or LOD 0 for mipmaps
[out]heightReturns the height of the texture or LOD 0 for mipmaps
[out]formatReturns the texel format
[out]mipmapReturns the mipmap enable flag.
Returns
none

◆ GX_GetTexObjData()

void * GX_GetTexObjData ( const GXTexObj obj)

Used to get a pointer to texture data from the GXTexObj structure.

Note
The returned pointer is a physical address.
Parameters
[in]objptr to a texture object
Returns
Physical pointer to texture data.

◆ GX_GetTexObjFilterMode()

void GX_GetTexObjFilterMode ( const GXTexObj obj,
u8 minfilt,
u8 magfilt 
)

Returns the filter mode for the texture object obj.

Note
Use GX_InitTexObjLOD() or GX_InitTexObjFilterMode() to initialize the texture filter mode.
Parameters
[in]objptr to a texture object
[out]minfiltminification filter mode; will be one of Texture filter types
[out]maxfiltmagnification filter mode; will be GX_NEAR or GX_LINEAR
Returns
none

◆ GX_GetTexObjFmt()

u32 GX_GetTexObjFmt ( const GXTexObj obj)

Returns the texture format described by texture object obj.

Note
Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture format.
Parameters
[in]objptr to a texture object
Returns
texture format of the given texture object

◆ GX_GetTexObjHeight()

u16 GX_GetTexObjHeight ( const GXTexObj obj)

Returns the texture height described by texture object obj.

Note
Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture height.
Parameters
[in]objptr to a texture object
Returns
texture height

◆ GX_GetTexObjLOD()

void GX_GetTexObjLOD ( const GXTexObj obj,
f32 *  minlod,
f32 *  maxlod 
)

Returns the min and max LOD values for the texture object obj.

Note
Use GX_InitTexObjLOD(), GX_InitTexObjMinLOD() or GX_InitTexObjMaxLOD() to initialize the texture minimum and maximum LOD.
Parameters
[in]objptr to a texture object
[out]minlodminimum LOD value from 0.0 - 10.0 inclusive
[out]maxlodmaximum LOD value from 0.0 - 10.0 inclusive
Returns
none

◆ GX_GetTexObjMipMap()

u32 GX_GetTexObjMipMap ( const GXTexObj obj)

Returns the texture mipmap enable described by texture object obj.

Note
Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture mipmap enable.
Parameters
[in]objptr to a texture object
Returns
mipmap enable flag

◆ GX_GetTexObjUserData()

void * GX_GetTexObjUserData ( const GXTexObj obj)

Used to get a pointer to user data from the GXTexObj structure.

You can use this function to retrieve private data structures from the texture object. This pointer is set using GX_InitTexObjUserData().

Parameters
[in]objptr to object to read data from
Returns
Pointer to user data.

◆ GX_GetTexObjWidth()

u16 GX_GetTexObjWidth ( const GXTexObj obj)

Returns the texture width described by texture object obj.

Note
Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture width.
Parameters
[in]objptr to a texture object
Returns
texture width

◆ GX_GetTexObjWrapS()

u8 GX_GetTexObjWrapS ( const GXTexObj obj)

Returns the texture wrap s mode described by texture object obj.

Note
Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture wrap s mode.
Parameters
[in]objptr to a texture object
Returns
wrap s mode

◆ GX_GetTexObjWrapT()

u8 GX_GetTexObjWrapT ( const GXTexObj obj)

Returns the texture wrap t mode described by texture object obj.

Note
Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture wrap t mode.
Parameters
[in]objptr to a texture object
Returns
wrap t mode

◆ GX_GetVtxDescv()

void GX_GetVtxDescv ( GXVtxDesc attr_list)

Gets the type of multiple attributes.

This function saves the attributes that are current set. This is usually used in conjunction with GX_SetVtxDescv

Note
The constant GX_MAX_VTXATTRFMT_LISTSIZE must be used to allocate memory for attr_list
Parameters
[in]attr_listarray of pointers to GXVtxDesc structs
Returns
none

◆ GX_GetYScaleFactor()

f32 GX_GetYScaleFactor ( u16  efbHeight,
u16  xfbHeight 
)

Calculates an appropriate Y scale factor value for GX_SetDispCopyYScale() based on the height of the EFB and the height of the XFB.

Parameters
[in]efbHeightHeight of embedded framebuffer. Range from 2 to 528. Should be a multiple of 2.
[in]xfbHeightHeight of external framebuffer. Range from 2 to 1024. Should be equal or greater than efbHeight.
Returns
Y scale factor which can be used as argument of GX_SetDispCopyYScale().

◆ GX_Init()

GXFifoObj * GX_Init ( void *  base,
u32  size 
)

Initializes the graphics processor to its initial state.

This function sets the default state of the graphics processor and should be called before any other GX functions. This function sets up an immediate-mode method of communicating graphics commands from the CPU to the Graphics Processor (GP). This function will initialize a FIFO and attach it to both the CPU and GP. The CPU will write commands to the FIFO and the GP will read the commands. This function returns a pointer to the initialized FIFO. The application must allocate the memory for the FIFO. The parameter base is a pointer to the allocated main memory and must be aligned to 32B. size is the size of the FIFO in bytes and must be a multiple of 32B. Refer to additional notes in GX_InitFifoBase() concerning the FIFO memory.

Note
It is also possible to override the default immediate-mode style and instead buffer the graphics for frame n+1 while the GP is reading the graphics for frame n. See GX_SetCPUFifo() and GX_SetGPFifo() for further information.

This function also designates the calling thread as the default GX thread; i.e., it assumes the calling thread is the one responsible for generating graphics data. This thread will be the thread to be suspended when the FIFO gets too full. The current GX thread can be changed by calling GX_SetCurrentGXThread().
Parameters
[in]basepointer to the GX FIFO buffer base address. Must be aligned on a 32 Byte boundery.
[in]sizesize of buffer. Must be a multiple of 32.
Returns
pointer to the intialized GXFifoObj object.

◆ GX_InitFifoBase()

void GX_InitFifoBase ( GXFifoObj fifo,
void *  base,
u32  size 
)

Describes the area of main memory that will be used for this fifo.

The Graphics FIFO is the mechanism used to communicate graphics commands from the CPU to the Graphics Processor (GP). The FIFO base pointer should be 32-byte aligned. memalign() can return 32-byte aligned pointers. The size should also be a multiple of 32B.

The CPU's write-gather pipe is used to write data to the FIFO. Therefore, the FIFO memory area must be forced out of the CPU cache prior to being used. DCInvalidateRange() may be used for this purpose. Due to the mechanics of flushing the write-gather pipe, the FIFO memory area should be at least 32 bytes larger than the maximum expected amount of data stored. Up to 32 NOPs may be written at the end during flushing.

Note
GX_Init() also takes the arguments base and size and initializes a FIFO using these values and attaches the FIFO to both the CPU and GP. The application must allocate the memory for the graphics FIFO before calling GX_Init(). Therefore, it is not necessary to call this function unless you want to resize the default FIFO sometime after GX_Init() has been called or you are creating a new FIFO. The minimum size is 64kB defined by GX_FIFO_MINSIZE.

This function will also set the read and write pointers for the FIFO to the base address, so ordinarily it is not necessary to call GX_InitFifoPtrs() when initializing the FIFO. In addition, This function sets the FIFO's high water mark to (size-16kB) and the low water mark to (size/2), so it is also not necessary to call GX_InitFifoLimits().
Parameters
[in]fifothe fifo struct to use
[in]baseptr to the base of allocation; must be 32-byte aligned
[in]sizesize of the FIFO in bytes; must be multiple of 32; size must be GX_FIFO_MINSIZE or larger
Returns
none

◆ GX_InitFifoLimits()

void GX_InitFifoLimits ( GXFifoObj fifo,
u32  hiwatermark,
u32  lowatermark 
)

Sets the high and low water mark for the fifo.

The high and low water marks are used in immediate-mode, i.e. when the fifo is attached to both the CPU and Graphics Processor (GP) (see GX_SetCPUFifo() and GX_SetGPFifo()).

The hardware keeps track of the number of bytes between the read and write pointers. This number represents how full the FIFO is, and when it is greater than or equal to the hiwatermark, the hardware issues an interrupt. The GX API will suspend sending graphics to the Graphics FIFO until it has emptied to a certain point. The lowatermark is used to set the point at which the FIFO is empty enough to resume sending graphics commands to the FIFO. Both hiwatermark and lowatermark should be in multiples of 32B. The count for lowatermark should be less than hiwatermark. Of course, hiwatermark and lowatermark must be less than the size of the FIFO.

Note
When the FIFO is only attached to the CPU or only attached to the GP, the high and low water mark interrupts are disabled.
Parameters
[in]fifothe fifo struct to use
[in]hiwatermarknumber of bytes to be queued before libogc stops writing commands to the FIFO
[in]lowatermarknumber of bytes to be queued before libogc resumes writing commands to the FIFO
Returns
none

◆ GX_InitFifoPtrs()

void GX_InitFifoPtrs ( GXFifoObj fifo,
void *  rd_ptr,
void *  wt_ptr 
)

Sets the fifo read and write pointers.

Note
This is normally done only during initialization of the FIFO. After that, the graphics hardware manages the FIFO pointers.
Parameters
[in]fifothe fifo struct to use
[in]rd_ptrthe pointer to use for the FIFO read pointer; must be 32-byte aligned
[in]wt_ptrthe pointer to use for the FIFO write pointer; must be 32-byte aligned
Returns
none

◆ GX_InitFogAdjTable()

void GX_InitFogAdjTable ( GXFogAdjTbl table,
u16  width,
f32  projmtx[4][4] 
)

Generates the standard range adjustment table and puts the results into table.

This table can be used by GX_SetFogRangeAdj() to adjust the eye-space Z used for fog based upon the X position of the pixels being rendered. The Y direction is not compensated. This effectively increases the fog density at the edges of the screen, making for a more realistic fog effect. The width of the viewport is specified using width. The projmtx parameter is the projection matrix that is used to render into the viewport. It must be specified so that the function can compute the X extent of the viewing frustum in eye space.

Note
You must allocate table yourself.
Parameters
[in]tablerange adjustment parameter table
[in]widthwidth of the viewport
[in]projmtxprojection matrix used to render into the viewport

◆ GX_InitLightAttn()

void GX_InitLightAttn ( GXLightObj lit_obj,
f32  a0,
f32  a1,
f32  a2,
f32  k0,
f32  k1,
f32  k2 
)

Sts coefficients used in the lighting attenuation calculation in a given light object.

The parameters a0, a1, and a2 are used for angular (spotlight) attenuation. The coefficients k0, k1, and k2 are used for distance attenuation. The attenuation function is:

      atten = clamp0(a2^2 * aattn^2 + a1 * aattn + a0) / (k2 * d^2 + k1 * d + k0)

where aattn is the cosine of the angle between the light direction and the vector from the light position to the vertex, and d is the distance from the light position to the vertex when the channel attenuation function is GX_AF_SPOT. The light color will be multiplied by the atten factor when the attenuation function for the color channel referencing this light is set to GX_AF_SPOT (see GX_SetChanCtrl()).

Note
The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.

The convenience macro GX_InitLightShininess() can be used to set the attenuation parameters for specular lights.

When the channel attenuation function is set to GX_AF_SPEC, the aattn and d parameter are equal to the dot product of the eye-space vertex normal and the half-angle vector set by GX_InitSpecularDir().

This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to a light object
[in]a0angle attenuation coefficient
[in]a1angle attenuation coefficient
[in]a2angle attenuation coefficient
[in]k0distance attenuation coefficient
[in]k1distance attenuation coefficient
[in]k2distance attenuation coefficient
Returns
none

◆ GX_InitLightAttnA()

void GX_InitLightAttnA ( GXLightObj lit_obj,
f32  a0,
f32  a1,
f32  a2 
)

Sets coefficients used in the lighting angle attenuation calculation in a given light object.

The parameters a0, a1, and a2 are used for angular (spotlight) attenuation. The attenuation function is:

      atten = clamp0(a2^2 * cos(theta)^2 + a1 * cos(theta) + a0) / (k2 * d^2 + k1 * d + k0)

where cos(theta) is the cosine of the angle between the light normal and the vector from the light position to the vertex, and d is the distance from the light position to the vertex. The k0-2 coefficients can be set using GX_InitLightAttnK(). You can set both the a0-2 and k0-2 coefficients can be set using GX_InitLightAttn(). The light color will be multiplied by the atten factor when the attenuation function for the color channel referencing this light is set to GX_AF_SPOT (see GX_SetChanCtrl()).

Note
The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.

This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to a light object
[in]a0angle attenuation coefficient
[in]a1angle attenuation coefficient
[in]a2angle attenuation coefficient
Returns
none

◆ GX_InitLightAttnK()

void GX_InitLightAttnK ( GXLightObj lit_obj,
f32  k0,
f32  k1,
f32  k2 
)

Sets coefficients used in the lighting distance attenuation calculation in a given light object.

The coefficients k0, k1, and k2 are used for distance attenuation. The attenuation function is:

      atten = clamp0(a2^2 * cos(theta)^2 + a1 * cos(theta) + a0) / (k2 * d^2 + k1 * d + k0)

where cos(theta) is the cosine of the angle between the light normal and the vector from the light position to the vertex, and d is the distance from the light position to the vertex. The a0-2 coefficients can be set using GX_InitLightAttnA(). You can set both the a0-2 and k0-2 coefficients can be set using GX_InitLightAttn(). The light color will be multiplied by the atten factor when the attenuation function for the color channel referencing this light is set to GX_AF_SPOT (see GX_SetChanCtrl()).

Note
The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.

Note that this function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to a light object
[in]k0distance attenuation coefficient
[in]k1distance attenuation coefficient
[in]k2distance attenuation coefficient
Returns
none

◆ GX_InitLightColor()

void GX_InitLightColor ( GXLightObj lit_obj,
GXColor  col 
)

Sets the color of the light in the light object.

Note
The memory for the light object should be allocated by the application; this function does not load any hardware register directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to the light object
[in]colcolor to set the light to
Returns
none

◆ GX_InitLightDir()

void GX_InitLightDir ( GXLightObj lit_obj,
f32  nx,
f32  ny,
f32  nz 
)

Sets the direction of a light in the light object.

This direction is used when the light object is used as spotlight or a specular light (see the attn_fn parameter of GX_SetChanCtrl()).

Note
The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be transformed to view space.

This function does not set the direction of parallel directional diffuse lights. If you want parallel diffuse lights, you may put the light position very far from every objects to be lit. (See GX_InitLightPos() and GX_SetChanCtrl())

The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to the light object
[in]nxX coordinate of the light normal
[in]nyY coordinate of the light normal
[in]nzZ coordinate of the light normal
Returns
none

◆ GX_InitLightDistAttn()

void GX_InitLightDistAttn ( GXLightObj lit_obj,
f32  ref_dist,
f32  ref_brite,
u8  dist_fn 
)

Sets coefficients for distance attenuation in a light object.

This function uses three easy-to-control parameters instead of k0, k1, and k2 in GX_InitLightAttn().

In this function, you can specify the brightness on an assumed reference point. The parameter ref_distance is distance between the light and the reference point. The parameter ref_brite specifies ratio of the brightness on the reference point. The value for ref_dist should be greater than 0 and that for ref_brite should be within 0 < ref_brite < 1, otherwise distance attenuation feature is turned off. The parameter dist_fn defines type of the brightness decreasing curve by distance; GX_DA_OFF turns distance attenuation feature off.

Note
If you want more flexible control, it is better to use GX_InitLightAttn() and calculate appropriate coefficients.

This function sets parameters only for distance attenuation. Parameters for angular attenuation should be set by using GX_InitLightSpot() or GX_InitLightAttnA().

This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to a light object
[in]ref_distdistance between the light and reference point
[in]ref_britebrightness of the reference point
[in]dist_fnBrightness decreasing function to use
Returns
none

◆ GX_InitLightPos()

void GX_InitLightPos ( GXLightObj lit_obj,
f32  x,
f32  y,
f32  z 
)

Sets the position of the light in the light object.

The GameCube graphics hardware supports local diffuse lights. The position of the light should be in the same space as a transformed vertex position (i.e., view space).

Note
Although the hardware doesn't support parallel directional diffuse lights, it is possible to get "almost parallel" lights by setting sufficient large values to position parameters (x, y and z) which makes the light position very far away from objects to be lit and all rays considered almost parallel.

The memory for the light object must be allocated by the application; this function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to the light object
[in]xX coordinate to place the light at
[in]yY coordinate to place the light at
[in]zZ coordinate to place the light at
Returns
none

◆ GX_InitLightSpot()

void GX_InitLightSpot ( GXLightObj lit_obj,
f32  cut_off,
u8  spotfn 
)

Sets coefficients for angular (spotlight) attenuation in light object.

This function uses two easy-to-control parameters instead of a0, a1, and a2 on GX_InitLightAttn().

The parameter cut_off specifies cutoff angle of the spotlight by degree. The spotlight works while the angle between the ray for a vertex and the light direction given by GX_InitLightDir() is smaller than this cutoff angle. The value for cut_off should be within 0 < cut_off <= 90.0, otherwise given light object doesn't become a spotlight.

The parameter spotfn defines type of the illumination distribution within cutoff angle. The value GX_SP_OFF turns spotlight feature off even if color channel setting is using GX_AF_SPOT (see GX_SetChanCtrl()).

Note
This function can generate only some kind of simple spotlights. If you want more flexible control, it is better to use GX_InitLightAttn() and calculate appropriate coefficients.

This function sets parameters only for angular attenuation. Parameters for distance attenuation should be set by using GX_InitLightDistAttn() or GX_InitLightAttnK().

This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to a light object
[in]cut_offcutoff angle of the spotlight, in degrees
[in]spotfnSpot illumination distribution function to use for this light
Returns
none

◆ GX_InitSpecularDir()

void GX_InitSpecularDir ( GXLightObj lit_obj,
f32  nx,
f32  ny,
f32  nz 
)

Sets the direction of a specular light in the light object.

This direction is used when the light object is used only as specular light. The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be transformed to view space.

Note
This function should be used if and only if the light object is used as specular light. One specifies a specular light in GX_SetChanCtrl() by setting the Attenuation function to GX_AF_SPEC. Furthermore, one must not use GX_InitLightDir() or GX_InitLightPos() to set up a light object which will be used as a specular light since these functions will destroy the information set by GX_InitSpecularDir(). In contrast to diffuse lights (including spotlights) that are considered local lights, a specular light is a parallel light (i.e. the specular light is infinitely far away such that all the rays of the light are parallel), and thus one can only specify directional information.
This function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to a light object
[in]nxX coordinate of the light normal
[in]nyY coordinate of the light normal
[in]nzZ coordinate of the light normal
Returns
none

◆ GX_InitSpecularDirHA()

void GX_InitSpecularDirHA ( GXLightObj lit_obj,
f32  nx,
f32  ny,
f32  nz,
f32  hx,
f32  hy,
f32  hz 
)

Sets the direction and half-angle vector of a specular light in the light object.

These vectors are used when the light object is used only as specular light. In contrast to GX_InitSpecularDir(), which caclulates half-angle vector automatically by assuming the view vector as (0, 0, 1), this function allows users to specify half-angle vector directly as input arguments. It is useful to do detailed control for orientation of highlights.

Note
This function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().

Other notes are similar to those described in GX_InitSpecularDir().
Parameters
[in]lit_objptr to a light object
[in]nxX coordinate of the light normal
[in]nyY coordinate of the light normal
[in]nzZ coordinate of the light normal
[in]hxX coordinate of half-angle
[in]hyY coordinate of half-angle
[in]hzZ coordinate of half-angle
Returns
none

◆ GX_InitTexCacheRegion()

void GX_InitTexCacheRegion ( GXTexRegion region,
u8  is32bmipmap,
u32  tmem_even,
u8  size_even,
u32  tmem_odd,
u8  size_odd 
)

Initializes a texture memory (TMEM) region object for cache.

The region is allocated by the application and can be used as a cache. An application can create many region objects and some of them can overlap; however, no two overlapping regions can be active at the same time.

The possible sizes of a TMEM cache region are 32K, 128K or 512K.

Note
For pre-loaded textures, the region must be defined by using GX_InitTexPreloadRegion().

GX_Init() creates default texture regions, so it is not necessary for the application to use this function unless a different Texture Memory configuration is desired. In that case, the application should also define a region allocator using GX_SetTexRegionCallback().

The function GX_InvalidateTexRegion() can be used to force the texture in main memory associated with this region to be reloaded. This will be necessary whenever the texture data in main memory changes. You may invalidate all cached regions at once using GX_InvalidateTexAll().
Parameters
[in]regionptr to a GXTexRegion struct
[in]is32bmipmapshould be set to GX_TRUE to interpret parameters according to the 32b mipmap meaning.
[in]tmem_evenbase ptr in TMEM for even LODs; must be multiple of 2KB
[in]size_eveneven Texture cache size other than GX_TEXCACHE_NONE
[in]tmem_oddbase ptr in TMEM for odd LODs; must be multiple of 2KB
[in]size_oddodd Texture cache size other than GX_TEXCACHE_NONE
Returns
none

◆ GX_InitTexObj()

void GX_InitTexObj ( GXTexObj obj,
void *  img_ptr,
u16  wd,
u16  ht,
u8  fmt,
u8  wrap_s,
u8  wrap_t,
u8  mipmap 
)

Used to initialize or change a texture object for non-color index textures.

Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes, etc. It is the application's responsibility to provide memory for a texture object. Once initialized, a texture object can be associated with one of eight active texture IDs using GX_LoadTexObj().

Note
To initialize a texture object for color index format textures, use GX_InitTexObjCI().

If the mipmap flag is GX_TRUE, then the texture is a mipmap and the texture will be trilerped. If the mipmap flag is GX_FALSE, the texture is not a mipmap and the texture will be bilerped. To override the filter modes and other mipmap controls, see GX_InitTexObjLOD().
Parameters
[out]objptr to a texture object
[in]img_ptrptr to the image data for a texture, aligned to 32B
[in]wdwidth of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
[in]htheight of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
[in]fmtTexture format
[in]wrap_stexture coordinate wrapping strategy in the S direction; use GX_CLAMP, GX_REPEAT or GX_MIRROR
[in]wrap_ttexture coordinate wrapping strategy in the T direction; use GX_CLAMP, GX_REPEAT or GX_MIRROR
[in]mipmaptrilinear filtering will be used if GX_TRUE, otherwise bilinear is used
Returns
none

◆ GX_InitTexObjBiasClamp()

void GX_InitTexObjBiasClamp ( GXTexObj obj,
u8  biasclamp 
)

Enables bias clamping for texture LOD.

If biasclamp is GX_ENABLE, the sum of LOD and lodbias (given in GX_InitTexObjLODBias()) is clamped so that it is never less than the minimum extent of the pixel projected in texture space. This prevents over-biasing the LOD when the polygon is perpendicular to the view direction.

Parameters
[in]objtexture to set the bias clamp value for
[in]biasclampwhether or not to enable the bias clamp

◆ GX_InitTexObjCI()

void GX_InitTexObjCI ( GXTexObj obj,
void *  img_ptr,
u16  wd,
u16  ht,
u8  fmt,
u8  wrap_s,
u8  wrap_t,
u8  mipmap,
u32  tlut_name 
)

Used to initialize or change a texture object when the texture is color index format.

Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes, etc. It is the application's responsibility to provide memory for a texture object. Once initialized, a texture object can be associated with one of eight active texture IDs using GX_LoadTexObj().

Note
If the mipmap flag is GX_TRUE, then the texture is a mipmap and the texture will be filtered using the GX_LIN_MIP_NEAR filter mode (color index mipmaps cannot use the GX_LIN_MIP_LIN or GX_NEAR_MIP_LIN mode). If the mipmap flag is GX_FALSE, the texture is not a mipmap and the texture will be bilerped. To override the filter modes and other mipmap controls, use GX_InitTexObjLOD(). Mipmap textures should set the width and height to a power of two, but mipmaps do not need to be square.

Non-mipmap (planar) textures do not have to be a power of two. However, to use the GX_REPEAT or GX_MIRROR modes for wrap_s and wrap_t the width and height, respectively, must be a power of two.

The tlut_name is used to indicate which texture lookup table (TLUT) to use for the index to color conversion. To load the TLUT into texture memory, use GX_LoadTlut().
Parameters
[in]objptr to a texture object
[in]img_ptrptr to the image data for a texture, aligned to 32B
[in]wdwidth of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
[in]htheight of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
[in]fmtTexture format
[in]wrap_stexture coordinate wrapping strategy in the S direction; use GX_CLAMP, GX_REPEAT or GX_MIRROR
[in]wrap_ttexture coordinate wrapping strategy in the T direction; use GX_CLAMP, GX_REPEAT or GX_MIRROR
[in]mipmapif GX_TRUE, it is a mipmap texture, else it is a planar texture
[in]tlut_nameTLUT name to use for this texture; default texture configuration recognizes TLUT name
Returns
none

◆ GX_InitTexObjData()

void GX_InitTexObjData ( GXTexObj obj,
void *  img_ptr 
)

Allows one to modify the image data pointer for an existing texture object.

Note
The image format and size for the new data must agree with what they were when the texture object was first initialized using GX_InitTexObj() or GX_InitTexObjCI().
Parameters
[in]objptr to a texture object
[in]img_ptrptr to the texture data in main memory
Returns
none

◆ GX_InitTexObjEdgeLOD()

void GX_InitTexObjEdgeLOD ( GXTexObj obj,
u8  edgelod 
)

Changes LOD computing mode.

When set to GX_ENABLE, the LOD is computed using adjacent texels; when GX_DISABLE, diagonal texels are used instead. This should be set to GX_ENABLE if you use bias clamping (see GX_InitTexObjBiasClamp()) or anisotropic filtering (GX_ANISO_2 or GX_ANISO_4 for GX_InitTexObjMaxAniso() argument).

Parameters
[in]objtexture to set the edge LOD for
[in]edgelodmode to set LOD computation to

◆ GX_InitTexObjFilterMode()

void GX_InitTexObjFilterMode ( GXTexObj obj,
u8  minfilt,
u8  magfilt 
)

Sets the filter mode for a texture.

When the ratio of texels for this texture to pixels is not 1:1, the filter type for minfilt or magfilt is used.

Parameters
[in]objtexture object to set the filters for
[in]minfiltfilter mode to use when the texel/pixel ratio is >= 1.0; needs to be one of Texture filter types.
[in]magfiltfilter mode to use when the texel/pixel ratio is < 1.0; needs to be GX_NEAR or GX_LINEAR

◆ GX_InitTexObjLOD()

void GX_InitTexObjLOD ( GXTexObj obj,
u8  minfilt,
u8  magfilt,
f32  minlod,
f32  maxlod,
f32  lodbias,
u8  biasclamp,
u8  edgelod,
u8  maxaniso 
)

Sets texture Level Of Detail (LOD) controls explicitly for a texture object.

It is the application's responsibility to provide memory for a texture object. When initializing a texture object using GX_InitTexObj() or GX_InitTexObjCI(), this information is set to default values based on the mipmap flag. This function allows the programmer to override those defaults.

Note
This function should be called after GX_InitTexObj() or GX_InitTexObjCI() for a particular texture object.

Setting biasclamp prevents over-biasing the LOD when the polygon is perpendicular to the view direction.

edgelod should be set if biasclamp is set or maxaniso is set to GX_ANISO_2 or GX_ANISO_4.

Theoretically, there is no performance difference amongst various magnification/minification filter settings except GX_LIN_MIP_LIN filter with GX_TF_RGBA8 texture format which takes twice as much as other formats. However, this argument is assuming an environment where texture cache always hits. On real environments, you will see some performance differences by changing filter modes (especially minification filter) because cache-hit ratio changes according to which filter mode is being used.
Parameters
[in]objptr to a texture object
[in]minfiltTexture filter types to use when the texel/pixel ratio is >= 1.0
[in]magfiltTexture filter types to use when the texel/pixel ratio is < 1.0; use only GX_NEAR or GX_LINEAR
[in]minlodminimum LOD value from 0.0 - 10.0 inclusive
[in]maxlodmaximum LOD value from 0.0 - 10.0 inclusive
[in]lodbiasbias to add to computed LOD value
[in]biasclampif GX_ENABLE, clamp (LOD+lodbias) so that it is never less than the minimum extent of the pixel projected in texture space
[in]edgelodif GX_ENABLE, compute LOD using adjacent texels
[in]maxanisoMaximum anisotropy filter control to use
Returns
none

◆ GX_InitTexObjLODBias()

void GX_InitTexObjLODBias ( GXTexObj obj,
f32  lodbias 
)

Sets the LOD bias for a given texture.

The LOD computed by the graphics hardware can be biased using this function. The lodbias is added to the computed lod and the result is clamped between the values given to GX_InitTexObjMinLOD() and GX_InitTexObjMaxLOD(). If GX_ENABLE is given to GX_InitTexObjBiasClamp(), the effect of lodbias will diminish as the polygon becomes more perpendicular to the view direction.

Parameters
[in]objtexture to set the LOD bias for
[in]lodbiasbias to add to computed LOD value

◆ GX_InitTexObjMaxAniso()

void GX_InitTexObjMaxAniso ( GXTexObj obj,
u8  maxaniso 
)

Sets the maximum anisotropic filter to use for a texture.

Anisotropic filtering is accomplished by iterating the square filter along the direction of anisotropy to better approximate the quadralateral. This type of filtering results in sharper textures at the expense of multiple cycles per quad. The hardware will only use multiple cycles when necessary, and the maximum number of cycles is clamped by the maxaniso parameter, so setting maxaniso to GX_ANISO_2 will use at most 2 filter cycles per texture.

Note
These filter cycles are internal to the texture filter hardware and do not affect the available number of TEV stages. When setting maxaniso to GX_ANISO_2 or GX_ANISO_4, the minfilt parameter given to GX_InitTexObjFilterMode() should be set to GX_LIN_MIP_LIN.
Parameters
[in]objtexture to set the max anisotropy value to
[in]maxanisothe maximum anistropic filter to use; must be one of Maximum anisotropy filter control

◆ GX_InitTexObjMaxLOD()

void GX_InitTexObjMaxLOD ( GXTexObj obj,
f32  maxlod 
)

Sets the maximum LOD for a given texture.

void GX_InitTexObjMaxLOD(GXTexObj *obj,f32 maxlod)

Parameters
[in]objtexture to set the maximum LOD for
[in]maxlodmaximum LOD value; the hardware will use MIN(max_lod, lod); range is 0.0 to 10.0.

◆ GX_InitTexObjMinLOD()

void GX_InitTexObjMinLOD ( GXTexObj obj,
f32  minlod 
)

Sets the minimum LOD for a given texture.

Parameters
[in]objtexture to set the minimum LOD for
[in]minlodminimum LOD value; the hardware will use MAX(min_lod, lod); range is 0.0 to 10.0.

◆ GX_InitTexObjTlut()

void GX_InitTexObjTlut ( GXTexObj obj,
u32  tlut_name 
)

Allows one to modify the TLUT that is associated with an existing texture object.

Parameters
[in]objptr to a texture object
[in]tlut_nameTLUT name to use for this texture; default texture configuration recognizes TLUT name
Returns
none

◆ GX_InitTexObjUserData()

GX_InitTexObjUserData ( GXTexObj obj,
void *  userdata 
)

Used to set a pointer to user data in the GXTexObj structure.

You can use this function to attach private data structures to the texture object. This pointer can be retrieved using GX_GetTexObjUserData().

Parameters
[in]objptr to a texture object
[in]userdatapointer to your data to attach to this texture

◆ GX_InitTexObjWrapMode()

void GX_InitTexObjWrapMode ( GXTexObj obj,
u8  wrap_s,
u8  wrap_t 
)

Allows one to modify the texture coordinate wrap modes for an existing texture object.

Parameters
[in]objptr to a texture object
[in]wrap_stexture coordinate wrapping strategy in the S direction; use GX_CLAMP, GX_REPEAT or GX_MIRROR
[in]wrap_ttexture coordinate wrapping strategy in the T direction; use GX_CLAMP, GX_REPEAT or GX_MIRROR
Returns
none

◆ GX_InitTexPreloadRegion()

void GX_InitTexPreloadRegion ( GXTexRegion region,
u32  tmem_even,
u32  size_even,
u32  tmem_odd,
u32  size_odd 
)

Initializes a Texture Memory (TMEM) region object for preloading.

The region is allocated in TMEM by the application and can be used only as a pre-loaded buffer. Cache regions must be allocated by using GX_InitTexCacheRegion(). For pre-loaded textures, the size of the region must match the size of the texture. An application can create many region objects and some of them can overlap; however, no two overlapping regions can be active at the same time.

Note
The maximum size of a region is 512K.
Warning
GX_Init() creates no region for preloading, so the application should allocate appropriate regions if preloading is necessary. It is also required to create cache regions and its allocator by using GX_InitTexCacheRegion() and GX_SetTexRegionCallback(), otherwise new cache regions may overwrite the preloaded areas. (Alternatively, if you do not use any color-index textures, you may preload textures into the portion of texture memory normally allocated to color-index usage by the default allocator.)
Parameters
[in]regionptr to a GXTexRegion struct
[in]tmem_evenbase ptr in TMEM for even LODs; must be 32B aligned
[in]size_evensize of the even cache, in bytes; should be multiple of 32B
[in]tmem_oddbase ptr in TMEM for odd LODs; must be 32B aligned
[in]size_oddsize of the odd cache, in bytes; should be multiple of 32B
Returns
none

◆ GX_InitTlutObj()

void GX_InitTlutObj ( GXTlutObj obj,
void *  lut,
u8  fmt,
u16  entries 
)

Initializes a Texture Look-Up Table (TLUT) object.

The TLUT object describes the location of the TLUT in main memory, its format and the number of entries. The TLUT in main memory described by this object can be loaded into a TLUT allocated in the texture memory using the GX_LoadTlut() function.

Parameters
[in]objptr to a TLUT object
[in]lutptr to look-up table data; must be 32B aligned
[in]fmtformat of the entries in the TLUt; GX_TL_IA8, GX_TL_RGB565 or GX_TL_RGB5A3
[in]entriesnumber of entries in this table; maximum is 16,384
Returns
none

◆ GX_InitTlutRegion()

void GX_InitTlutRegion ( GXTlutRegion region,
u32  tmem_addr,
u8  tlut_sz 
)

Initializes a Texture Look-Up Table (TLUT) region object.

Note
GX_Init() creates default TLUT regions, so the application does not need to call this function unless a new configuration of Texture Memory is desired. In that case, the application should also set a new TLUT region allocator using GX_SetTlutRegionCallback().
Parameters
[in]regionobj ptr to a TLUT region struct; application must allocate this
[in]tmem_addrlocation of the TLU in TMEM; ptr must be aligned to table size
[in]tlut_szsize of the table
Returns
none

◆ GX_InitXfRasMetric()

void GX_InitXfRasMetric ( void  )

Initialize the transformation unit (XF) rasterizer unit (RAS) to take performance measurements.

Warning
This function should be avoided; use the GP performance metric functions instead.
Returns
none

◆ GX_InvalidateTexAll()

void GX_InvalidateTexAll ( void  )

Invalidates the current caches of the Texture Memory (TMEM).

It takes about 512 GP clocks to invalidate all the texture caches.

Note
Preloaded textures (see GX_PreloadEntireTexture()) are not affected.
Returns
none

◆ GX_InvalidateTexRegion()

void GX_InvalidateTexRegion ( GXTexRegion region)

Invalidates the texture cache in Texture Memory (TMEM) described by region.

This function should be called when the CPU is used to modify a texture in main memory, or a new texture is loaded into main memory that is possibly cached in the texture region.

Note
In reality, this function invalidates the cache tags, forcing the texture cache to load new data. Preloaded textures (see GX_PreloadEntireTexture()) do not use the tags.

The texture hardware can invalidate 4 tags each GP clock. Each tag represents a superline or 512B of TMEM. Therefore, it takes 16 GP clocks to invalidate a 32KB texture region.
Parameters
[in]regionptr to GXTexRegion object
Returns
none

◆ GX_InvVtxCache()

void GX_InvVtxCache ( void  )

Invalidates the vertex cache.

Specifically, this functions invalidates the vertex cache tags. This function should be used whenever you relocate or modify data that is read by, or may be cached by, the vertex cache. The invalidate is very fast, taking only two Graphics Processor (GP) clock cycles to complete.

Note
The vertex cache is used to cache indexed attribute data. Any attribute that is set to GX_INDEX8 or GX_INDEX16 in the current vertex descriptor (see GX_SetVtxDesc()) is indexed. Direct data bypasses the vertex cache. Direct data is any attribute that is set to GX_DIRECT in the current vertex descriptor.
Returns
none

◆ GX_LoadLightObj()

void GX_LoadLightObj ( const GXLightObj lit_obj,
u8  lit_id 
)

Loads a light object into a set of hardware registers associated with a Light ID.

This function copies the light object data into the graphics FIFO through the CPU write-gather buffer mechanism. This guarantees that the light object is coherent with the CPU cache.

Note
The light object must have been initialized first using the necessary GX_InitLight*() functions.

Another way to load a light object is with GX_LoadLightObjIdx().
Parameters
[in]lit_objptr to the light object to load
[in]lit_idLight ID to load this light into
Returns
none

◆ GX_LoadLightObjIdx()

void GX_LoadLightObjIdx ( u32  litobjidx,
u8  litid 
)

Instructs the GP to fetch the light object at ltobjindx from an array.

The light object is retrieved from the array to which GX_SetArray(GX_VA_LIGHTARRAY, ...) points. Then it loads the object into the hardware register associated with Light ID.

Note
Data flows directly from the array in DRAM to the GP; therefore, the light object data may not be coherent with the CPU's cache. The application is responsible for storing the light object data from the CPU cache (using DCStoreRange()) before calling GX_LoadLightObjIdx().
Parameters
[in]litobjidxindex to a light object
[in]litidLight ID to load this light into
Returns
none

◆ GX_LoadNrmMtxIdx3x3()

void GX_LoadNrmMtxIdx3x3 ( u16  mtxidx,
u32  pnidx 
)

Loads a 3x3 normal matrix into matrix memory at location pnidx from a 3x3 matrix located at index mtxidx from the array in main memory.

The array is set by set by GX_SetArray(), and the matrix is loaded into matrix memory at index pnidx. This matrix can be used to transform normals in model space to view space, either by making the matrix the current one (see GX_SetCurrentMtx()), or by setting a matrix pnidx for each vertex (see GX_SetVtxDesc()). The matrix will be loaded through the vertex cache. You can also load a position matrix (GX_LoadPosMtxImm() or GX_LoadPosMtxIdx()) to the same pnidx.

Note
You cannot use an indexed load to load a 3x3 matrix from an indexed 3x4 matrix in main memory; you must use GX_LoadNrmMtxImm() for this case.

The matrix is loaded directly from main memory into the matrix memory through the vertex cache, therefore it is incoherent with the CPU's cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.
Parameters
[in]mtxidxindex to the matrix array to load
[in]pnidxPosition-normal matrix index to load into
Returns
none

◆ GX_LoadNrmMtxImm()

void GX_LoadNrmMtxImm ( Mtx  mt,
u32  pnidx 
)

Used to load a normal transform matrix into matrix memory at location pnidx from the 4x3 matrix mt.

This matrix is used to transform normals in model space to view space, either by making it the current matrix (see GX_SetCurrentMtx()), or by setting a matrix pnidx for each vertex. The parameter mt is a pointer to a 3x4 (row x column) matrix. The translation terms in the 3x4 matrix are not needed for normal rotation and are ignored during the load. The parameter pnidx is used to refer to the matrix location (see Position-normal matrix index) in matrix memory.

Note
You can also load a position matrix (GX_LoadPosMtxImm()) to the same pnidx. Normally, the normal matrix will be the inverse transpose of the position (modelview) matrix and is used during vertex lighting. In cases where the modelview and the inverse transpose of the modelview matrix (excluding translation) are the same, the same matrix can be loaded for both normal and position matrices.

The matrix data is copied from main memory or the CPU cache into the Graphics FIFO, so matrices loaded by this function are always coherent with the CPU cache.

To load a normal matrix from a 3x3 matrix, use GX_LoadNrmMtxImm3x3().
Parameters
[in]mtthe matrix to load
[in]pnidxPosition-normal matrix index to load into
Returns
none

◆ GX_LoadNrmMtxImm3x3()

void GX_LoadNrmMtxImm3x3 ( Mtx33  mt,
u32  pnidx 
)

Used to load a normal transform matrix into matrix memory at location pnidx from the 3x3 matrix mt.

This matrix is used to transform normals in model space to view space, either by making it the current matrix (see GX_SetCurrentMtx()), or by setting a matrix pnidx for each vertex. The parameter mt is a pointer to a 3x3 (row x column) matrix. The translation terms in the 3x3 matrix are not needed for normal rotation and are ignored during the load. The parameter pnidx is used to refer to the matrix location (see Position-normal matrix index) in matrix memory.

Note
You can also load a position matrix (GX_LoadPosMtxImm()) to the same pnidx. Normally, the normal matrix will be the inverse transpose of the position (modelview) matrix and is used during vertex lighting. In cases where the modelview and the inverse transpose of the modelview matrix (excluding translation) are the same, the same matrix can be loaded for both normal and position matrices.

The matrix data is copied from main memory or the CPU cache into the Graphics FIFO, so matrices loaded by this function are always coherent with the CPU cache.

Parameters
[in]mtthe matrix to load
[in]pnidxPosition-normal matrix index to load into
Returns
none

◆ GX_LoadPosMtxIdx()

void GX_LoadPosMtxIdx ( u16  mtxidx,
u32  pnidx 
)

Loads a 3x4 modelview matrix at index mtxidx from the array in main memory.

The array is set by GX_SetArray(), and the matrix is loaded into matrix memory at index pnidx (see Position-normal matrix index). This modelview matrix is used to transform positions in model space to view space, either by making the matrix the current one (see GX_SetCurrentMtx()) or by setting a matrix pnidx for each vertex (see GX_SetVtxDesc()). The matrix will be loaded through the vertex cache.

You can also load a normal matrix (GX_LoadNrmMtxImm() or GX_LoadNrmMtxIdx3x3()) to the same pnidx. Generally, the normal matrix will be the inverse transpose of the position matrix. The normal matrix is used during vertex lighting. In cases where the modelview and inverse transpose of the modelview (excluding translation) are the same, you can load the same matrix for both position and normal transforms. Since indexed matrix loads are through the vertex cache, you will only incur the main memory bandwidth load of one matrix load.

Note
The matrix is loaded directly from main memory into the matrix memory thrugh the vertex cache, so it is incoherent with the CPU's cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.
Parameters
[in]mtxidxindex to the matrix array to load
[in]pnidxPosition-normal matrix index to load into
Returns
none

◆ GX_LoadPosMtxImm()

void GX_LoadPosMtxImm ( Mtx  mt,
u32  pnidx 
)

Used to load a 3x4 modelview matrix mt into matrix memory at location pnidx.

This matrix can be used to transform positions in model space to view space, either by making the matrix the current one (see GX_SetCurrentMtx()), or by setting a matrix pnidx for each vertex. The parameter mt is a pointer to a 3x4 (row x column) matrix. The parameter pnidx is used to refer to the matrix location (see Position-normal matrix index) in matrix memory.

You can also load a normal matrix (GX_LoadNrmMtxImm() or GX_LoadNrmMtxIdx3x3()) to the same pnidx. Generally, the normal matrix will be the inverse transpose of the position matrix. The normal matrix is used during vertex lighting. In cases where the modelview and inverse transpose of the modelview (excluding translation) are the same, you can load the same matrix for both position and normal transforms.

Note
The matrix data is copied from DRAM through the CPU cache into the Graphics FIFO, so matrices loaded using this function are always coherent with the CPU cache.
Parameters
[in]mtthe matrix to load
[in]pnidxPosition-normal matrix index to load into
Returns
none

◆ GX_LoadProjectionMtx()

void GX_LoadProjectionMtx ( Mtx44  mt,
u8  type 
)

Sets the projection matrix.

Note
Only two types of projection matrices are supported: GX_PERSPECTIVE or GX_ORTHOGRAPHIC.
Parameters
[in]mtmatrix to use for the perspective
[in]typewhich perspective type to use
Returns
none

◆ GX_LoadTexMtxIdx()

void GX_LoadTexMtxIdx ( u16  mtxidx,
u32  texidx,
u8  type 
)

Loads a texture matrix at index mtxidx from the array in main memory.

The array is set by GX_SetArray(), and the matrix is loaded into matrix memory at location texid. The loaded matrix can be either 2x4 or 3x4 as indicated by type. This matrix can be used to generate texture coordinates from positions, normals, and input texture coordinates (see GX_SetTexCoordGen()). The matrix is loaded through the vertex cache. The size of the matrix to load is indicated by its type. Texture matrices can be either 2x4 or 3x4. GX_MTX_2x4 matrices can be used for simple translations and/or rotations of texture coordinates; GX_MTX_3x4 matrices are used when projection is required.

Note
The matrix is loaded directly from main memory into the matrix memory through the vertex cache, so it is incoherent with the CPU's cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.

This function allows one to load post-transform texture matrices as well. Specifying a texidx in the range of Post-transform texture matrix index will load a post-transform texture matrix instead of a regular, first-pass texture matrix. Note that post-transform matrices are always 3x4. Refer to GX_SetTexCoordGen2() for information about how to use post-transform texture matrices.
Parameters
[in]mtxidxindex to the matrix array to load
[in]texidxTexture matrix index
[in]typeMatrix type
Returns
none

◆ GX_LoadTexMtxImm()

void GX_LoadTexMtxImm ( Mtx  mt,
u32  texidx,
u8  type 
)

Loads a texture matrix mt into the matrix memory at location texidx.

The matrix loaded can be either a 2x4 or 3x4 matrix as indicated by type. You can use the loaded matrix to transform texture coordinates, or to generate texture coordinates from position or normal vectors. Such generated texture coordinates are used for projected textures, reflection mapping, etc. See GX_SetTexCoordGen() for more details.

Texture matrices can be either 2x4 or 3x4. GX_MTX_2x4 matrices can be used for simple translations and/or rotations of texture coordinates. GX_MTX_3x4 matrices are used when projection is required.

Note
The default matrix memory configuration allows for ten (3x4 or 2x4) texture matrices, and a 3x4 identity matrix. The GX_IDENTITY matrix is preloaded by GX_Init().

This function allows one to load post-transform texture matrices as well. Specifying a texidx in the range of Post-transform texture matrix index will load a post-transform texture matrix instead of a regular, first-pass texture matrix. Note that post-transform matrices are always 3x4. Refer to GX_SetTexCoordGen2() for information about how to use post-transform texture matrices.
Parameters
[in]mtthe matrix to load
[in]texidxTexture matrix index
[in]typeMatrix type
Returns
none

◆ GX_LoadTexObj()

void GX_LoadTexObj ( GXTexObj obj,
u8  mapid 
)

Loads the state describing a texture into one of eight hardware register sets.

Before this happens, the texture object obj should be initialized using GX_InitTexObj() or GX_InitTexObjCI(). The id parameter refers to the texture state register set. Once loaded, the texture can be used in any Texture Environment (TEV) stage using GX_SetTevOrder().

Note
This function will call the functions set by GX_SetTexRegionCallback() (and GX_SetTlutRegionCallback() if the texture is color-index format) to obtain the texture regions associated with this texture object. These callbacks are set to default functions by GX_Init().
Warning
If the texture is a color-index texture, you must load the associated TLUT (using GX_LoadTlut()) before calling GX_LoadTexObj().
Parameters
[in]objptr to a texture object
[in]mapidtexture map slot, GX_TEXMAP0 to GX_TEXMAP7 only
Returns
none

◆ GX_LoadTexObjPreloaded()

void GX_LoadTexObjPreloaded ( GXTexObj obj,
GXTexRegion region,
u8  mapid 
)

Loads the state describing a preloaded texture into one of eight hardware register sets.

Before this happens, the texture object obj should be initialized using GX_InitTexObj() or GX_InitTexObjCI(). The mapid parameter refers to the texture state register set. The texture should be loaded beforehand using GX_PreloadEntireTexture(). Once loaded, the texture can be used in any Texture Environment (TEV) stage using GX_SetTevOrder().

Note
GX_Init() initially calls GX_SetTevOrder() to make a simple texture pipeline that associates GX_TEXMAP0 with GX_TEVSTAGE0, GX_TEXMAP1 with GX_TEVSTAGE1, etc.

GX_LoadTexObjPreloaded() will not call the functions set by GX_SetTexRegionCallback() (and GX_SetTlutRegionCallback() if the texture is color index format) because the region is set explicitly; however, these callback functions must be aware of all regions that are preloaded. The default callbacks set by GX_Init() assume there are no preloaded regions.
Parameters
[in]objptr to a texture object
[in]regionptr to a region object that describes an area of texture memory
[in]mapidtexture map slot for reference in a TEV stage
Returns
none

◆ GX_LoadTlut()

void GX_LoadTlut ( GXTlutObj obj,
u32  tlut_name 
)

Copies a Texture Look-Up Table (TLUT) from main memory to Texture Memory (TMEM).

The tlut_name parameter is the name of a pre-allocated area of TMEM. The callback function set by GX_SetTlutRegionCallback() converts the tlut_name into a GXTlutRegion pointer. The TLUT is loaded in the TMEM region described by this pointer. The TLUT object obj describes the location of the TLUT in main memory, the TLUT format, and the TLUT size. obj should have been previously initialized using GX_InitTlutObj().

Note
GX_Init() sets a default callback to convert tlut_names from TLUT name to GXTlutRegion pointers. The default configuration of TMEM has 20 TLUTs, 16 each 256 entries by 16 bits, and 4 each 1k entries by 16 bits. This configuration can be overriden by calling GX_InitTlutRegion() and GX_InitTexCacheRegion() to allocate TMEM. Then you can define your own region allocation scheme using GX_SetTlutRegionCallback() and GX_SetTexRegionCallback().
Parameters
[in]objptr to a TLUT object; application must allocate this
[in]tlut_nameTLUT name
Returns
none

◆ GX_PeekARGB()

void GX_PeekARGB ( u16  x,
u16  y,
GXColor color 
)

Allows the CPU to read a color value directly from the Embedded Frame Buffer (EFB) at position x,y.

Note
For an antialiased frame buffer, only subsample 0 of a pixel is read.
Parameters
[in]xcoordinate, in pixels; must be 0 - 639 inclusive
[in]ycoordinate, in lines; must be 0 - 527 inclusive
[out]colorstruct to store color in
Returns
none

◆ GX_PeekZ()

void GX_PeekZ ( u16  x,
u16  y,
u32 z 
)

Allows the CPU to read a z value directly from the Embedded Frame Buffer (EFB) at position x,y.

The z value is raw integer value from the Z buffer.

Note
The value range is 24-bit when reading from non-antialiased frame buffer. When reading from an antialiased frame buffer, subsample 0 is read and returned. The value will be compressed 16-bit form in this case.
Parameters
[in]xcoordinate, in pixels; must be 0 - 639 inclusive
[in]ycoordinate, in lines; must be 0 - 527 inclusive
[out]zpointer to a returned Z value
Returns
none

◆ GX_PixModeSync()

void GX_PixModeSync ( void  )

Causes the GPU to wait for the pipe to flush.

This function inserts a synchronization command into the graphics FIFO. When the GPU sees this command it will allow the rest of the pipe to flush before continuing. This command is useful in certain situation such as after using GX_CopyTex() and before a primitive that uses the copied texture.

Note
The command is actually implemented by writing the control register that determines the format of the embedded frame buffer (EFB). As a result, care should be used if this command is placed within a display list.
Returns
none

◆ GX_PokeAlphaMode()

GX_PokeAlphaMode ( u8  func,
u8  threshold 
)

Sets a threshold which is compared to the alpha of pixels written to the Embedded Frame Buffer (EFB) using the GX_Poke*() functions.

The compare function order is:

      src_alpha func threshold

Note
The alpha compare function can be used to conditionally write pixels to the EFB using the source alpha channel as a template. If the compare function is true, the source color will be written to the EFB based on the result of the Z compare (see GX_PokeZMode()). If the alpha compare function is false, the source color is not written to the EFB.

The alpha compare test happens before the Z compare and before blending (see GX_PokeBlendMode()).
Parameters
[in]funcCompare type to use
[in]thresholdto which the source alpha will be compared to
Returns
none

◆ GX_PokeAlphaRead()

void GX_PokeAlphaRead ( u8  mode)

Determines what value of alpha will be read from the Embedded Frame Buffer (EFB).

The mode only applies to GX_Peek*() functions.

Note
This feature works no matter what pixel type (see GX_SetPixelFmt()) you are using. If you are using the EFB with alpha plane, it is recommended that you use GX_READ_NONE so that you can read correct alpha value from the EFB. If you are using the EFB with no alpha, you should set either of GX_READ_00 or GX_READ_FF in order to get a certain value.

Parameters
[in]modeAlpha read mode that determines value of alpha read from a frame buffer with no alpha channel.
Returns
none

◆ GX_PokeAlphaUpdate()

void GX_PokeAlphaUpdate ( u8  update_enable)

Enables or disables alpha-buffer updates for GX_Poke*() functions.

The normal rendering state (set by GX_SetAlphaUpdate()) is not affected.

Parameters
[in]update_enableenables alpha-buffer updates with GX_TRUE, otherwise does not
Returns
none

◆ GX_PokeARGB()

void GX_PokeARGB ( u16  x,
u16  y,
GXColor  color 
)

Allows the CPU to write color directly to the Embedded Frame Buffer (EFB) at position x,y.

The alpha value in color can be compared with the current alpha threshold (see GX_PokeAlphaMode()). The color will be blended into the EFB using the blend mode set by GX_PokeBlendMode().

Note
For an antialiased frame buffer, all 3 subsamples of a pixel are affected by the poke.
Parameters
[in]xcoordinate, in pixels; must be 0 - 639 inclusive
[in]ycoordinate, in lines; must be 0 - 527 inclusive
[in]colorcolor to write at the location
Returns
none

◆ GX_PokeBlendMode()

void GX_PokeBlendMode ( u8  type,
u8  src_fact,
u8  dst_fact,
u8  op 
)

Determines how the source image, is blended with the current Embedded Frame Buffer (EFB).

When type is set to GX_BM_NONE, no color data is written to the EFB. When type is set to GX_BM_BLEND, the source and EFB pixels are blended using the following equation:

      dst_pix_clr = src_pix_clr * src_fact + dst_pix_clr * dst_fact<br>

When type is set to GX_BM_SUBTRACT, the destination pixel is computed as follows:

      dst_pix_clr = dst_pix_clr - src_pix_clr [clamped to zero]

Note that src_fact and dst_fact are not part of the equation.

Note
dst_fact can be used only when the frame buffer has GX_PF_RGBA6_Z24 as the pixel format (see GX_SetPixelFmt()).

When type is set to GX_BM_LOGIC, the source and EFB pixels are blended using logical bitwise operations.

This function does not effect the normal rendering state; see GX_SetBlendMode().
Parameters
[in]typeBlending type
[in]src_factsource Blending control; the pixel color produced by the graphics processor is multiplied by this factor
[in]dst_factdestination Blending control; the current frame buffer pixel color is multiplied by this factor
[in]opLogical operation type to use

◆ GX_PokeColorUpdate()

void GX_PokeColorUpdate ( u8  update_enable)

Enables or disables color-buffer updates when writing the Embedded Frame Buffer (EFB) using the GX_Poke*() functions.

Parameters
[in]update_enableenables color-buffer updates with GX_TRUE, otherwise does not
Returns
none

◆ GX_PokeDither()

void GX_PokeDither ( u8  dither)

Enables dithering when writing the Embedded Frame Buffer (EFB) using GX_Poke*() functions.

Note
The dither enable is only valid when the pixel format (see GX_SetPixelFmt()) is either GX_PF_RGBA6_Z24 or GX_PF_RGB565_Z16.

A 4x4 Bayer matrix is used for dithering.
Parameters
[in]ditherif set to GX_TRUE and pixel format is one of the above, dithering is enabled; otherwise disabled
Returns
none

◆ GX_PokeDstAlpha()

void GX_PokeDstAlpha ( u8  enable,
u8  a 
)

Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB).

The EFB pixel type must have an alpha channel for this function to be effective (see GX_SetPixelFmt()). The blending operations (see GX_PokeBlendMode()) still use source alpha but when writing the pixel color, the constant a will replace the pixel alpha in the EFB.

Parameters
[in]enableif set to GX_ENABLE and pixel format supports dest alpha, a will be written to the framebuffer
[in]aconstant alpha value
Returns
none

◆ GX_PokeZ()

void GX_PokeZ ( u16  x,
u16  y,
u32  z 
)

Allows the CPU to write a z value directly to the Embedded Frame Buffer (EFB) at position x,y.

The z value can be compared with the current contents of the EFB. The Z compare fuction is set using GX_PokeZMode().

Note
The z value should be in the range of 0x00000000 <= z < 0x00FFFFFF in the case of non-antialiased frame buffer. For an antialiased frame buffer, the z value should be in the compressed 16-bit format (0x00000000 <= z <= 0x0000FFFF), and the poke will affect all 3 subsamples of a pixel.
Parameters
[in]xcoordinate, in pixels; must be 0 - 639 inclusive
[in]ycoordinate, in lines; must be 0 - 527 inclusive
[in]zvalue to write at position x,y in the EFB
Returns
none

◆ GX_PokeZMode()

void GX_PokeZMode ( u8  comp_enable,
u8  func,
u8  update_enable 
)

Sets the Z-buffer compare mode when writing the Embedded Frame Buffer (EFB).

The result of the Z compare is used to conditionally write color values to the EFB. The Z value will be updated according to the result of the compare if Z update is enabled.

When comp_enable is set to GX_DISABLE, poke Z buffering is disabled and the Z buffer is not updated. The func parameter determines the comparison that is performed. In the comparison function, the poked Z value is on the left while the Z value from the Z buffer is on the right. If the result of the comparison is false, the poked Z value is discarded. The parameter update_enable determines whether or not the Z buffer is updated with the new Z value after a comparison is performed.

Note
The normal rendering Z mode (set by GX_SetZMode()) is not affected by this function.

Even if update_enable is GX_FALSE, compares may still be enabled.
Parameters
[in]comp_enableenables comparisons with source and destination Z values if GX_TRUE
[in]funcCompare type function to use
[in]update_enableenables Z-buffer updates when GX_TRUE
Returns
none

◆ GX_PreloadEntireTexture()

void GX_PreloadEntireTexture ( GXTexObj obj,
GXTexRegion region 
)

Loads a given texture from DRAM into the texture memory.

Accesses to this texture will bypass the texture cache tag look-up and instead read the texels directly from texture memory. The texture region must be the same size as the texture (see GX_InitTexPreloadRegion()).

Note
This function loads the texture into texture memory, but to use it as a source for the Texture Environment (TEV) unit, you must first call GX_LoadTexObjPreloaded(). The default configuration (as set by GX_Init()) of texture memory has no preloaded regions, so you must install your own region allocator callbacks using GX_SetTexRegionCallback() and GX_SetTlutRegionCallback().
Parameters
[in]objptr to object describing the texture to laod
[in]regionTMEM texture region to load the texture into
Returns
none

◆ GX_ReadBoundingBox()

void GX_ReadBoundingBox ( u16 top,
u16 bottom,
u16 left,
u16 right 
)

Returns the bounding box of pixel coordinates that are drawn in the Embedded Framebuffer (EFB).

This function reads the bounding box values. GX_ClearBoundingBox() can be used reset the values of the bounding box.

Note
Since the hardware can only test the bounding box in quads (2x2 pixel blocks), the result of this function may contain error of plus or minus 1 pixel. Also because of this, left and top are always even-numbered and right and bottom are always odd-numbered.
Parameters
[out]topuppermost line in the bounding box
[out]bottomlowest line in the bounding box
[out]leftleftmost pixel in the bounding box
[out]rightrightmost pixel in the bounding box
Returns
none

◆ GX_ReadGPMetric()

void GX_ReadGPMetric ( u32 cnt0,
u32 cnt1 
)

Returns the count of the previously set performance metrics.

Note
The performance metrics can be set using GX_SetGPMetric(); the counters can be cleared using GX_ClearGPMetric().

GX_ReadGPMetric() and GX_ClearGPMetric() can be used in the callback associated with the draw sync interrupt (see GX_SetDrawSyncCallback()). The function GX_SetGPMetric() should not be used in the draw sync callback because it will insert tokens in the GP command stream at random times.

Warning
This function reads results from CPU-accessible registers in the GP, therefore, this command must not be used in a display list. It may also be necessary to send a draw sync token using GX_SetDrawSync() or GX_SetDrawDone() before GX_ReadGPMetric() is called to ensure that the state has actually been processed by the GP.
Parameters
[out]cnt0current value of GP counter 0
[out]cnt1current value of GP counter 1
Returns
none

◆ GX_ReadVCacheMetric()

void GX_ReadVCacheMetric ( u32 check,
u32 miss,
u32 stall 
)

Returns Vertex Cache performance counters.

Each call to this function resets the counter to zero. GX_SetVCacheMetric() sets the metric to be measured by the Vertex Cache performance counter.

Warning
This function reads CPU-accessible registers in the GP and so should not be called in a display list.
Parameters
[out]checktotal number of accesses to the vertex cache
[out]misstotal number of cache misses to the vertex cache
[out]stallnumber of GP clocks that the vertex cache was stalled
Returns
none

◆ GX_ReadXfRasMetric()

void GX_ReadXfRasMetric ( u32 xfwaitin,
u32 xfwaitout,
u32 rasbusy,
u32 clks 
)

Read performance metric values from the XF and RAS units.

Warning
This function should be avoided; use the GP performance metric functions instead.

The parameters for this function are a best guess based on names and existing code.
Parameters
[out]xfwaitinNumber of clocks the XF has waited for data to arrive?
[out]xfwaitoutNumber of clocks the XF has waited to push finished data down?
[out]rasbusyNumber of clocks the RAS has spent being busy?
[out]clksClocks that have passed since last count reset?
Returns
none

◆ GX_RedirectWriteGatherPipe()

volatile void * GX_RedirectWriteGatherPipe ( void *  ptr)

Temporarily points the CPU's write-gather pipe at a new location.

After calling this function, subsequent writes to the address returned by this function (or the WGPipe union) will be gathered and sent to a destination buffer. The write pointer is automatically incremented by the GP. The write gather pipe can be restored by calling GX_RestoreWriteGatherPipe(). This function cannot be called between a GX_Begin()/GX_End() pair.

Note
The destination buffer, referred to by ptr, must be 32 byte aligned. The amount of data written should also be 32-byte aligned. If it is not, zeroes will be added to pad the destination buffer to 32 bytes. No part of the destination buffer should be modified inside the CPU caches - this may introduce cache incoherency problems.

The write gather pipe is one of the fastest ways to move data out of the CPU (the other being the locked cache DMA). In general, you are compute-bound when sending data from the CPU.

This function is cheaper than trying to create a fake CPU fifo around a destination buffer, which requires calls to GX_SetCPUFifo(), GX_InitFifoBase(), etc. This function performs very light weight state saves by assuming that the CPU and GP FIFOs never change.
Warning
No GX commands can be called until the write gather pipe is restored. You MUST call GX_RestoreWriteGatherPipe() before calling this function again, or else the final call to restore the pipe will fail.
Parameters
[in]ptrto destination buffer, 32-byte aligned
Returns
real address of the write-gather "port". All writes to this address will be gathered by the CPU write gather pipe. You may also use the WGPipe union. If you do not use the WGPipe union, ensure that your local variable is volatile.

◆ GX_RestoreWriteGatherPipe()

void GX_RestoreWriteGatherPipe ( void  )

Restores the write-gather pipe.

The CPU fifo that was attached at the time GX_RedirectWriteGatherPipe() was called will be re-attached. If there is data pending in the write gather pipe (e.g. if the amount of data written was not a multiple of 32 bytes), the data will be padded with zeroes and flushed out.

Warning
This function must be called between successive calls to GX_RedirectWriteGatherPipe().
Returns
none

◆ GX_SetAlphaCompare()

void GX_SetAlphaCompare ( u8  comp0,
u8  ref0,
u8  aop,
u8  comp1,
u8  ref1 
)

Sets the parameters for the alpha compare function which uses the alpha output from the last active TEV stage.

The alpha compare operation is:

      alpha_pass = (alpha_src (comp0) ref0) (op) (alpha_src (comp1) ref1)

where alpha_src is the alpha from the last active TEV stage. As an example, you can implement these equations:

      alpha_pass = (alpha_src > ref0) AND (alpha_src < ref1)

or

      alpha_pass = (alpha_src > ref0) OR (alpha_src < ref1)

Note
The output alpha can be used in the blending equation (see GX_SetBlendMode()) to control how source and destination (frame buffer) pixels are combined.

The Z compare can occur either before or after texturing (see GX_SetZCompLoc()). In the case where Z compare occurs before texturing, the Z is written based only on the Z test. The color is written if both the Z test and alpha test pass. When Z compare occurs after texturing, the color and Z are written if both the Z test and alpha test pass. When using texture to make cutout shapes (like billboard trees) that need to be correctly Z buffered, you should configure the pipeline to Z buffer after texturing.

The number of active TEV stages is specified using GX_SetNumTevStages().
Parameters
[in]comp0Compare type subfunction 0
[in]ref0reference val for subfunction 0
[in]aopAlpha combine control for combining subfunctions 0 and 1; must not be GX_MAX_ALPHAOP
[in]comp1Compare type subfunction 1
[in]ref1reference val for subfunction 1
Returns
none

◆ GX_SetAlphaUpdate()

void GX_SetAlphaUpdate ( u8  enable)

Enables or disables alpha-buffer updates of the Embedded Frame Buffer (EFB).

Note
This function also affects whether the alpha buffer is cleared during copy operations; see GX_CopyDisp() and GX_CopyTex().

The only EFB pixel format supporting an alpha buffer is GX_PF_RGBA6_Z24; see GX_SetPixelFmt(). The alpha enable is ignored for non-alpha pixel formats.
Parameters
[in]enableenables alpha-buffer updates with GX_TRUE
Returns
none

◆ GX_SetArray()

void GX_SetArray ( u32  attr,
void *  ptr,
u8  stride 
)

Sets the array base pointer and stride for a single attribute.

The array base and stride are used to compute the address of indexed attribute data using the equation:

      attr_addr = ptr + attr_idx * stride

When drawing a graphics primitive that has been enabled to use indexed attributes (see GX_SetVtxDesc()), attr_idx is supplied in the vertex data. The format and size of the data in the array must also be described using GX_SetVtxAttrFmt(). You can also index other data, such as matrices (see GX_LoadPosMtxIdx(), GX_LoadNrmMtxIdx3x3(), and GX_LoadTexMtxIdx()), and light objects (see GX_LoadLightObjIdx()). In the case of matrices and light objects, the size and format of the data to be loaded is implied by the function call.

There is a base pointer, ptr, for each type of attribute as well as for light data and matrices. Each attribute can be stored in its own array for maximum data compression (i.e., removal of redundant attribute data). The stride is in byte units and is the distance between attributes in the array.

Note
Indexed data is loaded into a vertex cache in the graphics processor. The vertex cache fetches 32B of data for each cache miss; therefore, there is a small performance benefit to aligning attribute arrays to 32B, and possibly for arranging vertex data so that it doesn't span 32B boundaries. Conveniently enough, memalign() returns 32-byte aligned pointers. For static data arrays, you can use the ATTRIBUTE_ALIGN(32) attribute macro to align the ptr to 32B.
Parameters
[in]attrVertex attribute array type that the array is storing
[in]ptrpointer to the array itself
[in]stridestride (in bytes) between each element in the array
Returns
none

◆ GX_SetBlendMode()

void GX_SetBlendMode ( u8  type,
u8  src_fact,
u8  dst_fact,
u8  op 
)

Determines how the source image, generated by the graphics processor, is blended with the Embedded Frame Buffer (EFB).

When type is set to GX_BM_NONE, the source data is written directly to the EFB. When type is set to GX_BM_BLEND, the source color and EFB pixels are blended using the following equation:

      dst_pix_clr = src_pix_clr * src_fact + dst_pix_clr * dst_fact

The GX_BL_DSTALPHA / GX_BL_INVDSTALPHA can be used only when the EFB has GX_PF_RGBA6_Z24 as the pixel format (see GX_SetPixelFmt()). If the pixel format is GX_PF_RGBA6_Z24 then the src_fact and dst_fact are also applied to the alpha channel. To write the alpha channel to the EFB you must call GX_SetAlphaUpdate().

When type is set to GX_BM_LOGIC, the source and EFB pixels are blended using logical bitwise operations. When type is set to GX_BM_SUBTRACT, the destination pixel is computed as follows:

      dst_pix_clr = dst_pix_clr - src_pix_clr [clamped to zero]

Note that src_fact and dst_fact are not part of this equation.

Note
Color updates should be enabled by calling GX_SetColorUpdate().
Parameters
[in]typeBlending type
[in]src_factBlending control
[in]dst_factBlending control
[in]opLogical operation type
Returns
none

◆ GX_SetBreakPtCallback()

GXBreakPtCallback GX_SetBreakPtCallback ( GXBreakPtCallback  cb)

Registers cb as a function to be invoked when a break point is encountered.

Warning
The callback will run with interrupts disabled, so it should terminate as quickly as possible.
Parameters
[in]cbfunction to be invoked when the breakpoint is encountered; NULL means no function will run
Returns
pointer to the previous callback function

◆ GX_SetChanAmbColor()

void GX_SetChanAmbColor ( s32  channel,
GXColor  color 
)

Sets the ambient color register for color channel chan.

This color will be used by the channel as the ambient color if the ambient source, set by GX_SetChanCtrl(), is GX_SRC_REG.

Parameters
[in]channelchannel to set
[in]colorcolor to set it to
Returns
none

◆ GX_SetChanCtrl()

void GX_SetChanCtrl ( s32  channel,
u8  enable,
u8  ambsrc,
u8  matsrc,
u8  litmask,
u8  diff_fn,
u8  attn_fn 
)

Sets the lighting controls for a particular color channel.

The color channel can have one or more (up to 8) lights associated with it, set using litmask. The diff_fn and attn_fn parameters control the lighting equation for all lights associated with this channel; the ambsrc and matsrc can be used to select whether the input source colors come from register colors or vertex colors. When the channel enable is set to GX_FALSE, the material color source (set by matsrc) is passed through as the channel's output color. When the channel enable is GX_TRUE, the output color depends on the settings of the other controls (i.e., the lighting equation). GX_Init() sets the enable for all channels to GX_FALSE. This function only configures the lighting channel; to output the result of the channel computation, use GX_SetNumChans().

Note
Even though channels GX_COLOR0 and GX_ALPHA0 are controlled separately for lighting, they are rasterized together as one RGBA color, effectively GX_COLOR0A0. The same is true for GX_COLOR1 and GX_ALPHA1– effectively, they are rasterized as GX_COLOR1A1. Since there is only one rasterizer for color in the graphics hardware, you must choose which color to rasterize for each stage in the Texture Environment (TEV) unit. This is accomplished using GX_SetTevOrder().

In order to use a vertex color in channel GX_COLOR1A1, two colors per vertex must be supplied, i.e. both GX_VA_CLR0 and GX_VA_CLR1 must be enabled in the current vertex descriptor. If only GX_VA_CLR0 or GX_VA_CLR1 is enabled in the current vertex descriptor, the vertex color is directed to the channel GX_VA_COLOR0A0.

When ambsrc is set to GX_SRC_REG, the color set by GX_SetChanAmbColor() is used as the ambient color. When matsrc is GX_SRC_REG, the color set by GX_SetChanMatColor() is used as the material color.
Parameters
[in]channelcolor channel to use
[in]enablewhether or not to enable lighting for this channel
[in]ambsrcsource for the ambient color
[in]matsrcsource for the material color
[in]litmaskLight ID or IDs to associate with this channel
[in]diff_fnDiffuse function to use
[in]attn_fnAttenuation function to use
Returns
none

◆ GX_SetChanMatColor()

void GX_SetChanMatColor ( s32  channel,
GXColor  color 
)

Sets the material color register for color channel chan.

This color will be used by the channel as the material color if the material source, set by GX_SetChanCtrl(), is GX_SRC_REG.

Parameters
[in]channelchannel to set
[in]colorcolor to set it to
Returns
none

◆ GX_SetClipMode()

void GX_SetClipMode ( u8  mode)

Enables or disables clipping of geometry.

This may help performance issues that occur when objects are far-clipped; however, any near-clipped objects will be rendered incorrectly.

Note
GX_Init() sets this to GX_CLIP_ENABLE.
Parameters
[in]modeClipping mode
Returns
none

◆ GX_SetColorUpdate()

void GX_SetColorUpdate ( u8  enable)

Enables or disables color-buffer updates when rendering into the Embedded Frame Buffer (EFB).

Note
This function also affects whether the color buffer is cleared during copies; see GX_CopyDisp() and GX_CopyTex().
Parameters
[in]enableenables color-buffer updates with GX_TRUE
Returns
none

◆ GX_SetCoPlanar()

void GX_SetCoPlanar ( u8  enable)

Enables or disables coplanar triangle processing.

While coplanar mode is enabled, all subsequent triangles (called decal triangles) will have the same Z coefficients as the reference plane. Coplanar mode should be enabled immediately after a reference triangle is drawn.

Note
The reference triangle can be culled using GX_SetCullMode(GX_CULL_ALL) to create an invisible reference plane; however, the reference triangle must not be completely out of view, i.e. trivially rejected by clipping.

GX_Init() disables coplanar mode.
Parameters
[in]enablewhen GX_ENABLE, coplanar mode is enabled; GX_DISABLE disables this mode
Returns
none

◆ GX_SetCopyClamp()

void GX_SetCopyClamp ( u8  clamp)

Sets the vertical clamping mode to use during the EFB to XFB or texture copy.

Parameters
[in]clampbit-wise OR of desired XFB clamp modes. Use GX_CLAMP_NONE for no clamping.
Returns
none

◆ GX_SetCopyClear()

void GX_SetCopyClear ( GXColor  color,
u32  zvalue 
)

Sets color and Z value to clear the EFB to during copy operations.

These values are used during both display copies and texture copies.

Parameters
[in]colorRGBA color (8-bit/component) to use during clear operation.
[in]zvalue24-bit Z value to use during clear operation. Use the constant GX_MAX_Z24 to specify the maximum depth value.
Returns
none

◆ GX_SetCopyFilter()

void GX_SetCopyFilter ( u8  aa,
u8  sample_pattern[12][2],
u8  vf,
u8  vfilter[7] 
)

Sets the subpixel sample patterns and vertical filter coefficients used to filter subpixels into pixels.

This function normally uses the aa, sample_pattern and vfilter provided by the render mode struct:

GXRModeObj* rmode = VIDEO_GetPreferredMode(NULL);
GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter);
#define NULL
Pointer to 0.
Definition: gctypes.h:56
void GX_SetCopyFilter(u8 aa, u8 sample_pattern[12][2], u8 vf, u8 vfilter[7])
Sets the subpixel sample patterns and vertical filter coefficients used to filter subpixels into pixe...
Definition: gx_struct.h:58
Note
In order to make use of the sample_pattern, antialiasing must be enabled by setting the Embedded Frame Buffer (EFB) format to GX_PF_RGB565_Z16; see GX_SetPixelFmt().
Parameters
[in]aautilizes sample_pattern if GX_TRUE, otherwise all sample points are centered
[in]sample_patternarray of coordinates for sample points; valid range is 1 - 11 inclusive
[in]vfuse vfilter if GX_TRUE, otherwise use default 1-line filter
[in]vfiltervertical filter coefficients; valid coefficient range is 0 - 63 inclusive; sum should equal 64
Returns
none

◆ GX_SetCPUFifo()

void GX_SetCPUFifo ( GXFifoObj fifo)

Attaches a FIFO to the CPU.

Note
If the FIFO being attached is one already attached to the GP, the FIFO can be considered to be in immediate mode. If not, the CPU can write commands, and the GP will execute them when the GP attaches to this FIFO (multi-buffered mode).
Parameters
[in]fifofifo struct containing info on the FIFO to attach
Returns
none

◆ GX_SetCullMode()

void GX_SetCullMode ( u8  mode)

Enables or disables culling of geometry based on its orientation to the viewer.

Primitives in which the vertex order is clockwise to the viewer are considered front-facing.

Note
GX_Init() sets this to GX_CULL_BACK.
Parameters
[in]modeBackface culling mode
Returns
none

◆ GX_SetCurrentGXThread()

lwp_t GX_SetCurrentGXThread ( void  )

Sets the current GX thread to the calling thread.

The new thread should be the thread that will be responsible for generating graphics data. By default, the GX thread is the thread that invoked GX_Init(); however, it may be changed by calling this function.

Note
It is a programming error to change GX thread while the current GX thread is suspended by a high water mark interrupt. This indicates that you have two threads about to generate GX data.

When graphics data is being generated in immediate mode (that is, the CPU FIFO = GP FIFO, and the GP is actively consuming data), the high watermark may be triggered. When this happens, the high watermark interrupt handler will suspend the GX thread, thus preventing any further graphics data from being generated. The low watermark interrupt handler will resume the thread.
Returns
the previous GX thread ID

◆ GX_SetCurrentMtx()

void GX_SetCurrentMtx ( u32  mtx)

Selects a specific matrix to use for transformations.

The matrix mtx specified will be used to select the current modelview transform matrix and normal transform matrix, as long as a matrix index is not present in the vertex data (see GX_SetVtxDesc()). If the current vertex descriptor enables GX_VA_PTNMTXIDX, the matrix mtx specified by this function will be overwritten when the vertices are drawn.

Parameters
[in]mtxPosition-normal matrix index
Returns
none

◆ GX_SetDispCopyDst()

void GX_SetDispCopyDst ( u16  wd,
u16  ht 
)

Sets the witdth and height of the display buffer in pixels.

The application typical renders an image into the EFB(source) and then copies it into the XFB(destination) in main memory. wd specifies the number of pixels between adjacent lines in the destination buffer and can be different than the width of the EFB.

Parameters
[in]wdDistance between successive lines in the XFB, in pixels. Must be a multiple of 16.
[in]htHeight of the XFB in lines.
Returns
none

◆ GX_SetDispCopyFrame2Field()

void GX_SetDispCopyFrame2Field ( u8  mode)

Determines which lines are read from the Embedded Frame Buffer (EFB) when using GX_CopyDisp().

Specifically, it determines whether all lines, only even lines, or only odd lines are read.

Note
The opposite function, which determines whether all lines, only even lines or only odd lines are written to the EFB, is GX_SetFieldMask().

Only applies to display copies, GX_CopyTex() always uses the GX_COPY_PROGRESSIVE mode.
Parameters
[in]modeEFB copy mode to determine which field to copy (or both)
Returns
none

◆ GX_SetDispCopyGamma()

void GX_SetDispCopyGamma ( u8  gamma)

Sets the gamma correction applied to pixels during EFB to XFB copy operation.

Parameters
[in]gammaGamma values
Returns
none

◆ GX_SetDispCopySrc()

void GX_SetDispCopySrc ( u16  left,
u16  top,
u16  wd,
u16  ht 
)

Sets the source parameters for the EFB to XFB copy operation.

Parameters
[in]leftleft most source pixel to copy. Must be a multiple of 2 pixels.
[in]toptop most source line to copy. Must be a multiple of 2 lines.
[in]wdwidth in pixels to copy. Must be a multiple of 2 pixels.
[in]htheight in lines to copy. Must be a multiple of 2 lines.
Returns
none

◆ GX_SetDispCopyYScale()

u32 GX_SetDispCopyYScale ( f32  yscale)

Sets the vertical scale factor for the EFB to XFB copy operation.

The number of actual lines copied is returned, based on the current EFB height. You can use this number to allocate the proper XFB size. You have to call GX_SetDispCopySrc() prior to this function call if you want to get the number of lines by using this function.

Parameters
[in]yscaleVertical scale value. Range from 1.0 to 256.0.
Returns
Number of lines that will be copied.

◆ GX_SetDither()

void GX_SetDither ( u8  dither)

Enables or disables dithering.

A 4x4 Bayer matrix is used for dithering.

Note
Only valid when the pixel format (see GX_SetPixelFmt()) is either GX_PF_RGBA6_Z24 or GX_PF_RGB565_Z16.

Dithering should probably be turned off if you are planning on using the result of rendering for comparisons (e.g. outline rendering algorithm that writes IDs to the alpha channel, copies the alpha channel to a texture, and later compares the texture in the TEV).
Parameters
[in]ditherenables dithering if GX_TRUE is given and pixel format is one of the two above, otherwise disabled
Returns
none

◆ GX_SetDrawDone()

void GX_SetDrawDone ( void  )

Sends a DrawDone command to the GP.

When all previous commands have been processed and the pipeline is empty, a DrawDone status bit will be set, and an interrupt will occur. You can receive notification of this event by installing a callback on the interrupt with GX_SetDrawDoneCallback(), or you can poll the status bit with GX_WaitDrawDone(). This function also flushes the write-gather FIFO in the CPU to make sure that all commands are sent to the graphics processor.

Note
This function is normally used in multibuffer mode (see GX_SetCPUFifo()). In immediate mode, the GX_DrawDone() command can be used, which both sends the command and stalls until the DrawDone status is true.
Returns
none

◆ GX_SetDrawDoneCallback()

GXDrawDoneCallback GX_SetDrawDoneCallback ( GXDrawDoneCallback  cb)

Installs a callback that is invoked whenever a DrawDone command is encountered by the GP.

The DrawDone command is sent by GX_SetDrawDone().

Note
By the time the callback is invoked, the GP will already have resumed reading from the FIFO, if there are any commands in it.
Parameters
[in]cbcallback to be invoked when DrawDone is encountered
Returns
pointer to the previous callback

◆ GX_SetDrawSync()

void GX_SetDrawSync ( u16  token)

This function sends a token into the command stream.

When the token register is set, an interrupt will also be received by the CPU. You can install a callback on this interrupt with GX_SetDrawSyncCallback(). Draw syncs can be used to notify the CPU that the graphics processor is finished using a shared resource (a vertex array for instance).

Parameters
[in]token16-bit value to write to the token register.
Returns
none

◆ GX_SetDrawSyncCallback()

GXDrawSyncCallback GX_SetDrawSyncCallback ( GXDrawSyncCallback  cb)

Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline.

The callback's argument is the value of the token most recently encountered. Since it is possible to miss tokens (graphics processing does not stop while the callback is running), your code should be capable of deducing if any tokens have been missed.

Parameters
[in]cbcallback to be invoked when the DrawSync tokens are encountered in the graphics pipeline.
Returns
pointer to the previously set callback function.

◆ GX_SetDstAlpha()

void GX_SetDstAlpha ( u8  enable,
u8  a 
)

Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB).

Note
To be effective, the EFB pixel type must have an alpha channel (see GX_SetPixelFmt()). The alpha compare operation (see GX_SetAlphaCompare()) and blending operations (see GX_SetBlendMode()) still use source alpha (output from the last TEV stage) but when writing the pixel color, the constant alpha will replace the pixel alpha in the EFB.
Parameters
[in]enablea will be written to the framebuffer if GX_ENABLE is here and frame buffer pixel format supports destination alpha
[in]aconstant alpha value
Returns
none

◆ GX_SetFieldMask()

void GX_SetFieldMask ( u8  even_mask,
u8  odd_mask 
)

selectively enables and disables interlacing of the frame buffer image.

This function is used when rendering fields to an interlaced Embedded Frame Buffer (EFB).

Note
When the mask is GX_FALSE, that field will not be written to the EFB, but the other field will be computed. In other words, you pay the fill rate price of a frame to produce a field.
Parameters
[in]even_maskwhether to write pixels with even Y coordinate
[in]odd_maskwhether to write pixels with odd Y coordinate
Returns
none

◆ GX_SetFieldMode()

void GX_SetFieldMode ( u8  field_mode,
u8  half_aspect_ratio 
)

Controls various rasterization and texturing parameters that relate to field-mode and double-strike rendering.

In field-mode rendering, one must adjust the vertical part of the texture LOD computation to account for the fact that pixels cover only half of the space from one rendered scan line to the next (with the other half of the space filled by a pixel from the other field). In both field-mode and double-strike rendering, one must adjust the aspect ratio for points and lines to account for the fact that pixels will be double-height when displayed (the pixel aspect ratio is 1/2).

Note
The values set here usually come directly from the render mode. The field_rendering flags goes straight into field_mode. The half_aspect_ratio parameter is true if the xfbHeight is half of the viHeight, false otherwise.

GX_Init() sets both fields according to the default render mode.

On production hardware (i.e. a retail GameCube), only line aspect-ratio adjustment is implemented. Points are not adjusted.
Parameters
[in]field_modeadjusts texture LOD computation as described above if true, otherwise does not
[in]half_aspect_ratioadjusts line aspect ratio accordingly, otherwise does not
Returns
none

◆ GX_SetFog()

void GX_SetFog ( u8  type,
f32  startz,
f32  endz,
f32  nearz,
f32  farz,
GXColor  col 
)

Enables fog.

Using type, the programmer may select one of several functions to control the fog density as a function of range to a quad (2x2 pixels). Range is cosine corrected Z in the x-z plane (eye coordinates), but is not corrected in the y direction (see GX_SetFogRangeAdj()). The parameters startz and endz allow further control over the fog behavior. The parameters nearz and farz should be set consistent with the projection matrix parameters. Note that these parameters are defined in eye-space. The fog color, in RGBX format (i.e. the alpha component is ignored), is set using the col parameter. This will be the color of the pixel when fully fogged.

Note
GX_Init() turns fog off by default.
Parameters
[in]typeFog equation control to use
[in]startzminimum Z value at which the fog function is active
[in]endzmaximum Z value at which the fog function is active
[in]nearznear plane (which should match the projection matrix parameters)
[in]farzfar plane (which should match the projection matrix parameters)
[in]colfog color; alpha component is ignored
Returns
none

◆ GX_SetFogColor()

GX_SetFogColor ( GXColor  color)

Sets the fog color.

color is the color that a pixel will be if fully fogged. Alpha channel is ignored.

Parameters
[in]colorcolor to set fog to

◆ GX_SetFogRangeAdj()

void GX_SetFogRangeAdj ( u8  enable,
u16  center,
GXFogAdjTbl table 
)

Enables or disables horizontal fog-range adjustment.

This adjustment is a factor that is multiplied by the eye-space Z used for fog computation; it is based upon the X position of the pixels being rendered. The Y direction is not compensated. This effectively increases the fog density at the edges of the screen, making for a more realistic fog effect. The adjustment is computed per quad (2x2 pixels), not per-pixel. The center of the viewport is specified using center. The range adjustment table is specified using table. The range adjust function is mirrored horizontally about the center.

Note
GX_Init() disables range adjustment.
See also
GX_InitFogAdjTable()
Parameters
[in]enableenables adjustment when GX_ENABLE is passed; disabled with GX_DISABLE
[in]centercenters the range adjust function; normally corresponds with the center of the viewport
[in]tablerange adjustment parameter table
Returns
none

◆ GX_SetGPFifo()

void GX_SetGPFifo ( GXFifoObj fifo)

Attaches fifo to the GP.

Note
If the FIFO is also attached to the CPU, the system is in immediate-mode, and the fifo acts like a true FIFO. In immediate-mode, graphics commands are fed directly from the CPU to the GP. In immediate-mode the FIFO's high and low water marks are active. The high and low water marks implement the flow-control mechanism between the CPU and GP. When the FIFO becomes more full than the high water mark, the CPU will stop writing graphics commands into the FIFO. When the FIFO empties to a point lower than the low water mark, the CPU will resume writing graphics commands into the FIFO. The high and low water marks are set when intializing the FIFO using GX_InitFifoLimits().

If the FIFO is only attached to the GP, the FIFO acts like a buffer. In this case, high and low water marks are disabled, and the GP reads the FIFO until it is empty. Before attaching a new FIFO to the GP, you should make sure the previous FIFO is empty, using the cmdIdle status returned by GX_GetGPStatus().

The break point mechanism can be used to force the FIFO to stop reading commands at a certain point; see GX_EnableBreakPt().
Parameters
[in]fifostruct containing info on the FIFO to attach
Returns
none

◆ GX_SetGPMetric()

void GX_SetGPMetric ( u32  perf0,
u32  perf1 
)

Sets two performance metrics to measure in the GP.

perf0 and perf1 are set to measure. The initial metrics measured are GX_PERF0_NONE and GX_PERF1_NONE, which return counts of zero for the first call to GX_ReadGPMetric().

Each performance counter has a unique set of events or ratios that it can count. In some cases the same metric can be counted using both counters, for example GX_PERF0_VERTICES and GX_PERF1_VERTICES. Ratios (the metric name ends in _RATIO) are multiplied by 1000 (1000 = all misses/clips, etc., 0 = no misses/clips, etc.).

Note
GX_ReadGPMetric() and GX_ClearGPMetric() can be used in the callback associated with the draw sync interrupt (see GX_SetDrawSyncCallback()). This function should not be used in the draw sync callback because it will insert tokens in the GP command stream at random times.
Warning
This function reads results from CPU-accessible registers in the GP, therefore, this command must not be used in a display list. In addition, the performance counters in some cases are triggered by sending tokens through the Graphics FIFO to the GP. This implies that the function should only be used in immediate mode (when the Graphics FIFO is connected to the CPU and the GP at the same time). It may also be necessary to send a draw sync token using GX_SetDrawSync() or call GX_SetDrawDone() after GX_ReadGPMetric() to ensure that the state has actually been processed by the GP.
Parameters
[in]perf0Performance counter 0 metric to measure
[in]perf1Performance counter 1 metric to measure
Returns
none

◆ GX_SetIndTexCoordScale()

void GX_SetIndTexCoordScale ( u8  indtexid,
u8  scale_s,
u8  scale_t 
)

Allows the sharing of a texcoord between an indirect stage and a regular TEV stage.

It allows the texture coordinates to be scaled down for use with an indirect map that is smaller than the corresponding regular map.

Parameters
[in]indtexidIndirect texture stage being affected
[in]scale_sIndirect texture scale factor for the S coord
[in]scale_tIndirect texture scale factor for the T coord
Returns
none

◆ GX_SetIndTexMatrix()

void GX_SetIndTexMatrix ( u8  indtexmtx,
f32  offset_mtx[2][3],
s8  scale_exp 
)

Sets one of the three static indirect matrices and the associated scale factor.

The indirect matrix and scale is used to process the results of an indirect lookup in order to produce offsets to use during a regular lookup. The matrix is multiplied by the [S T U] offsets that have been extracted (and optionally biased) from the indirect lookup color. In this matrix-vector multiply, the matrix is on the left and the [S T U] column vector is on the right.

Note
The matrix values are stored in the hardware as a sign and 10 fractional bits (two's complement); thus the smallest number that can be stored is -1 and the largest is (1 - 1/1024) or approximately 0.999. Since +1 cannot be stored, you may consider dividing all the matrix values by 2 (thus +1 becomes +0.5) and adding one to the scale value in order to compensate.
Parameters
[in]indtexmtxIndirect texture matrix that is being affected
[in]offset_mtxvalues to assign to the indirect matrix
[in]scale_expexponent to use for the associated scale factor
Returns
none

◆ GX_SetIndTexOrder()

void GX_SetIndTexOrder ( u8  indtexstage,
u8  texcoord,
u8  texmap 
)

Used to specify the texcoord and texmap to used with a given indirect lookup.

Parameters
[in]indtexstageIndirect texture stage being affected
[in]texcoordtexture coordinate slot to be used for this stage
[in]texmaptexture map slot to be used for this stage
Returns
none

◆ GX_SetLineWidth()

void GX_SetLineWidth ( u8  width,
u8  fmt 
)

Sets the width of line primitives.

The parameter fmt is added to the texture coordinate to obtain texture coordinates at the other corners of a wide line. The fmt values are added after the texture coordinate generation operation; see GX_SetTexCoordGen().

Parameters
[in]widthwidth of the line in 1/16th pixel increments; maximum width is 42.5 px
[in]fmtTexture offset value
Returns
none

◆ GX_SetMisc()

void GX_SetMisc ( u32  token,
u32  value 
)

Sets miscellanous settings in the GP.

Parameters
[in]tokensetting to change
[in]valuevalue to change the setting to
Returns
none

◆ GX_SetNumChans()

void GX_SetNumChans ( u8  num)

Sets the number of color channels that are output to the TEV stages.

Color channels are the mechanism used to compute per-vertex lighting effects. Color channels are controlled using GX_SetChanCtrl(). Color channels are linked to specific TEV stages using GX_SetTevOrder().

This function basically defines the number of per-vertex colors that get rasterized. If num is set to 0, then at least one texture coordinate must be generated (see GX_SetNumTexGens()). If num is set to 1, then channel GX_COLOR0A0 will be rasterized. If num is set to 2 (the maximum value), then GX_COLOR0A0 and GX_COLOR1A1 will be rasterized.

Parameters
[in]numnumber of color channels to rasterize; number must be 0, 1 or 2
Returns
none

◆ GX_SetNumIndStages()

void GX_SetNumIndStages ( u8  nstages)

Used to set how many indirect lookups will take place.

The results from these indirect lookups may then be used to alter the lookups for any number of regular TEV stages.

Parameters
[in]nstagesnumber of indirect lookup stages
Returns
none

◆ GX_SetNumTevStages()

void GX_SetNumTevStages ( u8  num)

Enables a consecutive number of TEV stages.

The output pixel color (before fogging and blending) is the result from the last stage. The last TEV stage must write to register GX_TEVPREV; see GX_SetTevColorOp() and GX_SetTevAlphaOp(). At least one TEV stage must be enabled. If a Z-texture is enabled, the Z texture must be looked up on the last stage; see GX_SetZTexture().

Note
The association of lighting colors, texture coordinates, and texture maps with a TEV stage is set using GX)SetTevOrder(). The number of texture coordinates available is set using GX_SetNumTexGens(). The number of color channels available is set using GX_SetNumChans().

GX_Init() will set num to 1.
Parameters
[in]numnumber of active TEV stages, between 1 and 16 inclusive
Returns
none

◆ GX_SetNumTexGens()

void GX_SetNumTexGens ( u32  nr)

Sets the number of texture coordinates that are generated and available for use in the Texture Environment TEV stages.

Texture coordinates are generated from input data as described by GX_SetTexCoordGen(). The generated texture coordinates are linked to specific textures and specific TEV stages using GX_SetTevOrder().

Note
A consecutive number of texture coordinates may be generated, starting at GX_TEXCOORD0. A maximum of 8 texture coordinates may be generated. If nr is set to 0, no texture coordinates will be generated. In this case, at least one color channel must be output (see GX_SetNumChans()).
Parameters
[in]nrnumber of tex coords to generate, between 0 and 8 inclusive
Returns
none

◆ GX_SetPixelFmt()

void GX_SetPixelFmt ( u8  pix_fmt,
u8  z_fmt 
)

Sets the format of pixels in the Embedded Frame Buffer (EFB).

There are two non-antialiased pix_fmts: GX_PF_RGB8_Z24 and GX_PF_RGBA6_Z24. The stride of the EFB is fixed at 640 pixels. The non-antialiased EFB has 528 lines available.

When pix_fmt is set to GX_PF_RGB565_Z16, multi-sample antialiasing is enabled. In order to get proper results, one must also call GX_SetCopyFilter(). The position of the subsamples and the antialiasing filter coefficients are set using GX_SetCopyFilter(). When antialiasing, three 16b color/Z samples are computed for each pixel, and the total available number of pixels in the EFB is reduced by half (640 pixels x 264 lines). This function also sets the compression type for 16-bit Z formats, which allows trading off Z precision for range. The following guidelines apply:

      a) far/near ratio <= 2^16, use GX_ZC_LINEAR
      b) far/near ratio <= 2^18, use GX_ZC_NEAR
      c) far/near ratio <= 2^20, use GX_ZC_MID
      d) far/near ratio <= 2^24, use GX_ZC_FAR

It is always best to use as little compression as possible (choice "a" is least compressed, choice "d" is most compressed). You get less precision with higher compression. The "far" in the above list does not necessarily refer to the far clipping plane. You should think of it as the farthest object you want correct occlusion for.

Note
This function also controls antialiasing (AA) mode.

Since changing pixel format requires the pixel pipeline to be synchronized, the use of this function causes stall of the graphics processor as a result. Therefore, you should avoid redundant calls of this function.
Parameters
[in]pix_fmtGX_PF_RGB8_Z24 or GX_PF_RGBA6_Z24 for non-AA, GX_PF_RGB565_Z16 for AA
[in]z_fmtCompressed Z format to use
Returns
none

◆ GX_SetPointSize()

void GX_SetPointSize ( u8  width,
u8  fmt 
)

Sets the size of point primitives.

The parameter fmt is added to the texture coordinate(s), if any, to obtain texture coordinates at the other corners of a point. The fmts are added after the texture coordinate generation operation; see GX_SetTexCoordGen().

Parameters
[in]widthwidth of the point in 1/16th pixel increments; maximum width is 42.5 px
[in]fmtTexture offset value
Returns
none

◆ GX_SetScissor()

void GX_SetScissor ( u32  xOrigin,
u32  yOrigin,
u32  wd,
u32  ht 
)

Sets the scissor rectangle.

The scissor rectangle specifies an area of the screen outside of which all primitives are culled. This function sets the scissor rectangle in screen coordinates. The screen origin (xOrigin=0, yOrigin=0) is at the top left corner of the display.

The values may be within the range of 0 - 2047 inclusive. Using values that extend beyond the EFB size is allowable since the scissor box may be repositioned within the EFB using GX_SetScissorBoxOffset().

Note
By default, the scissor rectangle is set to match the viewport rectangle. GX_Init() initializes the scissor rectangle to match the viewport given the current render mode.
Parameters
[in]xOriginleft-most coord in screen coordinates
[in]yOrigintop-most coord in screen coordinates
[in]wdwidth of the scissorbox in screen coordinates
[in]htheight of the scissorbox in screen coordinates
Returns
none

◆ GX_SetScissorBoxOffset()

void GX_SetScissorBoxOffset ( s32  xoffset,
s32  yoffset 
)

Repositions the scissorbox rectangle within the Embedded Frame Buffer (EFB) memory space.

The offsets are subtracted from the screen coordinates to determine the actual EFB coordinates where the pixels are stored. Thus with positive offsets, the scissor box may be shifted left and/or up; and with negative offsets, the scissor box may be shifted right and/or down.

The intended use for this command is to make it easy to do two-pass antialiased rendering. To draw the top half of the screen, the scissor box is set to the top and the offset set to zero. To draw the bottom half, the scissor box is set to the bottom, and the offset is set to shift the scissor box back up to the top.

Another use for the offset is to displace how an image is rendered with respect to the dither matrix. Since the dither matrix is 4x4, a yoffset of -2 shifts the image down by 2 lines with respect to the matrix. This can be useful for field-rendering mode.

Note
Achieving an offset of an odd number of lines is possible, but more difficult than just changing the scissor box: one must render and copy 2 additional lines, then skip one by adjusting the argument of VIDEO_SetNextFrameBuffer().

GX_Init() initializes the scissor box offset to zero. Since the GP works on 2x2 regions of pixels, only even offsets are allowed.
Parameters
[in]xoffsetnumber of pixels to shift the scissorbox left, between -342 - 382 inclusive; must be even
[in]yoffsetnumber of pixels to shift the scissorbox up, between -342 - 494 inclusive; must be even
Returns
none

◆ GX_SetTevAlphaIn()

void GX_SetTevAlphaIn ( u8  tevstage,
u8  a,
u8  b,
u8  c,
u8  d 
)

Sets the alpha input sources for one tevstage of the Texture Environment (TEV) alpha combiner.

There are fewer alpha inputs than color inputs, and there are no color channels available in the alpha combiner.

Note
The input controls are independent for each TEV stage.
Parameters
[in]tevstageTEV stage
[in]aTEV alpha combiner input
[in]bTEV alpha combiner input
[in]cTEV alpha combiner input
[in]dTEV alpha combiner input
Returns
none

◆ GX_SetTevAlphaOp()

void GX_SetTevAlphaOp ( u8  tevstage,
u8  tevop,
u8  tevbias,
u8  tevscale,
u8  clamp,
u8  tevregid 
)

Sets the tevop, tevbias, tevscale and clamp-mode operation for the alpha combiner for this tevstage of the TEV unit.

This function also specifies the register, tevregid, that will contain the result of the alpha combiner function. The alpha combiner function is:

   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a tevregid = (d (\a tevop) ((1.0 - c)*a + c*b) + \a tevbias) * \a tevscale;<br><br>

The input sources a,b,c and d are set using GX_SetTevAlphaIn().

Parameters
[in]tevstageTEV stage.
[in]tevopTEV combiner operator
[in]tevbiasTEV bias value.
[in]tevscaleTEV scale value.
[in]clampClamp results when GX_TRUE.
[in]tevregidTEV color/output register
Returns
none

◆ GX_SetTevColor()

void GX_SetTevColor ( u8  tev_regid,
GXColor  color 
)

Used to set one of the primary color registers in the TEV unit.

These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the next in a multi-texture configuration. The application is responsible for allocating these registers so that no collisions in usage occur.

Note
This function can only set unsigned 8-bit colors. To set signed, 10-bit colors use GX_SetTevColorS10().
Parameters
[in]tev_regidTEV color/output register.
[in]colorConstant color value.
Returns
none

◆ GX_SetTevColorIn()

void GX_SetTevColorIn ( u8  tevstage,
u8  a,
u8  b,
u8  c,
u8  d 
)

Sets the color input sources for one tevstage of the Texture Environment (TEV) color combiner.

This includes constant (register) colors and alphas, texture color/alpha, rasterized color/alpha (the result of per-vertex lighting), and a few useful constants.

Note
The input controls are independent for each TEV stage.
Parameters
[in]tevstageTEV stage
[in]aTEV color combiner input
[in]bTEV color combiner input
[in]cTEV color combiner input
[in]dTEV color combiner input
Returns
none

◆ GX_SetTevColorOp()

void GX_SetTevColorOp ( u8  tevstage,
u8  tevop,
u8  tevbias,
u8  tevscale,
u8  clamp,
u8  tevregid 
)

Sets the tevop, tevbias, tevscale and clamp-mode operation for the color combiner for this tevstage of the TEV unit.

This function also specifies the register, tevregid, that will contain the result of the color combiner function. The color combiner function is:

      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a tevregid = (d (\a tevop) ((1.0 - c)*a + c*b) + \a tevbias) * \a tevscale;<br><br>

The input sources a,b,c and d are set using GX_SetTevColorIn().

Parameters
[in]tevstageTEV stage.
[in]tevopTEV combiner operator
[in]tevbiasTEV bias value.
[in]tevscaleTEV scale value.
[in]clampClamp results when GX_TRUE.
[in]tevregidTEV color/output register
Returns
none

◆ GX_SetTevColorS10()

void GX_SetTevColorS10 ( u8  tev_regid,
GXColorS10  color 
)

Used to set one of the constant color registers in the TEV unit.

These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the next in a multi-texture configuration. The application is responsible for allocating these registers so that no collisions in usage occur.

Note
This function enables the color components to be signed 10-bit numbers. To set 8-bit unsigned colors (the common case), use GX_SetTevColor().
Parameters
[in]tev_regidTEV color/output register.
[in]colorConstant color value in S10 format.
Returns
none

◆ GX_SetTevDirect()

void GX_SetTevDirect ( u8  tevstage)

Used to turn off all indirect texture processing for the specified regular TEV stage.

Parameters
[in]tevstagethe TEV stage to change
Returns
none

◆ GX_SetTevIndBumpST()

void GX_SetTevIndBumpST ( u8  tevstage,
u8  indstage,
u8  mtx_sel 
)

Sets up an environment-mapped bump-mapped indirect lookup.

The indirect map specifies offsets in (S,T) space. This kind of lookup requires 3 TEV stages to compute. As a result of all this work, a simple 2D bump map is properly oriented to the surface to which it is applied. It is used to alter a normal-based texgen which then looks up an environment map. The environment map may be a simple light map, or else it may be a reflection map of the surrounding scenery.

Note
When using this function, texture lookup should be disabled for the first two TEV stages. The third stage is where the texture lookup is actually performed. The associated geometry must supply normal/binormal/tangent coordinates at each vertex. Appropriate texgens must supply each of these to the proper stages (binormal to the first, tangent to the second, and normal to the third). Although a static indirect matrix is not used, one must choose a matrix slot and set up the associated scale value to be used with this lookup.
Parameters
[in]tevstageTEV stage that is being affected
[in]indstageIndirect texture stage results to use with this TEV stage
[in]mtx_selwhich Indirect texture matrix to multiply the offsets with
Returns
none

◆ GX_SetTevIndBumpXYZ()

void GX_SetTevIndBumpXYZ ( u8  tevstage,
u8  indstage,
u8  mtx_sel 
)

Sets up an environment-mapped bump-mapped indirect lookup.

The indirect map specifies offsets in object (X, Y, Z) space. This kind of lookup requires only one TEV stage to compute; however, the bump map (indirect map) used is geometry-specific. Thus there is a space/computation tradeoff between using this function and using GX_SetTevIndBumpST().

Note
The indirect matrix must be loaded with a transformation for normals from object space to texture space (similar to eye space, but possibly with an inverted Y axis). The surface geometry need only provide regular normals at each vertex. A normal-based texgen must be set up for the regular texture coordinate.
Parameters
[in]tevstageTEV stage that is being affected
[in]indstageIndirect texture stage results to use with this TEV stage
[in]mtx_selwhich Indirect texture matrix to multiply the offsets with
Returns
none

◆ GX_SetTevIndirect()

void GX_SetTevIndirect ( u8  tevstage,
u8  indtexid,
u8  format,
u8  bias,
u8  mtxid,
u8  wrap_s,
u8  wrap_t,
u8  addprev,
u8  utclod,
u8  a 
)

Controls how the results from an indirect lookup will be used to modify a given regular TEV stage lookup.

Parameters
[in]tevstageTEV stage being affected
[in]indtexidIndirect texture stage results to use with this TEV stage
[in]formatIndirect texture format, i.e. how many bits to extract from the indirect result color to use in indirect offsets and the indirect "bump" alpha
[in]biasIndirect texture bias select to be applied to each component of the indirect offset
[in]mtxidwhich Indirect texture matrix and scale value to multiply the offsets with
[in]wrap_sIndirect texture wrap value to use with the S component of the regular texture coordinate
[in]wrap_tIndirect texture wrap value to use with the T component of the regular texture coordinate
[in]addprevwhether the tex coords results from the previous TEV stage should be added in
[in]utclodwhether to the unmodified (GX_TRUE) or modified (GX_FALSE) tex coords for mipmap LOD computation
[in]awhich offset component will supply the Indirect texture bump alpha select, if any
Returns
none

◆ GX_SetTevIndRepeat()

void GX_SetTevIndRepeat ( u8  tevstage)

Set a given TEV stage to use the same texture coordinates as were computed in the previous stage.

Note
This is only useful when the previous stage texture coordinates took more than one stage to compute, as is the case for GX_SetTevIndBumpST().
Parameters
[in]tevstageTEV stage to modify
Returns
none

◆ GX_SetTevIndTile()

void GX_SetTevIndTile ( u8  tevstage,
u8  indtexid,
u16  tilesize_x,
u16  tilesize_y,
u16  tilespacing_x,
u16  tilespacing_y,
u8  indtexfmt,
u8  indtexmtx,
u8  bias_sel,
u8  alpha_sel 
)

Used to implement tiled texturing using indirect textures.

It will set up the correct values in the given indirect matrix; you only need to specify which matrix slot to use.

Note
The regular texture map contains only the tile definitions. The actual texture size to be applied to the polygon being drawn is the product of the base tile size and the size of the indirect map. In order to set the proper texture coordinate scale, one must call GX_SetTexCoordScaleManually(). One can also use GX_SetIndTexCoordScale() in order to use the same texcoord for the indirect stage as the regular TEV stage.
Parameters
[in]tevstageTEV stage that is being affected
[in]indtexidIndirect texture stage results to use with this TEV stage
[in]tilesize_xsize of the tile in the X dimension
[in]tilesize_ysize of the tile in the Y dimension
[in]tilespacing_xspacing of the tiles (in the tile-definition map) in the X dimension
[in]tilespacing_yspacing of the tiles (in the tile-definition map) in the Y dimension
[in]indtexfmtIndirect texture format to use
[in]indtexmtxIndirect texture matrix to multiply the offsets with
[in]bias_selIndirect texture bias select to indicate tile stacking direction for pseudo-3D textures
[in]alpha_selwhich Indirect texture bump alpha select will supply the indirect "bump" alpha, if any (for pseudo-3D textures).
Returns
none

◆ GX_SetTevIndWarp()

void GX_SetTevIndWarp ( u8  tevstage,
u8  indtexid,
u8  bias_flag,
u8  replace_tex,
u8  mtxid 
)

Used to warp a normal texture lookup using an indirect texture map with 8-bit offsets.

Parameters
[in]tevstageTEV stage that is being affected
[in]indtexidIndirect texture stage results to use with this TEV stage
[in]bias_flagbiases the indirect texture map offsets by -128 if the value is GX_TRUE
[in]replace_texGX_TRUE makes the indirect texture map offsets replace the input texture coordinates rather than offset them as with GX_FALSE
[in]mtxidwhich Indirect texture matrix to use for warping the texture
Returns
none

◆ GX_SetTevKAlphaSel()

void GX_SetTevKAlphaSel ( u8  tevstage,
u8  sel 
)

Selects a "konstant" alpha input to be used in a given TEV stage.

The constant alpha input is used only if GX_CA_KONST is selected for an input for that TEV stage. Only one constant alpha selection is available for a given TEV stage, though it may be used for more than one input.

Parameters
[in]tevstageTEV stage
[in]selTEV constant alpha selection
Returns
none

◆ GX_SetTevKColor()

void GX_SetTevKColor ( u8  sel,
GXColor  col 
)

Sets one of the "konstant" color registers in the TEV unit.

These registers are available to all TEV stages. They are constant in the sense that they cannot be written to be the TEV itself.

Parameters
[in]selTEV constant color register
[in]colconstant color value
Returns
none

◆ GX_SetTevKColorS10()

void GX_SetTevKColorS10 ( u8  sel,
GXColorS10  col 
)

Used to set one of the constant color registers in the Texture Environment (TEV) unit.

These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the next in a multi-texture configuration.

Note
The application is responsible for allocating these registers so that no collisions in usage occur.

This function takes 10-bit signed values as color values; use GX_SetTevColor() to give 8-bit values.
Parameters
[in]selTEV color/output register
[in]colconstant color value
Returns
none

◆ GX_SetTevKColorSel()

void GX_SetTevKColorSel ( u8  tevstage,
u8  sel 
)

Selects a "konstant" color input to be used in a given TEV stage.

The constant color input is used only if GX_CC_KONST is selected for an input for that TEV stage. Only one constant color selection is available for a given TEV stage, though it may be used for more than one input.

Parameters
[in]tevstageTEV stage
[in]selTEV constant color selection
Returns
none

◆ GX_SetTevOp()

void GX_SetTevOp ( u8  tevstage,
u8  mode 
)

Simplified function to set various TEV parameters for this tevstage based on a predefined combiner mode.

This is a convenience function designed to make initial programming of the Texture Environment unit (TEV) easier. This function calls GX_SetTevColorIn(), GX_SetTevColorOp(), GX_SetTevAlphaIn() and GX_SetTevAlphaOp() with predefined arguments to implement familiar texture combining functions.

Note
To enable a consecutive set of TEV stages, you must call GX_SetNumTevStages().
Parameters
[in]tevstageTEV stage.
[in]modeTEV combiner operation
Returns
none

◆ GX_SetTevOrder()

void GX_SetTevOrder ( u8  tevstage,
u8  texcoord,
u32  texmap,
u8  color 
)

Specifies the texture and rasterized color that will be available as inputs to this TEV tevstage.

The texture coordinate texcoord is generated from input attributes using the GX_SetTexCoordGen() function and is used to look up the texture map, previously loaded by GX_LoadTexObj(). The color to rasterize for this tevstage is also specified. The color is the result of per-vertex lighting which is controlled by GX_SetChanCtrl().

This function will scale the normalized texture coordinates produced by GX_SetTexCoordGen() according to the size of the texture map in the function call. For this reason, texture coordinates can only be broadcast to multiple texture maps if and only if the maps are the same size. In some cases, you may want to generate a texture coordinate having a certain scale, but disable the texture lookup (this comes up when generating texture coordinates for indirect bump mapping). To accomplish this, use the GX_TEXMAP_DISABLE flag:

GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP3 | GX_TEXMAP_DISABLE, GX_COLORNULL);
#define GX_TEXMAP_DISABLE
Definition: gx.h:675
#define GX_TEXMAP3
Definition: gx.h:668
void GX_SetTevOrder(u8 tevstage, u8 texcoord, u32 texmap, u8 color)
Specifies the texture and rasterized color that will be available as inputs to this TEV tevstage.

This will scale GX_TEXCOORD0 using GX_TEXMAP3 but disable the lookup of GX_TEXMAP3.

Note
This function does not enable the TEV stage. To enable a consecutive number of TEV stages, starting at stage GX_TEVSTAGE0, use GX_SetNumTevStages().

The operation of each TEV stage is independent. The color operations are controlled by GX_SetTevColorIn() and GX_SetTevColorOp(). The alpha operations are controlled by GX_SetTevAlphaIn() and GX_SetTevAlphaOp().

The number of texture coordinates available for all the active TEV stages is set using GX_SetNumTexGens(). The number of color channels available for all the active TEV stages is set using GX_SetNumChans(). Active TEV stages should not reference more texture coordinates or colors than are being generated.

There are some special settings for the color argument. If you specify GX_COLOR_ZERO, you always get zero as rasterized color. If you specify GX_ALPHA_BUMP or GX_ALPHA_BUMPN, you can use "Bump alpha" component from indirect texture unit as rasterized color input (see GX_SetTevIndirect() for details about how to configure bump alpha). Since bump alpha contains only 5-bit data, GX_ALPHA_BUMP shifts them to higher bits, which makes the value range 0-248. Meanwhile GX_ALPHA_BUMPN performs normalization and you can get the value range 0-255.
Parameters
[in]tevstageTEV stage
[in]texcoordtexture coordinate slot
[in]texmaptexture map slot
[in]colorColor channel ID
Returns
none

◆ GX_SetTevSwapMode()

void GX_SetTevSwapMode ( u8  tevstage,
u8  ras_sel,
u8  tex_sel 
)

Selects a set of swap modes for the rasterized color and texture color for a given TEV stage.

This allows the color components of these inputs to be rearranged or duplicated.

Note
There are four different swap mode table entries, and each entry in the table specifies how the RGBA inputs map to the RGBA outputs.
Parameters
[in]tevstageTEV stage
[in]ras_selselects a swap mode for the rasterized color input.
[in]tex_selselects a swap mode for the texture color input.
Returns
none

◆ GX_SetTevSwapModeTable()

void GX_SetTevSwapModeTable ( u8  swapid,
u8  r,
u8  g,
u8  b,
u8  a 
)

Sets up the TEV color swap table.

The swap table allows the rasterized color and texture color to be swapped component-wise. An entry in the table specifies how the input color components map to the output color components.

Parameters
[in]swapidTEV color swap table entry
[in]rinput color component that should be mapped to the red output component.
[in]ginput color component that should be mapped to the green output component.
[in]binput color component that should be mapped to the blue output component.
[in]ainput color component that should be mapped to the alpha output component.
Returns
none

◆ GX_SetTexCoordBias()

void GX_SetTexCoordBias ( u8  texcoord,
u8  s_enable,
u8  t_enable 
)

Sets the texture coordinate bias of a particular texture.

Range bias is used with texture coordinates applied in GX_REPEAT wrap mode in order to increase the precision of texture coordinates that spread out over a large range. The texture coordinate values for a primitive are biased (by an equal integer) towards zero early in the graphics pipeline, thus preserving bits for calculation later in the pipe. Since the coordinates are repeated, this bias by an integer should have no effect upon the actual appearance of the texture.

Note
Texture coordinate range bias is something that is normally set automatically by the GX API (during GX_Begin()); however, when a texture coordinate is being scaled manually (by using GX_SetTexCoordScaleManually()), the associated bias is no longer modified by GX. Thus, GX_SetTexCoordBias() allows the bias to be changed while a texture coordinate is being manually controlled.
Parameters
[in]texcoordtexture coordinate slot being changed
[in]s_enableenable or disable range bias in the S direction with GX_ENABLE/GX_DISABLE
[in]t_enableenable or disable range bias in the T direction with GX_ENABLE/GX_DISABLE
Returns
none

◆ GX_SetTexCoordGen()

void GX_SetTexCoordGen ( u16  texcoord,
u32  tgen_typ,
u32  tgen_src,
u32  mtxsrc 
)

Specifies how texture coordinates are generated.

Output texture coordinates are usually the result of some transform of an input attribute; either position, normal, or texture coordinate. You can also generate texture coordinates from the output color channel of the per-vertex lighting calculations. In C-language syntax the texture coordinate generation function would look like this:

      texcoord = tgen_typ(tgen_src, mtxsrc);

The current vertex descriptor as set by GX_SetVtxDesc() only describes the data input to the graphics processor. Using this function, you can create new output texture coordinates from the input data. The texcoord parameter is used to give the output texture coordinate a name. This texture coordinate can be bound to a texture using GX_SetTevOrder(). GX_SetNumTexGens() specifies a consecutive number of texture coordinates, starting at GX_TEXCOORD0, that are available to GX_SetTevOrder().

Texture matrix index defines a default set of texture matrix names that can be supplied as mtxsrc. The matrix names are actually row addresses (4 floats per row) in the matrix memory that indicate the first row of a loaded matrix. The user may define another memory map of matrix memory to suit their needs. Keep in mind, however, that modelview matrices (see GX_LoadPosMtxImm() and Position-normal matrix index) and texture matrices share matrix memory.

Note
Input texture coordinates must always go through the texture coordinate generation hardware. GX_Init() initializes the hardware (by calling this function) so that all texture coordinates are transformed by the GX_IDENTITY matrix in order to appear as if input coordinates are passed unchanged through to the texture hardware.

There are 8 output texture coordinates that can be referenced in any of the 16 TEV stages. There are a maximum of 8 input texture coordinates.

Parameters
[in]texcoordtexture coordinate slot
[in]tgen_typTexture coordinate generation type
[in]tgen_srcTexture coordinate source
[in]mtxsrcTexture matrix index
Returns
none

◆ GX_SetTexCoordGen2()

void GX_SetTexCoordGen2 ( u16  texcoord,
u32  tgen_typ,
u32  tgen_src,
u32  mtxsrc,
u32  normalize,
u32  postmtx 
)

An extension of GX_SetTexCoordGen(). It allows one to specify additional texgen options.

The first four arguments are identical to those for GX_SetTexCoordGen() and function in the same way. All requirements for the first four arguments are the same as they are for that function as well. The new options only apply for "ordinary" texgens, where the texgen type is GX_TG_MTX2x4 or GX_TG_MTX3x4. They do not work for light-based texgens or emboss texgens.

The normalize argument allows the computed texcoord to be normalized after the multiplication by mtxsrc (the first-pass transformation). After the optional normalization step, the texcoord is then multiplied by the 3x4 matrix postmtx. This matrix is refered to as the post-transform matrix.

The result of this step is the texture coordinate that is used to look up the texture.

Note
The post-transform matrices are separate from the first pass matrices. They are stored in a separate memory area in the same format as the first pass matrices, except that all matrices have three rows.

When a vertex contains only position and one texture coordinate and the texgen type is GX_TG_MTX2x4, there are certain limitations. In this special performance case, normalization is not performed (even if specified).
Parameters
[in]texcoordtexture coordinate slot
[in]tgen_typTexture coordinate generation type
[in]tgen_srcTexture coordinate source
[in]mtxsrcTexture matrix index
[in]normalizeif GX_TRUE, normalize tex coord after first-pass transform. Only used with GX_TG_MTX*.
[in]postmtxPost-transform texture matrix index
Returns
none

◆ GX_SetTexCoordScaleManually()

void GX_SetTexCoordScaleManually ( u8  texcoord,
u8  enable,
u16  ss,
u16  ts 
)

Overrides the automatic texture coordinate scaling (based upon the associated map size) and lets one manually assign the scale values that are used for a given texcoord.

Setting the enable parameter to GX_TRUE gives this behavior. The given texcoord retains these manual scale values until this function is called again. This function is also used to return a given texture coordinate back to normal, automatic scaling (by setting enable to GX_FALSE).

Note
A texture coordinate is scaled after being computed by the relevant texgen and before the actual texture lookup Normally, the scale value is set according to the texture map that is associated with the texcoord by GX_SetTevOrder(). However, there are certain cases where a different scale value is desirable. One such case is when using indirect tiled textures (see GX_SetTevIndTile()).
Parameters
[in]texcoordthe texture coordinate slot being changed
[in]enableif GX_TRUE, scale will be set manually, otherwise set automatically and ss and ts ignored
[in]ssmanual scale value for the S component of the coordinate
[in]tsmanual scale value for the T component of the coordinate
Returns
none

◆ GX_SetTexCopyDst()

void GX_SetTexCopyDst ( u16  wd,
u16  ht,
u32  fmt,
u8  mipmap 
)

This function sets the width and height of the destination texture buffer in texels.

This function sets the width (wd) and height (ht) of the destination texture buffer in texels. The application may render an image into the EFB and then copy it into a texture buffer in main memory. wd specifies the number of texels between adjacent lines in the texture buffer and can be different than the width of the source image. This function also sets the texture format (fmt) to be created during the copy operation. An optional box filter can be enabled using mipmap. This flag will scale the source image by 1/2.

Normally, the width of the EFB and destination wd are the same. When rendering smaller images that get copied and composited into a larger texture buffer, however, the EFB width and texture buffer wd are not necessarily the same.

The Z buffer can be copied to a Z texture format by setting fmt to GX_TF_Z24X8. This operation is only valid when the EFB format is GX_PF_RGB8_Z24 or GX_PF_RGBA6_Z24.

The alpha channel can be copied from an EFB with format GX_PF_RGBA6_Z24 by setting fmt to GX_TF_A8.

Parameters
[in]wddistance between successive lines in the texture buffer, in texels; must be a multiple of the texture tile width, which depends on fmt.
[in]htheight of the texture buffer
[in]fmtTexture format
[in]mipmapflag that indicates framebuffer should be cleared if GX_TRUE.
Returns
none

◆ GX_SetTexCopySrc()

void GX_SetTexCopySrc ( u16  left,
u16  top,
u16  wd,
u16  ht 
)

Sets the source parameters for the Embedded Frame Buffer (EFB) to texture image copy.

The GP will copy textures into the tiled texture format specified in GX_CopyTex(). The GP always copies tiles (32B) so image widths and heights that are not a multiple of the tile width will be padded with undefined data in the copied image

Parameters
[in]leftleft-most source pixel to copy, multiple of two
[in]toptop-most source line to copy, multiple of two
[in]wdwidth to copy in pixels, multiple of two
[in]htheight to copy in pixels, multiple of two
Returns
none

◆ GX_SetTexRegionCallback()

GXTexRegionCallback GX_SetTexRegionCallback ( GXTexRegionCallback  cb)

Sets the callback function called by GX_LoadTexObj() to obtain an available texture region.

GX_Init() calls this function to set a default region-assignment policy. A programmer can override this default region assignment by implementing his own callback function. A pointer to the texture object and the texture map ID that are passed to GX_LoadTexObj() are provided to the callback function.

Parameters
[in]cbptr to a function that takes a pointer to a GXTexObj and a texture map slot as a parameter and returns a pointer to a GXTexRegion.
Returns
pointer to the previously set callback

◆ GX_SetTlutRegionCallback()

GXTlutRegionCallback GX_SetTlutRegionCallback ( GXTlutRegionCallback  cb)

Sets the callback function called by GX_LoadTlut() to find the region into which to load the TLUT.

GX_LoadTexObj() will also call cb to obtain the Texture Look-up Table (TLUT) region when the texture forma is color-index.

GX_Init() calls GX_SetTlutRegionCallback() to set a default TLUT index-to-region mapping. The name for the TLUT from the texture object is provided as an argument to the callback. The callback should return a pointer to the GXTlutRegion for this TLUT index.

Note
For a given tlut_name (in the GXTlutRegionCallback struct), cb must always return the same GXTlutRegion; this is because GX_LoadTlut() will initialize data into the GXTlutRegion which GX_LoadTexObj() will subsequently use.
Parameters
[in]cbptr to a function that takes a u32 TLUT name as a parameter and returns a pointer to a GXTlutRegion.
Returns
pointer to the previously set callback

◆ GX_SetVCacheMetric()

void GX_SetVCacheMetric ( u32  attr)

Sets the metric the Vertex Cache performance counter will measure.

It is possible to monitor a particular attribute or all attributes using attr.

Note
To clear the counter, call GX_ClearVCacheMetric(); to read the counter value, call GX_ReadVCacheMetric().
Parameters
[in]attrVertex cache performance counter to measure
Returns
none

◆ GX_SetViewport()

void GX_SetViewport ( f32  xOrig,
f32  yOrig,
f32  wd,
f32  ht,
f32  nearZ,
f32  farZ 
)

Sets the viewport rectangle in screen coordinates.

The screen origin (xOrig = 0.0f, yOrig = 0.0f) is at the top left corner of the display. Floating point arguments allow the viewport to be adjusted by 1/2 line for interlaced field rendering modes; see GX_SetViewportJitter(). The viewport depth parameters are normalized coordinates from 0.0f - 1.0f. The GX API will convert the depth range values to proper scale values depending on the type and format of the Z-buffer.

Note
You should avoid using negative values for xOrig or yOrig. While this may work, it may cause problems with points and lines being clipped incorrectly. If you need to shift the viewport up or left, consider using GX_SetScissorBoxOffset() instead.
Parameters
[in]xOrigleft-most X coordinate on the screen
[in]yOrigtop-most Y coordinate on the screen
[in]wdwidth of the viewport
[in]htheight of the viewport
[in]nearZvalue to use for near depth scale
[in]farZvalue to use for far depth scale
Returns
none

◆ GX_SetViewportJitter()

void GX_SetViewportJitter ( f32  xOrig,
f32  yOrig,
f32  wd,
f32  ht,
f32  nearZ,
f32  farZ,
u32  field 
)

Sets the viewport and adjusts the viewport's line offset for interlaced field rendering.

Depending on whether the viewport starts on an even or odd line, and whether the next field to be rendered is even or odd, the viewport may be adjusted by half a line. This has the same effect as slightly tilting the camera down and is necessary for interlaced rendering. No other camera adjustment (i.e. don't change the projection matrix) is needed for interlaced field rendering.

Note
To set a viewport without jitter, use GX_SetViewport().
Parameters
[in]xOrigleft-most X coordinate on the screen
[in]yOrigtop-most Y coordinate on the screen
[in]wdwidth of the viewport
[in]htheight of the viewport
[in]nearZvalue to use for near depth scale
[in]farZvalue to use for far depth scale
[in]fieldwhether the next field is even (0) or odd (1)
Returns
none

◆ GX_SetVtxAttrFmt()

void GX_SetVtxAttrFmt ( u8  vtxfmt,
u32  vtxattr,
u32  comptype,
u32  compsize,
u32  frac 
)

Sets the attribute format (vtxattr) for a single attribute in the Vertex Attribute Table (VAT).

Each attribute format describes the data type (comptype), number of elements (compsize), and fixed point format (frac), if required. The are eight vertex formats available in the VAT. The vertex format describes the format of all attributes in a vertex. The application can pre-program all eight vertex formats and then select one of them during the actual drawing of geometry (See GX_Begin()). Note that all vertices used to draw a particular graphics primitive will have the same format. The vertex format set using this function, along with the current vertex descriptor set using GX_SetVtxDesc(), completely define the vertex data format.

Note
The vertex format allows data to be sent to the graphics processor in its most quantized format. The graphics hardware will inverse-quantize the data (into floating point format) before it is used. The vertex attribute format is used to communicate the data quantization format to the hardware.

GX_VA_NRM and GX_VA_NBT attributes share the same type. Also, the frac for these attributes is fixed according to the type. The component count (compsize) for GX_VA_NRM must be set to GX_NRM_XYZ. The component count for GX_VA_NBT must be set to GX_NRM_NBT or GX_NRM_NBT3.
Parameters
[in]vtxfmtVertex format index
[in]vtxattrVertex attribute array type
[in]comptypeAttribute component type
[in]compsizeNumber of components in an attribute
[in]fracnumber of fractional bits in a fixed-point number
Returns
none

◆ GX_SetVtxAttrFmtv()

void GX_SetVtxAttrFmtv ( u8  vtxfmt,
GXVtxAttrFmt attr_list 
)

Sets multiple attribute formats within a single vertex format.

This is useful when you need to set all the attributes in a vertex format at once (e.g., during graphics initialization).

Note
The constant GX_MAX_VTXATTRFMT_LISTSIZE should be used to allocate the list. You can get a current vertex format using GX_GetVtxAttrFmtv().
Parameters
[in]vtxfmtVertex format index
[in]attr_listpointer to array of GXVtxAttrFmt structs to draw from
Returns
none

◆ GX_SetVtxDesc()

void GX_SetVtxDesc ( u8  attr,
u8  type 
)

Sets the type of a single attribute (attr) in the current vertex descriptor.

The current vertex descriptor defines which attributes are present in a vertex and how each attribute is referenced. The current vertex descriptor is used by the Graphics Processor (GP) to interpret the graphics command stream produced by the GX API. In particular, the current vertex descriptor is used to parse the vertex data that is present in the command stream.

Parameters
[in]attrVertex attribute array type
[in]typeVertex data input type
Returns
none

◆ GX_SetVtxDescv()

void GX_SetVtxDescv ( GXVtxDesc attr_list)

Sets the type of multiple attributes.

This function is used when more than one attribute needs to be set (e.g., during initialization of geometry).

Note
The constant GX_MAX_VTXATTRFMT_LISTSIZE can be used to allocate memory for attr_list
Parameters
[in]attr_listarray of pointers to GXVtxDesc structs; last element of the array should be GX_VA_NULL
Returns
none

◆ GX_SetZCompLoc()

void GX_SetZCompLoc ( u8  before_tex)

Sets whether Z buffering happens before or after texturing.

Normally, Z buffering should happen before texturing, as this enables better performance by not texturing pixels that are not visible; however, when alpha compare is used, Z buffering must be done after texturing (see GX_SetAlphaCompare()).

Parameters
[in]before_texEnables Z-buffering before texturing when set to GX_TRUE; otherwise, Z-buffering takes place after texturing.
Returns
none

◆ GX_SetZMode()

void GX_SetZMode ( u8  enable,
u8  func,
u8  update_enable 
)

Sets the Z-buffer compare mode.

The result of the Z compare is used to conditionally write color values to the Embedded Frame Buffer (EFB).

When enable is set to GX_DISABLE, Z buffering is disabled and the Z buffer is not updated.

The func parameter determines the comparison that is performed. In the comparison function, the newly rasterized Z value is on the left while the Z value from the Z buffer is on the right. If the result of the comparison is false, the newly rasterized pixel is discarded.

The parameter update_enable determines whether or not the Z buffer is updated with the new Z value after a comparison is performed. This parameter also affects whether the Z buffer is cleared during copy operations (see GX_CopyDisp() and GX_CopyTex()).

Parameters
[in]enableEnables comparisons with source and destination Z values if GX_TRUE; disables compares otherwise.
[in]funcCompare type
[in]update_enableEnables Z-buffer updates when GX_TRUE; otherwise, Z-buffer updates are disabled, but compares may still be enabled.
Returns
none

◆ GX_SetZTexture()

void GX_SetZTexture ( u8  op,
u8  fmt,
u32  bias 
)

Controls Z texture operations.

Z textures can be used to implement image-based rendering algorithms. A composite image consisting of color and depth image planes can be merged into the Embedded Frame Buffer (EFB).

Normally, the Z for a quad (2x2) of pixels is computed as a reference Z and two slopes. Once Z texturing is enabled, the Z is computed by adding a Z texel to the reference Z (op = GX_ZT_ADD) or by replacing the reference Z with the Z texel value (op = GX_ZT_REPLACE).

Z textures are always the output from the last active Texture Environment (TEV) stage (see GX_SetNumTevStages()) when enabled. When Z texturing is enabled, the texture color of the last TEV stage is not available, but all other color inputs and operations are available. The pixel color is always output from the last active TEV stage. You cannot use the TEV to operate on the Z texture, it is fed directly into the Z texture logic.

Z texel formats can be unsigned 8-bit (GX_TF_Z8), 16-bit (GX_TF_Z16), or 24-bit (GX_TF_Z24X8 (32-bit texture)) are used. The Graphics Processor converts the Z-textures to 24-bit values by placing the texel value in the least-significant bits and inserting zero's in the remaining most-significant bits. The 24-bit constant bias is added to the Z texture. If the pixel format is GX_PF_RGB565_Z16 the 24-bit result is converted to the current 16-bit Z format before comparing with the EFB's Z.

Note
The Z-texture calculation is done before the fog range calculation.

GX_Init() disables Z texturing.
Parameters
[in]opZ Texture operator to perform
[in]fmtZ Texture format to use
[in]biasBias value. Format is 24bit unsigned.
Returns
none

◆ GX_TexModeSync()

void GX_TexModeSync ( void  )

Inserts a synchronization command into the graphics FIFO. When the Graphics Processor sees this command, it will allow the texture pipeline to flush before continuing.

This command is necessary when changing the usage of regions of texture memory from preloaded or TLUT to cached areas. It makes sure that the texture pipeline is finished with that area of the texture memory prior to changing its usage. This function should be called prior to drawing any primitives that uses the texture memory region in its new mode. It is not necessary to call this command when changing texture memory regions from cached to preloaded (or TLUT), since the commands to load the regions with data will cause the necessary synchronization to happen automatically.

Returns
none

◆ GX_WaitDrawDone()

void GX_WaitDrawDone ( void  )

Stalls until DrawDone is encountered by the GP.

It means all graphics commands sent before this DrawDone command have executed and the last pixel has been written to the frame buffer. You may want to execute some non-graphics operations between executing GX_SetDrawDone() and this function, but if you simply want to wait and have nothing to execute, you can use GX_DrawDone().

Note
This function is normally used in immediate mode (see GX_SetCPUFifo()). In multibuffer mode, sending the 'done' command is separated from polling the 'done' status (see GX_SetDrawDone() and GX_WaitDrawDone()).
Returns
none