PixelLightAPI  .
Public Member Functions | Protected Member Functions
PLRenderer::DrawHelpers Class Reference

Abstract draw helpers interface. More...

#include <DrawHelpers.h>

List of all members.

Public Member Functions

virtual void Begin2DMode (float fX1=0.0f, float fY1=0.0f, float fX2=1.0f, float fY2=1.0f)=0
 Begin 2D mode.
virtual bool Is2DMode () const =0
 Returns whether the renderer is currently in the 2D mode or not.
virtual bool Get2DMode (float &fX1, float &fY1, float &fX2, float &fY2) const =0
 Returns the virtual 2D mode screen size.
virtual void End2DMode ()=0
 End 2D mode.
virtual float Get2DZValue () const =0
 Returns the z value to be used for 2D rendering.
virtual void Set2DZValue (float fZValue=0.0f)=0
 Sets the Z Value to be used for 2D rendering.
virtual const PLMath::Matrix4x4GetObjectSpaceToClipSpaceMatrix () const =0
 Returns the 2D mode object space to clip space matrix.
virtual void DrawText (Font &cFont, const PLCore::String &sText, const PLGraphics::Color4 &cColor, const PLMath::Vector2 &vPosition, PLCore::uint32 nFlags=0, const PLMath::Vector2 &vScale=PLMath::Vector2::One, const PLMath::Vector2 &vBias=PLMath::Vector2::Zero)=0
 Draws a text at a given 2D position.
virtual void DrawText (Font &cFont, const PLCore::String &sText, const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vPosition, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, PLCore::uint32 nFlags=0, const PLMath::Vector2 &vScale=PLMath::Vector2::One, const PLMath::Vector2 &vBias=PLMath::Vector2::Zero)=0
 Draws a text at a given 3D position.
virtual float GetTextWidth (Font &cFont, const PLCore::String &sText) const =0
 Returns the width of a text.
virtual float GetTextHeight (Font &cFont) const =0
 Returns the height of a font.
virtual void DrawImage (TextureBuffer &cTextureBuffer, SamplerStates &cSamplerStates, const PLMath::Vector2 &vPos, const PLMath::Vector2 &vSize=PLMath::Vector2::Zero, const PLGraphics::Color4 &cColor=PLGraphics::Color4::White, float fAlphaReference=1.0f, const PLMath::Vector2 &vTextureCoordinate=PLMath::Vector2::Zero, const PLMath::Vector2 &vTextureCoordinateSize=PLMath::Vector2::One, const PLMath::Matrix4x4 &mTexture=PLMath::Matrix4x4::Identity)=0
 Draws an image using a given 2D position.
virtual void DrawImage (TextureBuffer &cTextureBuffer, SamplerStates &cSamplerStates, const PLMath::Vector3 &vPos, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, const PLMath::Vector2 &vSize=PLMath::Vector2::Zero, const PLGraphics::Color4 &cColor=PLGraphics::Color4::White, float fAlphaReference=1.0f, const PLMath::Vector2 &vTextureCoordinate=PLMath::Vector2::Zero, const PLMath::Vector2 &vTextureCoordinateSize=PLMath::Vector2::One, const PLMath::Matrix4x4 &mTexture=PLMath::Matrix4x4::Identity)=0
 Draws an image using a given 3D position.
virtual void DrawPoint (const PLGraphics::Color4 &cColor, const PLMath::Vector2 &vPosition, float fSize=1.0f)=0
 Draws a single colored point using a given 2D position.
virtual void DrawPoint (const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vPosition, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, float fSize=1.0f)=0
 Draws a single colored point using a given 3D position.
virtual void DrawLine (const PLGraphics::Color4 &cColor, const PLMath::Vector2 &vStartPosition, const PLMath::Vector2 &vEndPosition, float fWidth=1.0f)=0
 Draws a single colored line using a given 2D start position and 2D end position.
virtual void DrawLine (const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vStartPosition, const PLMath::Vector3 &vEndPosition, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, float fWidth=1.0f)=0
 Draws a single colored line using a given 3D start position and 3D end position.
