Visual Computing Library  devel
Loading...
Searching...
No Matches
vcl::CanvasBGFX< DerivedRenderApp > Class Template Reference

The Canvas class describes a canvas on which bgfx can draw. More...

#include <vclib/bgfx/canvas.h>

Public Types

using CallbackReadBuffer = ReadBufferTypes::CallbackReadBuffer
 

Public Member Functions

 CanvasBGFX (void *winId, uint width, uint height, void *displayId=nullptr)
 
bgfx::FrameBufferHandle frameBuffer () const
 
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 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 onReadId (const Point2i &point, CallbackReadBuffer callback=nullptr)
 Automatically called by the DerivedRenderApp when a drawer asks to read the ID at a specific point.
 
void onResize (uint width, uint height)
 Automatically called by the DerivedRenderApp when the window is resized.
 
bool onScreenshot (const std::string &filename, uint multiplier=1)
 Automatically called by the DerivedRenderApp when a drawer asks for a screenshot. Also called by the public member function screenshot().
 
bool screenshot (const std::string &filename, uint multiplier=1)
 Request a screenshot of the canvas. The screenshot will be saved asynchronously.
 
void setDefaultClearColor (const Color &color)
 
Point2< uint > size () const
 
bgfx::ViewId viewId () const
 

Protected Types

using ByteData = ReadBufferTypes::ByteData
 
using FloatData = ReadBufferTypes::FloatData
 
using ReadData = ReadBufferTypes::ReadData
 

Private Types

using ReadFramebufferRequest = detail::ReadFramebufferRequest
 

Private Member Functions

autoderived ()
 
const autoderived () const
 
void offscreenFrame ()
 

Private Attributes

uint32_t mCurrFrame = 0
 
vcl::Color mDefaultClearColor = vcl::Color::Black
 
bgfx::FrameBufferHandle mFbh = BGFX_INVALID_HANDLE
 
std::optional< ReadFramebufferRequest > mReadRequest = std::nullopt
 
Point2< uint > mSize = {0, 0}
 
bgfx::ViewId mViewId = BGFX_INVALID_VIEW
 
voidmWinId = nullptr
 

Detailed Description

template<typename DerivedRenderApp>
class vcl::CanvasBGFX< DerivedRenderApp >

The Canvas class describes a canvas on which bgfx can draw.

Member Function Documentation

◆ onReadDepth()

bool vcl::CanvasBGFX< DerivedRenderApp >::onReadDepth ( const Point2i point,
CallbackReadBuffer  callback = nullptr 
)
inline

Automatically called by the DerivedRenderApp when a drawer asks to read the depth buffer at a specific point.

Parameters
point
callback
Returns

◆ onReadId()

bool vcl::CanvasBGFX< DerivedRenderApp >::onReadId ( const Point2i point,
CallbackReadBuffer  callback = nullptr 
)
inline

Automatically called by the DerivedRenderApp when a drawer asks to read the ID at a specific point.

Parameters
pointThe point where the ID must be read.
callbackThe callback function that will be called when the ID is read.
Returns
true id the red Id request is successfully submitted, false otherwise.

◆ onResize()

void vcl::CanvasBGFX< DerivedRenderApp >::onResize ( uint  width,
uint  height 
)
inline

Automatically called by the DerivedRenderApp when the window is resized.

Parameters
width
height

◆ onScreenshot()

bool vcl::CanvasBGFX< DerivedRenderApp >::onScreenshot ( const std::string &  filename,
uint  multiplier = 1 
)
inline

Automatically called by the DerivedRenderApp when a drawer asks for a screenshot. Also called by the public member function screenshot().

Parameters
filename
multipliermultiplier applied to the canvas image.
Returns
true if the screenshot is requested, false otherwise.
Note
this function is asynchronous, the screenshot will be saved later.

◆ screenshot()

bool vcl::CanvasBGFX< DerivedRenderApp >::screenshot ( const std::string &  filename,
uint  multiplier = 1 
)
inline

Request a screenshot of the canvas. The screenshot will be saved asynchronously.

Parameters
filenameThe filename where the screenshot will be saved.
multiplierThe multiplier applied to the canvas image.
Returns
true if the screenshot is requested, false otherwise.

The documentation for this class was generated from the following file: