Linderdaum Engine: clCanvas Class Reference
Updated: Sun Feb 5 2012 22:59:49
clCanvas Class Reference

Drawing of geometry primitives. Not designed to be fast. More...

#include <Canvas.h>

List of all members.

Public Member Functions

 clCanvas ()
virtual ~clCanvas ()
virtual void AfterConstruction ()
void Cleanup ()
 called by the renderer to reset Canvas before shutdown
void Geom (const LMatrix4 &Projection, const LMatrix4 &ModelView, clGeom *Geom, clRenderState *OverrideShader)
 Draw a geom with specified rendering parameters. Slow.
void Rect (float X1, float Y1, float X2, float Y2, const LVector4 &Color)
 Draw a rectangle with solid color (alpha-transparent)
void TexturedRect (float X1, float Y1, float X2, float Y2, iTexture *Texture, iShaderProgram *ShaderProgram, const LVector4 &Color)
 Draw a textured rectangle in normalized screen coordinates with overlay Color (multiplied, alpha-transparent) applying shader program (if any)
void TexturedRectTiled (const LVector4 &Pos, float TilesX, float TilesY, iTexture *Texture, iShaderProgram *ShaderProgram, const LVector4 &Color, iVertexArray *VA, const LRect *UV)
 Draw a textured rectangle repeating texture TilesX*TilesY times, texture should have clamping set to L_REPEAT. Vertex array and UV can be NULL.
void TexturedRect3D (const LVector3 &v1, const LVector3 &v2, const LVector3 &v3, const LVector3 &v4, iTexture *Texture, iShaderProgram *ShaderProgram, bool UseDepthTest)
 Draw a 3D polygon with specified vertices.
void Rect3DShader (const LVector3 &v1, const LVector3 &v2, const LVector3 &v3, const LVector3 &v4, clRenderState *State)
 Draw the rectangle using some custom shader (renderstate)
void AlphaTexture (float X1, float Y1, float X2, float Y2, iTexture *Texture)
 Blend the rectangle with on-screen contents using alpha-channel.
void FullscreenRect (clRenderState *Shader)
 Draw a 0,0-1,1 rect with a given shader. Useful to show splash screens.
void FullscreenRectSP (iShaderProgram *ShaderProgram)
 Draw a 0,0-1,1 rect with a given shader program. Textures are undefined (left from previous drawcall)
void Line3D (const LVector3 &Point1, const LVector3 &Point2, const LVector4 &Color)
 Draw a line in 3D space from Point1 to Point2 with the current projection and movelview matrices (use SetMatrices to set)
void Line3DGlow (const LVector3 &Point1, const LVector3 &Point2, const LVector4 &Color, float Thickness)
 Draw a thick line with glow in 3D space from Point1 to Point2 with the current projection and movelview matrices (use SetMatrices to set)
void Circle3D (const LVector3 &Center, float Radius, const LVector4 &Color, bool AspectCorrection)
 Draw a circle in Z-plane with the current projection and movelview matrices (use SetMatrices to set)
void Arrow3D (const LVector3 &Point1, const LVector3 &Point2, const float TipSize, const LVector4 &TipColor, const LVector4 &ArrowColor)
 Draw a colored 3D arrow with the current projection and movelview matrices (use SetMatrices to set)
void BoundingBox (const LAABoundingBox &Box, const LVector4 &Color)
 Draw a wireframe axis-aligned bounding-box with the current projection and movelview matrices (use SetMatrices to set)
void OrientedBox (const LBox &B, const LVector4 &Color)
 Draw a wireframe oriented bounding-box with the current projection and movelview matrices (use SetMatrices to set)
void Sphere (const LSphere &Sphere, const LVector4 &Color)
 Draw a wireframe hemisphere with the current projection and movelview matrices (use SetMatrices to set)
void FullSphere (const LSphere &Sphere, const LVector4 &Color)
 Draw a wireframe sphere with the current projection and movelview matrices (use SetMatrices to set)
void Plane (const LVector3 &p0, const LVector3 &v1, const LVector3 &v2, int numx, int numy, float step1, float step2, const LVector4 &color)
 Draw a wireframe plane with base vectors v1 and v2 with the current projection and movelview matrices (use SetMatrices to set)
void Curve (const LMatrix4 &_proj, const LMatrix4 &_view, const LCurve &Curve)
 Render curve outline.
