DEMO Font Functions

C Specification

#include <demo.h>

typedef enum
{
DMTF_POINTSAMPLE,   // Point sampling
DMTF_BILERP         // Bilerp filtering
}   DMTexFlt;

#define	DM_FT_OPQ       0 // Opaque
#define	DM_FT_RVS       1 // Reverse
#define	DM_FT_XLU       2 // Translucent

void DEMOInitCaption( s32 ftype, s32 swidth, s32 sheight);
void    DEMOPrintf   ( s16 x, s16 y, s16 z, char* fmt, ... );
void    DEMOPuts     ( s16 x, s16 y, s16 z, char* str);

void    DEMOSetFontType( s32 ftype );
void    DEMOSetupScrnSpc( s32 swidth, s32 sheight, float depth);
void    DEMOLoadFont ( GXTexMapID tmap, GXTexMtx tmat, DMTexFlt tflt);
void    DEMOMtxScreen( Mtx mmtx, Mtx44 mprj, float vpw, float vph, float near);

Arguments

ftype Font type. Determines the GX blend mode.
swidth Screen width.
sheight Screen height.
... Plans for future additions.

Return Values

None.

Description

This function library provides a simple means for displaying text on screen. The text character set is defined using a texture map, and text characters are rendered by rendering texture rectangles.

The DEMOInitCaption function initializes the font system and the DEMOPrintf commands can immediately follow. DEMOInitCaption takes three arguments: font type, screen width, and screen height. The font type controls the GX blending mode and determines if the text is white on black, black on white, or white on transparent. Other text colors and backgrounds are available, but require that the TEV and color channels be set manually. DEMOInitCaption also initializes projection and transform matrices that places the origin in the upper left corner of the screen and maps (X, Y) to absolute pixel coordinates relative to the origin. The default Z values range from 0 to 100.

The DEMOPrintf and DEMOPuts functions render text strings. Carriage returns are also read, but any other nondisplayable text characters are interpreted as EOL markers. The position passed to the function specifies the upper left corner for the first text character to display (also establishes the left margin for carriage returns). Each text character is defined by an 8 x 8 cell including spaces.

The DEMOSetFontType function can be used to change the font type (GX blend mode) without reinitializing everything. The DEMOSetupScrnSpc function can be used to modify projections and transformations. The DEMOLoadFont function may be used to modify texture filtering. DEMOMtxScreen returns a matrix that specifies the screen to camera transformation.

Example Program

The GX and other demos use this example program.

See Also

Revision History

03/01/2006 Initial version.