GXBegin

Syntax

#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 Point.
GX_LINES Line.
GX_LINESTRIP Line strip.
GX_TRIANGLES Triangle.
GX_TRIANGLESTRIP Triangle strip.
GX_TRIANGLEFAN Triangle fan.
GX_QUADS Quad.
vtxfmt Specifies the vertex attribute format.
This format is set using the GXSetVtxAttrFmt function before calling the GXBegin function. The following values are acceptable: GX_VTXFMT0, GX_VTXFMT1, GX_VTXFMT2, GX_VTXFMT3, GX_VTXFMT4, GX_VTXFMT5, GX_VTXFMT6, GX_VTXFMT7.
nverts Specifies the number of vertices between GXBegin and GXEnd.
The maximum number of vertices is 65535. 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 descriptions in both the GXSetVtxDesc and GXSetVtxAttrFmt functions is enclosed between a GXBegin/GXEnd pair.

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) * 3 );

GXBegin(GX_TRIANGLES, GX_VTXFMT0, 6);
    GXPosition1x8(0);  // tri 0, vertex 0, 8b index
    GXPosition1x8(1);  // tri 0, vertex 1, 8b index
    GXPosition1x8(2);  // tri 0, vertex 2, 8b index
    GXPosition1x8(3);  // tri 1, vertex 0, 8b index
    GXPosition1x8(4);  // tri 1, vertex 1, 8b index
    GXPosition1x8(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 in which the vertex order is clockwise to the viewer are considered front-facing.

Within GXBegin / GXEnd, a vertex stream is unable, on principle, to call any GX functions other than (GXPosition, GXNormal, GXColor, GXTexCoord, GXMatrixIndex).

See Also

GXEnd, GXClearVtxDesc, GXSetVtxDescv, GXSetVtxAttrFmt, GXSetVtxAttrFmtv, GXSetArray, GXPosition, GXNormal, GXColor, GXTexCoord, GXMatrixIndex

Revision History

2008/05/26 Corrected errors.
2007/01/18 Revised Description.
2006/03/01 Initial version.


CONFIDENTIAL