GXBegin

C Specification

#include <revolution/gx.h>
void GXBegin(GXPrimitive type, GXVtxFmt vtxfmt, u16 nverts);

Arguments

type specifies the primitive type
Accepted values are:
Name Primitive Type
GX_POINTS Points
GX_LINES Lines
GX_LINESTRIP Line strip
GX_TRIANGLES Triangles
GX_TRIANGLESTRIP Triangle Strips
GX_TRIANGLEFAN Triangle fans
GX_QUADS quad
vtxfmt Specifies the vertex attribute format.
This format is set using GXSetVtxAttrFmt before calling GXBegin. The following values are acceptable: GX_VTXFMT0, GX_VTXFMT1, GX_VTXFMT2, GX_VTXFMT3, GX_VTXFMT4, GX_VTXFMT5, GX_VTXFMT6, and GX_VTXFMT7.
nverts Specifies the number of vertices between GXBegin and GXEnd.
The maximum number of vertices is 65,536. The minimum number of vertices is the same as the minimum number of required primitive types.

Return Values

None.

Description

Use this function to begin drawing a graphics primitive. To draw a graphics primitive, a stream of vertex data matching the description of both GXSetVtxDesc and GXSetVtxAttrFmt is enclosed between GXBegin/GXEnd pairs.

GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_INDEX8);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetArray(GX_VA_POS, &myverts[0], sizeof(f32));

GXBegin(GX_TRIANGLES, GX_VTXFMT0, 6);
    GXPosition1u8(0);  // tri 0, vertex 0, 8b index
    GXPosition1u8(1);  // tri 0, vertex 1, 8b index
    GXPosition1u8(2);  // tri 0, vertex 2, 8b index
    GXPosition1u8(3);  // tri 1, vertex 0, 8b index
    GXPosition1u8(4);  // tri 1, vertex 1, 8b index
    GXPosition1u8(5);  // tri 1, vertex 2, 8b index
GXEnd();

The number of vertices between GXBegin and GXEnd must match that specified by the nverts argument. The type of the primitive will determine the minimum number of vertices required. For example, a GX_TRIANGLES primitive must have at least three vertices.

Primitives for which the vertex order is clockwise, as seen from the viewpoint, are handled as front-facing.

As a rule, GX functions other than vertex stream functions (GXPosition,GXNormal,GXColor,GXTexCoord,GXMatrixIndex) cannot be called between GXBegin and GXEnd.

See Also

GXEnd
GXClearVtxDesc
GXSetVtxDescv
GXSetVtxAttrFmt
GXSetVtxAttrFmtv
GXSetArray
GXPosition
GXNormal
GXColor
GXTexCoord
GXMatrixIndex

Revision History

2007/01/18 Revised the description.
2006/03/01 Initial version.


CONFIDENTIAL