AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
SoftwareRenderer Class Reference

Public Member Functions

void putPixel (glm::ivec2 position, AColor color, AOptional< Blending > blending=std::nullopt) noexcept
 
_< IMultiStringCanvasnewMultiStringCanvas (const AFontStyle &style) override
 Creates new canvas for batching multiple prerender string calls. More...
 
void rectangle (const ABrush &brush, glm::vec2 position, glm::vec2 size) override
 Draws simple rectangle. More...
 
void roundedRectangle (const ABrush &brush, glm::vec2 position, glm::vec2 size, float radius) override
 Draws rounded rect (with antialiasing, if msaa enabled). More...
 
void rectangleBorder (const ABrush &brush, glm::vec2 position, glm::vec2 size, float lineWidth) override
 Draws rectangle's border. More...
 
void roundedRectangleBorder (const ABrush &brush, glm::vec2 position, glm::vec2 size, float radius, int borderWidth) override
 Draws rounded rectangle's border. More...
 
void boxShadow (glm::vec2 position, glm::vec2 size, float blurRadius, const AColor &color) override
 Draws a rectangle-shaped shadow. More...
 
void boxShadowInner (glm::vec2 position, glm::vec2 size, float blurRadius, float spreadRadius, float borderRadius, const AColor &color, glm::vec2 offset) override
 Draws inner (inset) rectangle-shaped shadow. More...
 
void string (glm::vec2 position, const AString &string, const AFontStyle &fs) override
 Draws string. More...
 
_< IPrerenderedStringprerenderString (glm::vec2 position, const AString &text, const AFontStyle &fs) override
 Analyzes string and creates an instance of IRenderer::IPrerenderedString which helps IRenderer to efficiently render the string. More...
 
void setBlending (Blending blending) override
 Sets blending mode. More...
 
void setWindow (AWindowBase *window) override
 Sets the window to render on. More...
 
glm::mat4 getProjectionMatrix () const override
 
void pushMaskBefore () override
 witches drawing to the stencil buffer instead of color buffer. More...
 
void pushMaskAfter () override
 Switches drawing to the color buffer back from the stencil. Increases stencil depth. More...
 
void popMaskBefore () override
 Switches drawing to the stencil buffer instead of color buffer. More...
 
void popMaskAfter () override
 Switches drawing to the color buffer back from the stencil. Decreases stencil depth. More...
 
_unique< IRenderViewToTexturenewRenderViewToTexture () noexcept override
 Returns a new instance of IRenderViewToTexture interface associated with this renderer. More...
 
void lines (const ABrush &brush, AArrayView< glm::vec2 > points, const ABorderStyle &style, AMetric width) override
 Draws polyline (non-loop line strip). More...
 
void points (const ABrush &brush, AArrayView< glm::vec2 > points, AMetric size) override
 Draws points list. More...
 
void lines (const ABrush &brush, AArrayView< std::pair< glm::vec2, glm::vec2 > > points, const ABorderStyle &style, AMetric width) override
 Draws multiple individual lines in a batch. More...
 
void squareSector (const ABrush &brush, const glm::vec2 &position, const glm::vec2 &size, AAngleRadians begin, AAngleRadians end) override
 Draws sector in rectangle shape. The sector is drawn clockwise from begin to end angles. More...
 
- Public Member Functions inherited from IRenderer
_< ITexturegetNewTexture ()
 Creates new texture (image representation optimized for GPU rendering).
 
void line (const ABrush &brush, glm::vec2 p1, glm::vec2 p2, const ABorderStyle &style=ABorderStyle::Solid{}, AMetric width=1_dp)
 
void lines (const ABrush &brush, AArrayView< glm::vec2 > points, const ABorderStyle &style=ABorderStyle::Solid{})
 Draws polyline (non-loop line strip). More...
 
void lines (const ABrush &brush, AArrayView< std::pair< glm::vec2, glm::vec2 > > points, const ABorderStyle &style=ABorderStyle::Solid{})
 Draws multiple individual lines in a batch. More...
 
void setColorForced (const AColor &color)
 Sets the color which is multiplied with any brush. More...
 
void setColor (const AColor &color)
 
const AColorgetColor () const
 
void setTransform (const glm::mat4 &transform)
 Sets the transform matrix which is applicable for any figure. Unlike setTransformForced, the new matrix is multiplied by the previous matrix. More...
 
void setTransformForced (const glm::mat4 &transform)
 Sets the transform matrix which is applicable for any figure. More...
 
AWindowBasegetWindow () const noexcept
 
const glm::mat4 & getTransform ()
 
std::uint8_t getStencilDepth () const noexcept
 
void setStencilDepth (uint8_t stencilDepth)
 
