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

Base class for rendering. More...

Detailed Description

Base class for rendering.

Renderer is shared between windows. It's expected to share resources (if any). Thus, it does not perform any platform specific routines.

See also
IRenderingContext

Classes

class  IMultiStringCanvas
 
class  IPrerenderedString
 

Public Member Functions

_< ITexturegetNewTexture ()
 Creates new texture (image representation optimized for GPU rendering).
 
virtual _< IMultiStringCanvasnewMultiStringCanvas (const AFontStyle &style)=0
 Creates new canvas for batching multiple prerender string calls. More...
 
virtual void rectangle (const ABrush &brush, glm::vec2 position, glm::vec2 size)=0
 Draws simple rectangle. More...
 
virtual void roundedRectangle (const ABrush &brush, glm::vec2 position, glm::vec2 size, float radius)=0
 Draws rounded rect (with antialiasing, if msaa enabled). More...
 
virtual void rectangleBorder (const ABrush &brush, glm::vec2 position, glm::vec2 size, float lineWidth=1.f)=0
 Draws rectangle's border. More...
 
virtual void roundedRectangleBorder (const ABrush &brush, glm::vec2 position, glm::vec2 size, float radius, int borderWidth)=0
 Draws rounded rectangle's border. More...
 
virtual void boxShadow (glm::vec2 position, glm::vec2 size, float blurRadius, const AColor &color)=0
 Draws a rectangle-shaped shadow. More...
 
virtual void boxShadowInner (glm::vec2 position, glm::vec2 size, float blurRadius, float spreadRadius, float borderRadius, const AColor &color, glm::vec2 offset)=0
 Draws inner (inset) rectangle-shaped shadow. More...
 
virtual void string (glm::vec2 position, const AString &string, const AFontStyle &fs={})=0
 Draws string. More...
 
virtual _< IPrerenderedStringprerenderString (glm::vec2 position, const AString &text, const AFontStyle &fs)=0
 Analyzes string and creates an instance of IRenderer::IPrerenderedString which helps IRenderer to efficiently render the string. More...
 
void line (const ABrush &brush, glm::vec2 p1, glm::vec2 p2, const ABorderStyle &style=ABorderStyle::Solid{}, AMetric width=1_dp)
 
virtual void lines (const ABrush &brush, AArrayView< glm::vec2 > points, const ABorderStyle &style, AMetric width)=0
 Draws polyline (non-loop line strip). More...
 
void lines (const ABrush &brush, AArrayView< glm::vec2 > points, const ABorderStyle &style=ABorderStyle::Solid{})
 Draws polyline (non-loop line strip). More...
 
virtual void points (const ABrush &brush, AArrayView< glm::vec2 > points, AMetric size)=0
 Draws points list. More...
 
virtual void lines (const ABrush &brush, AArrayView< std::pair< glm::vec2, glm::vec2 > > points, const ABorderStyle &style, AMetric width)=0
 Draws multiple individual lines in a batch. 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...
 
virtual void squareSector (const ABrush &brush, const glm::vec2 &position, const glm::vec2 &size, AAngleRadians begin, AAngleRadians end)=0
 Draws sector in rectangle shape. The sector is drawn clockwise from begin to end angles. 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...
 
virtual void pushMaskBefore ()=0
 witches drawing to the stencil buffer instead of color buffer. More...
 
virtual void pushMaskAfter ()=0
 Switches drawing to the color buffer back from the stencil. Increases stencil depth. More...
 
virtual void popMaskBefore ()=0
 Switches drawing to the stencil buffer instead of color buffer. More...
 
virtual void popMaskAfter ()=0
 Switches drawing to the color buffer back from the stencil. Decreases stencil depth. More...
 
virtual void setBlending (Blending blending)=0
 Sets blending mode. More...
 
virtual _unique< IRenderViewToTexturenewRenderViewToTexture () noexcept=0
 Returns a new instance of IRenderViewToTexture interface associated with this renderer. More...
 
virtual void setWindow (AWindowBase *window)
 Sets the window to render on. More...
 
AWindowBasegetWindow () const noexcept
 
virtual glm::mat4 getProjectionMatrix () const =0
 
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

virtual _unique< ITexturecreateNewTexture ()=0
 
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)
 

Protected Attributes

AColor mColor
 
glm::mat4 mTransform
 
AWindowBasemWindow = nullptr
 
APool< ITexturemTexturePool
 
uint8_t mStencilDepth = 0
 

Member Function Documentation

◆ backdrops()

void IRenderer::backdrops ( glm::ivec2  position,
glm::ivec2  size,
std::span< ass::Backdrop::Any >  backdrops 
)

Draws rectangular backdrop effects.

Parameters
positionrectangle position (px)
sizerectangle size (px)
backdropsarray of backdrop effects. Impl might apply optimizations on using several effects at once.

Implementation might draw stub (i.e., gray rectangle) instead of drawing complex backdrop effects.

◆ boxShadow()

virtual void IRenderer::boxShadow ( glm::vec2  position,
glm::vec2  size,
float  blurRadius,
const AColor color 
)
pure virtual

Draws a rectangle-shaped shadow.

Parameters
positionposition
sizerectangle size
blurRadiusblur radius
colorshadow color

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ boxShadowInner()

virtual void IRenderer::boxShadowInner ( glm::vec2  position,
glm::vec2  size,
float  blurRadius,
float  spreadRadius,
float  borderRadius,
const AColor color,
glm::vec2  offset 
)
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ line()

