java.lang.Object
de.grogra.gl.TextRenderer3D
This class renders a TrueType Font into OpenGL
- Author:
- Davide Raccagni, Erik Tollerud
-
Constructor Summary
ConstructorDescriptionTextRenderer3D
(Font font, float depth) Intstantiates a new TextRenderer3D initially rendering in the specified font. -
Method Summary
Modifier and TypeMethodDescriptionvoid
call()
Draws the current compiled string, if any.void
call
(int index) Draws the specified compiled string, if any.int
Creates the specified string as a display list.int
Creates the specified string as a display list.void
dispose()
Diposes of the ALL the current compiled shapes, if any.void
dispose
(int index) Diposes of the specified compiled shapes, if it is in the list.void
Renders a string into the specified GL object, starting at the (0,0,0) point in OpenGL coordinates.void
Get the bounding box for the supplied string with the current font, etc.Get the bounding box for the supplied string for the current font and specified scale factor.boolean
Gets whether normals are being calculatedfloat
getDepth()
Retrieves the z-depth used for this TextRenderer3D's text rendering.float
Set the flatness to which the glyph's curves will be flattenedgetFont()
Retrieves the Font currently associated with this TextRenderer3Dboolean
isFill()
Determines if the text is being rendered as filled polygons or wireframes.void
setCalcNormals
(boolean normals) Sets whether the normals will eb calculated for each facevoid
setDepth
(float depth) Determines how long the sides of the rendered text is.void
setFill
(boolean fill) Sets if the text should be rendered as filled polygons or wireframe.void
setFlatness
(float flatness) Get the current flatness to which the glyph's curves will be flattenedvoid
Specifies which font to render with this TextRenderer3D
-
Constructor Details
-
TextRenderer3D
Intstantiates a new TextRenderer3D initially rendering in the specified font.- Parameters:
font
- - the initial font for this TextRenderer3D depth - the extruded depth for the font- Throws:
NullPointerException
- if the supplied font is null
-
-
Method Details
-
setFont
Specifies which font to render with this TextRenderer3D- Parameters:
font
- a font to use for rendering *- Throws:
NullPointerException
- if the supplied font is null
-
getFont
Retrieves the Font currently associated with this TextRenderer3D- Returns:
- the Font in which this object renders strings
-
setDepth
public void setDepth(float depth) Determines how long the sides of the rendered text is. In the special case of 0, the rendering is 2D.- Parameters:
depth
- specifies the z-size of the rendered 3D text. Negative numbers will be set to 0.
-
getDepth
public float getDepth()Retrieves the z-depth used for this TextRenderer3D's text rendering.- Returns:
- the z-depth of the rendered 3D text.
-
setFill
public void setFill(boolean fill) Sets if the text should be rendered as filled polygons or wireframe.- Parameters:
fill
- if true, uses filled polygons, if false, renderings are wireframe.
-
isFill
public boolean isFill()Determines if the text is being rendered as filled polygons or wireframes.- Returns:
- if true, uses filled polygons, if false, renderings are wireframe.
-
getFlatness
public float getFlatness()Set the flatness to which the glyph's curves will be flattened- Returns:
-
setFlatness
public void setFlatness(float flatness) Get the current flatness to which the glyph's curves will be flattened -
setCalcNormals
public void setCalcNormals(boolean normals) Sets whether the normals will eb calculated for each face- Parameters:
mode
- the mode to render in. Default is flat.
-
getCalcNormals
public boolean getCalcNormals()Gets whether normals are being calculated- Returns:
- the normal technique for this TextRenderer3D.
- See Also:
-
setNormal(javax.media.opengl.GL,float,float,float,float,float,float)
-
draw
-
draw
Renders a string into the specified GL object, starting at the (0,0,0) point in OpenGL coordinates.- Parameters:
str
- the string to render.glu
- a GLU instance to use for the text rendering (provided to prevent continuous re-instantiation of a GLU object)gl
- the OpenGL context in which to render the text.
-
compile
Creates the specified string as a display list. Can subsequently be drawn by calling "call".- Parameters:
str
-xOff
-yOff
-zOff
-scaleFactor
-
-
compile
Creates the specified string as a display list. Can subsequently be drawn by calling "call".- Parameters:
str
-
-
call
public void call()Draws the current compiled string, if any. -
call
public void call(int index) Draws the specified compiled string, if any. -
dispose
public void dispose()Diposes of the ALL the current compiled shapes, if any. -
dispose
public void dispose(int index) Diposes of the specified compiled shapes, if it is in the list. If it is the last-compiled, that index is cleared (set to -1) -
getBounds
Get the bounding box for the supplied string with the current font, etc.- Parameters:
str
-- Returns:
-
getBounds
Get the bounding box for the supplied string for the current font and specified scale factor.- Parameters:
str
-scaleFactor
-- Returns:
-