void translate (const glm::vec2 &offset)
 Wrapper for setTransform applying matrix translate transformation. More...
 
void rotate (const glm::vec3 &axis, AAngleRadians angle)
 wrapper for setTransform applying matrix rotation along the specified axis. More...
 
void rotate (AAngleRadians angle)
 wrapper for setTransform applying matrix rotation along z axis. More...
 
void setAllowRenderToTexture (bool allowRenderToTexture)
 
bool allowRenderToTexture () const noexcept
 
void backdrops (glm::ivec2 position, glm::ivec2 size, std::span< ass::Backdrop::Any > backdrops)
 Draws rectangular backdrop effects. More...
 
- Public Member Functions inherited from aui::noncopyable
 noncopyable (const noncopyable &)=delete
 
noncopyableoperator= (const noncopyable &)=delete
 

Protected Member Functions

_unique< ITexturecreateNewTexture () override
 
void drawLine (const ABrush &brush, glm::vec2 p1, glm::vec2 p2, const ABorderStyle &style, AMetric width)
 
- Protected Member Functions inherited from IRenderer
void stub (glm::vec2 position, glm::vec2 size)
 Draws stub (i.e., gray rectangle) More...
 
virtual void backdrops (glm::ivec2 position, glm::ivec2 size, std::span< ass::Backdrop::Preprocessed > backdrops)
 

Additional Inherited Members

- Protected Attributes inherited from IRenderer
AColor mColor
 
glm::mat4 mTransform
 
AWindowBasemWindow = nullptr
 
APool< ITexturemTexturePool
 
uint8_t mStencilDepth = 0
 

Member Function Documentation

◆ boxShadow()

void SoftwareRenderer::boxShadow ( glm::vec2  position,
glm::vec2  size,
float  blurRadius,
const AColor color 
)
overridevirtual

Draws a rectangle-shaped shadow.

Parameters
positionposition
sizerectangle size
blurRadiusblur radius
colorshadow color

Implements IRenderer.

◆ boxShadowInner()

void SoftwareRenderer::boxShadowInner ( glm::vec2  position,
glm::vec2  size,
float  blurRadius,
float  spreadRadius,
float  borderRadius,
const AColor color,
glm::vec2  offset 
)
overridevirtual

Draws inner (inset) rectangle-shaped shadow.

Parameters
positionposition
sizerectangle size
blurRadiusblur radius
spreadRadiusspread (offset) radius
borderRadiusborder radius of the rectangle.
colorshadow color
offsetshadow offset. Unlike outer shadow (ctx.render.boxShadow), the offset is passed to the shader instead of a simple rectangle position offset.

Implements IRenderer.

◆ createNewTexture()

_unique< ITexture > SoftwareRenderer::createNewTexture ( )
overrideprotectedvirtual

Implements IRenderer.

◆ getProjectionMatrix()

glm::mat4 SoftwareRenderer::getProjectionMatrix ( ) const
overridevirtual

Implements IRenderer.

◆ lines() [1/2]

void SoftwareRenderer::lines ( const ABrush &  brush,
AArrayView< glm::vec2 >  points,
const ABorderStyle style,
AMetric  width 
)
overridevirtual

Draws polyline (non-loop line strip).

Parameters
brushbrush
pointspolyline points
stylestyle
widthline width

Implements IRenderer.

◆ lines() [2/2]

void SoftwareRenderer::lines ( const ABrush &  brush,
AArrayView< std::pair< glm::vec2, glm::vec2 > >  points,
const ABorderStyle style,
AMetric  width 
)
overridevirtual

Draws multiple individual lines in a batch.

Parameters
brushbrush
pointsline points
stylestyle
widthline width

Implements IRenderer.

◆ newMultiStringCanvas()

_< IRenderer::IMultiStringCanvas > SoftwareRenderer::newMultiStringCanvas ( const AFontStyle style)
overridevirtual

Creates new canvas for batching multiple prerender string calls.

Returns
a new instance of IMultiStringCanvas

Implements IRenderer.

◆ newRenderViewToTexture()

_unique< IRenderViewToTexture > SoftwareRenderer::newRenderViewToTexture ( )
overridevirtualnoexcept

Returns a new instance of IRenderViewToTexture interface associated with this renderer.

Returns
A new instance. Can return null if unsupported.

Implements IRenderer.

◆ points()

void SoftwareRenderer::points ( const ABrush &  brush,
AArrayView< glm::vec2 >  points,
AMetric  size 
)
overridevirtual

Draws points list.

Parameters
brushbrush
pointspoints
sizepoint size

Implements IRenderer.

◆ popMaskAfter()

void SoftwareRenderer::popMaskAfter ( )
overridevirtual

Switches drawing to the color buffer back from the stencil. Decreases stencil depth.

