3D Game Builder SDK

SDK Functions

gameCreateFont( int id, char * name, int height )


Create a new font which can be used for drawing. There is a default font 0 and you can specify up to 10 others by using a font id from 1 to 10.


int gameCreateFont( int id, char * name, int height )

int id

= a font id number to use (you can specify from 1 to 10)

char * name

= the name of the font (e.g: "Arial")

int height

= the height of the new font (use from 8 to 72)

return value

= font id number or 0 if failed


Select the new font using the gameSelectFont( int id ) function before you start drawing the font text.

Set the font position on screen using the gameSetFontPosition( float x, float y, float z ) function. The screen coordinates are in pixels. The screen size = 480 x 272. The center of the screen = ( 0,0,0 ) the top left = ( -240,-136,0 ) and the bottom right = ( 240, 136, 0 ). Set the z value as the depth of the font on screen. Typically use the range from 0.0 (top of screen) to 1.0 (bottom of screen). This allows you to draw text on top and behind other text (for example, to create a black shadow).

Set the font color and transparency using the gameSetFontColor( float r, float g, float b, float a ) function. These values are in the range 0.0 (no color) to 1.0 (full color) for each of RED, GREEN and BLUE. The ALPHA is the transparency value in the range 0.0 (fully transparent / invisible) to 1.0 (no tranparency / opaque).

When you are finished with the font (usually at the end of your game) you can close it using the gameCloseFont( int id ) function.

For Example

#include "3dgamebuilder.h"

// exported game function
DLL_EXPORT int gameLoop(void)
	// create a new font
	gameCreateFont( 1, "Arial", 20 );

	// game loop
		// read the controller

		// start drawing

		// draw hello world in the middle of the screen
		gameSetFontColor( 1.0f, 1.0f, 0.0f, 1.0f );
		gameSetFontPosition( -100.0f, 0.0f, 0.0f );
		gameDrawFont( "Hello World!" );

		// end of drawing

	// clean up

	return 0;

See Also

  gameCreateFont( int id, char * name, int height )
  gameDrawFont( char * message )
  gameSetFontPosition( float x, float y, float z )
  gameSetFontColor( float r, float g, float b, float a )
  gameSelectFont( int id )
  gameCloseFont( int id )

Go Back

SDK Functions