void RigidBody (const LMatrix4 &Proj, const LMatrix4 &View, clRigidBody *Body, bool RenderVelocities, bool RenderForces, bool RenderCollision)
 Render the body reference frame. RenderCollision flag tells if we should draw the collision shape (if any)
void CoordFrame (const LMatrix4 &_proj, const LMatrix4 &_view, const LVector3 &Center, const LVector3 &V1, const LVector3 &V2, const LVector3 &V3)
 Draw the coordinate frame centered at point. Vector lengths give the arrows' sizes.
void CollisionShape (const LMatrix4 &_proj, const LMatrix4 &_view, LCollisionShape *Shape, clRigidBody *Body)
 Draw some collision shape.
void OBBTree (const LMatrix4 &_proj, const LMatrix4 &_view, LOBBTree *Tree, int Depth, bool ShowPlanes, const LVector4 &Color, const LVector4 &PlaneColor)
 If Depth is not -1 then only nodes at the Depth level are rendered.
void Poly (const LMatrix4 &_proj, const LMatrix4 &_view, const Math::LPoly &Poly, float NormalSize, const LVector4 &PolyColor, const LVector4 &NormalColor)
 Draw a single oriented polygon. If the normal size is more than zero, the normal is rendered.
void PolyList (const LMatrix4 &_proj, const LMatrix4 &_view, const Math::LPolyList &Polys, float NormalSize, const LVector4 &PolyColor, const LVector4 &NormalColor)
 Draw the list of wireframe polygons.
void PlaneHullOutlines (const LMatrix4 &_proj, const LMatrix4 &_view, const Math::LPlaneHull &Hull, const LBox &Extents, float CellSize, const LVector4 &Color)
 Draw the plane hull near the hint point Extents.FCenter not larger than the Extents. Use plane "cell" size of CellSize units.
void Wireframe (const LMatrix4 &_proj, const LMatrix4 &_view, int NumTris, LVector3 *Pts, int *Idx, const LVector4 &Color)
 "Draw indexed primitive"
void Point (const LMatrix4 &_proj, const LMatrix4 &_view, const LVector3 &Pt, float PtSize, const LVector4 &Color)
 Draw a little cross near specified point.
void ContactInfo (const LMatrix4 &_proj, const LMatrix4 &_view, Math::sCollisionInfo *Info, float PointSize, float NormalSize, const LVector4 &PointColor1, const LVector4 &PointColor2, const LVector4 &NormalColor1, const LVector4 &NormalColor2)
 Draw the information about multi-point contact stored in Info structure.
void TextStr (float X, float Y, const std::string &Str, const LVector4 &Color, clFixedFontProperties *Font)
 Draw a 2D text string using bitmap font.
void TextStrFreeType (const LRect &Rect, const std::string &Str, const float Size, const LVector4 &Color, clFontFace *FontFace, LTextAlignment Alignment)
 Draw a 2D text string using FreeType.
clRenderableStringTextStrGetBitmapFreeType (const std::string &Str, const float Size, clFontFace *FontFace)
 precache FreeType-rendered text string into a bitmap/texture
void TextStrBitmapFreeType (const LRect &Rect, clRenderableString *Str, const LVector4 &Color, LTextAlignment Alignment)
 draw precached text string from bitmap (using common texture)
void TextStrTextureFreeType (const LRect &Rect, clRenderableString *Str, const LVector4 &Color, LTextAlignment Alignment)
 draw precached text string from texture (using precached texture in clRenderableString)
LRect GetTextStrRectFreeType (const std::string &Str, const float Size, clFontFace *FontFace)
 calculate dimensions os text string
clFontFaceCreateFontFace (const std::string &FileName)
 Create a clFontFace from a given .ttf file.
void BeginTextPacket ()
 Begin packetized output of text. No text is rendered until next call to EndTextPacket()
void EndTextPacket ()
 Render and flush text output buffers.
void TurnOnLineClipping ()
void TurnOffLineClipping ()
void DrawOrientation (const LMatrix4 &Projection, const LMatrix4 &ModelView)
 Render a small coordinate frame (three axes) to show the camera's orientation.
void Flush ()
 Force everything to be drawn.
