Visual Computing Library
Loading...
Searching...
No Matches
vcl::Context Class Reference

Public Member Functions

bool isHeadless () const
 
const bgfx::Caps & capabilites () const
 Return the capabilities of the backend renderer.
 
bool supportsReadback () const
 
bool isDefaultWindow (void *windowHandle) const
 Checks whether the context is initialized with the provided window handle.
 
bool isValidViewId (bgfx::ViewId viewId) const
 
bgfx::ViewId requestViewId ()
 
void releaseViewId (bgfx::ViewId viewId)
 
bgfx::FrameBufferHandle createOffscreenFramebuffer (uint16_t width, uint16_t height, bgfx::TextureFormat::Enum colorFormat=DEFAULT_COLOR_FORMAT, bgfx::TextureFormat::Enum depthFormat=DEFAULT_DEPTH_FORMAT)
 Create a framebuffer with with 2 attachments (color and depth)
 
void resetDefaultFramebuffer (uint16_t width, uint16_t height, bgfx::TextureFormat::Enum colorFormat=DEFAULT_COLOR_FORMAT)
 
bgfx::FrameBufferHandle createFramebufferAndInitView (void *winId, bgfx::ViewId view, uint16_t width, uint16_t height, bool clear=false, uint32_t clearColor=DEFAULT_CLEAR_COLOR, float clearDepth=DEFAULT_CLEAR_DEPTH, uint8_t clearStencil=DEFAULT_CLEAR_STENCIL, bgfx::TextureFormat::Enum colorFormat=DEFAULT_COLOR_FORMAT, bgfx::TextureFormat::Enum depthFormat=DEFAULT_DEPTH_FORMAT)
 
bgfx::FrameBufferHandle createOffscreenFramebufferAndInitView (bgfx::ViewId view, uint16_t width, uint16_t height, bool clear=false, uint32_t clearColor=DEFAULT_CLEAR_COLOR, float clearDepth=DEFAULT_CLEAR_DEPTH, uint8_t clearStencil=DEFAULT_CLEAR_STENCIL, bgfx::TextureFormat::Enum colorFormat=DEFAULT_COLOR_FORMAT, bgfx::TextureFormat::Enum depthFormat=DEFAULT_DEPTH_FORMAT)
 
FontManagerfontManager ()
 
ProgramManagerprogramManager ()
 
 Context (const Context &)=delete
 
Contextoperator= (const Context &)=delete
 
 Context (Context &&)=delete
 
Contextoperator= (Context &&)=delete
 

Static Public Member Functions

static Contextinstance (void *windowHandle=nullptr, void *displayHandle=nullptr)
 Return the context instance.
 
static void init (void *windowHandle=nullptr, void *displayHandle=nullptr)
 
static void initHeadless ()
 
static bool isInitialized ()
 
static void shutdown ()
 
static bgfx::RendererType::Enum renderType ()
 Return the backend renderer type used by bgfx.
 
static void setRenderType (bgfx::RendererType::Enum renderType)
 Set the backend renderer type used by bgfx.
 
static void setResetFlags (uint flags)
 Set the reset flags used by the default frame buffer.
 
static void setDebugVerbosity (bool verbose)
 

Static Public Attributes

static constexpr uint32_t DEFAULT_CLEAR_COLOR = 0x000000ff
 
static constexpr float DEFAULT_CLEAR_DEPTH = 1.0f
 
static constexpr uint8_t DEFAULT_CLEAR_STENCIL = 0
 
static constexpr bgfx::TextureFormat::Enum DEFAULT_COLOR_FORMAT
 
static constexpr bgfx::TextureFormat::Enum DEFAULT_DEPTH_FORMAT
 

Private Member Functions

 Context (void *windowHandle, void *displayHandle)
 

Private Attributes

voidmWindowHandle = nullptr
 
voidmDisplayHandle = nullptr
 
std::stack< bgfx::ViewId > mViewStack
 
Callback mCallBack
 
FontManagermFontManager = nullptr
 
ProgramManagermProgramManager = nullptr
 

Static Private Attributes

static bgfx::RendererType::Enum sRenderType
 
static uint sResetFlags = BGFX_RESET_VSYNC
 
static ContextsInstancePtr = nullptr
 
static std::mutex sMutex
 

Member Function Documentation

◆ createOffscreenFramebuffer()

bgfx::FrameBufferHandle vcl::Context::createOffscreenFramebuffer ( uint16_t  width,
uint16_t  height,
bgfx::TextureFormat::Enum  colorFormat = DEFAULT_COLOR_FORMAT,
bgfx::TextureFormat::Enum  depthFormat = DEFAULT_DEPTH_FORMAT 
)

Create a framebuffer with with 2 attachments (color and depth)

Parameters
[in]widthThe width of the framebuffer.
[in]heightThe height of the framebuffer.
[in]colorFormatThe format of the color attachment.
[in]depthFormatThe format of the depth attachment.
Returns
The handle of the created framebuffer.

◆ instance()

Context & vcl::Context::instance ( void windowHandle = nullptr,
void displayHandle = nullptr 
)
static

Return the context instance.

Parameters
[in]windowHandleThe window handle.
[in]displayHandleThe display handle.
Returns
The context instance.

◆ isDefaultWindow()

bool vcl::Context::isDefaultWindow ( void windowHandle) const

Checks whether the context is initialized with the provided window handle.

Parameters
[in]windowHandleThe window handle to check.

◆ renderType()

bgfx::RendererType::Enum vcl::Context::renderType ( )
static

Return the backend renderer type used by bgfx.

This function can be called before the context is initialized or after. If called before, it returns the default renderer type (or the one set by calling setRenderType). If called after, it returns the renderer type used by bgfx.

◆ setRenderType()

void vcl::Context::setRenderType ( bgfx::RendererType::Enum  renderType)
static

Set the backend renderer type used by bgfx.

This function can be called before the context is initialized, to set the type of renderer used by bgfx.

Depending on the platform, some renderer types could not be available. In such cases, the renderer type is set to the default one.

Warning
This function must be called before the context is initialized. Otherwise, it throws an exception.
Parameters
[in]renderTypethe renderer type to set.

◆ setResetFlags()

void vcl::Context::setResetFlags ( uint  flags)
static

Set the reset flags used by the default frame buffer.

If this function is not called before the context is initialized, the reset flags are set by default to BGFX_RESET_VSYNC.

See also
https://bkaradzic.github.io/bgfx/bgfx.html#_CPPv4N4bgfx10ResolutionE
Parameters
[in]flags: the reset flags.

Member Data Documentation

◆ DEFAULT_COLOR_FORMAT

constexpr bgfx::TextureFormat::Enum vcl::Context::DEFAULT_COLOR_FORMAT
staticconstexpr
Initial value:
=
bgfx::TextureFormat::RGBA8

◆ DEFAULT_DEPTH_FORMAT

constexpr bgfx::TextureFormat::Enum vcl::Context::DEFAULT_DEPTH_FORMAT
staticconstexpr
Initial value:
=
bgfx::TextureFormat::D24S8

◆ sRenderType

bgfx::RendererType::Enum vcl::Context::sRenderType
inlinestaticprivate
Initial value:
=
bgfx::RendererType::Count

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