Canvas
The Canvas class represents a graphical canvas in a rendering system, providing methods for managing its state, rendering, transformations, and hierarchy. It allows multiple canvases to be combined, offering significant flexibility in how canvases and their elements are composed and rendered together in a graphical system.
#include <interface/TellusimCanvas.h>
Constructors
Canvas()
explicit Canvas(Canvas *parent)
Methods
Clear canvas.
void clear()
Check canvas.
bool isCreated() const
Canvas scale.
uint32_t getScale(const Target &target, uint32_t scale = 100) const
Create canvas.
bool create(const Device &device, Format color, Format depth, uint32_t multisample = 1, uint32_t scale = 0)
bool create(const Device &device, const Target &target, uint32_t scale = 0)
Pipeline hash.
void setPipelineHash(uint32_t hash)
uint32_t getPipelineHash() const
Canvas parameters.
Format getColorFormat() const
Format getDepthFormat() const
uint32_t getMultisample() const
Canvas order.
void setOrder(int32_t order)
int32_t getOrder() const
Canvas enabled flag.
void setEnabled(bool enabled)
bool isEnabled() const
Canvas viewport.
void setViewport(Viewport viewport)
void setViewport(uint32_t width, uint32_t height)
void setViewport(float32_t width, float32_t height)
const Viewport getViewport() const
float32_t getWidth() const
float32_t getHeight() const
Canvas color.
void clearColor()
void setColor(Color color)
void setColor(float32_t r, float32_t g, float32_t b, float32_t a)
const Color getColor() const
Canvas scissor.
void clearScissor()
void setScissor(Rect scissor)
const Rect getScissor() const
Canvas transform.
void clearTransform()
void setTransform(Matrix4x4f transform)
const Matrix4x4f getTransform() const
Canvas parent.
uint32_t setParent(Canvas &parent)
const Canvas getParent() const
Canvas getParent()
Canvas children.
uint32_t addChild(Canvas &child)
bool removeChild(Canvas &child)
bool raiseChild(Canvas &child)
bool lowerChild(Canvas &child)
void releaseChildren()
uint32_t findChild(const Canvas &child) const
bool isChild(const Canvas &child) const
uint32_t getNumChildren() const
const Array<Canvas> getChildren() const
Array<Canvas> getChildren()
const Canvas getChild(uint32_t index) const
Canvas getChild(uint32_t index)
Canvas elements.
uint32_t addElement(CanvasElement &element)
bool removeElement(CanvasElement &element)
bool raiseElement(CanvasElement &element)
bool lowerElement(CanvasElement &element)
uint32_t findElement(const CanvasElement &element) const
bool isElement(const CanvasElement &element) const
uint32_t getNumElements() const
const Array<CanvasElement> getElements() const
Array<CanvasElement> getElements()
const CanvasElement getElement(uint32_t index) const
CanvasElement getElement(uint32_t index)
Canvas fonts.
bool isFont(const char *name) const
bool addFont(const char *name, Stream &stream)
bool addFont(const char *name, const uint8_t (*blob)[256])
void removeFont(const char *name)
Font getFont(const char *name)
Canvas textures.
bool isTexture(const char *name) const
bool addTexture(const char *name, Stream &stream)
bool addTexture(const char *name, Texture &texture)
bool addTexture(const char *name, const uint8_t (*blob)[256])
void removeTexture(const char *name)
Texture getTexture(const char *name)
Depth parameters.
void setDepthMask(DepthMask mask)
DepthMask getDepthMask() const
void setDepthFunc(DepthFunc func)
DepthFunc getDepthFunc() const
Draw canvas.
void draw(Command &command, const Target &target)
void draw(Command &command)
Create callback.
void setCreateCallback(const CreateCallback &func)
CreateCallback getCreateCallback() const
Type | Name | Description |
---|---|---|
Canvas::CreateCallback | func | Function that runs on Canvas::create() call. Returning false prevents Canvas creation. |
Pipeline callback.
void setPipelineCallback(const PipelineCallback &func)
PipelineCallback getPipelineCallback() const
Type | Name | Description |
---|---|---|
Canvas::PipelineCallback | func | Function that runs on CanvasElement::create() call. Returning false prevents Pipeline creation, so the Pipeline can be completely replaced. |
Begin callback.
void setBeginCallback(const BeginCallback &func)
BeginCallback getBeginCallback() const
Type | Name | Description |
---|---|---|
Canvas::BeginCallback | func | Function that runs on Canvas::draw() call. Returning false prevents Canvas draw. |
Draw callback.
void setDrawCallback(const DrawCallback &func)
DrawCallback getDrawCallback() const
Type | Name | Description |
---|---|---|
Canvas::DrawCallback | func | Function that runs on each CanvasElement group draw call of Canvas::draw(). |
Draw statistics.
uint32_t getNumDrawPipelines() const
uint32_t getNumDrawElements() const
uint32_t getNumDrawCommands() const
Canvas rectangle.
Rect getRect() const
Types
using CreateCallback = Function<bool(const Device device, Canvas canvas, uint32_t scale)>
using PipelineCallback = Function<bool(Pipeline pipeline, Canvas canvas, CanvasElement element)>
using BeginCallback = Function<bool(Command command, Canvas canvas)>
using DrawCallback = Function<bool(Command command, Canvas canvas)>