Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes. More...
#include <kanzi/core.ui/platform/graphics_backend/gl/texture_create_info.hpp>
Public Member Functions | |
const Sampler & | getSampler () const |
Returns the Sampler used by the texture. More... | |
Type | getType () const |
Returns type of the texture. More... | |
void | reattachFramebuffer () |
Reattaches the internal framebuffer object. More... | |
void | reattachFramebuffer (RenderbufferSharedPtr colorRenderbuffer) |
Reattaches the internal framebuffer object and includes the renderbuffer given as parameter. More... | |
void | reattachFramebuffer (TextureSharedPtr depthTexture) |
Reattaches the internal framebuffer object and includes the depth texture given as parameter. More... | |
void | generateMipmaps () |
Generates the mipmaps from the base level image. More... | |
void | setData (Face face, unsigned int mipmapLevel, unsigned int x, unsigned int y, unsigned int width, unsigned int height, const kanzi::byte *data) |
Sets the texture data for the specified area in a texture. More... | |
void | setData (unsigned int mipmapLevel, unsigned int x, unsigned int y, unsigned int width, unsigned int height, const kanzi::byte *data) |
Sets the texture data for the specified area in the texture. More... | |
void | setData (const kanzi::byte *data) |
Sets the texture data for base level of a non-cubemap texture. More... | |
unsigned int | getNativeHandle () const |
Gets native texture handle for the texture. More... | |
unsigned int | getNativeFramebufferHandle () const |
Gets native framebuffer handle for the texture. More... | |
GraphicsFormat | getDepthStencilFormat () const |
Returns depthStencil format of the texture. More... | |
BitmapImageSharedPtr | getHostCopyImage (Face face, unsigned int slice) const |
Returns the host-side memory copy of texture data as an image, if available. More... | |
BitmapImageSharedPtr | getHostCopyImage () const |
Returns the host-side memory copy of a non-cubemap texture, if available. More... | |
RenderTargetMode | getRenderTargetMode () const |
Returns rendertarget mode of the texture. More... | |
void | resize (unsigned width, unsigned height) |
Changes the size of the texture. More... | |
bool | hasAutomaticWidth () const |
Tell if width is or should be automatically calculated. More... | |
bool | hasAutomaticHeight () const |
Tell if height is or should be automatically calculated. More... | |
unsigned int | getHeightDivisor () const |
Get height divisor for automatic sizes. More... | |
unsigned int | getWidthDivisor () const |
Get width divisor for automatic sizes. More... | |
CreateInfo () | |
Default constructor for texture create info. More... | |
Status | validate (const Renderer &renderer) const |
Perform validation of texture creation parameters. More... | |
Status | adjust (const Renderer &renderer, string_view name) |
Validates and applies adjustments to some texture creation parameters in case of avoidable error conditions. More... | |
void | updateShapeAndFormatFromImages () |
Use updateShapeAndFormatFromImages() to fill in format, width, height from images. More... | |
CreateInfo2D (BitmapImageUniquePtr image) | |
CreateInfo2D constructor for texture creation parameters, for creating a two dimensional texture that is initialized from an image. More... | |
CreateInfo2D (Sampler::MipmapMode mipmaps, BitmapImageUniquePtr image) | |
CreateInfo2D constructor that also takes in mipmap mode. More... | |
CreateInfo2D (unsigned int width, unsigned int height, GraphicsFormat format) | |
CreateInfo2D constructor for texture creation parameters, for creating a two dimensional texture with specified format and size. More... | |
CreateInfoHostCopy2D (unsigned int width, unsigned int height, GraphicsFormat format) | |
Constructor for CreateInfoHostCopy2D. More... | |
CreateInfoNode2DRenderTarget (unsigned int width, unsigned int height, GraphicsFormat format) | |
Constructor for CreateInfoNode2DRenderTarget. More... | |
CreateInfoRenderpassRenderTarget (unsigned int width, unsigned int height, GraphicsFormat format) | |
Constructor for CreateInfoRenderpassRenderTarget - non-multisample version. More... | |
CreateInfoRenderpassRenderTarget (Renderer *renderer, unsigned int sampleCount, unsigned int width, unsigned int height, GraphicsFormat format) | |
Constructor for CreateInfoRenderpassRenderTarget - multisample version. More... | |
CreateInfoCubemap (BitmapImageVector images) | |
CreateInfoCubemap constructor for texture creation parameters, for creating a cube map texture that is initialized from six images. More... | |
CreateInfoCubemap (Sampler::MipmapMode mipmapMode, BitmapImageVector images) | |
CreateInfoCubemap constructor that also takes in mipmap mode. More... | |
Public Member Functions inherited from kanzi::Surface | |
void | attach (Usage usage, APIAttachment apiAttachment, Face face, unsigned int mipmapLevel) |
Attach surface to framebuffer. More... | |
GraphicsFormat | getFormat () const |
Get GraphicsFormat of Surface. More... | |
unsigned int | getFeatures () const |
Get features for Surface. More... | |
unsigned int | getRenderTargetSampleCount () const |
Get number of multisample samples for Surface. More... | |
unsigned int | getWidth () const |
Get width in pixels. More... | |
unsigned int | getHeight () const |
Get height in pixels. More... | |
unsigned int | getSliceCount () const |
Get number of slices. More... | |
unsigned int | getFaceCount () const |
Get number of faces. This should be six for cubemaps and one for everything else. More... | |
unsigned int | getMipmapLevelCount () const |
Get number of mipmap levels. More... | |
Public Member Functions inherited from kanzi::GPUResource | |
virtual | ~GPUResource () KZ_OVERRIDE |
void | invalidate () |
Notify resource that graphics context was lost and all GPU resources are invalid. More... | |
unsigned int | getGPUMemoryUsage () const |
Renderer * | getRenderer () const |
bool | isDeployed () const |
Public Member Functions inherited from kanzi::Resource | |
KzcMemoryManager * | getMemoryManager () const |
Resource (Domain *domain, string_view name) | |
virtual | ~Resource () |
virtual void | loadFromKZB (const ResourceLoaderThreadContext *threadContext, KzcInputStream *inputStream, const KzuBinaryFileInfo *file) |
Function for loading the resource from .KZB. More... | |
virtual void | unloadOverride () |
Unload function for resource. Releases all CPU memory taken by the resource except the resource loader. More... | |
virtual unsigned int | getCPUMemoryUsage () const |
Function for getting the memory usage of a resource. More... | |
void | setKZB (const KzuBinaryDirectory *binaryDirectory, string_view path) |
Set the binary directory and path of the resource. More... | |
const string & | getName () const |
Gets the resource name. More... | |
const string & | getUrl () const |
Gets the resource URL. More... | |
void | setUrl (string_view url) |
Sets the resource URL. More... | |
void | setNotLoaded () |
bool | isFromKZB () const |
void | reload () |
void | reloadFromKzb (KzcInputStream *inputStream, const KzuBinaryFileInfo *file) |
void | reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) |
void | reloadFromFile (string_view filePath) |
void | load () |
void | unload () |
bool | isLoaded () const |
void | kzuResourceLoad_private (const ResourceLoaderThreadContext *threadContext) |
Private function for kzuResourceLoad() with specified thread context. More... | |
void | kzuResourceFinishLoading_private (const ResourceLoaderThreadContext *threadContext) |
Private function for finishing the loading of the resource. More... | |
bool | isKeepAlive () const |
Tells if the resource has keep alive flag set. More... | |
void | setKeepAlive (bool keepAlive) |
Sets the keep alive flag. More... | |
Public Member Functions inherited from kanzi::Object | |
Object (Domain *domain) | |
virtual | ~Object () |
Domain * | getDomain () const |
Returns the domain the object belongs to. 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 KZ_OVERRIDE |
Returns the metaclass of the dynamic type of the object. More... | |
AppliedStyleEntrySharedPtr | applyObjectStyle (kanzi::StyleSharedPtr style) |
Applies a style to an object. More... | |
void | unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
void | applyObjectStyles () |
Apply all styles for an object node. More... | |
void | unapplyObjectStyles () |
Unapplies and removes all applied styles. More... | |
Public Member Functions inherited from kanzi::MetaObject | |
virtual | ~MetaObject () |
bool | isTypeOf (const Metaclass *objectType) const |
Determines if the type of this object is the given type or derived from it. More... | |
Public Member Functions inherited from kanzi::PropertyObject | |
PropertyObject () | |
virtual | ~PropertyObject () |
template<typename DataType > | |
void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
Sets the local value of a property. More... | |
void | removeKzbProperties () |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property. More... | |
template<typename DataType > | |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalProperty (const PropertyType< DataType > &propertyType) 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 > | |
PropertyType< DataType >::Traits::ReturnType | getPropertyBase (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property disregarding modifiers. More... | |
template<typename DataType > | |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const |
void | setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
bool | isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const |
void | clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
bool | hasValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value. More... | |
bool | hasBaseValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value, disregarding modifiers. More... | |
bool | hasLocalValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a local value set for the property. More... | |
bool | hasNonClassValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a value of any precedence higher than class default value set for the property. More... | |
void | removeLocalValue (AbstractPropertyType propertyType) |
Removes the local value associated with the property. More... | |
void | copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType) |
Copies local value of single property from another object. More... | |
void | copyLocalValues (const PropertyObject &other) |
Copies all local values from another object. More... | |
virtual void | onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) |
Virtual function to handle property change notifications. More... | |
template<typename DataType > | |
void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *owner) |
template<typename DataType > | |
void | removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *owner) |
template<typename DataType > | |
void | addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
template<typename DataType > | |
void | removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
void | validatePropertyModifiers (AbstractPropertyType propertyType) |
template<typename DataType > | |
void | addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
template<typename DataType > | |
void | removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
template<typename DataType > | |
size_t | getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) |
Gets number of current notification handlers for given property type. More... | |
Static Public Member Functions | |
static TextureSharedPtr | create (Domain *domain, const CreateInfo &createInfo, string_view name) |
Creates a texture with specified texture creation parameters. More... | |
static TextureSharedPtr | create (Domain *domain, Type type, int nativeHandle, bool takeOwnership, GraphicsFormat format, unsigned int mipmapLevelCount, unsigned int width, unsigned int height, string_view name) |
Creates texture from a pre-existing GL texture object. More... | |
static ResourceManager::LoadTaskSharedPtr | createLoadTask (string_view name, KzbFile *kzbFile, unique_ptr< ReadOnlyMemoryFile > file) |
static CreateInfo | createSubstitutePattern (const Renderer &renderer, Type type) |
Create a texture create info structure for a black 1x1 texture. More... | |
Static Public Member Functions inherited from kanzi::Object | |
static const Metaclass * | getStaticMetaclass () |
Returns the metaclass of Object class. More... | |
static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
Default implementation that returns empty editor info. More... | |
Static Public Member Functions inherited from kanzi::MetaObject | |
static const Metaclass * | getStaticMetaclass () |
Returns the metaclass of Object class. More... | |
static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
Default implementation that returns empty editor info. More... | |
Public Attributes | |
vector< BitmapImageSharedPtr > | images |
Images that are used to create the texture. More... | |
GraphicsFormat | format |
Format for texture. More... | |
GraphicsFormat | depthStencilFormat |
DepthStencil format. More... | |
unsigned int | features |
Required format features. More... | |
Type | type |
Texture type. More... | |
unsigned int | width |
Width for the base level of texture. More... | |
unsigned int | height |
Height for the base level of texture. More... | |
unsigned int | widthDivisor |
Automatic size determination divisor for width, 0 when not automatic. More... | |
unsigned int | heightDivisor |
Automatic size determination divisor for height, 0 when not automatic. More... | |
unsigned int | depth |
Reserved for future use. More... | |
unsigned int | renderTargetSampleCount |
Specifies number of samples for the draw renderbuffer when RenderTargetMode is RenderTargetModeExternal. More... | |
unsigned int | mipmapLevelCount |
Number of mipmap levels for the texture. More... | |
MemoryType | memoryType |
Memory type for the texture. More... | |
RenderTargetMode | renderTargetMode |
RenderTarget mode for the texture. More... | |
Sampler::MipmapMode | mipmapMode |
Mipmap mode for the texture. More... | |
Sampler::Filter | minificationFilter |
Texture magnification filter. More... | |
Sampler::Filter | magnificationFilter |
Texture minification filter. More... | |
Sampler::AddressingMode | addressingMode |
Texture addressing mode. More... | |
float | anisotropy |
Texture anisotropy. More... | |
GraphicsCompareFunction | depthCompareFunction |
Depth comparison function. More... | |
float | mipLodBias |
Reserved for future use. More... | |
float | minLod |
Reserved for future use. More... | |
float | maxLod |
Reserved for future use. More... | |
Static Protected Member Functions | |
static vector< BitmapImageSharedPtr > | makeHostCopyImages (const CreateInfo &createInfo) |
Helper function to allocate host images. More... | |
static GLTextureHandle | makeTexture (Renderer *renderer, const CreateInfo &createInfo) |
Helper function to create GL texture object. More... | |
static GLFramebufferHandle | makeFramebuffer (Renderer *renderer, const CreateInfo &createInfo) |
Helper function to create GL framebuffer object. More... | |
static GLRenderbufferHandle | makeRenderbufferHandle (Renderer *renderer, const CreateInfo &createInfo) |
Helper function to create GL renderbuffer object for color or depth/stencil buffer. More... | |
Friends | |
class | ResourceManager |
class | Texture |
void | swap (Texture &texture1, Texture &texture2) |
Additional Inherited Members | |
Protected Types inherited from kanzi::Object | |
typedef vector< AppliedStyleEntrySharedPtr > | AppliedStyleContainer |
Applied style container. More... | |
Protected Attributes inherited from kanzi::Object | |
AppliedStyleContainer | m_appliedStyles |
Listing of applied styles applied to this object. More... | |
Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes.
Texture creation parameters for cubemap texture that is initialized from six images.
Texture creation parameters for texture that can be used as render target for renderpasses.
Texture creation parameters for texture that can be used as render target for 2D nodes.
Texture creation parameters for two dimensional texture that is updated from the CPU.
Texture creation parameters for two dimensional texture.
Struct which contains all the parameters that are needed for texture creation.
Textures can be set as render target. Texture can be set to as render target for either 2d node or render pass, but not both.
Texture can optionally maintain CPU accessible copy of texture data.
In order to create a texture, you must prepare Texture::CreateInfo structure and make sure it is valid using CreateInfo::validate(), then create the texture with Texture::create(). If texture creation parameters are not valid, Texture::create() will throw an exception, which can stop program execution.
Two dimensional textures can be created from Image or by specifying size, format and features. Cubemap textures can be created from six Images or by specifying size, format and features.
You must specify texture filtering, addressing mode (also known as wrap mode), and mipmap settings in Texture::CreateInfo before you create the texture. Two dimensional textures which are shown without scaling can be created with default texture creation parameters, which improve performance and reduce memory usage. If you show texture content with scaling, consider using linear filtering and prefiltered mipmaps to reduce aliasing, with some performance and memory cost.
To create a two dimensional texture from image:
To load image from file and create texture:
To access the image data after you create a texture:
To create a two dimensional texture from image with custom sampler settings:
To create a cubemap texture from 6 face images:
Examples - Loading textures with Kanzi C++ API using ResourceManager
To load texture with ResourceManager using file URL:
To load texture with ResourceManager:
To update texture data of two dimensional texture base level image:
To update texture data of cubemap texture all mipmap level images:
To use texture as render target for 2D node:
To use texture as render target for renderpass:
To create a two dimensional texture and render to it through framebuffer:
To create a two dimensional texture with mipmaps and render to it through framebuffer:
To create a cubemap texture with mipmaps and render to it through framebuffers:
You can use resulting texture as content in Image2D nodes or texture brushes, or in materials for 3D rendering or material brushes.
You can use CreateInfoHostCopy2D to initialize texture creation parameters for textures that you update from the CPU. Textures will be created with specified format and size, and texture will maintain CPU accessible copy of texture content. Use Texture::getHostCopyImage() to access copy of texture data. Use this kind of texture is when you update texture contents only from the CPU, and you nead read access to the texture data. For example glyph cache for font rendering is a plausible use case.
You can use the resulting texture as content in Image2D nodes or texture brushes. You can also use resulting texture in materials for 3D rendering or material brushes.
You can use the resulting texture as content in Image2D nodes or texture brushes. You can also use the resulting texture in materials for 3D rendering or material brushes.
Texture size, format and mipmap mode is determined from the images. You can use texture created with CreateInfoCubemap as content in materials for 3D rendering or material brushes.
enum kanzi::Texture::Type |
Texture type.
RenderTarget mode for Texture.
Rendering to a Texture may require extra resources (such as framebuffer when using OpenGL or OpenGL ES). RenderTargetMode specifies who manages these resources.
Enumerator | |
---|---|
RenderTargetModeNone |
When texture has rendertarget mode RenderTargetModeNone, that texture cannot be rendered to. You must not set such texture as render target for 2D nodes. You should not set such texture as render target for renderpasses. |
RenderTargetModeInternal |
RenderTargetModeInternal allows texture to be rendered to without externally managed resources. You can set such texture as render target for 2D nodes. You should not set such texture as render target for renderpasses.
|
RenderTargetModeExternal |
RenderTargetModeExternal allows texture to be rendered to with externally managed resources. You can set texture as render target for renderpasses. You must not set texture as render target for 2D nodes. When you create texture with renderTargetMode set to RenderTargetModeExternal, an external entity such as renderpass is responsible for creating necessary resources that are required to perform rendering to the texture. |
Status tells if texture creation parameters can be used to create a texture.
If status is not StatusValid, create info must not be passed to Texture::create().
Enumerator | |
---|---|
StatusInvalidType |
Invalid texture type. See Texture::Type for valid texture types. |
StatusTypeNotSupported |
Requested Texture type is not supported. |
StatusInvalidRenderTargetMode |
Requested rendertarget mode is not valid. |
StatusInvalidImageCount |
Wrong number of images. Two dimensional textures must have 0 or 1 image, cubemap textures must have 0 or 6 images. |
StatusMissingImages |
Not all images were properly defined. |
StatusImageMissingMipmaps |
Mipmaps are required, but the image is missing them. |
StatusInvalidImageSize |
Sizes of images are inconsistent. |
StatusInvalidMinimumSize |
Image size must be at least 1 x 1. |
StatusInvalidMaximumSize |
Image size cannot exceed size supported by the GL device. |
StatusInvalidMipmapSize |
Image mipmap size was not correctly derived from base image. |
StatusUnsupportedGraphicsFormat |
Unsupported image format. |
StatusUnsupportedTextureFilter |
Requested filtering mode is not supported for requested graphics format. |
StatusInvalidFeatures |
Requested graphics format features are not valid for texture. |
StatusUnsupportedMultisampleFilter |
Multisample textures do not support filtering. |
StatusUnsupportedMultisampleMipmaps |
Multisample textures do not support mipmaps. |
StatusUnsupportedMultisampleSamples |
Multisample textures must have a valid number of samples. |
StatusUnsupportedInternalRenderTargetSampleCount |
Textures with rendertarget mode set to RenderTargetModeInternal do not support multisampling. |
StatusUnsupportedSampleCount |
Requested number of multisample sample exceeds number of multisample samples supported by the graphics device. |
StatusImageFormatMismatch |
Inconsistent image formats. |
StatusImageIncompatibleWithDevice |
Image incompatible with target device. |
StatusUnsupportedDepthComparisonMode |
Requested depth comparison mode is not supported by graphics device. |
StatusValid |
CreateInfo is valid and can be used to create Texture. |
|
explicitprotected |
|
explicitprotected |
Creates texture from an existing GL object handle.
Caller must also provide texture format, and size. glHandle should be a valid GL texture object. Optionally, kanzi::Texture can take ownership of the provided GL texture object, in which case destroying kanzi::Texture will also destroy the GL texture object. If ownership is not passed to kanzi::Texture, then GL texture must be deleted after kanzi::Texture. Do not delete GL texture object while kanzi::Texture exists.
Domain | Domain for texture. |
type | Texture type. |
glHandle | Pre-existing valid GL texture object name. |
format | Format of the texture. |
mipmapLevelCount | Mipmap level count of the texture. |
width | Width of the texture. |
height | Height of the texture. |
takeOwnership | Should kanzi::Texture take ownership of provided GL texture object |
name | Name |
|
static |
Creates a texture with specified texture creation parameters.
In order to create a texture, you will need a CreateInfo structure that is filled with valid combination of texture creation parameters. You can use CreateInfo, CreateInfo2D, CreateInfoHostCopy2D, CreateInfoNode2DRenderTarget, CreateInfoRenderpassRenderTarget and CreateInfoCubemap constructors to create and initialize a texture creation parameter structure. After calling the constructor you can fine tune texture creation parameters.
You can check that parameters are valid by calling CreateInfo::validate().
If you pass CreateInfo that is not valid, Texture::create() will throw an exception and program execution may will terminate. To avoid exceptions for recoverable errors, use Renderer::adjust() on the create info prior to calling this function.
If createInfo memory type includes Gpu, texture will be deployed.
If createInfo memory type includes Ram, host copy of texture data will be made accessible. Otherwise, texture host copy will not be accessible.
domain | Domain for the texture. |
createInfo | Texture creation parameters. |
name | Name for the texture. |
|
static |
Creates texture from a pre-existing GL texture object.
Optionally, kanzi::Texture can take ownership of the provided GL texture object, in which case destroying kanzi::Texture will also destroy the GL texture object. If ownership is not passed to kanzi::Texture, then GL texture must be deleted after kanzi::Texture. Do not delete GL texture object while kanzi::Texture exists.
domain | Domain. |
type | Texture type. |
nativeHandle | Pre-existing native handle that identifies a valid GL texture object. |
takeOwnership | If true, texture will take ownership of the native resource (GL texture object). |
format | Format of the texture. |
mipmapLevelCount | Number of mipmap levels in the texture. |
width | Width of the texture. |
height | Height of the texture. |
name | Name. |
Type kanzi::Texture::getType | ( | ) | const |
Returns type of the texture.
void kanzi::Texture::reattachFramebuffer | ( | ) |
Reattaches the internal framebuffer object.
Only renderbuffers and the color texture within the texture object will be used.
void kanzi::Texture::reattachFramebuffer | ( | RenderbufferSharedPtr | colorRenderbuffer | ) |
Reattaches the internal framebuffer object and includes the renderbuffer given as parameter.
The texture does not take ownership of the renderbuffer. The texture must not have an internal color texture.
colorRenderbuffer | Renderbuffer to use as the color target in the framebuffer. |
void kanzi::Texture::reattachFramebuffer | ( | TextureSharedPtr | depthTexture | ) |
Reattaches the internal framebuffer object and includes the depth texture given as parameter.
The texture does not take ownership of the depth texture. The texture must not have an internal depth render buffer.
depthTexture | Depth texture to use as the depth target in the framebuffer. |
void kanzi::Texture::generateMipmaps | ( | ) |
Generates the mipmaps from the base level image.
This reads from Gpu texture data from the base level images, and only updates Gpu texture data of the remaining mipmap images. If texture has host copy data, it remains unchanged.
void kanzi::Texture::setData | ( | Face | face, |
unsigned int | mipmapLevel, | ||
unsigned int | x, | ||
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height, | ||
const kanzi::byte * | data | ||
) |
Sets the texture data for the specified area in a texture.
The texture data is updated to the GPU memory, and to the CPU accessible copy of the texture, if the texture is created with such storage.
face | Which texture face to update. |
mipmapLevel | Which mipmap level to update. |
x,y,width,height | Specifies the rectangle to update. |
data | Texture data. |
void kanzi::Texture::setData | ( | unsigned int | mipmapLevel, |
unsigned int | x, | ||
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height, | ||
const kanzi::byte * | data | ||
) |
Sets the texture data for the specified area in the texture.
The texture data is updated to the GPU memory, and to the CPU accessible copy of the texture, if the texture is created with such storage.
mipmapLevel | Which mip level to update. |
x,y,width,height | Specifies the rectangle to update. |
data | Texture data. |
void kanzi::Texture::setData | ( | const kanzi::byte * | data | ) |
Sets the texture data for base level of a non-cubemap texture.
data | Texture data. |
unsigned int kanzi::Texture::getNativeHandle | ( | ) | const |
Gets native texture handle for the texture.
unsigned int kanzi::Texture::getNativeFramebufferHandle | ( | ) | const |
Gets native framebuffer handle for the texture.
GraphicsFormat kanzi::Texture::getDepthStencilFormat | ( | ) | const |
Returns depthStencil format of the texture.
BitmapImageSharedPtr kanzi::Texture::getHostCopyImage | ( | Face | face, |
unsigned int | slice | ||
) | const |
Returns the host-side memory copy of texture data as an image, if available.
Returns as an image the copy of the host-side memory of the texture data, but does not create a copy of that image. Use this function only to retrieve data that was sent to the GPU from the CPU memory. To retrieve data rendered to a texture by the GPU use kzcScreenCaptureToImage().
face | The texture face for which you want to get the data. For single textures, this value is FaceDefault. For cube-map textures use a valid face for the texture. For example, FacePositiveX, or FaceNegativeZ. If you try to access an invalid texture face, the function throws an exception. |
slice | The texture slice for which you want to get the data. Slice applies to array and 3D textures. Currently this parameter must always be 0. If you access an invalid texture slice, the function throws an exception. |
BitmapImageSharedPtr kanzi::Texture::getHostCopyImage | ( | ) | const |
Returns the host-side memory copy of a non-cubemap texture, if available.
Returns as an image the copy of the host-side memory of the default face of a single texture data, but it does not create a copy of that image.
|
inline |
void kanzi::Texture::resize | ( | unsigned | width, |
unsigned | height | ||
) |
Changes the size of the texture.
Texture contents are undefined after resizing, user should assume they are destroyed. Specifying size identical to current size will cause resizing not to happen.
NOTE: Internal API and subject to change or removal.
width | New width. |
height | New height. |
|
inline |
Tell if width is or should be automatically calculated.
|
inline |
Tell if height is or should be automatically calculated.
|
inline |
Get height divisor for automatic sizes.
|
inline |
Get width divisor for automatic sizes.
|
static |
|
protectedvirtual |
Resource::reloadOverride() implementation.
Reimplemented from kanzi::Resource.
|
protectedvirtual |
Resource::reloadFromKzbOverride() implementation.
Reimplemented from kanzi::Resource.
|
protectedvirtual |
Resource::reloadFromKzbOverride() implementation.
Reimplemented from kanzi::Resource.
|
protectedvirtual |
Resource::reloadFromFileOverride() implementation.
Reimplemented from kanzi::Resource.
|
protectedvirtual |
Resource::getCPUMemoryUsageOverride() implementation.
Reimplemented from kanzi::Resource.
|
protected |
Validates the CreateInfo texture descriptor, creates a new texture and swaps it in place.
createInfo | The texture descriptor. |
|
protectedvirtual |
GPUResource::invalidateOverride() implementation.
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
GpuResource::isDeployed() implementation.
Implements kanzi::GPUResource.
|
protectedvirtual |
GpuResource::getGPUMemoryUsageOverride() implementation.
Reimplemented from kanzi::GPUResource.
|
protectedvirtual |
Surface::attachOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getFormatOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getFeaturesOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getRenderTargetSampleCountOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getWidthOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getHeightOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getSliceCountOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getFaceCountOverride() implementation.
Implements kanzi::Surface.
|
protectedvirtual |
Surface::getMipmapLevelCountOverride() implementation.
Implements kanzi::Surface.
|
staticprotected |
Helper function to allocate host images.
There are three cases:
createInfo | Texture create info. |
|
staticprotected |
|
staticprotected |
Helper function to create GL framebuffer object.
Only dummy handle will be created if create info specifies RamOnly texture, or if texture rendertarget mode is not RenderTargetModeInternal.
|
staticprotected |
Helper function to create GL renderbuffer object for color or depth/stencil buffer.
Only dummy handle will be created if create info specifies RamOnly texture, or if texture rendertarget mode is not RenderTargetModeInternal.
|
protected |
|
protected |
Helper function to setup GL framebuffer and renderbuffer state Called as part of texture construction.
Texture internal variables must already be initialized.
renderer | Renderer. |
colorRenderbuffer | Color renderbuffer not owned by the texture to attach. |
depthTexture | Depth texture not owned by this texture to attach. |
|
explicit |
Default constructor for texture create info.
After the CreateInfo constructor:
If you use this constructor, then you must fill in at least type, format, width and height before CreateInfo can be used to create texture.
Perform validation of texture creation parameters.
You can call validate() to see if texture creation parameters are valid before you pass create info to Texture::create().
renderer | Renderer to validate with. |
Validates and applies adjustments to some texture creation parameters in case of avoidable error conditions.
Some error conditions cause adjustments instead of resulting in an error. These include:
renderer | Renderer to validate with. |
name | A name to be used for this texture in possible warning log messages. |
|
static |
Create a texture create info structure for a black 1x1 texture.
renderer | Renderer to use for feature queries. |
textureType | The type of the texture. |
void kanzi::Texture::updateShapeAndFormatFromImages | ( | ) |
Use updateShapeAndFormatFromImages() to fill in format, width, height from images.
Those parameters must match images in order for Texture::create() to accept CreateInfo.
Validates texture format and features.
renderer | Renderer to validate with. |
Validates texture size against minimum valid texture size (1x1) and maximum supported by graphics adapter.
renderer | Renderer to validate with. |
Checks for known device incompatibilities, for example with texture formats and size.
renderer | Renderer to validate with. |
|
explicit |
CreateInfo2D constructor for texture creation parameters, for creating a two dimensional texture that is initialized from an image.
After the CreateInfo2D constructor:
The following (from CreateInfo constructor) also applies:
image | Source image for texture. |
|
explicit |
CreateInfo2D constructor that also takes in mipmap mode.
For details, see #CreateInfo(ImageUniquePtr)
mipmaps | Mipmap mode. |
|
explicit |
CreateInfo2D constructor for texture creation parameters, for creating a two dimensional texture with specified format and size.
After the CreateInfo2D constructor:
The following (from CreateInfo constructor) also applies:
width | Width for the texture |
height | Height for the texture |
format | Format for the texture |
|
explicit |
Constructor for CreateInfoHostCopy2D.
After the CreateInfoHostCopy2D constructor:
The following (from CreateInfo2D constructor) also applies:
The following (from CreateInfo constructor) also applies:
width | Width for the texture |
height | Height for the texture |
format | Format for the texture |
|
explicit |
Constructor for CreateInfoNode2DRenderTarget.
After the CreateInfoNode2DRenderTarget constructor:
The following (from CreateInfo2D constructor) also applies:
The following (from CreateInfo constructor) also applies:
When you create texture from CreateInfoNode2DRenderTarget, texture contents are initially undefined. Set texture as rendertarget for a node, and arrange node to be rendered before using the texture as content.
width | Width for the texture. |
height | Height for the texture. |
format | Format for the texture. |
|
explicit |
Constructor for CreateInfoRenderpassRenderTarget - non-multisample version.
After the CreateInfoRenderpassRenderTarget constructor:
The following (from CreateInfo2D constructor) also applies:
The following (from CreateInfo constructor) also applies:
When you create texture from CreateInfoRenderpassRenderTarget, texture contents are initially undefined. Set texture as rendertarget for a renderpass, and arrange viewport node to be rendered with the renderpass before using the texture as content.
width | Width for the texture. |
height | Height for the texture. |
format | Format for the texture. |
|
explicit |
Constructor for CreateInfoRenderpassRenderTarget - multisample version.
Use this CreateInfoRenderpassRenderTarget to create a texture which can be used in renderpasses with multisample anti aliasing.
After the CreateInfoRenderpassRenderTarget constructor:
The following (from CreateInfo2D constructor) also applies:
The following (from CreateInfo constructor) also applies:
When you create texture from CreateInfoRenderpassRenderTarget, texture contents are initially undefined. Set texture as rendertarget for a renderpass, and arrange a viewport node to be rendered with the renderpass before using the texture as content.
|
explicit |
CreateInfoCubemap constructor for texture creation parameters, for creating a cube map texture that is initialized from six images.
After the CreateInfoCubemap constructor:
The following (from CreateInfo constructor) also applies:
images | Source images. There must be six images in the vector. |
|
explicit |
CreateInfoCubemap constructor that also takes in mipmap mode.
For details, see #CreateInfoCubemap(ImageVector)
mipmaps | Mipmap mode. |
|
friend |
|
friend |
vector<BitmapImageSharedPtr> kanzi::Texture::images |
Images that are used to create the texture.
If you set texture type to two dimensional, images must contain zero or one image. If you set texture type to cube map, images must contain zero or six images.
Default CreateInfo constructor initializes this to empty.
GraphicsFormat kanzi::Texture::format |
Format for texture.
Default CreateInfo constructor initializes this to GraphicsFormatNone, which is not valid value for Texture::create().
GraphicsFormat kanzi::Texture::depthStencilFormat |
DepthStencil format.
This is only used when you set renderTargetMode to RenderTargetModeInternal.
Default CreateInfo constructor initializes this to GraphicsFormatNone, meaning there will be no depth/stencil for native framebuffer that is created if you set renderTargetMode to RenderTargetModeInternal.
unsigned int kanzi::Texture::features |
Required format features.
Default CreateInfo constructor initializes this to GraphicsFormatFeatureSampledImage.
Type kanzi::Texture::type |
Texture type.
Default CreateInfo constructor initializes this to TypeInvalid, which is not valid value for Texture::create().
unsigned int kanzi::Texture::width |
Width for the base level of texture.
Default CreateInfo constructor initializes this to 0, which is not valid value for Texture::create().
unsigned int kanzi::Texture::height |
Height for the base level of texture.
Default CreateInfo constructor initializes this to 0, which is not valid value for Texture::create().
unsigned int kanzi::Texture::widthDivisor |
Automatic size determination divisor for width, 0 when not automatic.
Default CreateInfo constructor initializes this to 0.
unsigned int kanzi::Texture::heightDivisor |
Automatic size determination divisor for height, 0 when not automatic.
Default CreateInfo constructor initializes this to 0.
unsigned int kanzi::Texture::depth |
Reserved for future use.
Set to 1.
Depth for the base level of texture.
Default CreateInfo constructor initializes this to 1.
unsigned int kanzi::Texture::renderTargetSampleCount |
Specifies number of samples for the draw renderbuffer when RenderTargetMode is RenderTargetModeExternal.
Default CreateInfo constructor initializes this to 0, meaning no multisample samples.
unsigned int kanzi::Texture::mipmapLevelCount |
Number of mipmap levels for the texture.
Default CreateInfo constructor initializes this to 1, meaning there is only base level image and no mipmap images.
MemoryType kanzi::Texture::memoryType |
Memory type for the texture.
If Gpu is not included, texture will not be deployed when created.
If Ram is not included, texture will not contain images after it has been deployed.
Default CreateInfo constructor initializes this to GpuOnly.
RenderTargetMode kanzi::Texture::renderTargetMode |
RenderTarget mode for the texture.
Default CreateInfo constructor initializes this to RenderTargetModeNone.
Sampler::MipmapMode kanzi::Texture::mipmapMode |
Mipmap mode for the texture.
Default CreateInfo constructor initializes this to Sampler::MipmapModeBase.
Sampler::Filter kanzi::Texture::minificationFilter |
Texture magnification filter.
Default CreateInfo constructor initializes this to Sampler::FilterNearest.
Sampler::Filter kanzi::Texture::magnificationFilter |
Texture minification filter.
Default CreateInfo constructor initializes this to Sampler::FilterNearest.
Sampler::AddressingMode kanzi::Texture::addressingMode |
Texture addressing mode.
Default CreateInfo constructor initializes this to Sampler::AddressingModeClamp.
float kanzi::Texture::anisotropy |
Texture anisotropy.
Default CreateInfo constructor initializes this to 1.0 (no anisotropy).
GraphicsCompareFunction kanzi::Texture::depthCompareFunction |
Depth comparison function.
Default CreateInfo constructor initializes this to GraphicsCompareFunctionLessOrEqual.
float kanzi::Texture::mipLodBias |
Reserved for future use.
Set to 0.0f. Texture mipmap level of detail bias. Default CreateInfo constructor initializes this to 0.
float kanzi::Texture::minLod |
Reserved for future use.
Set to -1000.0f. Minimum texture level of detail. Default CreateInfo constructor initializes this to -1000.0f (effectively no clamping for level of detail).
float kanzi::Texture::maxLod |
Reserved for future use.
Maximum texture level of detail. Default CreateInfo constructor initializes this to 1000 (effectively no clamping for level of detail).