void SetMatrices (const LMatrix4 &Projection, const LMatrix4 &ModelView)
const sMatricesGetOrthoMatrices () const
 Get default matrices for rendering with orthographic projection. Useful for GUI, HUD etc.
clFixedFontPropertiesGetDefaultFont () const

Public Attributes

std::string FDefaultFontName

Private Member Functions

void InitCanvas ()
void FlushTextPacket ()

Private Attributes

iVertexArrayFScreenQuad
sMatrices FMatrices
iVertexArrayFLinesArray [2]
int FCurrentLinesArray
clRenderStateFLinesShader
Lint FProjectionMatrixUniform
Lint FModelViewMatrixUniform
Lint FProjectionMatrixUniformTex
Lint FModelViewMatrixUniformTex
int FLineCount
iVertexArrayFRect
clRenderStateFRectShader
clRenderStateFTexRectShader
 Simple textured rect shader.
clRenderStateFTexRectShader3D
clRenderStateFGlowLinesShader
Lint FRectColorUniform
 Uniform handle for the Colered rectangle.
Lint FRectPosUniform
Lint FTexRectPosUniform
Lint FTexRectColorUniform
Lint FTexRectTilesUniform
Lint FTexRectUVUniform
clRenderStateFAlphaBlendShader
 Alpha-blend shader for AlphaTexture.
sMatrices FTextMatrices
 A collection of matrices used for text rendering.
clRenderStateFTextShader
 A bitmap font rendering shader.
iVertexArrayFTextVA
 Temporary rectangular vertex array for text rendering.
bool FTextPacketStarted
size_t FTextPacketNumGlyphs
clCVarFGlyphSizeX
clCVarFGlyphSizeY
clCVarFFontWidth
clCVarFFontHeight
clFixedFontPropertiesFDefaultFont
 Default raster system font.
clFontFaceFDefaultFreeTypeFont
 Default FreeType font.
clTextRendererFTextRenderer
 FreeType text rendering interface.
iTextureFFontTexture
clRenderStateFFontShader
bool FUseOverlayRendering
 Switch for Flush() method. If true the contents of FOverlayScene is bleneded with the screen.
clSceneFOverlayScene
 An instance of sequencer to produce overlay polygonal rendering.

Detailed Description

Drawing of geometry primitives. Not designed to be fast.

All screen coordinates are normalized (0..1) unless stated otherwise.

0,0 1,0 ---------- | | | | | | ---------- 0,1 1,1


Constructor & Destructor Documentation

clCanvas::clCanvas ( )
clCanvas::~clCanvas ( ) [virtual]

Member Function Documentation

void clCanvas::AfterConstruction ( ) [virtual]

Reimplemented from iObject.

void clCanvas::AlphaTexture ( float  X1,
float  Y1,
float  X2,
float  Y2,
iTexture Texture 
)

Blend the rectangle with on-screen contents using alpha-channel.

This method is used in RenderMeshDirect() and Canvas::Flush() to blend rendered primitives with on-screen contens

The functionality is already implemented in Test_VolumesAndScene (two volumes and a poly-scene is blended there)? but there are bugs for the Radeon cards

void clCanvas::Arrow3D ( const LVector3 Point1,
const LVector3 Point2,
const float  TipSize,
const LVector4 TipColor,
const LVector4 ArrowColor 
)

Draw a colored 3D arrow with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::BeginTextPacket ( )

Begin packetized output of text. No text is rendered until next call to EndTextPacket()

void clCanvas::BoundingBox ( const LAABoundingBox Box,
const LVector4 Color 
)

Draw a wireframe axis-aligned bounding-box with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::Circle3D ( const LVector3 Center,
float  Radius,
const LVector4 Color,
bool  AspectCorrection 
)

Draw a circle in Z-plane with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::Cleanup ( )

called by the renderer to reset Canvas before shutdown

void clCanvas::CollisionShape ( const LMatrix4 _proj,
const LMatrix4 _view,
LCollisionShape Shape,
clRigidBody Body 
)

Draw some collision shape.

void clCanvas::ContactInfo ( const LMatrix4 _proj,
const LMatrix4 _view,
Math::sCollisionInfo *  Info,
float  PointSize,
float  NormalSize,
const LVector4 PointColor1,
const LVector4 PointColor2,
const LVector4 NormalColor1,
const LVector4 NormalColor2 
)

Draw the information about multi-point contact stored in Info structure.