void IRenderer::line ( const ABrush &  brush,
glm::vec2  p1,
glm::vec2  p2,
const ABorderStyle style = ABorderStyle::Solid{},
AMetric  width = 1_dp 
)
inline
Performance note
if you want to drawElements multiple lines, consider using ARender::lines function instead.

◆ lines() [1/4]

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

Draws polyline (non-loop line strip).

Parameters
brushbrush
pointspolyline points
stylestyle
widthline width

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ lines() [2/4]

void IRenderer::lines ( const ABrush &  brush,
AArrayView< glm::vec2 >  points,
const ABorderStyle style = ABorderStyle::Solid{} 
)
inline

Draws polyline (non-loop line strip).

Parameters
brushbrush
pointspolyline points
stylestyle

◆ lines() [3/4]

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

Draws multiple individual lines in a batch.

Parameters
brushbrush
pointsline points
stylestyle
widthline width

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ lines() [4/4]

void IRenderer::lines ( const ABrush &  brush,
AArrayView< std::pair< glm::vec2, glm::vec2 > >  points,
const ABorderStyle style = ABorderStyle::Solid{} 
)
inline

Draws multiple individual lines in a batch.

Parameters
brushbrush
pointsline points
stylestyle

◆ newMultiStringCanvas()

virtual _< IMultiStringCanvas > IRenderer::newMultiStringCanvas ( const AFontStyle style)
pure virtual

Creates new canvas for batching multiple prerender string calls.

Returns
a new instance of IMultiStringCanvas

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ newRenderViewToTexture()

virtual _unique< IRenderViewToTexture > IRenderer::newRenderViewToTexture ( )
pure virtualnoexcept

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

Returns
A new instance. Can return null if unsupported.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ points()

virtual void IRenderer::points ( const ABrush &  brush,
AArrayView< glm::vec2 >  points,
AMetric  size 
)
pure virtual

Draws points list.

Parameters
brushbrush
pointspoints
sizepoint size

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ popMaskAfter()

virtual void IRenderer::popMaskAfter ( )
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ popMaskBefore()

virtual void IRenderer::popMaskBefore ( )
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ prerenderString()

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

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

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ pushMaskAfter()

virtual void IRenderer::pushMaskAfter ( )
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ pushMaskBefore()

virtual void IRenderer::pushMaskBefore ( )
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ rectangle()

virtual void IRenderer::rectangle ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size 
)
pure virtual

Draws simple rectangle.

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

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ rectangleBorder()

virtual void IRenderer::rectangleBorder ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size,
float  lineWidth = 1.f 
)
pure virtual

Draws rectangle's border.

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

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ rotate() [1/2]

void IRenderer::rotate ( AAngleRadians  angle)
inline

wrapper for setTransform applying matrix rotation along z axis.

Parameters
angleangle to rotate

◆ rotate() [2/2]

void IRenderer::rotate ( const glm::vec3 &  axis,
AAngleRadians  angle 
)
inline

wrapper for setTransform applying matrix rotation along the specified axis.

Parameters
axisaxis
angleangle to rotate

◆ roundedRectangle()

virtual void IRenderer::roundedRectangle ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size,
float  radius 
)
pure virtual

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

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

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ roundedRectangleBorder()

virtual void IRenderer::roundedRectangleBorder ( const ABrush &  brush,
glm::vec2  position,
glm::vec2  size,
float  radius,
int  borderWidth 
)
pure virtual

Draws rounded rectangle's border.

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

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ setBlending()

virtual void IRenderer::setBlending ( Blending  blending)
pure virtual

Sets blending mode.

Parameters
blendingnew blending mode

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ setColor()

void IRenderer::setColor ( const AColor color)
inline

@bruef Sets the color which is multiplied with any brush. Unlike setColorForced, the new color is multiplied by the previous color.

Parameters
colorcolor

◆ setColorForced()

void IRenderer::setColorForced ( const AColor color)
inline

Sets the color which is multiplied with any brush.

Parameters
colorcolor

◆ setTransform()

void IRenderer::setTransform ( const glm::mat4 &  transform)
inline

Sets the transform matrix which is applicable for any figure. Unlike setTransformForced, the new matrix is multiplied by the previous matrix.

Parameters
transformtransform matrix

◆ setTransformForced()

void IRenderer::setTransformForced ( const glm::mat4 &  transform)
inline

Sets the transform matrix which is applicable for any figure.

Parameters
transformtransform matrix

◆ setWindow()

virtual void IRenderer::setWindow ( AWindowBase window)
inlinevirtual

Sets the window to render on.

Parameters
windowtarget window

Reimplemented in SoftwareRenderer.

◆ squareSector()

virtual void IRenderer::squareSector ( const ABrush &  brush,
const glm::vec2 &  position,
const glm::vec2 &  size,
AAngleRadians  begin,
AAngleRadians  end 
)
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ string()

virtual void IRenderer::string ( glm::vec2  position,
const AString string,
const AFontStyle fs = {} 
)
pure virtual

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.

Implemented in OpenGLRenderer, and SoftwareRenderer.

◆ stub()

void IRenderer::stub ( glm::vec2  position,
glm::vec2  size 
)
protected

Draws stub (i.e., gray rectangle)

This can be used if implementation does not support or can't draw complex effects (i.e., blur)

◆ translate()

void IRenderer::translate ( const glm::vec2 &  offset)
inline

Wrapper for setTransform applying matrix translate transformation.

Parameters
offsetoffset in pixels to translate.

#include <AUI/Render/IRenderer.h>


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