| |
Main Page Namespace List Class Hierarchy Alphabetical List Compound List Namespace Members Compound Members
P3DFont Class ReferenceTexture font for 3D modes (OpenGL).
More...
#include <P3DFont.hpp>
Inheritance diagram for P3DFont:
[legend]List of all members.
|
Public Types |
| enum | FontAlign { TOP,
BOTTOM,
LINE
} |
| enum | { FORMAT_UNK = 0,
FORMAT_DEF = 1
} |
Public Methods |
| | P3DFont (const char *filename=NULL) |
| virtual | ~P3DFont () |
| void | GetMetrics (u8 &space_c, u8 &space_w, s16 &ascent, s16 &descent) const |
| void | SetMetrics (u8 space_c, u8 space_w, s16 ascent, s16 descent) |
| int | CSpace () const |
| int | WSpace () const |
| int | Ascent () const |
| int | Descent () const |
| const char * | Name () const |
| u8 | FirstChar () const |
| u8 | LastChar () const |
| P3DChar * | GetChar (u8 c) const |
| u32 | Height () const |
| u32 | CharWidth (u8 c) const |
| u32 | CharHeight (u8 c) const |
| u32 | TextHeight (const char *text, u32 nb=PLM::INDEX_ERROR) const |
| u32 | TextWidth (const char *text, u32 nb=PLM::INDEX_ERROR) const |
| void | TextSize (const char *text, u32 &width, u32 &height, u32 nb=PLM::INDEX_ERROR) const |
| void | DrawChar (int x, int y, u8 c, float size=1.0f) |
| void | DrawChar (u8 c, float size=1.0f) |
| void | DrawString (int x, int y, const char *str, u32 len=PLM::INDEX_ERROR, float size=1.0f, FontAlign valign=TOP) |
| void | DrawString (const char *str, u32 len=PLM::INDEX_ERROR, float size=1.0f, FontAlign valign=TOP) |
| void | DrawClipString (int x, int y, int clipx1, int clipx2, const char *str, u32 len=PLM::INDEX_ERROR, float size=1.0f, FontAlign valign=TOP) |
| virtual bool | Load (PLMResFile &src, int format=PLMResource::FORMAT_UNK) |
| virtual bool | Save (PLMResFile &dest, int format=PLMResource::FORMAT_DEF) |
| virtual u32 | MemoryUsed () const |
| void | SetTexture (P3DTexture *tex) |
| P3DTexture * | GetTexture () const |
| void | PrintInfo (bool detail) const |
| virtual bool | LoadName (const char *filename, int format=FORMAT_UNK) |
| virtual bool | SaveName (const char *filename, int format=FORMAT_DEF) |
Detailed Description
Texture font for 3D modes (OpenGL).
Notes:
- resource (see PLMResource), load/save, handled by the resource manager
- simple "texture" implementation (not a 3D model)
- can not be used to create a font, no modifier method and Save() disabled. Use PLMFont class (2D) for that, it uses the same file format. Check you use a correct texture size suitable for OpenGL (a power of 2).
Member Enumeration Documentation
|
|
Font alignment (vertical) for drawing routine.
- Enumeration values:
-
| TOP |
height is the top of the line (nothing upon) |
| BOTTOM |
height is the bottom of the line (nothing below) |
| LINE |
height is the base line (can draw upon and below) |
|
anonymous enum [inherited]
|
|
|
|
- Enumeration values:
-
| FORMAT_UNK |
unknown format (usually for load) |
| FORMAT_DEF |
default format (usually for save) |
|
Constructor & Destructor Documentation
| P3DFont::P3DFont |
( |
const char * |
filename = NULL |
) |
|
|
|
|
Create a new font and try to load data from file filename.
|
| virtual P3DFont::~P3DFont |
( |
|
) |
[virtual] |
|
|
|
Delete the font, destroy the texture.
|
Member Function Documentation
| void P3DFont::GetMetrics |
( |
u8 & |
space_c, |
|
|
u8 & |
space_w, |
|
|
s16 & |
ascent, |
|
|
s16 & |
descent |
|
) |
const [inline] |
|
|
|
Get global font metrics.
- Parameters:
-
| space_c |
pixels between two letters (inside a word) |
| space_w |
pixels between two words |
| ascent |
maximum height of characters above base line |
| descent |
maximum height of characters under base line |
|
| void P3DFont::SetMetrics |
( |
u8 |
space_c, |
|
|
u8 |
space_w, |
|
|
s16 |
ascent, |
|
|
s16 |
descent |
|
) |
[inline] |
|
|
|
Modify global font metrics.
- Parameters:
-
| space_c |
space in pixels between two letters (inside a word) |
| space_w |
space in pixels between two words |
| ascent |
maximum height of characters above base line |
| descent |
maximum height of characters under base line |
|
| int P3DFont::CSpace |
( |
|
) |
[inline] |
|
|
|
Get the number of pixels between two letters (in the same word).
|
| int P3DFont::WSpace |
( |
|
) |
[inline] |
|
|
|
Get the number of pixels between two words.
|
| int P3DFont::Ascent |
( |
|
) |
[inline] |
|
|
|
Get the maximum height of a character above the base line (in pixels).
|
| int P3DFont::Descent |
( |
|
) |
[inline] |
|
|
|
Get the maximum height of a character below the base line (in pixels).
|
| const char * P3DFont::Name |
( |
|
) |
[inline] |
|
| u8 P3DFont::FirstChar |
( |
|
) |
[inline] |
|
|
|
Get first character (index) of the font.
|
| u8 P3DFont::LastChar |
( |
|
) |
[inline] |
|
|
|
Get last character (index) of the font.
|
| P3DChar * P3DFont::GetChar |
( |
u8 |
c |
) |
const [inline] |
|
|
|
Get character information for c, returns NULL if out of range.
|
| u32 P3DFont::Height |
( |
|
) |
[inline] |
|
|
|
Get font height (max ascent + max descent).
|
| u32 P3DFont::CharWidth |
( |
u8 |
c |
) |
const |
|
|
|
Get width of a specific character c.
|
| u32 P3DFont::CharHeight |
( |
u8 |
c |
) |
const |
|
|
|
Get height of a specific character c.
|
| u32 P3DFont::TextHeight |
( |
const char * |
text, |
|
|
u32 |
nb = PLM::INDEX_ERROR |
|
) |
const [inline] |
|
|
|
Compute the width of a string, in pixels (sum of widths).
- Parameters:
-
| text |
the string |
| nb |
characters to use in the string, PLM::INDEX_ERROR for all. |
|
| u32 P3DFont::TextWidth |
( |
const char * |
text, |
|
|
u32 |
nb = PLM::INDEX_ERROR |
|
) |
const |
|
|
|
Compute the height of a string, in pixels (max of heights).
- Parameters:
-
| text |
the string |
| nb |
characters to use in the string, PLM::INDEX_ERROR for all. |
|
| void P3DFont::TextSize |
( |
const char * |
text, |
|
|
u32 & |
width, |
|
|
u32 & |
height, |
|
|
u32 |
nb = PLM::INDEX_ERROR |
|
) |
const |
|
|
|
Compute both width and height of a string, in pixels.
Like in TextHeight() and TextWidth(), you can limit the range to the first nb characters of text. - Returns:
-
width in width and height in height.
|
| void P3DFont::DrawChar |
( |
int |
x, |
|
|
int |
y, |
|
|
u8 |
c, |
|
|
float |
size = 1.0f |
|
) |
|
|
|
|
Draw the character c at the position (x, y), using current color.
|
| void P3DFont::DrawChar |
( |
u8 |
c, |
|
|
float |
size = 1.0f |
|
) |
|
|
|
|
Draw the character c at the current position, using current color.
|
| void P3DFont::DrawString |
( |
int |
x, |
|
|
int |
y, |
|
|
const char * |
str, |
|
|
u32 |
len = PLM::INDEX_ERROR, |
|
|
float |
size = 1.0f, |
|
|
FontAlign |
valign = TOP |
|
) |
|
|
|
|
Draw the string str at the position (x, y), using current color.
Only the first len characters are drawn, (all if PLM::INDEX_ERROR). |
| void P3DFont::DrawString |
( |
const char * |
str, |
|
|
u32 |
len = PLM::INDEX_ERROR, |
|
|
float |
size = 1.0f, |
|
|
FontAlign |
valign = TOP |
|
) |
|
|
|
|
Draw the string str at the current position.
Only the first len characters are drawn, (all if PLM::INDEX_ERROR). |
| void P3DFont::DrawClipString |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
clipx1, |
|
|
int |
clipx2, |
|
|
const char * |
str, |
|
|
u32 |
len = PLM::INDEX_ERROR, |
|
|
float |
size = 1.0f, |
|
|
FontAlign |
valign = TOP |
|
) |
|
|
|
|
Draw the string str at the position (x, y), using current color.
Only the first len characters are drawn, (all if PLM::INDEX_ERROR). Every character before clipx1 and after clipx2 is ignored. |
| virtual bool P3DFont::Load |
( |
PLMResFile & |
src, |
|
|
int |
format = PLMResource::FORMAT_UNK |
|
) |
[virtual] |
|
|
|
Load the font data from the file src.
Note that only the characters definitions are loaded. The texture must be loaded separately into the texture manager, as an image from the same file.
Implements PLMResource. |
| bool P3DFont::Save |
( |
PLMResFile & |
dest, |
|
|
int |
format = PLMResource::FORMAT_DEF |
|
) |
[inline, virtual] |
|
|
|
Save data to the file dest, using a specific format.
Implements PLMResource. |
| virtual u32 P3DFont::MemoryUsed |
( |
|
) |
[virtual] |
|
|
|
Get the total amount of memory used by this resource.
Implements PLMResource. |
| void P3DFont::SetTexture |
( |
P3DTexture * |
tex |
) |
[inline] |
|
|
|
Change the texture used to draw the string.
Normally, the image contained in the same font file should be used. |
|
|
Get the texture used by this font (NULL if none).
|
| void P3DFont::PrintInfo |
( |
bool |
detail |
) |
const |
|
|
|
Print some debug information about the font, and all characters (if detail).
|
| virtual bool PLMResource::LoadName |
( |
const char * |
filename, |
|
|
int |
format = FORMAT_UNK |
|
) |
[virtual, inherited] |
|
|
|
Load data from the file filename.
Reimplemented in PLMMusic. |
| virtual bool PLMResource::SaveName |
( |
const char * |
filename, |
|
|
int |
format = FORMAT_DEF |
|
) |
[virtual, inherited] |
|
|
|
Save data to the file filename.
|
The documentation for this class was generated from the following file:
Generated by
Doxygen 1.2.18 on Tue Oct 26 12:07:44 2004.
|