virtual void DrawTriangle (const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vV1, const PLMath::Vector3 &vV2, const PLMath::Vector3 &vV3, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, float fWidth=0.0f)=0
 Draws a colored triangle.
virtual void DrawQuad (const PLGraphics::Color4 &cColor, const PLMath::Vector2 &vPos, const PLMath::Vector2 &vSize, float fWidth=0.0f)=0
 Draws a colored 2D quad.
virtual void DrawQuad (const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vV1, const PLMath::Vector3 &vV2, const PLMath::Vector3 &vV3, const PLMath::Vector3 &vV4, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, float fWidth=0.0f)=0
 Draws a colored quad using given 3D positions.
virtual void DrawGradientQuad (const PLGraphics::Color4 &cColor1, const PLGraphics::Color4 &cColor2, float fAngle, const PLMath::Vector2 &vPos, const PLMath::Vector2 &vSize)=0
 Draws a gradient colored 2D quad.
virtual void DrawGradientQuad (const PLGraphics::Color4 &cColor1, const PLGraphics::Color4 &cColor2, float fAngle, const PLMath::Vector3 &vV1, const PLMath::Vector3 &vV2, const PLMath::Vector3 &vV3, const PLMath::Vector3 &vV4, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace)=0
 Draws a gradient colored quad using given 3D positions.
virtual void DrawBox (const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vMin, const PLMath::Vector3 &vMax, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, float fWidth=0.0f)=0
 Draws a colored box.
virtual void DrawPlane (const PLGraphics::Color4 &cColor, const PLMath::Vector3 &vN, float fD, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, float fSize=10000.0f, float fLineWidth=1.0f)=0
 Draws a colored plane.

Protected Member Functions

PLRENDERER_API DrawHelpers ()
 Constructor.
virtual PLRENDERER_API ~DrawHelpers ()
 Destructor.

Detailed Description

Abstract draw helpers interface.

Remarks:
If you want for example to draw a simple point or line with just one line of code, use this offered draw helpers. If you want to draw huge point clouds and so on, use vertex buffers and draw them all at once using a single draw call - this is the more efficient and universal way! The 2D draw helper space looks like this

(0, 0) |------ | | (Width, Height)

The origin is at the upper left which is also usually true for GUI systems.


Constructor & Destructor Documentation

PLRENDERER_API PLRenderer::DrawHelpers::DrawHelpers ( ) [protected]

Constructor.

virtual PLRENDERER_API PLRenderer::DrawHelpers::~DrawHelpers ( ) [protected, virtual]

Destructor.


Member Function Documentation

virtual void PLRenderer::DrawHelpers::Begin2DMode ( float  fX1 = 0.0f,
float  fY1 = 0.0f,
float  fX2 = 1.0f,
float  fY2 = 1.0f 
) [pure virtual]

Begin 2D mode.

Parameters:
[in]fX1Virtual screen x start position
[in]fY1Virtual screen y start position
[in]fX2Virtual screen x end position
[in]fY2Virtual screen y end position
Note:
  • If all parameters are 0.0f, the current viewport settings will be used
  • The projection matrix is set to an orthographic matrix
  • The projection and view matrix will be reset to the old states by calling End2DMode(), so be careful when using matrix or render state operations withing Begin2DMode() and End2DMode() - or better don't do it!
  • If the renderer is already in the 2D mode the old is ended automatically before the new one is started
  • If bitmaps, texts etc. are drawn without an active 2D mode the 2D mode is set automatically using the default values
  • When drawing lines, points etc. note that you should go sure that no for instance no textures are used else its possible that your lines will be e.g. black
virtual bool PLRenderer::DrawHelpers::Is2DMode ( ) const [pure virtual]

Returns whether the renderer is currently in the 2D mode or not.

Returns:
'true' if the renderer is currently in the 2D mode, else 'false'
virtual bool PLRenderer::DrawHelpers::Get2DMode ( float &  fX1,
float &  fY1,
float &  fX2,
float &  fY2 
) const [pure virtual]