void clCanvas::CoordFrame ( const LMatrix4 _proj,
const LMatrix4 _view,
const LVector3 Center,
const LVector3 V1,
const LVector3 V2,
const LVector3 V3 
)

Draw the coordinate frame centered at point. Vector lengths give the arrows' sizes.

clFontFace * clCanvas::CreateFontFace ( const std::string &  FileName)

Create a clFontFace from a given .ttf file.

void clCanvas::Curve ( const LMatrix4 _proj,
const LMatrix4 _view,
const LCurve Curve 
)

Render curve outline.

void clCanvas::DrawOrientation ( const LMatrix4 Projection,
const LMatrix4 ModelView 
)

Render a small coordinate frame (three axes) to show the camera's orientation.

void clCanvas::EndTextPacket ( )

Render and flush text output buffers.

void clCanvas::Flush ( )

Force everything to be drawn.

void clCanvas::FlushTextPacket ( ) [private]
void clCanvas::FullscreenRect ( clRenderState Shader)

Draw a 0,0-1,1 rect with a given shader. Useful to show splash screens.

void clCanvas::FullscreenRectSP ( iShaderProgram ShaderProgram)

Draw a 0,0-1,1 rect with a given shader program. Textures are undefined (left from previous drawcall)

void clCanvas::FullSphere ( const LSphere Sphere,
const LVector4 Color 
)

Draw a wireframe sphere with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::Geom ( const LMatrix4 Projection,
const LMatrix4 ModelView,
clGeom Geom,
clRenderState OverrideShader 
)

Draw a geom with specified rendering parameters. Slow.

Override shader provides possibility for volume rendering

clFixedFontProperties * clCanvas::GetDefaultFont ( ) const
const sMatrices* clCanvas::GetOrthoMatrices ( ) const [inline]

Get default matrices for rendering with orthographic projection. Useful for GUI, HUD etc.

LRect clCanvas::GetTextStrRectFreeType ( const std::string &  Str,
const float  Size,
clFontFace FontFace 
)

calculate dimensions os text string

void clCanvas::InitCanvas ( ) [private]
void clCanvas::Line3D ( const LVector3 Point1,
const LVector3 Point2,
const LVector4 Color 
)

Draw a line in 3D space from Point1 to Point2 with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::Line3DGlow ( const LVector3 Point1,
const LVector3 Point2,
const LVector4 Color,
float  Thickness 
)

Draw a thick line with glow in 3D space from Point1 to Point2 with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::OBBTree ( const LMatrix4 _proj,
const LMatrix4 _view,
LOBBTree Tree,
int  Depth,
bool  ShowPlanes,
const LVector4 Color,
const LVector4 PlaneColor 
)

If Depth is not -1 then only nodes at the Depth level are rendered.

If Depth is not -1 then only nodes at the Depth level are rendered

void clCanvas::OrientedBox ( const LBox B,
const LVector4 Color 
)

Draw a wireframe oriented bounding-box with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::Plane ( const LVector3 p0,
const LVector3 v1,
const LVector3 v2,
int  numx,
int  numy,
float  step1,
float  step2,
const LVector4 color 
)

Draw a wireframe plane with base vectors v1 and v2 with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::PlaneHullOutlines ( const LMatrix4 _proj,
const LMatrix4 _view,
const Math::LPlaneHull &  Hull,
const LBox Extents,
float  CellSize,
const LVector4 Color 
)

Draw the plane hull near the hint point Extents.FCenter not larger than the Extents. Use plane "cell" size of CellSize units.

Draw the plane hull near the hint point Extents.FCenter not larger than the Extents. Use plane "cell" size of CellSize units

void clCanvas::Point ( const LMatrix4 _proj,
const LMatrix4 _view,
const LVector3 Pt,
float  PtSize,
const LVector4 Color 
)

Draw a little cross near specified point.

void clCanvas::Poly ( const LMatrix4 _proj,
const LMatrix4 _view,
const Math::LPoly &  Poly,
float  NormalSize,
const LVector4 PolyColor,
const LVector4 NormalColor 
)

Draw a single oriented polygon. If the normal size is more than zero, the normal is rendered.

If the normal size is more than zero, it is drawn.

void clCanvas::PolyList ( const LMatrix4 _proj,
const LMatrix4 _view,
const Math::LPolyList &  Polys,
float  NormalSize,
const LVector4 PolyColor,
const LVector4 NormalColor 
)