Stencil buffer should not be changed after calling this function. Should be called after the popMaskBefore function.

Implements IRenderer.

◆ popMaskBefore()

void SoftwareRenderer::popMaskBefore ( )
overridevirtual

Switches drawing to the stencil buffer instead of color buffer.

Stencil pixel is decreased by each affected pixel. Should be called before the popMaskAfter function.

Implements IRenderer.

◆ prerenderString()

_< IRenderer::IPrerenderedString > SoftwareRenderer::prerenderString ( glm::vec2  position,
const AString text,
const AFontStyle fs 
)
overridevirtual

Analyzes string and creates an instance of IRenderer::IPrerenderedString which helps IRenderer to efficiently render the string.

Parameters
positionstring's top left point
textstring to prerender
fsfont style
Returns
an instance of IPrerenderedString

Implements IRenderer.

◆ pushMaskAfter()

void SoftwareRenderer::pushMaskAfter ( )
overridevirtual

Switches drawing to the color buffer back from the stencil. Increases stencil depth.

Stencil buffer should not be changed after calling this function. Should be called after the pushMaskBefore function.

Implements IRenderer.

◆ pushMaskBefore()

void SoftwareRenderer::pushMaskBefore ( )
overridevirtual

witches drawing to the stencil buffer instead of color buffer.

Stencil pixel is increased by each affected pixel. Should be called before the pushMaskAfter function.

Implements IRenderer.

◆ putPixel()

void SoftwareRenderer::putPixel ( glm::ivec2  position,
AColor  color,
AOptional< Blending >  blending = std::nullopt 
)
inlinenoexcept

Draws a pixel onto the software framebuffer following the stencil and blending rules.

Sneaky assertions
position is inside the framebuffer.
Parameters
positionposition. An assertion is triggered if position is not inside the framebuffer.
colorcolor.
blendingblending. Optional. Cheaper. When set, the one set by the setBlending function is ignored.

◆ rectangle()

void SoftwareRenderer::rectangle ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size 
)
overridevirtual

Draws simple rectangle.

Parameters
brushbrush to use
positionrectangle position (px)
sizerectangle size (px)

Implements IRenderer.

◆ rectangleBorder()

void SoftwareRenderer::rectangleBorder ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size,
float  lineWidth 
)
overridevirtual

Draws rectangle's border.

Parameters
brushbrush to use
positionrectangle position (px)
sizerectangle size (px)
lineWidthborder line width (px)

Implements IRenderer.

◆ roundedRectangle()

void SoftwareRenderer::roundedRectangle ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size,
float  radius 
)
overridevirtual

Draws rounded rect (with antialiasing, if msaa enabled).

Parameters
brushbrush to use
positionrectangle position (px)
sizerectangle size (px)
radiuscorner radius (px)

Implements IRenderer.

◆ roundedRectangleBorder()

void SoftwareRenderer::roundedRectangleBorder ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size,
float  radius,
int  borderWidth 
)
overridevirtual

Draws rounded rectangle's border.

Parameters
brushbrush to use
positionrectangle position (px)
sizerectangle size (px)
radiuscorner radius (px)
borderWidthborder line width (px)

Implements IRenderer.

◆ setBlending()

void SoftwareRenderer::setBlending ( Blending  blending)
overridevirtual

Sets blending mode.

Parameters
blendingnew blending mode

Implements IRenderer.

◆ setWindow()

void SoftwareRenderer::setWindow ( AWindowBase window)
overridevirtual

Sets the window to render on.

Parameters
windowtarget window

Reimplemented from IRenderer.

◆ squareSector()

void SoftwareRenderer::squareSector ( const ABrush &  brush,
const glm::vec2 &  position,
const glm::vec2 &  size,
AAngleRadians  begin,
AAngleRadians  end 
)
overridevirtual

Draws sector in rectangle shape. The sector is drawn clockwise from begin to end angles.

Parameters
brushbrush to use
positionrectangle position (px)
sizerectangle size (px)

The method can be used as mask to ctx.render.roundedRect, creating arc shape.

Implements IRenderer.

◆ string()

void SoftwareRenderer::string ( glm::vec2  position,
const AString string,
const AFontStyle fs 
)
overridevirtual

Draws string.

Parameters
positionstring's top left point
stringstring to render
fsfont style (optional)
Note
This function is dramatically inefficient since it does symbol lookup for every character is the string and does GPU buffer allocations. If you want to render the same string for several times (frames), consider using the IRenderer::prerenderString function or high level views (such as ALabel) instead.

Implements IRenderer.


The documentation for this class was generated from the following files:
Inheritance diagram for SoftwareRenderer:
Collaboration diagram for SoftwareRenderer: