|
| CanvasBGFX (void *winId, uint width, uint height, void *displayId=nullptr) |
|
Point2< uint > | size () const |
|
bgfx::ViewId | viewId () const |
|
bgfx::FrameBufferHandle | frameBuffer () const |
|
void | setDefaultClearColor (const Color &color) |
|
void | onInit () |
| Automatically called by the DerivedRenderApp when the window initializes. Initialization is requires in some backends+window manager combinations, and therefore it must be implemented (also if empty) in every Canvas class.
|
|
void | onResize (uint width, uint height) |
| Automatically called by the DerivedRenderApp when the window is resized.
|
|
void | onPaint () |
| Automatically called by the DerivedRenderApp when the window asks to repaint.
|
|
bool | onReadDepth (const Point2i &point, CallbackReadBuffer callback=nullptr) |
| Automatically called by the DerivedRenderApp when a drawer asks to read the depth buffer at a specific point.
|
|
bool | onScreenshot (const std::string &filename, uint width=0, uint height=0) |
| Automatically called by the DerivedRenderApp when a drawer asks for a screenshot.
|
|
The Canvas class describes a canvas on which bgfx can draw.
Its usage requires to have a window object that can be used to initialize the canvas. The window object is not managed by the Canvas class, and can be managed by any of the windowing systems or libraries that allow to retrieve the native window handle (e.g. Qt, GLFW...).
You can create your custom bgfx canvas class by inheriting from this class and passing to the constructor the native window handle and the window size. Alternatively to the constructor, you can also use the init() method to initialize the canvas (if the required parameters are not available at construction time).
This class does not provide a render loop, that must be implemented in one of the derived classes. The render loop must call the frame() member function at the end of each frame, after all the bgfx rendering commands have been issued.
The bgfx rendering code should be implemented in the virtual member function draw(uint viewId), that must be reimplemented in the derived classes. This method is called by the frame() method (that must be called in the render loop), and its argument is the bgfx view ID.
The class provides two important member functions:
- frame(): this function must be called by the derived classes at the end of each frame, after all the bgfx rendering commands have been issued;
- onResize(width, height): this function must be called by the derived classes whenever the window is resized.