NVIDIA DRIVE OS Linux API Reference

5.1.3.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
3D Font Text APIs

Detailed Description

Implements 3D APIs for font text used by applications.

For details on the original implementation, see: http://www.opengl.org/code/detail/texfont_glut_based_library_for_creating_fonts_out_of_textures.

The OpenGL ES 2.0 NVTexfont library has been expanded to include both raster and vector fonts. The main functions are described below.

Macros

#define TXF_FORMAT_BYTE   0
 
#define TXF_FORMAT_BITMAP   1
 

Typedefs

typedef void * NVTexfontContext
 
typedef struct _NVTexfontRasterFont NVTexfontRasterFont
 
typedef struct _NVTexfontVectorFont NVTexfontVectorFont
 

Enumerations

enum  NVTexfontRasterFontName {
  NV_TEXFONT_DEFAULT = 0,
  NV_TEXFONT_HELVETICA = 0
}
 
enum  NVTexfontVectorFontName {
  NV_VECTOR_TEXFONT_DEFAULT = 0,
  NV_VECTOR_TEXFONT_INCONSOLATA = 0
}
 

Functions

char * nvtexfontErrorString (void)
 
NVTexfontContext nvtexfontAllocContext (void)
 Allocates a handle for an NVTexfont context. More...
 
void nvtexfontFreeContext (NVTexfontContext tfc)
 Frees the specified NVTexfont context handle. More...
 
void nvtexfontSetContextPos (NVTexfontContext tfc, float x, float y)
 Sets the x,y attributes for the NVTexfont context tfc. More...
 
void nvtexfontSetContextScale (NVTexfontContext tfc, float scaleX, float scaleY)
 Sets the x,y attributes for the NVTexfont context tfc. More...
 
void nvtexfontSetContextColor (NVTexfontContext tfc, float r, float g, float b)
 

Raster Font Functions

int nvtexfontInRasterFont (NVTexfontRasterFont *txf, int c)
 
NVTexfontRasterFontnvtexfontInitRasterFont (NVTexfontRasterFontName font, GLuint texobj, GLboolean setupMipmaps, GLenum minFilter, GLenum magFilter)
 Initializes an NVTexfontRasterFont. More...
 
void nvtexfontUnloadRasterFont (NVTexfontRasterFont *txf)
 Frees textures used by the font txf. More...
 
void nvtexfontRenderString_All (NVTexfontRasterFont *txf, char *string, float x, float y, float scaleX, float scaleY, float r, float g, float b)
 Renders the specified null-terminated string by using the NVTexfont txf. More...
 
void nvtexfontRenderString_Pos (NVTexfontRasterFont *txf, NVTexfontContext tfc, char *string, float x, float y)
 Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted. More...
 
void nvtexfontRenderString (NVTexfontRasterFont *txf, NVTexfontContext tfc, char *string)
 
void nvtexfontGetStringMetrics (NVTexfontRasterFont *txf, char *string, int len, int *width, int *max_ascent, int *max_descent)
 

Vector Font Functions

int nvtexfontInVectorFont (NVTexfontVectorFont *vtf, int c)
 
NVTexfontVectorFontnvtexfontInitVectorFont (NVTexfontVectorFontName font, GLboolean antialias, GLboolean use_vbo)
 Initialize an NVTexfontVectorFont. More...
 
void nvtexfontUnloadVectorFont (NVTexfontVectorFont *vtf)
 Frees resources used by the vector font vtf, including the VBO if used. More...
 
void nvtexfontRenderVecString_All (NVTexfontVectorFont *vtf, char *string, float x, float y, float scaleX, float scaleY, float r, float g, float b)
 Renders the specified null-terminated string by using the NVTexfontVectorFont vtf. More...
 
void nvtexfontRenderVecString_Pos (NVTexfontVectorFont *vtf, NVTexfontContext tfc, char *string, float x, float y)
 Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted. More...
 
void nvtexfontRenderVecString (NVTexfontVectorFont *vtf, NVTexfontContext tfc, char *string)
 Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted. More...
 

Macro Definition Documentation

#define TXF_FORMAT_BITMAP   1

Definition at line 71 of file nvtexfont.h.

#define TXF_FORMAT_BYTE   0

Definition at line 70 of file nvtexfont.h.

Typedef Documentation

typedef void* NVTexfontContext

Definition at line 73 of file nvtexfont.h.

typedef struct _NVTexfontRasterFont NVTexfontRasterFont

Definition at line 85 of file nvtexfont.h.

typedef struct _NVTexfontVectorFont NVTexfontVectorFont

Definition at line 86 of file nvtexfont.h.

Enumeration Type Documentation

Enumerator
NV_TEXFONT_DEFAULT 
NV_TEXFONT_HELVETICA 

Definition at line 75 of file nvtexfont.h.

Enumerator
NV_VECTOR_TEXFONT_DEFAULT 
NV_VECTOR_TEXFONT_INCONSOLATA 

Definition at line 80 of file nvtexfont.h.

Function Documentation

NVTexfontContext nvtexfontAllocContext ( void  )

Allocates a handle for an NVTexfont context.

Default settings are held for each context.

char* nvtexfontErrorString ( void  )
void nvtexfontFreeContext ( NVTexfontContext  tfc)

Frees the specified NVTexfont context handle.

