Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TGLOutlineFont
Unit
CastleGLOutlineFonts
Declaration
type TGLOutlineFont = class(TGLOutlineFontAbstract)
Description
Outline 3D font for OpenGL.
This allows you to create outline font (that implements TGLOutlineFontAbstract interface) based on information expressed as CastleOutlineFonts.TOutlineFont type.
You can use font2pascal program to convert fonts' files to Pascal units with TOutlineFont constant.
So the basic road to use some font in your OpenGL program as 3d text is:
convert font to Pascal unit using font2pascal, to get unit like castleoutlinefont_xxx.pas
add to your uses clause CastleOutlineFont_Xxx and this unit, CastleGLOutlineFonts
and now you can create object like
Font := TGLOutlineFont.Create(OutlineFont_Xxx)
and use it like
Font.Print('foo');
Hierarchy
Overview
Methods
Description
Methods
 |
constructor Create(AFont: TOutlineFont; const depth: TGLfloat = 0.0; const onlyLines: boolean = false; const CharactersSubset: TSetOfChars = SimpleAsciiCharacters); overload; |
Create instance from OutlineFont.
Parameters
- OutlineFont
- This is the pointer to your font, TOutlineFont.
Note that to conserve the use of time and memory this constructor copies only this pointer (not the memory pointed to) so you must make sure that this pointer is valid for the lifetime of this object. Also you shouldn't modify the pointed font data after creating this instace (otherwise some things (like precalculated OpenGL display lists and stored font sizes) could get desynchronized).
The usual simple way to keep all the assumptions above is to make OutlineFont a pointer to a constant defined in unit generated by font2pascal program.
- Depth
- This is the thickness of the font shape. When Depth > 0 then the resulting letters will be true 3D objects. Otherwise, when Depth = 0, the resulting letters will be flat. Note that Depth > 0 (i.e. 3D objects) increases triangle count of resulting letters, so the font with Depth > 0 will be rendered slower than the same font with Depth = 0.
When Depth > 0, we automatically generate proper normals pointing out from CCW (for both front and back caps and side). For Depth < 0 results are undefined, don't use !
When Depth = 0, no normals are generated. It's guaranteed that normal (0, 0, -1) points from CCW side, so you can call glNormal yourself if you want (and adjust it for your current glFrontFace setting).
- OnlyLines
- If
True then the font will be only a "skeleton" (only lines, no polygons).
- CharactersSubset
- If non-empty, this set defines the characters that will be actually rendered.
Other characters can still be passed in strings to Print and other methods, they just will not be visible. (Although even invisible characters will still shift the "cursor" used when writing the string. This means that e.g. monospace font will be shifted appropriately, even if some characters were excluded by CharactersSubset.)
By default we use SimpleAsciiCharacters constant here.
This makes font preparations faster (for example, Debian Linux x86_64 currently has much slower GLU tesselator, and so optimizing by providing only SimpleAsciiCharacters makes sense). Also, font takes less memory space.
|
 |
destructor Destroy; override; |
|
 |
procedure Print(const s: string); override; |
|
 |
procedure PrintAndMove(const s: string); override; |
|
 |
function TextWidth(const s: string): single; override; |
|
 |
function TextHeight(const s: string): single; override; |
|
 |
procedure PrintTexturedAndMove(const s: string; const texOriginX, texOriginY: TGLfloat); |
This renders the text additionally generating texture coordinates.
texOriginX and texOriginY will map to texture coord = (0, 0), then texture coord will increase by 1 when the distance will increase by RowHeight.
This requires one place on attrib stack of OpenGL. Version without the "AndMove" requires also one place on matrix modelview stack of OpenGL.
|
 |
procedure PrintTextured(const s: string; const texOriginX, texOriginY: TGLfloat); |
|
 |
procedure PrintExtrusionAndMove(const S: string; const Depth: Single); |
Render extrusion of given text. This renders the side walls of text that would be created when pushing the text into z = Depth.
If you want to render letters as solid 3D objects, then the text has three parts: front cap (you get this by normal Print or PrintAndMove or PrintTexturedAndMove), back cap (this is the same thing as front cap but with z = Depth) and extrusion (connecting front cap and back cap; this is rendered using this method).
This is supposed to be used on text created with Depth = 0 at constructor. Text created with Depth <> 0 at constructions already gets this extrusion (along with back cap) rendered by normal Print or PrintAndMove etc. methods.
This generates proper normal vectors. For now, they are only suitable for flat shading, so be sure to render fonts with flat shading if using this. Generated normals point out from CCW side, when Depth > 0 (when Depth < 0, things are reversed, so normals are from CW).
PrintTexturedExtrusionAndMove version generates also proper texture coordinates (matching coordinates made by PrintTexturedAndMove).
This doesn't use any display list.
|
 |
procedure PrintTexturedExtrusionAndMove( const S: string; const Depth: Single; const TexOriginX, TexOriginY: TGLfloat); |
|
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:12
|