OpenGL_Text_DrawRasterFont

 

Draw a string of text in an OpenGL window.

 

 

Syntax

 

int  OpenGL_Text_DrawRasterFont(

          char *str,

          short size,

          unsigned char r, unsigned char g, unsigned char b,

          float x, float y, float z

) ;

 

 

Parameters

 

str

Character string to write.

 

size

Font size

 

r, g, b

Color of the text.

 

x, y, z

Position of the string.

 

Return value

 

This function return "0" if an error has occurred.

 

 

Remarks

 

You can use the following codes inside your text string to change the color or font of the text.

 

 

0x01

0x02

0x03

0x04

0x05

0x06

Blue text

Black text

White text

Red text

Yellow text

Green text

 

0xF0

0xF1

0xF2

Normal text

Bold text

Italic text

          

ex:

OpenGL_Text_DrawRasterFont( "Text: \01 Blue, \02 Black, \03 White \04 Red, \05 Yellow, \06 Green", 10, 0, 0, 0, 5, 25, 5 ) ;

OpenGL_Text_DrawRasterFont( "Text: \xF0 Normal, \xF1 Bold, \xF2 Italic", 10, 0, 0, 0, 5, 5, 5 ) ;

 

 

 

Requirements

 

Header:

          sliceO_include.hpp

          sliceO_OpenGL.hpp

 

 

Library:

          sliceO_Structures.lib

 

 

Example

 

...

 

#include          "sliceO_include.hpp"

#include          "sliceO_OpenGL.hpp"

 

// ----------------------------------------------------------------------------

// Draw a 3 line axis system in the bottom left corner of the window

// ----------------------------------------------------------------------------

static          void          Draw_Axis( float scale )

{

static          Vect          p[4] ;

unsigned char          r[3], g[3], b[3] ;

 

          p[1].x = p[2].y = p[3].z = 0.55f * scale ;

 

          // --- each axis can have a diff. color ---

          r[0] = 0xFF, g[0] = 0xFF, b[0] = 0xFF ; // --- white

          r[1] = 0xFF, g[1] = 0xFF, b[1] = 0x00 ; // --- yellow

          r[2] = 0xFF, g[2] = 0x80, b[2] = 0x80 ; // --- red

 

          glBegin( GL_LINES ) ;

 

          // --- X axis ---

          glColor3ub( r[0], g[0], b[0] ) ;

 

          glVertex3fv( &(p[0].x) ) ;

          glVertex3fv( &(p[1].x) ) ;

 

          // --- Y axis ---

          glColor3ub( r[1], g[1], b[1] ) ;

 

          glVertex3fv( &(p[0].x) ) ;

          glVertex3fv( &(p[2].x) ) ;

 

          // --- Z axis ---

          glColor3ub( r[2], g[2], b[2] ) ;

 

          glVertex3fv( &(p[0].x) ) ;

          glVertex3fv( &(p[3].x) ) ;

 

          glEnd() ;

 

          p[1].x = p[2].y = p[3].z = 0.65f * scale ;

          OpenGL_Text_DrawRasterFont( "x", 10, r[0], g[0], b[0], p[1].x, p[1].y, p[1].z ) ;

          OpenGL_Text_DrawRasterFont( "y", 10, r[1], g[1], b[1], p[2].x, p[2].y, p[2].z ) ;

          OpenGL_Text_DrawRasterFont( "z", 10, r[2], g[2], b[2], p[3].x, p[3].y, p[3].z ) ;

}

 

...

 

 

See also