Basic Image AlgorithmS Library
2.8.0
|
Draw text to OpenGL as 2D bitmap font. More...
#include <Utils/DrawTextGL.hh>
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... | |
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.
Definition at line 71 of file DrawTextGL.hh.
|
virtual |
destructor, kills display lists JW
Definition at line 61 of file DrawTextGL.cpp.
DrawTextGL::DrawTextGL | ( | ) |
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
theFontname | name of the font, e.g. "Arial" |
theFontname | e.g. "Arial", "Times New Roman" or on Linux: "-*-helvetica-bold-r-normal--24-*-*-*-p-*-iso8859-1");" |
handleDC | pointer to protected GDI device context, on WIN32: a HDC, e.g. for wxWindow use: GetDC(HWND(this->GetHandle())) on Linux: .. TODO .. |
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().
|
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 |
Definition at line 275 of file DrawTextGL.cpp.
References Print().
Referenced by BIAS::GeometryGL::DisplayCoordCrossAxesLabel(), BIAS::SceneText::Draw(), BIAS::ThreeDOut::OpenGLOutWCS(), and Print3DAbsolute().
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:
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.
winWidthFallback | and |
winHeightFallback | are used only as GL 1.1 fallback. JW |
Definition at line 237 of file DrawTextGL.cpp.
References Print().
Referenced by BIAS::SceneTextScreen::Draw().
|
protected |
inde xof our first display list:
Definition at line 142 of file DrawTextGL.hh.
Referenced by DeleteFont(), DrawTextGL(), InitFont(), and Print().
|
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().
|
protected |
true if we created the font as display lists
Definition at line 139 of file DrawTextGL.hh.
Referenced by InitFont(), and Print().