Framebuffer allows the rendering to the user-specified texture or renderbuffer, instead of rendering directly to the window. More...
#include <kanzi/graphics_3d/framebuffer.hpp>
Public Types | |
enum | Attachment { AttachmentColor0, AttachmentColor1, AttachmentColor2, AttachmentColor3, AttachmentDepthStencil, AttachmentCount } |
Public Member Functions | |
Framebuffer (Domain *domain, string_view name="") | |
virtual | ~Framebuffer () KZ_OVERRIDE |
bool | isRenderable (unsigned int face, unsigned int mipLevel) const |
void | configure (unsigned int width, unsigned int height, unsigned int faceCount, unsigned int sampleCount, unsigned int mipLevelCount) |
Sets the common dimensions and sample count for the framebuffer. More... | |
TextureSharedPtr | addTexture (Attachment attachment, Texture::Target target, GraphicsFormat format, Sampler::Filter minFilter, Sampler::Filter magFilter, Sampler::MipmapMode mipmapMode, Sampler::AddressingMode address) |
Creates a texture and attaches it to the framebuffer. More... | |
RenderbufferSharedPtr | addRenderbuffer (Attachment attachment, GraphicsFormat format) |
Adds a renderbuffer attachment to the framebuffer. More... | |
void | setAttachment (Attachment attachment, SurfaceSharedPtr surface) |
Sets the attachment for the framebuffer. More... | |
SurfaceSharedPtr | getAttachment (Attachment attachment) const |
Returns the attachment from the framebuffer for the specified attachment point. More... | |
TextureSharedPtr | getTexture (Attachment attachment) const |
Returns the attachment as texture from the framebuffer. More... | |
unsigned int | getWidth () const |
Returns the common width of the framebuffer. More... | |
unsigned int | getHeight () const |
Returns the common height of the framebuffer. More... | |
unsigned int | getFaceCount () const |
Returns the face count of the framebuffer. More... | |
unsigned int | getSampleCount () const |
Returns the common sample count of the framebuffer. More... | |
unsigned int | getMipLevelCount () const |
Returns the number of mipmap levels in the framebuffer. More... | |
unsigned int | getGLHandle (unsigned int face, unsigned int mipLevel) const |
Returns the GL API object handle for a specific (face, mipLevel) pair in the framebuffer. More... | |
void | bind (unsigned int face, unsigned int mipLevel) |
Binds the framebuffer for both reading and writing. More... | |
void | unbind () |
Unbinds the framebuffer. Rendering continues to the default framebuffer (window). More... | |
virtual void | loadFromKZB (const KzuResourceLoaderThreadContext *threadContext, KzcInputStream *inputStream, const KzuBinaryFileInfo *file) KZ_OVERRIDE |
Function for loading the resource from .KZB. More... | |
![]() | |
virtual | ~GPUResource () KZ_OVERRIDE |
void | deploy () |
Make graphics API object(s) in the resource usable by preparing GPU objects and data in them. More... | |
void | undeploy () |
Free the GPU objects. After this, the resource is not usable for graphics API until deploy() is called again. More... | |
void | invalidate () |
Notify resource that graphics context was lost and all GPU resources are invalid. More... | |
unsigned int | getGPUMemoryUsage () const |
Renderer * | getRenderer () const |
bool | getDeployOnLoad () const |
Returns true if GPUResource is automatically deployed when loaded. More... | |
void | setDeployOnLoad (bool value) |
Sets GPUResource automatic deployment on loade on or orr. More... | |
bool | isDeployed () const |
void | deployed () |
void | undeployed () |
virtual void | finishLoadingOverride (const KzuResourceLoaderThreadContext *threadContext) KZ_OVERRIDE |
Function for finishing the loading of the resource. More... | |
virtual void | unloadOverride () KZ_OVERRIDE |
Unload function for resource. More... | |
virtual unsigned int | getCPUMemoryUsage () const KZ_OVERRIDE |
Function for getting the memory usage of a resource. More... | |
![]() | |
KzcMemoryManager * | getMemoryManager () const |
Resource (Domain *domain, string_view name) | |
virtual | ~Resource () |
void | setKZB (const KzuBinaryDirectory *binaryDirectory, kzString path) |
void | setLoaded () |
kzString | getName () const |
Accessor. More... | |
void | load () |
void | unload () |
bool | isLoaded () const |
void | kzuResourceLoad_private (const KzuResourceLoaderThreadContext *threadContext) |
Private function for kzuResourceLoad() with specified thread context. More... | |
void | kzuResourceFinishLoading_private (const KzuResourceLoaderThreadContext *threadContext) |
Private function for finishing the loading of the resource. More... | |
KzuResourceLoadingStrategy | getLoadingStrategy () const |
void | setLoadingStrategy (KzuResourceLoadingStrategy loadingStrategy) |
bool | getKeepAlive () const |
Tells if the resource has keep alive flag set. More... | |
void | setKeepAlive (bool keepAlive) |
Sets the keep alive flag. More... | |
![]() | |
Object (Domain *domain) | |
virtual | ~Object () |
Domain * | getDomain () const |
Returns the domain the object belongs to. More... | |
KzuPropertyManager * | getPropertyManager () const |
Returns the property manager of the object. More... | |
KzuTaskScheduler * | getTaskScheduler () const |
Returns the task scheduler of the object. More... | |
KzuMessageDispatcher * | getMessageDispatcher () const |
Returns the message dispatcher of the object. More... | |
ResourceManager * | getResourceManager () const |
Returns the resource manager of the object. More... | |
virtual const Metaclass * | getDynamicMetaclass () const |
Returns the metaclass of the dynamic type of the object. More... | |
bool | isTypeOf (const Metaclass *objectType) const |
Determines if the type of this object is the given type or derived from it. More... | |
template<typename DataType > | |
void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::DataType value) |
Sets the local value of a property. More... | |
void | setProperty (const PropertyType< ResourceID > &propertyType, ResourceSharedPtr value) |
Sets the local value of a resource id property with a resource pointer. More... | |
template<typename DataType > | |
DataType | getProperty (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property. More... | |
template<typename DataType > | |
bool | getProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::DataType &value) const |
Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More... | |
template<typename DataType > | |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::DataType value) |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, ResourceSharedPtr value) |
template<typename DataType > | |
DataType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
bool | getAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::DataType &value) const |
bool | hasValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value. More... | |
bool | hasLocalValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a local value set for the property. More... | |
void | removeLocalValue (AbstractPropertyType propertyType) |
Removes the local value associated with the property. More... | |
void | copyLocalValues (const Object &other) |
Copies all local values from another object. More... | |
virtual void | onPropertyChanged (AbstractPropertyType propertyType, KzuPropertyNotificationReason reason) |
Virtual function to handle property change notifications. More... | |
AppliedStyleEntry * | applyObjectStyle (kanzi::StyleSharedPtr style) |
Applies a style to an object. More... | |
void | unapplyObjectStyle (AppliedStyleEntry *appliedStyleEntry) |
void | applyObjectStyles () |
Apply all styles for an object node. More... | |
void | unapplyObjectStyles () |
Unapplies and removes all applied styles. More... | |
Static Public Member Functions | |
static FramebufferSharedPtr | createEmpty (Domain *domain, string_view name="") |
Creates the framebuffer without specifying the shape. More... | |
static FramebufferSharedPtr | create (Domain *domain, unsigned int width, unsigned int height, bool depth, string_view name="") |
Creates the framebuffer of specified size and R8G8B8A8_UNORM color attachment to it and optionally a depth attachment. More... | |
![]() | |
static const Metaclass * | getStaticMetaclass () |
Returns the metaclass of Object class. More... | |
static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
Default implementation that returns empty editor info. More... | |
Protected Member Functions | |
virtual void | invalidateOverride () KZ_OVERRIDE |
Notify resource that graphics context was lost and all GPU resources are invalid. Called by invalidate() More... | |
virtual void | deployOverride () KZ_OVERRIDE |
Make graphics API object(s) in the resource usable by preparing GPU objects and data in them. Called by deploy() More... | |
virtual void | undeployOverride () KZ_OVERRIDE |
Free the GPU objects. After this, the resource is not usable for graphics API until deploy() is called again. Called by undeploy() More... | |
virtual void | freeCommonData () KZ_OVERRIDE |
Notify resource that graphics context was lost and all GPU resources are invalid. More... | |
![]() | |
GPUResource (Domain *domain, string_view name="") | |
virtual unsigned int | getGPUMemoryUsageOverride () const |
![]() | |
KzuResourceLoadState | getLoadState () |
Access. More... | |
![]() | |
void | initialize () |
void | onCopy (const Object &other) |
Additional Inherited Members | |
![]() | |
typedef vector < AppliedStyleEntry * > | AppliedStyleContainer |
Applied style container. More... | |
![]() | |
AppliedStyleContainer | m_appliedStyles |
Listing of applied styles applied to this object. More... | |
Framebuffer allows the rendering to the user-specified texture or renderbuffer, instead of rendering directly to the window.
Framebuffer must have at least one Surface (Texture or Renderbuffer) attached to it. Depth and stencil tests require that a Surface (typically Renderbuffer) is attached to the depth and stencil attachment point.
|
explicit |
|
virtual |
|
static |
Creates the framebuffer without specifying the shape.
You must configure the framebuffer with the configure() function, it needs one or more textures or renderbuffers to be attached to it, and you must deploy it before you can use it.
|
static |
Creates the framebuffer of specified size and R8G8B8A8_UNORM color attachment to it and optionally a depth attachment.
The framebuffer is deployed and ready to use.
domain | Domain for the graphics resource |
width | Width of the framebuffer |
height | Height of the framebuffer |
depth | When true, a D24_UNORM_S8_UINT depth and stencil renderbuffer are created and attached to the framebuffer. |
bool kanzi::Framebuffer::isRenderable | ( | unsigned int | face, |
unsigned int | mipLevel | ||
) | const |
void kanzi::Framebuffer::configure | ( | unsigned int | width, |
unsigned int | height, | ||
unsigned int | faceCount, | ||
unsigned int | sampleCount, | ||
unsigned int | mipLevelCount | ||
) |
Sets the common dimensions and sample count for the framebuffer.
These are used by new attachments created with the addTexture() and addRenderbuffer() functions.
width | Width of the framebuffer |
height | Height of the framebuffer |
faceCount | Number of faces. Must be 6 for cubemap framebuffers and 1 for all other framebuffers. |
mipLevelCount | Number of mipmap levels. Must be at least one. |
TextureSharedPtr kanzi::Framebuffer::addTexture | ( | Attachment | attachment, |
Texture::Target | target, | ||
GraphicsFormat | format, | ||
Sampler::Filter | minFilter, | ||
Sampler::Filter | magFilter, | ||
Sampler::MipmapMode | mipmapMode, | ||
Sampler::AddressingMode | address | ||
) |
Creates a texture and attaches it to the framebuffer.
Contents of the texture are not defined, it is expected that the texture is not sampled until framebuffer has been rendered to. The added texture is not deployed. It is expected that framebuffer is deployed after surfaces have been attached to it, and this will deploy all surfaces attached to it.
attachment | Attachment point for the texture. For OpenGL ES 2, use either Framebuffer::AttachmentColor0 or Framebuffer::AttachmentDepthStencil. |
target | Texture target. For OpenGL ES 2, use either Texture::TargetTwoDimensional or Texture::TargetCubeMap, and possibly Texture::TargetExternal if the required extension is supported. |
format | Format for the texture |
minFilter | Minification filter for the texture |
magFilter | Magnification filter for the texture |
mipmapMode | Mipmap mode for the texture. Texture will only get mipmap images if mipmap mode given here needs mipmap images. |
address | Addressing mode for the texture |
RenderbufferSharedPtr kanzi::Framebuffer::addRenderbuffer | ( | Attachment | attachment, |
GraphicsFormat | format | ||
) |
Adds a renderbuffer attachment to the framebuffer.
attachemnt | Attachment point for the renderbuffer. For OpenGL ES 2, use either Framebuffer::AttachmentColor0 or Framebuffer::AttachmentDepthStencil. |
format | Format for the renderbuffer. |
void kanzi::Framebuffer::setAttachment | ( | Attachment | attachment, |
SurfaceSharedPtr | surface | ||
) |
Sets the attachment for the framebuffer.
You can attach textures and renderbuffers to framebuffer. Note that not every GraphicsFormat can be rendered to, so not all textures be rendered to.
attachment | Attachment point for the surface. For OpenGL ES 2, use either Framebuffer::AttachmentColor0 or Framebuffer::AttachmentDepthStencil. |
surface | Surface to attach to the framebuffer (either Texture or Renderbuffer) |
SurfaceSharedPtr kanzi::Framebuffer::getAttachment | ( | Attachment | attachment | ) | const |
Returns the attachment from the framebuffer for the specified attachment point.
attachment | Attachment point to examine |
TextureSharedPtr kanzi::Framebuffer::getTexture | ( | Attachment | attachment | ) | const |
Returns the attachment as texture from the framebuffer.
attachment | Attachment point to query from the framebuffer. For OpenGL ES 2, either Framebuffer::AttachmentColor0 or Framebuffer::AttachmentDepthStencil. |
unsigned int kanzi::Framebuffer::getWidth | ( | ) | const |
Returns the common width of the framebuffer.
unsigned int kanzi::Framebuffer::getHeight | ( | ) | const |
Returns the common height of the framebuffer.
unsigned int kanzi::Framebuffer::getFaceCount | ( | ) | const |
Returns the face count of the framebuffer.
unsigned int kanzi::Framebuffer::getSampleCount | ( | ) | const |
Returns the common sample count of the framebuffer.
unsigned int kanzi::Framebuffer::getMipLevelCount | ( | ) | const |
Returns the number of mipmap levels in the framebuffer.
unsigned int kanzi::Framebuffer::getGLHandle | ( | unsigned int | face, |
unsigned int | mipLevel | ||
) | const |
Returns the GL API object handle for a specific (face, mipLevel) pair in the framebuffer.
face | Face for the query |
mipLevel | Mipmap level for the query |
void kanzi::Framebuffer::bind | ( | unsigned int | face, |
unsigned int | mipLevel | ||
) |
void kanzi::Framebuffer::unbind | ( | ) |
Unbinds the framebuffer. Rendering continues to the default framebuffer (window).
|
virtual |
Function for loading the resource from .KZB.
This function is called when loading the data from .KZB file. Implementations should call super class loadFromKZB before reading anything else from inputStream. This function is called from arbitrary loading threads. The parameter threadContext contains thread safe memory manager and a thread specific Property manager which can be locked with the threadLock in the threadContext. This function may not access resource manager or the UIDomain due to race conditions.
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Notify resource that graphics context was lost and all GPU resources are invalid. Called by invalidate()
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Make graphics API object(s) in the resource usable by preparing GPU objects and data in them. Called by deploy()
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Free the GPU objects. After this, the resource is not usable for graphics API until deploy() is called again. Called by undeploy()
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Notify resource that graphics context was lost and all GPU resources are invalid.
Reimplemented from kanzi::GPUResource.