void nvtexfontGetStringMetrics ( NVTexfontRasterFont txf,
char *  string,
int  len,
int *  width,
int *  max_ascent,
int *  max_descent 
)
NVTexfontRasterFont* nvtexfontInitRasterFont ( NVTexfontRasterFontName  font,
GLuint  texobj,
GLboolean  setupMipmaps,
GLenum  minFilter,
GLenum  magFilter 
)

Initializes an NVTexfontRasterFont.

By default, NVTexfont supports only the NV_TEXFONT_HELVETICA font. NV_TEXFONT_DEFAULT is the same as NV_TEXFONT_HELVETICA. More may be compiled into the library, at the cost of making the library larger.

Parameters
fontSpecifies the raster font to initialize.
texobjSpecifies the texture object. If 0, a name is generated using the OpenGL 4 glGenTextures function.
setupMipmapsSpecifies the MIP maps to accompany this texture.
minFilterSpecifies the minimum filter for the MIP maps.
magFilterSpecifies the maximum filter for the MIP maps.
NVTexfontVectorFont* nvtexfontInitVectorFont ( NVTexfontVectorFontName  font,
GLboolean  antialias,
GLboolean  use_vbo 
)

Initialize an NVTexfontVectorFont.

By default, NVTexfont supports one vector font: NV_VECTOR_TEXFONT_INCONSOLATA. NV_TEXFONT_DEFAULT is the same as NV_VECTOR_TEXFONT_INCONSOLATA.

Parameters
fontSpecifies the vector font to initialize.
antialiasSpecifies whether the text should be antialiased when drawn.
use_vboSpecifies whether a vertex buffer object (VBO) should be used to speed up the rendering.
int nvtexfontInRasterFont ( NVTexfontRasterFont txf,
int  c 
)
int nvtexfontInVectorFont ( NVTexfontVectorFont vtf,
int  c 
)
void nvtexfontRenderString ( NVTexfontRasterFont txf,
NVTexfontContext  tfc,
char *  string 
)
void nvtexfontRenderString_All ( NVTexfontRasterFont txf,
char *  string,
float  x,
float  y,
float  scaleX,
float  scaleY,
float  r,
float  g,
float  b 
)

Renders the specified null-terminated string by using the NVTexfont txf.

The text gets drawn at position (x, y) on the screen with the relevant scale and the color (r,g,b).

The size of the text is one unit per font pixel. This is scaled so that the height of the text is 1/10th the height of the screen when scale = 1.0. txfGetStringMetrics may be used to get the width, maximum ascent from baseline, and maximum descent from baseline.

Parameters
txfA pointer to the texture font.
stringA pointer to the string to render.
xThe x position at which to render.
yThe y position at which to render.
scaleXThe X scale.
scaleYThe Y scale.
rThe red value.
gThe green value.
bThe blue value.
void nvtexfontRenderString_Pos ( NVTexfontRasterFont txf,
NVTexfontContext  tfc,
char *  string,
float  x,
float  y 
)

Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted.

Parameters
txfA pointer to the texture font.
tfcThe texture font context.
stringA pointer to the string to render.
xThe x position at which to draw.
yThe y position at which to draw.
void nvtexfontRenderVecString ( NVTexfontVectorFont vtf,
NVTexfontContext  tfc,
char *  string 
)

Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted.

Parameters
vtfA pointer to the vector font to use when rendering.
tfcThe texture font context.
stringA pointer to the string to render.
void nvtexfontRenderVecString_All ( NVTexfontVectorFont vtf,
char *  string,
float  x,
float  y,
float  scaleX,
float  scaleY,
float  r,
float  g,
float  b 
)

Renders the specified null-terminated string by using the NVTexfontVectorFont vtf.

A scale of 1.0 is equivalent to 1/10 the height of the viewport. The text gets drawn in the color specified by (r,g,b).

Parameters
vtfA pointer to the vector font to use when rendering.
stringA pointer to the string to render.
scaleXThe scale for X.
scaleYThe scale for Y.
xThe x position at which to draw, after being adjusted for scaleX.
yThe y position at which to draw, after being adjusted for scaleY.
rThe red value.
gThe green value.
bThe blue value.
void nvtexfontRenderVecString_Pos ( NVTexfontVectorFont vtf,
NVTexfontContext  tfc,
char *  string,
float  x,
float  y 
)

Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted.

Parameters
vtfA pointer to the vector font to use when rendering.
tfcThe texture font context.
stringA pointer to the string to render.
xThe x position at which to draw.
yThe y position at which to draw.
void nvtexfontSetContextColor ( NVTexfontContext  tfc,
float  r,
float  g,
float  b 
)
void nvtexfontSetContextPos ( NVTexfontContext  tfc,
float  x,
float  y 
)

Sets the x,y attributes for the NVTexfont context tfc.

Parameters
tfcSpecifies the NVTexfont context for which to set attributes.
xSpecifies the x attribute to set.
ySpecifies the y attribute to set.
void nvtexfontSetContextScale ( NVTexfontContext  tfc,
float  scaleX,
float  scaleY 
)

Sets the x,y attributes for the NVTexfont context tfc.

Parameters
tfcSpecifies the NVTexfont context for which to set attributes.
scaleXSpecifies the scale value for X.
scaleYSpecifies the scale value for Y.
void nvtexfontUnloadRasterFont ( NVTexfontRasterFont txf)

Frees textures used by the font txf.

Parameters
txfA pointer to the textures to free.
void nvtexfontUnloadVectorFont ( NVTexfontVectorFont vtf)

Frees resources used by the vector font vtf, including the VBO if used.

Parameters
vtfA pointer to the vector font resources to free.