3D Game Builder SDK

SDK Functions

gameSetFontPosition( float x, float y, float z )


Draw text using the currently selected font.


void gameSetFontPosition( float x, float y, float z )

float x

= the x position (range = -240.0 to 240.0)

float y

= the y position (range = -137.0 to 137.0)

float z

= the z position (range = 0.0 to 1.0 or more)

return value

= void (nothing)


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).

You do not have to create a new font to use this function because there is a default system font (font 0) which will be used to draw the text string.

You can optionally create a new font using the gameCreateFont( int id, char * name, int height ) function. Select the new font using the gameSelectFont( int id ) function before you start drawing the font text.

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