Returns the virtual 2D mode screen size.

Parameters:
[out]fX1Will receive the virtual screen x start position
[out]fY1Will receive the virtual screen y start position
[out]fX2Will receive the virtual screen x end position
[out]fY2Will receive the virtual screen y end position
Returns:
'true' if all went fine, else 'false' (maybe the 2D mode isn't active)
virtual void PLRenderer::DrawHelpers::End2DMode ( ) [pure virtual]

End 2D mode.

See also:
virtual float PLRenderer::DrawHelpers::Get2DZValue ( ) const [pure virtual]

Returns the z value to be used for 2D rendering.

Returns:
Z value
virtual void PLRenderer::DrawHelpers::Set2DZValue ( float  fZValue = 0.0f) [pure virtual]

Sets the Z Value to be used for 2D rendering.

Parameters:
[in]fZValueZ value

Returns the 2D mode object space to clip space matrix.

Returns:
2D mode object space to clip space matrix
virtual void PLRenderer::DrawHelpers::DrawText ( Font cFont,
const PLCore::String sText,
const PLGraphics::Color4 cColor,
const PLMath::Vector2 vPosition,
PLCore::uint32  nFlags = 0,
const PLMath::Vector2 vScale = PLMath::Vector2::One,
const PLMath::Vector2 vBias = PLMath::Vector2::Zero 
) [pure virtual]

Draws a text at a given 2D position.

Parameters:
[in]cFontFont to use
[in]sTextText to draw
[in]cColorText color
[in]vPositionText screen position
[in]nFlagsDraw flags, see Font::EDrawFlags
[in]vScaleFont scale
[in]vBiasFont bias (position offset)
virtual void PLRenderer::DrawHelpers::DrawText ( Font cFont,
const PLCore::String sText,
const PLGraphics::Color4 cColor,
const PLMath::Vector3 vPosition,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
PLCore::uint32  nFlags = 0,
const PLMath::Vector2 vScale = PLMath::Vector2::One,
const PLMath::Vector2 vBias = PLMath::Vector2::Zero 
) [pure virtual]

Draws a text at a given 3D position.

Parameters:
[in]cFontFont to use
[in]sTextText to draw
[in]cColorText color
[in]vPositionText object space position
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]nFlagsDraw flags, see Font::EDrawFlags
[in]vScaleFont scale
[in]vBiasFont bias (position offset)
Note:
  • "vPosition.To2DCoordinate(mObjectSpaceToClipSpace, cRenderer.GetViewport())" is used to calculate the screen space position
virtual float PLRenderer::DrawHelpers::GetTextWidth ( Font cFont,
const PLCore::String sText 
) const [pure virtual]

Returns the width of a text.

Parameters:
[in]cFontFont to use
[in]sTextText to 'draw'
Returns:
The width of a text
virtual float PLRenderer::DrawHelpers::GetTextHeight ( Font cFont) const [pure virtual]

Returns the height of a font.

Parameters:
[in]cFontFont to use
Returns:
The height of a font
virtual void PLRenderer::DrawHelpers::DrawImage ( TextureBuffer cTextureBuffer,
SamplerStates cSamplerStates,
const PLMath::Vector2 vPos,
const PLMath::Vector2 vSize = PLMath::Vector2::Zero,
const PLGraphics::Color4 cColor = PLGraphics::Color4::White,
float  fAlphaReference = 1.0f,
const PLMath::Vector2 vTextureCoordinate = PLMath::Vector2::Zero,
const PLMath::Vector2 vTextureCoordinateSize = PLMath::Vector2::One,
const PLMath::Matrix4x4 mTexture = PLMath::Matrix4x4::Identity 
) [pure virtual]

Draws an image using a given 2D position.

