Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Attributes | List of all members
BIAS::DrawTextGL Class Reference

Draw text to OpenGL as 2D bitmap font. More...

#include <Utils/DrawTextGL.hh>

+ Collaboration diagram for BIAS::DrawTextGL:

Public Member Functions

void DeleteFont ()
 frees the display lists JW More...
 
 DrawTextGL ()
 ctor JW More...
 
int InitFont (void *handleDC, const std::string theFontname=std::string(DrawTextGL_DEFAULT_FONTNAME), const int fontHeight=DrawTextGL_DEFAULT_FONTSIZE)
 set the font up More...
 
bool IsInitialized () const
 
void Print (const std::string &text) const
 print text on OpenGL screen using current RasterPosition , settings etc. More...
 
void Print3D (const std::string &text, const float &xpos, const float &ypos, const float &zpos) const
 
void Print3DAbsolute (const std::string &text, const float &xpos, const float &ypos, const float &zpos) const
 
draw text in 3d at absolute position,

thus ModelView matrix is set to identity (using push and pop). More...

 
void PrintNormCoords (const std::string &text, const float &xpos, const float &ypos) const
 
print text on OpenGL screen in 0..1 normalized coordinates

with origin at lower left corner with 0..1 normalizedx coordinates and origin in lower left corner: More...

 
void PrintWinCoords (const std::string &text, const int &xpos, const int &ypos, const int &winWidthFallback=640, const int &winHeightFallback=480) const
 print text on OpenGL screen at 2D pos (xpos,ypos) in windows (pixel) coordiantes. More...
 
virtual ~DrawTextGL ()
 destructor, kills display lists JW More...
 

Protected Attributes

unsigned int base
 inde xof our first display list: More...
 
std::string fontname
 the name of our font, e.g. "Arial" or "-*-helvetica-bold-r-normal--24-*-*-*-p-*-iso8859-1");" More...
 
bool initialized
 true if we created the font as display lists More...
 

Detailed Description

Draw text to OpenGL as 2D bitmap font.

Implemented as setting up a 2D display list for every standard character.

Uses standard Win32 calls to render TTF fonts on Windows and GLX fonts on Linux.

Tested with MS Windows XP and (Suse 9.2) Linux (JW).

See Gui/Examples/ExampleGLShared for an Example.

See http://www.opengl.org/resources/features/fontsurvey/ for other possible implementations, in particular 3D "outlined" fonts.

Author
Jan Woetzel

Definition at line 71 of file DrawTextGL.hh.

Constructor & Destructor Documentation

DrawTextGL::~DrawTextGL ( )
virtual

destructor, kills display lists JW

Definition at line 61 of file DrawTextGL.cpp.

DrawTextGL::DrawTextGL ( )

ctor JW

Definition at line 67 of file DrawTextGL.cpp.

References base, and fontname.

Member Function Documentation

void DrawTextGL::DeleteFont ( )

frees the display lists JW

Definition at line 194 of file DrawTextGL.cpp.

References base.

Referenced by BIAS::SceneTextScreen::Free(), and InitFont().

int DrawTextGL::InitFont ( void *  handleDC,
const std::string  theFontname = std::string(DrawTextGL_DEFAULT_FONTNAME),
const int  fontHeight = DrawTextGL_DEFAULT_FONTSIZE 
)

set the font up

Returns
0 on success, negativ eon error JW
Parameters
theFontnamename of the font, e.g. "Arial"
theFontnamee.g. "Arial", "Times New Roman" or on Linux: "-*-helvetica-bold-r-normal--24-*-*-*-p-*-iso8859-1");"
handleDCpointer to protected GDI device context, on WIN32: a HDC, e.g. for wxWindow use: GetDC(HWND(this->GetHandle())) on Linux: .. TODO ..
Author
Jan Woetzel

Definition at line 80 of file DrawTextGL.cpp.

References base, DeleteFont(), fontname, and initialized.

Referenced by BIAS::SceneTextScreen::Draw(), BIAS::SceneText::Draw(), BIAS::OpenGLCanvasBase::InitWithContext(), and BIAS::ThreeDOut::OpenGLOutWCS().

bool BIAS::DrawTextGL::IsInitialized ( ) const
inline

Definition at line 130 of file DrawTextGL.hh.

Referenced by BIAS::GeometryGL::DisplayCoordCrossAxesLabel().

void DrawTextGL::Print ( const std::string &  text) const

print text on OpenGL screen using current RasterPosition , settings etc.

JW

Definition at line 299 of file DrawTextGL.cpp.

References base, and initialized.

Referenced by Print3D(), PrintNormCoords(), and PrintWinCoords().

void DrawTextGL::Print3D ( const std::string &  text,
const float &  xpos,
const float &  ypos,
const float &  zpos 
) const
void DrawTextGL::Print3DAbsolute ( const std::string &  text,
const float &  xpos,
const float &  ypos,
const float &  zpos 
) const

draw text in 3d at absolute position,

thus ModelView matrix is set to identity (using push and pop).

Projection matrix is kept JW

Definition at line 284 of file DrawTextGL.cpp.

References Print3D().

void DrawTextGL::PrintNormCoords ( const std::string &  text,
const float &  xpos,
const float &  ypos 
) const

print text on OpenGL screen in 0..1 normalized coordinates

with origin at lower left corner with 0..1 normalizedx coordinates and origin in lower left corner:

Y=1
^
|
|
0,0 ---> x=1

JW

Definition at line 202 of file DrawTextGL.cpp.

References Print().

void DrawTextGL::PrintWinCoords ( const std::string &  text,
const int &  xpos,
const int &  ypos,
const int &  winWidthFallback = 640,
const int &  winHeightFallback = 480 
) const

print text on OpenGL screen at 2D pos (xpos,ypos) in windows (pixel) coordiantes.

Parameters
winWidthFallbackand
winHeightFallbackare used only as GL 1.1 fallback. JW

Definition at line 237 of file DrawTextGL.cpp.

References Print().

Referenced by BIAS::SceneTextScreen::Draw().

Member Data Documentation

unsigned int BIAS::DrawTextGL::base
protected

inde xof our first display list:

Definition at line 142 of file DrawTextGL.hh.

Referenced by DeleteFont(), DrawTextGL(), InitFont(), and Print().

std::string BIAS::DrawTextGL::fontname
protected

the name of our font, e.g. "Arial" or "-*-helvetica-bold-r-normal--24-*-*-*-p-*-iso8859-1");"

Definition at line 130 of file DrawTextGL.hh.

Referenced by DrawTextGL(), and InitFont().

bool BIAS::DrawTextGL::initialized
protected

true if we created the font as display lists

Definition at line 139 of file DrawTextGL.hh.

Referenced by InitFont(), and Print().


The documentation for this class was generated from the following files: