[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.13.2 Drawing Text

This section describes how to draw text.

Loading a Font

Before you can use text you need a font first. Typically you load a font in an initialization routine. Here is an example:

 
iGraphics2D* g2d = ...;
iFontServer* fontserver = g2d->GetFontServer ();
iFont* font = fontserver->LoadFont (CSFONT_COURIER);

See section Using a Custom Font for more information on what fonts are possible.

Actually Drawing the Text

To draw the text you must first make sure you are in 2D mode. Here is how it would work (this code could be put after the call to let the engine draw (view->Draw()):

 
g3d->BeginDraw (CSDRAW_2DGRAPHICS);
int fg = g2d->FindRGB (255, 0, 0);  // Red.
int bg = -1;   // Transparent.
g2d->Write (font, x, y, fg, bg, "This is text");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated using texi2html 1.76.