Parameters:
[in]cTextureBufferTexture buffer holding the image to draw
[in]cSamplerStatesSampler states
[in]vPosImage position
[in]vSizeImage size
[in]cColorColor to use
[in]fAlphaReferenceAlpha test reference value (0-1), all texels below the value will be discarded, if >= 1, no alpha test will be performed
[in]vTextureCoordinateNormalized texture coordinate (0..1)
[in]vTextureCoordinateSizeNormalized texture coordinate size (0..1)
[in]mTextureTexture matrix
Note:
  • Usually used together with Begin2DMode()
  • Use counter clockwise culling or deactivate culling
  • If vSize = (0 0), the image size is used
virtual void PLRenderer::DrawHelpers::DrawImage ( TextureBuffer cTextureBuffer,
SamplerStates cSamplerStates,
const PLMath::Vector3 vPos,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
const PLMath::Vector2 vSize = PLMath::Vector2::Zero,
const PLGraphics::Color4 cColor = PLGraphics::Color4::White,
float  fAlphaReference = 1.0f,
const PLMath::Vector2 vTextureCoordinate = PLMath::Vector2::Zero,
const PLMath::Vector2 vTextureCoordinateSize = PLMath::Vector2::One,
const PLMath::Matrix4x4 mTexture = PLMath::Matrix4x4::Identity 
) [pure virtual]

Draws an image using a given 3D position.

Parameters:
[in]cTextureBufferTexture buffer holding the image to draw
[in]cSamplerStatesSampler states
[in]vPosImage position
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]vSizeImage size
[in]cColorColor to use
[in]fAlphaReferenceAlpha test reference value (0-1), all texels below the value will be discarded, if >= 1, no alpha test will be performed
[in]vTextureCoordinateNormalized texture coordinate (0..1)
[in]vTextureCoordinateSizeNormalized texture coordinate size (0..1)
[in]mTextureTexture matrix
Note:
  • The image is drawn on the x/y plane and 'looks' into the positive z axis
  • If vSize = (0 0), the image size is used
virtual void PLRenderer::DrawHelpers::DrawPoint ( const PLGraphics::Color4 cColor,
const PLMath::Vector2 vPosition,
float  fSize = 1.0f 
) [pure virtual]

Draws a single colored point using a given 2D position.

Parameters:
[in]cColorColor to use
[in]vPosition2D point position
[in]fSizePoint size
Note:
  • For drawing many points you should use Renderer::DrawPrimitives() with Primitive::PointList for better performance. This way you also have more control over 'how' the points are rendered. (vertex color and so on)
  • You should use the draw functions for points and lines only for debug purposes because often they are not fast and in general not supported by each API! (OpenGL supports this function well :)
See also:
virtual void PLRenderer::DrawHelpers::DrawPoint ( const PLGraphics::Color4 cColor,
const PLMath::Vector3 vPosition,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
float  fSize = 1.0f 
) [pure virtual]

Draws a single colored point using a given 3D position.

Parameters:
[in]cColorColor to use
[in]vPosition3D object space point position
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]fSizePoint size
See also:
virtual void PLRenderer::DrawHelpers::DrawLine ( const PLGraphics::Color4 cColor,
const PLMath::Vector2 vStartPosition,
const PLMath::Vector2 vEndPosition,
float  fWidth = 1.0f 
) [pure virtual]

Draws a single colored line using a given 2D start position and 2D end position.

Parameters:
[in]cColorColor to use
[in]vStartPosition2D start position of the line
[in]vEndPosition2D end position of the line
[in]fWidthWidth of the line
Note:
See also:
virtual void PLRenderer::DrawHelpers::DrawLine ( const PLGraphics::Color4 cColor,
const PLMath::Vector3 vStartPosition,
const PLMath::Vector3 vEndPosition,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
float  fWidth = 1.0f 
) [pure virtual]

Draws a single colored line using a given 3D start position and 3D end position.

Parameters:
[in]cColorColor to use
[in]vStartPosition3D object space start position of the line
[in]vEndPosition3D object space end position of the line
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]fWidthWidth of the line
See also:
virtual void PLRenderer::DrawHelpers::DrawTriangle ( const PLGraphics::Color4 cColor,
const PLMath::Vector3 vV1,
const PLMath::Vector3 vV2,
const PLMath::Vector3 vV3,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
float  fWidth = 0.0f 
) [pure virtual]

