3D Game Builder SDK

SDK Functions

gameSetFontColor(float r,float g,float b,float a)


Set the color and transparency for the currently selected font.


void gameSetFontColor( float r, float g, float b, float a )

float r

= the RED value (range from 0.0 to 1.0)

float g

= the GREEN value (range from 0.0 to 1.0)

float b

= the BLUE value (range from 0.0 to 1.0)

float a

= the ALPHA (transparency) value (range from 0.0 to 1.0)

return value

= void (nothing)


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

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

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