ezEngine  Release 25.03
ezDebugRenderer Class Reference

Draws simple shapes into the scene or view. More...

#include <DebugRenderer.h>

Static Public Member Functions

static void DrawLines (const ezDebugRendererContext &context, ezArrayPtr< const ezDebugRendererLine > lines, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders the given set of lines for one frame.
 
static void Draw2DLines (const ezDebugRendererContext &context, ezArrayPtr< const ezDebugRendererLine > lines, const ezColor &color)
 Renders the given set of lines in 2D (screen-space) for one frame.
 
static void DrawCross (const ezDebugRendererContext &context, const ezVec3 &vGlobalPosition, float fLineLength, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders a cross for one frame.
 
static void DrawLineBox (const ezDebugRendererContext &context, const ezBoundingBox &box, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders a wireframe box for one frame.
 
static void DrawLineBoxCorners (const ezDebugRendererContext &context, const ezBoundingBox &box, float fCornerFraction, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders the corners of a wireframe box for one frame.
 
static void DrawLineSphere (const ezDebugRendererContext &context, const ezBoundingSphere &sphere, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders a wireframe sphere for one frame.
 
static void DrawLineCapsuleZ (const ezDebugRendererContext &context, float fLength, float fRadius, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders an upright wireframe capsule for one frame.
 
static void DrawLineCylinderZ (const ezDebugRendererContext &context, float fLength, float fRadius, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders an upright wireframe cylinder for one frame.
 
static void DrawLineFrustum (const ezDebugRendererContext &context, const ezFrustum &frustum, const ezColor &color, bool bDrawPlaneNormals=false)
 Renders a wireframe frustum for one frame.
 
static void DrawSolidBox (const ezDebugRendererContext &context, const ezBoundingBox &box, const ezColor &color, const ezTransform &transform=ezTransform::MakeIdentity())
 Renders a solid box for one frame.
 
static void DrawSolidTriangles (const ezDebugRendererContext &context, ezArrayPtr< ezDebugRendererTriangle > triangles, const ezColor &color, bool bTwoSided=false)
 Renders the set of filled triangles for one frame.
 
static void DrawTexturedTriangles (const ezDebugRendererContext &context, ezArrayPtr< ezDebugRendererTexturedTriangle > triangles, const ezColor &color, const ezTexture2DResourceHandle &hTexture, bool bTwoSided=false)
 Renders the set of textured triangles for one frame.
 
static void Draw2DRectangle (const ezDebugRendererContext &context, const ezRectFloat &rectInPixel, float fDepth, const ezColor &color)
 Renders a filled 2D rectangle in screen-space for one frame.
 
static void Draw2DRectangle (const ezDebugRendererContext &context, const ezRectFloat &rectInPixel, float fDepth, const ezColor &color, const ezTexture2DResourceHandle &hTexture, ezVec2 vScale=ezVec2(1, 1))
 Renders a textured 2D rectangle in screen-space for one frame.
 
static void Draw2DRectangle (const ezDebugRendererContext &context, const ezRectFloat &rectInPixel, float fDepth, const ezColor &color, ezGALTextureResourceViewHandle hResourceView, ezVec2 vScale=ezVec2(1, 1))
 Renders a textured 2D rectangle in screen-space for one frame.
 
static void Draw2DLineRectangle (const ezDebugRendererContext &context, const ezRectFloat &rectInPixel, float fDepth, const ezColor &color)
 Renders a wireframe 2D rectangle in screen-space for one frame.
 
static ezUInt32 Draw2DText (const ezDebugRendererContext &context, const ezFormatString &text, const ezVec2I32 &vPositionInPixel, const ezColor &color, ezUInt32 uiSizeInPixel=16, ezDebugTextHAlign::Enum horizontalAlignment=ezDebugTextHAlign::Left, ezDebugTextVAlign::Enum verticalAlignment=ezDebugTextVAlign::Top)
 Displays a string in screen-space for one frame. More...
 
static void DrawInfoText (const ezDebugRendererContext &context, ezDebugTextPlacement::Enum placement, ezStringView sGroupName, const ezFormatString &text, const ezColor &color=ezColor::White)
 Draws a piece of text in one of the screen corners. More...
 
static void AddPersistentInfoText (const ezDebugRendererContext &context, ezDebugTextPlacement::Enum placement, const ezFormatString &text, ezTime duration, const ezColor &color=ezColor::White)
 Same as DrawInfoText but displays the text for a certain duration.
 
static ezUInt32 Draw3DText (const ezDebugRendererContext &context, const ezFormatString &text, const ezVec3 &vGlobalPosition, const ezColor &color, ezUInt32 uiSizeInPixel=16, ezDebugTextHAlign::Enum horizontalAlignment=ezDebugTextHAlign::Center, ezDebugTextVAlign::Enum verticalAlignment=ezDebugTextVAlign::Bottom)
 Displays a string in 3D space for one frame.
 
static void AddPersistentCross (const ezDebugRendererContext &context, float fSize, const ezColor &color, const ezTransform &transform, ezTime duration)
 Renders a cross at the given location for as many frames until duration has passed.
 
static void AddPersistentLineSphere (const ezDebugRendererContext &context, float fRadius, const ezColor &color, const ezTransform &transform, ezTime duration)
 Renders a wireframe sphere at the given location for as many frames until duration has passed.
 
static void AddPersistentLineBox (const ezDebugRendererContext &context, const ezVec3 &vHalfSize, const ezColor &color, const ezTransform &transform, ezTime duration)
 Renders a wireframe box at the given location for as many frames until duration has passed.
 
static void AddPersistentLines (const ezDebugRendererContext &context, ezArrayPtr< const ezDebugRendererLine > lines, const ezColor &color, const ezTransform &transform, ezTime duration)
 Renders lines at the given location for as many frames until duration has passed.
 
static void DrawAngle (const ezDebugRendererContext &context, ezAngle startAngle, ezAngle endAngle, const ezColor &solidColor, const ezColor &lineColor, const ezTransform &transform, ezVec3 vForwardAxis=ezVec3::MakeAxisX(), ezVec3 vRotationAxis=ezVec3::MakeAxisZ())
 Renders a solid 2D cone in a plane with a given angle. More...
 
static void DrawOpeningCone (const ezDebugRendererContext &context, ezAngle halfAngle, const ezColor &colorInside, const ezColor &colorOutside, const ezTransform &transform, ezVec3 vForwardAxis=ezVec3::MakeAxisX())
 Renders a cone with the tip at the center position, opening up with the given angle.
 
static void DrawLimitCone (const ezDebugRendererContext &context, ezAngle halfAngle1, ezAngle halfAngle2, const ezColor &solidColor, const ezColor &lineColor, const ezTransform &transform)
 Renders a bent cone with the tip at the center position, pointing into the +X direction opening up with halfAngle1 and halfAngle2 along the Y and Z axis. More...
 
static void DrawCylinder (const ezDebugRendererContext &context, float fRadiusStart, float fRadiusEnd, float fLength, const ezColor &solidColor, const ezColor &lineColor, const ezTransform &transform, bool bCapStart=false, bool bCapEnd=false, ezBasisAxis::Enum cylinderAxis=ezBasisAxis::PositiveX)
 Renders a cylinder starting at the center position, along the +X axis. More...
 
static void DrawArrow (const ezDebugRendererContext &context, float fSize, const ezColor &color, const ezTransform &transform, ezVec3 vForwardAxis=ezVec3::MakeAxisX())
 Renders a line arrow.
 
static float GetTextGlyphWidth (ezUInt32 uiSizeInPixel=16)
 Returns the width of single glyph in pixels for the given text size.
 
static float GetTextLineHeight (ezUInt32 uiSizeInPixel=16)
 Returns the line height in pixels for the given text size.
 
static float GetTextScale ()
 Returns the global debug text scale.
 
static void SetTextScale (float fScale)
 Sets the global debug text scale.
 

Friends

class ezSimpleRenderPass
 

Detailed Description

Draws simple shapes into the scene or view.

Shapes can be rendered for a single frame, or 'persistent' for a certain duration. The 'context' specifies whether shapes are generally visible in a scene, from all views, or specific to a single view. See the ezDebugRendererContext constructors for what can be implicitly used as a context.

Member Function Documentation

◆ Draw2DText()

ezUInt32 ezDebugRenderer::Draw2DText ( const ezDebugRendererContext context,
const ezFormatString text,
const ezVec2I32 vPositionInPixel,
const ezColor color,
ezUInt32  uiSizeInPixel = 16,
ezDebugTextHAlign::Enum  horizontalAlignment = ezDebugTextHAlign::Left,
ezDebugTextVAlign::Enum  verticalAlignment = ezDebugTextVAlign::Top 
)
static

Displays a string in screen-space for one frame.

The string may contain newlines (
) for multi-line output. If horizontal alignment is right, the entire text block is aligned according to the longest line. If vertical alignment is bottom, the entire text block is aligned there.

Data can be output as a table, by separating columns with tabs (\t). For example: "| Col 1\t| Col 2\t| Col 3\t|\n| abc\t| 42\t| 11.23\t|"

Returns the number of lines that the text was split up into.

◆ DrawAngle()

void ezDebugRenderer::DrawAngle ( const ezDebugRendererContext context,
ezAngle  startAngle,
ezAngle  endAngle,
const ezColor solidColor,
const ezColor lineColor,
const ezTransform transform,
ezVec3  vForwardAxis = ezVec3::MakeAxisX(),
ezVec3  vRotationAxis = ezVec3::MakeAxisZ() 
)
static

Renders a solid 2D cone in a plane with a given angle.

The rotation goes around the given rotationAxis. An angle of zero is pointing into forwardAxis direction. Both angles may be negative.

◆ DrawCylinder()

void ezDebugRenderer::DrawCylinder ( const ezDebugRendererContext context,
float  fRadiusStart,
float  fRadiusEnd,
float  fLength,
const ezColor solidColor,
const ezColor lineColor,
const ezTransform transform,
bool  bCapStart = false,
bool  bCapEnd = false,
ezBasisAxis::Enum  cylinderAxis = ezBasisAxis::PositiveX 
)
static

Renders a cylinder starting at the center position, along the +X axis.

If the start and end radius are different, a cone or arrow can be created.

◆ DrawInfoText()

void ezDebugRenderer::DrawInfoText ( const ezDebugRendererContext context,
ezDebugTextPlacement::Enum  placement,
ezStringView  sGroupName,
const ezFormatString text,
const ezColor color = ezColor::White 
)
static

Draws a piece of text in one of the screen corners.

Text positioning is automatic, all lines are placed in each corner such that they don't overlap. Text from different corners may overlap, though.

For text formatting options, see Draw2DText().

The groupName parameter is used to insert whitespace between unrelated pieces of text, it is not displayed anywhere, though.

Text size cannot be changed.

◆ DrawLimitCone()

void ezDebugRenderer::DrawLimitCone ( const ezDebugRendererContext context,
ezAngle  halfAngle1,
ezAngle  halfAngle2,
const ezColor solidColor,
const ezColor lineColor,
const ezTransform transform 
)
static

Renders a bent cone with the tip at the center position, pointing into the +X direction opening up with halfAngle1 and halfAngle2 along the Y and Z axis.

If solidColor.a > 0, the cone is rendered with as solid triangles. If lineColor.a > 0, the cone is rendered as lines. Both can be combined.


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