Draw the list of wireframe polygons.

void clCanvas::Rect ( float  X1,
float  Y1,
float  X2,
float  Y2,
const LVector4 Color 
)

Draw a rectangle with solid color (alpha-transparent)

void clCanvas::Rect3DShader ( const LVector3 v1,
const LVector3 v2,
const LVector3 v3,
const LVector3 v4,
clRenderState State 
)

Draw the rectangle using some custom shader (renderstate)

void clCanvas::RigidBody ( const LMatrix4 Proj,
const LMatrix4 View,
clRigidBody Body,
bool  RenderVelocities,
bool  RenderForces,
bool  RenderCollision 
)

Render the body reference frame. RenderCollision flag tells if we should draw the collision shape (if any)

void clCanvas::SetMatrices ( const LMatrix4 Projection,
const LMatrix4 ModelView 
)
void clCanvas::Sphere ( const LSphere Sphere,
const LVector4 Color 
)

Draw a wireframe hemisphere with the current projection and movelview matrices (use SetMatrices to set)

void clCanvas::TextStr ( float  X,
float  Y,
const std::string &  Str,
const LVector4 Color,
clFixedFontProperties Font 
)

Draw a 2D text string using bitmap font.

Default system font (

See also:
FDefaultFont) is used if Font is NULL.
void clCanvas::TextStrBitmapFreeType ( const LRect Rect,
clRenderableString Str,
const LVector4 Color,
LTextAlignment  Alignment 
)

draw precached text string from bitmap (using common texture)

void clCanvas::TextStrFreeType ( const LRect Rect,
const std::string &  Str,
const float  Size,
const LVector4 Color,
clFontFace FontFace,
LTextAlignment  Alignment 
)

Draw a 2D text string using FreeType.

Default font is used if FontFace is NULL.

clRenderableString * clCanvas::TextStrGetBitmapFreeType ( const std::string &  Str,
const float  Size,
clFontFace FontFace 
)

precache FreeType-rendered text string into a bitmap/texture

void clCanvas::TextStrTextureFreeType ( const LRect Rect,
clRenderableString Str,
const LVector4 Color,
LTextAlignment  Alignment 
)

draw precached text string from texture (using precached texture in clRenderableString)

void clCanvas::TexturedRect ( float  X1,
float  Y1,
float  X2,
float  Y2,
iTexture Texture,
iShaderProgram ShaderProgram,
const LVector4 Color 
)

Draw a textured rectangle in normalized screen coordinates with overlay Color (multiplied, alpha-transparent) applying shader program (if any)

void clCanvas::TexturedRect3D ( const LVector3 v1,
const LVector3 v2,
const LVector3 v3,
const LVector3 v4,
iTexture Texture,
iShaderProgram ShaderProgram,
bool  UseDepthTest 
)

Draw a 3D polygon with specified vertices.

void clCanvas::TexturedRectTiled ( const LVector4 Pos,
float  TilesX,
float  TilesY,
iTexture Texture,
iShaderProgram ShaderProgram,
const LVector4 Color,
iVertexArray VA,
const LRect UV 
)

Draw a textured rectangle repeating texture TilesX*TilesY times, texture should have clamping set to L_REPEAT. Vertex array and UV can be NULL.

void clCanvas::TurnOffLineClipping ( )
void clCanvas::TurnOnLineClipping ( )
void clCanvas::Wireframe ( const LMatrix4 _proj,
const LMatrix4 _view,
int  NumTris,
LVector3 Pts,
int Idx,
const LVector4 Color 
)

"Draw indexed primitive"


Member Data Documentation

Alpha-blend shader for AlphaTexture.

Default raster system font.

Property(Name=DefaultFontName, Type=string, FieldName=FDefaultFontName)

Default FreeType font.

An instance of sequencer to produce overlay polygonal rendering.

It has its own offscreen buffer which is bleneded with screen in Canvas::Flush()

Uniform handle for the Colered rectangle.

Simple textured rect shader.

A collection of matrices used for text rendering.

FreeType text rendering interface.

A bitmap font rendering shader.

Temporary rectangular vertex array for text rendering.

Switch for Flush() method. If true the contents of FOverlayScene is bleneded with the screen.


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