Draws a colored triangle.

Parameters:
[in]cColorColor to use
[in]vV1Object space triangle vertex 1
[in]vV2Object space triangle vertex 2
[in]vV3Object space triangle vertex 3
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]fWidthWidth of the line, if 0, the box is not drawn using lines
Note:
  • This function should be used for debugging proposes only! Therefore you can use this only to visualize something without to be able to define normals, texture coordinates etc.
virtual void PLRenderer::DrawHelpers::DrawQuad ( const PLGraphics::Color4 cColor,
const PLMath::Vector2 vPos,
const PLMath::Vector2 vSize,
float  fWidth = 0.0f 
) [pure virtual]

Draws a colored 2D quad.

Parameters:
[in]cColorColor to use
[in]vPos2D position
[in]vSize2D size
[in]fWidthWidth of the line, if 0, the quad is not drawn using lines
See also:
virtual void PLRenderer::DrawHelpers::DrawQuad ( const PLGraphics::Color4 cColor,
const PLMath::Vector3 vV1,
const PLMath::Vector3 vV2,
const PLMath::Vector3 vV3,
const PLMath::Vector3 vV4,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
float  fWidth = 0.0f 
) [pure virtual]

Draws a colored quad using given 3D positions.

Parameters:
[in]cColorColor to use
[in]vV1Object space quad vertex 1
[in]vV2Object space quad vertex 2
[in]vV3Object space quad vertex 3
[in]vV4Object space quad vertex 4
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]fWidthWidth of the line, if 0, the quad is not drawn using lines
See also:
virtual void PLRenderer::DrawHelpers::DrawGradientQuad ( const PLGraphics::Color4 cColor1,
const PLGraphics::Color4 cColor2,
float  fAngle,
const PLMath::Vector2 vPos,
const PLMath::Vector2 vSize 
) [pure virtual]

Draws a gradient colored 2D quad.

Parameters:
[in]cColor1First color to use
[in]cColor2Second color to use
[in]fAngleClockwise angle (in radian) of the gradient color. 0° means from left to right.
[in]vPos2D position
[in]vSize2D size
See also:
virtual void PLRenderer::DrawHelpers::DrawGradientQuad ( const PLGraphics::Color4 cColor1,
const PLGraphics::Color4 cColor2,
float  fAngle,
const PLMath::Vector3 vV1,
const PLMath::Vector3 vV2,
const PLMath::Vector3 vV3,
const PLMath::Vector3 vV4,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace 
) [pure virtual]

Draws a gradient colored quad using given 3D positions.

Parameters:
[in]cColor1First color to use
[in]cColor2Second color to use
[in]fAngleClockwise angle (in radian) of the gradient color. 0° means from left to right.
[in]vV1Object space quad vertex 1
[in]vV2Object space quad vertex 2
[in]vV3Object space quad vertex 3
[in]vV4Object space quad vertex 4
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
See also:
virtual void PLRenderer::DrawHelpers::DrawBox ( const PLGraphics::Color4 cColor,
const PLMath::Vector3 vMin,
const PLMath::Vector3 vMax,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
float  fWidth = 0.0f 
) [pure virtual]

Draws a colored box.

Parameters:
[in]cColorColor to use
[in]vMinMinimum object space position
[in]vMaxMaximum object space position
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]fWidthWidth of the line, if 0, the box is not drawn using lines
See also:
virtual void PLRenderer::DrawHelpers::DrawPlane ( const PLGraphics::Color4 cColor,
const PLMath::Vector3 vN,
float  fD,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
float  fSize = 10000.0f,
float  fLineWidth = 1.0f 
) [pure virtual]

Draws a colored plane.

Parameters:
[in]cColorColor to use
[in]vNPlane normal (must be normalized)
[in]fDPlane d factor
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]fSizePlane size, a plane has an infinite size but often it's useful to limit the visible size...
[in]fLineWidthWidth of the line, if 0, draw no line to origin
See also:

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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:38
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported