Visual Computing Library
|
The Canvas class describes a canvas on which opengl2 can draw. More...
#include <vclib/opengl2/canvas.h>
Public Types | |
using | CallbackReadBuffer = ReadBufferTypes::CallbackReadBuffer |
Public Member Functions | |
CanvasOpenGL2 (void *winId, uint width, uint height, void *displayId=nullptr) | |
Point2< uint > | size () const |
uint | viewId () 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. | |
Protected Types | |
using | FloatData = ReadBufferTypes::FloatData |
using | ByteData = ReadBufferTypes::ByteData |
using | ReadData = ReadBufferTypes::ReadData |
Private Member Functions | |
void | readDepthData () |
auto * | derived () |
const auto * | derived () const |
Private Attributes | |
void * | mWinId = nullptr |
Point2< uint > | mSize = {0, 0} |
vcl::Color | mDefaultClearColor = vcl::Color::Black |
CallbackReadBuffer | mReadBufferCallback = nullptr |
Point2i | mReadDepthPoint = Point2i(-1, -1) |
The Canvas class describes a canvas on which opengl2 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 opengl2 rendering code should be implemented in the virtual member function draw(), that must be reimplemented in the derived classes. This method is called by the frame() method (that must be called in the render loop).
The class provides two important member functions:
|
inline |
Automatically called by the DerivedRenderApp when a drawer asks to read the depth buffer at a specific point.
point | |
callback |
|
inline |
Automatically called by the DerivedRenderApp when the window is resized.
width | |
height |
|
inline |
Automatically called by the DerivedRenderApp when a drawer asks for a screenshot.
filename | |
width | |
height |