Visual Computing Library
|
The CanvasConcept concept is used to check if a class satisfies the requirements of the Canvas concept. More...
#include <vclib/render/concepts/canvas.h>
The CanvasConcept concept is used to check if a class satisfies the requirements of the Canvas concept.
Each class that satisfies this concept can be used as a canvas in the vcl::RenderApp class (second template parameter). The Canvas class is responsible for managing the render backend and the surface where the Drawer objects can draw.
It is a class that is templated on the RenderApp class (using the CRTP pattern). The class is then allowed to access the member functions of the public members of the vcl::RenderApp class and all the members of the vcl::RenderApp::CNV inner class.
The class must have the following constructors:
CanvasType(void* winId, uint width, uint height)
: Constructor that initializes the canvas with the window id (the platform dependent identifier of the window where the canvas will be placed) and the initial size of the canvas.CanvasType(void* winId, uint width, uint height, void* displayId)
: Same as the previous constructor, but also takes the display id (the platform dependent identifier of the display where the window is placed - this parameter is required only on linux platforms, it can be left nullptr in other platforms).The class must have the following inner types:
CallbackReadBuffer
: A type that represents the signature of the callback function that will be called when the depth value is read from the depth buffer of the Canvas. See the onReadDepth
member function for more details.The class must have the following member functions:
size() -> Point2Concept
: Returns the size of the canvas, as a Point2i object having the width as x() and height as y().viewId() -> uint
: Returns an unsigned integer that represents the view id of the canvas. The view id is used to identify the canvas when drawing content on it, and it is passed to the Drawer objects at each draw call.setDefaultClearColor(const Color& color) -> void
: Sets the default clear color of the canvas to the specified color.onInit() -> void
: Called when the canvas is initialized. This function is called by the RenderApp class when the WindowManager of the vcl::RenderApp is initialized. This function should contain all the initialization calls that cannot be done in the constructor (e.g. because the WindowManager could not guarantee the initialization of the backend context in the constructor).onResize(uint width, uint height) -> void
: Called when the canvas is resized. This function is called by the RenderApp class when the WindowManager of the vcl::RenderApp is resized. The function should resize the canvas to the new size.onPaint() -> void
: Called when the canvas must be repainted. This function is called by the RenderApp class when the WindowManager of the vcl::RenderApp is repainted. The function should draw the content of the canvas, by calling the vcl::RenderApp::CNV::draw() member function of the RenderApp class.onReadDepth(const vcl::Point2i& point, CallbackReadBuffer callback) -> bool
: Called when a Drawer object asks to read the depth value at the specified point on the canvas. The function should read the depth value at the specified point and call the callback function with the depth value.onScreenshot(const std::string& filename, uint width = 0, uint height = 0) -> bool
: Called when a Drawer object asks for a screenshot of the canvas. The function should take a screenshot of the canvas and save it to the specified filename. If the width and height are specified, the screenshot should be resized to the specified dimensions.