Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes.
More...
|
| void | connectToFramebufferColor (Framebuffer &framebuffer, size_t attachmentIndex) |
| | Connects the texture into color attachment of a framebuffer.
|
| |
| void | connectToFramebufferDepthStencil (Framebuffer &framebuffer) |
| | Connects the texture into a depth attachments of a framebuffer.
|
| |
| void | connectToFramebufferResolveColor (Framebuffer &framebuffer, size_t attachmentIndex) |
| | Connects the texture into color resolve attachment of a framebuffer.
|
| |
| void | connectToFramebufferResolveDepthStencil (Framebuffer &framebuffer) |
| | Connects the texture into a resolve depth attachments of a framebuffer.
|
| |
| void | generateMipmaps () const |
| | Generates the mipmaps from the base level image.
|
| |
| RenderbufferSharedPtr | getColorRenderbuffer () const |
| | Returns internal color renderbuffer used for rendering, if one exists.
|
| |
| Sampler::CreateInfo | getCurrentSamplerCreateInfo () const |
| | Gets the current sampler create information.
|
| |
| GraphicsFormat | getDepthStencilFormat () const |
| | Returns depth/stencil format of the texture.
|
| |
| RenderbufferSharedPtr | getDepthStencilRenderbuffer () const |
| | Returns internal depth/stencil renderbuffer used for rendering, if one exists.
|
| |
| Framebuffer * | getFramebuffer () const |
| | Gets the framebuffer used for rendering.
|
| |
| gfx::ImageHandleGuard | getHandle () const |
| | Gets Kanzi graphics image handle for the texture.
|
| |
| unsigned int | getHeightDivisor () const |
| | Gets height divisor for automatic sizes.
|
| |
| BitmapImageSharedPtr | getHostCopyImage () const |
| | Returns the host-side memory copy of a non-cubemap texture, if available.
|
| |
| BitmapImageSharedPtr | getHostCopyImage (Face face, size_t slice) const |
| | Returns the host-side memory copy of texture data as an image, if available.
|
| |
| NativeDeploymentTarget | getNativeDeploymentTarget () const |
| | Gets the native deployment target.
|
| |
| size_t | getOverrideSamplerCreateInfoCount () const |
| | Gets the number of overrides in the sampler create info stack.
|
| |
| const Sampler & | getSampler () const |
| | Returns the Sampler used by the texture.
|
| |
| gfx::SamplerHandleGuard | getSamplerHandle (Renderer &renderer) |
| | Gets the current sampler handle guard for the texture.
|
| |
| TextureType | getType () const |
| | Gets type of the texture.
|
| |
| gfx::ImageUsageFlag | getUsageFlags () const |
| | Returns texture usage flags.
|
| |
| unsigned int | getWidthDivisor () const |
| | Gets width divisor for automatic sizes.
|
| |
| bool | hasAutomaticHeight () const |
| | Indicates whether height is or should be automatically calculated.
|
| |
| bool | hasAutomaticWidth () const |
| | Indicates whether width is or should be automatically calculated.
|
| |
| bool | isRenderTargetTransient () const |
| | Indicates whether render target buffers are transient.
|
| |
| void | popOverrideSamplerCreateInfo () |
| | Pups the topmost sampler create info into the override stack.
|
| |
| void | pushOverrideSamplerCreateInfo (Sampler::CreateInfo createInfo) |
| | Pushes an overriding sampler create info into the override stack.
|
| |
| void | reattachFramebuffer () |
| | Reattaches the internal framebuffer object.
|
| |
| void | reattachFramebuffer (RenderbufferSharedPtr colorRenderbuffer) |
| | Reattaches the internal framebuffer object and includes the renderbuffer given as parameter.
|
| |
| void | reattachFramebuffer (TextureSharedPtr depthTexture) |
| | Reattaches the internal framebuffer object and includes the depth texture given as parameter.
|
| |
| void | recreate (CreateInfo &createInfo) |
| | Validates the CreateInfo texture descriptor, creates a new texture and swaps it in place.
|
| |
| void | resize (size_t width, size_t height) |
| | Changes the size of the texture.
|
| |
| void | resolveMSAA (Renderer &renderer) const |
| | Resolves the internal multisample anti-aliasing renderbuffer to a single sample texture, if necessary.
|
| |
| void | setData (const kanzi::byte *data) |
| | Sets the texture data for base level of a non-cubemap texture.
|
| |
| void | setData (Face face, size_t mipmapLevel, size_t x, size_t y, size_t width, size_t height, const kanzi::byte *data) |
| | Sets the texture data for the specified area in a texture.
|
| |
| void | setData (size_t mipmapLevel, size_t x, size_t y, size_t width, size_t height, const kanzi::byte *data) |
| | Sets the texture data for the specified area in the texture.
|
| |
| void | setHeightDivisor (unsigned int divisor) |
| | Sets the height divisor.
|
| |
| void | setWidthDivisor (unsigned int divisor) |
| | Sets the wight divisor.
|
| |
| size_t | getFaceCount () const |
| | Get number of faces. This should be six for cubemaps and one for everything else.
|
| |
| GraphicsFormat | getFormat () const |
| | Get GraphicsFormat of Surface.
|
| |
| size_t | getHeight () const |
| | Get height in pixels.
|
| |
| size_t | getMipmapLevelCount () const |
| | Get number of mipmap levels.
|
| |
| size_t | getRenderTargetSampleCount () const |
| | Get number of multisample samples for Surface.
|
| |
| size_t | getSliceCount () const |
| | Get number of slices.
|
| |
| size_t | getWidth () const |
| | Get width in pixels.
|
| |
| void | destroy () |
| | Destroys a GPU resource.
|
| |
| size_t | getGPUMemoryUsage () const |
| | Gets the amount of GPU memory used by the resource.
|
| |
| Renderer * | getRenderer () const |
| |
| void | invalidate () |
| | Notify resource that graphics context was lost and all GPU resources are invalid.
|
| |
| bool | isDeployed () const |
| |
| | ~GPUResource () override |
| |
| size_t | getCPUMemoryUsage () const |
| | Gets the amount of CPU memory used by the resource.
|
| |
| const string & | getName () const |
| | Gets the resource name.
|
| |
| const string & | getUrl () const |
| | Gets the resource URL.
|
| |
| bool | isKeepAlive () const |
| | Tells if the resource has keep alive flag set.
|
| |
| void | reload () |
| |
| void | reloadFromFile (string_view filePath) |
| |
| void | reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) |
| |
| void | setKeepAlive (bool keepAlive) |
| | Sets the keep alive flag.
|
| |
| void | setUrl (string_view url) |
| | Sets the resource URL.
|
| |
| | ~Resource () override |
| | Destructor.
|
| |
| AppliedStyleEntrySharedPtr | applyObjectStyle (kanzi::StyleSharedPtr style) |
| | Applies a style to an object.
|
| |
| void | applyObjectStyles () |
| | Apply all styles for an object node.
|
| |
| Domain * | getDomain () const |
| | Returns the domain the object belongs to.
|
| |
| const Metaclass * | getDynamicMetaclass () const override |
| | Returns the metaclass of the dynamic type of the object.
|
| |
| MainLoopScheduler * | getMainLoopScheduler () const |
| | Returns the MainLoopScheduler instance of the associated Domain.
|
| |
| detail::MessageDispatcher * | getMessageDispatcher () const |
| | Returns the message dispatcher of the object.
|
| |
| ResourceManager * | getResourceManager () const |
| | Returns the resource manager of the object.
|
| |
| ScriptingContextSharedPtr | getScriptingContext () const |
| | Gets the scripting context of the object.
|
| |
| | Object (Domain *domain) |
| |
| void | setScriptingContext (ScriptingContextSharedPtr context) |
| | Sets the scripting context of the object.
|
| |
| void | unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
| |
| void | unapplyObjectStyles () |
| | Unapplies and removes all applied styles.
|
| |
| | ~Object () override |
| |
| bool | isTypeOf (const Metaclass *objectType) const |
| | Determines if the type of this object is the given type or derived from it.
|
| |
| virtual | ~MetaObject () |
| |
| void | addDestroyCallback (PropertyObjectDestroyCallback cb) |
| | Adds a destroy callback that is called when the object is being destroyed.
|
| |
| void | addDestroyCallback (PropertyObjectDestroyCallback cb, const void *owner) |
| | Adds a destroy callback that is called when the object is being destroyed.
|
| |
| template<typename DataType > |
| void | addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| | Adds a property modifier.
|
| |
| template<typename DataType > |
| void | addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| | Adds a property modifier without notifying handlers.
|
| |
| template<typename DataType > |
| void | addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
| |
| template<typename DataType > |
| void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner) |
| |
| template<typename DataType > |
| void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer) |
| |
| PropertyStorageContainer::iterator | beginPropertyStorage () |
| | Returns the begin iterator to the internal property storage container.
|
| |
| PropertyStorageContainer::const_iterator | beginPropertyStorage () const |
| | Returns the begin iterator to the internal property storage container.
|
| |
| void | clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
| |
| void | copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType) |
| | Copies local value of single property from another object.
|
| |
| void | copyLocalValues (const PropertyObject &other) |
| | Copies all local values from another object.
|
| |
| PropertyStorageContainer::iterator | endPropertyStorage () |
| | Returns the end iterator to the internal property storage container.
|
| |
| PropertyStorageContainer::const_iterator | endPropertyStorage () const |
| | Returns the end iterator to the internal property storage container.
|
| |
| 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 |
| |
| 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.
|
| |
| template<typename DataType > |
| optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const |
| | Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value.
|
| |
| template<typename DataType > |
| PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
| | Returns the current value of a property type.
|
| |
| template<typename DataType > |
| PropertyType< DataType >::Traits::ReturnType | getPropertyBase (const PropertyType< DataType > &propertyType) const |
| | Returns the current value of a property disregarding modifiers.
|
| |
| template<typename DataType > |
| size_t | getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const |
| | Gets number of current notification handlers for given property type.
|
| |
| bool | hasBaseValue (AbstractPropertyType propertyType) const |
| | Evaluates whether there are any inputs into the property value, disregarding modifiers.
|
| |
| bool | hasLocalValue (AbstractPropertyType propertyType) const |
| | Evaluates whether there is a local value set for the property.
|
| |
| bool | hasNonClassValue (AbstractPropertyType propertyType) const |
| | Evaluates whether there is a value of any precedence higher than class default value set for the property.
|
| |
| bool | hasValue (AbstractPropertyType propertyType) const |
| | Evaluates whether there are any inputs into the property value.
|
| |
| bool | isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const |
| |
| virtual void | onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) |
| | Virtual function to handle property change notifications.
|
| |
| | PropertyObject () |
| |
| void | removeDestroyCallback (const void *owner) |
| | Removes the destroy callbacks that you added with the given owner.
|
| |
| void | removeKzbProperties () |
| | Remove all KZB properties.
|
| |
| void | removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties) |
| | Remove all KZB properties that are not included in a given set.
|
| |
| template<typename DataType > |
| void | removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer) |
| |
| void | removeLocalValue (AbstractPropertyType propertyType) |
| | Removes the local value associated with the property.
|
| |
| template<typename DataType > |
| void | removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| | Removes a property modifier.
|
| |
| template<typename DataType > |
| void | removePropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| | Removes a property modifier without notifying handlers.
|
| |
| template<typename DataType > |
| void | removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
| |
| template<typename DataType > |
| void | removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer) |
| |
| template<typename DataType > |
| void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
| |
| template<typename DataType > |
| void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
| | Sets the local value of a property type.
|
| |
| void | setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
| |
| void | validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType) |
| | Validates property modifiers and notifies handlers.
|
| |
| virtual | ~PropertyObject () |
| |
|
| void | createFramebuffers (Renderer &renderer) |
| | Create internal framebuffers.
|
| |
| void | destroyOverride () override |
| | GPUResource::destroyOverride() implementation.
|
| |
| CreateInfo | generateCreateInfo (bool includeImages) |
| | Generate a create info for the texture based on current properties.
|
| |
| size_t | getCPUMemoryUsageOverride () const override |
| | Resource::getCPUMemoryUsageOverride() implementation.
|
| |
| size_t | getFaceCountOverride () const override |
| | Surface::getFaceCountOverride() implementation.
|
| |
| GraphicsFormat | getFormatOverride () const override |
| | Surface::getFormatOverride() implementation.
|
| |
| size_t | getGPUMemoryUsageOverride () const override |
| | GpuResource::getGPUMemoryUsageOverride() implementation.
|
| |
| size_t | getHeightOverride () const override |
| | Surface::getHeightOverride() implementation.
|
| |
| size_t | getMipmapLevelCountOverride () const override |
| | Surface::getMipmapLevelCountOverride() implementation.
|
| |
| size_t | getRenderTargetSampleCountOverride () const override |
| | Surface::getRenderTargetSampleCountOverride() implementation.
|
| |
| size_t | getSliceCountOverride () const override |
| | Surface::getSliceCountOverride() implementation.
|
| |
| size_t | getWidthOverride () const override |
| | Surface::getWidthOverride() implementation.
|
| |
| void | initialize () |
| | Initialize the texture.
|
| |
| void | invalidateOverride () override |
| | GPUResource::invalidateOverride() implementation.
|
| |
| bool | isDeployedOverride () const override |
| | GpuResource::isDeployed() implementation.
|
| |
| void | reloadFromFileOverride (string_view filePath) override |
| | Resource::reloadFromFileOverride() implementation.
|
| |
| void | reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) override |
| | Resource::reloadFromKzbOverride() implementation.
|
| |
| void | reloadOverride () override |
| | Resource::reloadOverride() implementation.
|
| |
| bool | shouldBeDeployedDuringConstruction () const |
| | Checks if the texture is deployable during construction.
|
| |
| | Texture (Domain *domain, const CreateInfo &createInfo, string_view name) |
| | Creates texture from CreateInfo.
|
| |
| | Texture (Domain *domain, TextureType type, const gfx::NativeTextureHandle &nativeHandle, bool takeOwnership, GraphicsFormat format, unsigned int mipmapLevelCount, unsigned int width, unsigned int height, string_view name) |
| | Creates texture from an existing GL object handle.
|
| |
| | Surface (Domain *domain, string_view name) |
| | Constructor.
|
| |
| | GPUResource (Domain *domain, string_view name="") |
| | Constructor.
|
| |
| | Resource (Domain *domain, string_view name) |
| | Constructor.
|
| |
| void | initialize () |
| |
| void | onCopy (const Object &other) |
| |
| void | initialize () |
| |
| | MetaObject () |
| |
| AbstractPropertyTypeDescriptor::ValueSourceEntry * | acquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) |
| | Acquires a local value source entry that is free for the assignment of a value.
|
| |
| AbstractPropertyTypeDescriptor::ModifierStorage * | acquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) |
| |
| AbstractPropertyTypeDescriptor::NotificationStorage * | acquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) |
| |
| PropertyStoragePtr | acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor) |
| | Acquires a property storage.
|
| |
| template<typename DataType > |
| void | addPropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify) |
| | Adds a property modifier entry to the property modifier stack and validates the modifiers.
|
| |
| void | addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner) |
| | Internally adds a property value source.
|
| |
| void | addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer) |
| | Internally adds a property value source.
|
| |
| AbstractPropertyTypeDescriptor::ValueSourceEntry * | constructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) |
| | Constructs a new local value source entry.
|
| |
| void | copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage) |
| | Copy local value from property storage.
|
| |
| AbstractPropertyTypeDescriptor::ModifierStorage * | findModifierStorage (AbstractPropertyTypeDescriptor &descriptor) |
| |
| AbstractPropertyTypeDescriptor::NotificationStorage * | findNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) const |
| |
| AbstractPropertyTypeDescriptor::PropertyStorage * | findPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const |
| | Gets the property storage for given property type descriptor.
|
| |
| PropertyStoragePtr | findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const |
| | Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation.
|
| |
| AbstractPropertyTypeDescriptor * | findPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const |
| | Finds a property type descriptor by name and data type.
|
| |
| AbstractPropertyTypeDescriptor * | findPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const |
| | Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names.
|
| |
| AbstractPropertyTypeDescriptor * | findPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const |
| | Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names.
|
| |
| AbstractPropertyTypeDescriptor::ValueSource * | getClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const |
| |
| AbstractPropertyTypeDescriptor::ValueSource * | getFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const |
| |
| AbstractPropertyTypeDescriptor::ValueSource * | getNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const |
| |
| AbstractPropertyTypeDescriptor::ValueSource * | getTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const |
| | Gets the top-level value source for a given property descriptor.
|
| |
| virtual void | notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason) |
| | Notifies all property handlers on a property storage.
|
| |
| void | onCopy (const PropertyObject &other) |
| |
| void | removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage) |
| | Removes a local value from the given property storage.
|
| |
| template<typename DataType > |
| void | removePropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify) |
| | Removes a property modifier entry from the property modifier stack and validates the remaining modifiers.
|
| |
| void | removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner) |
| | Removes a property value source.
|
| |
| void | validatePropertyModifiers (AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) |
| | Validates property modifiers without notifying handlers.
|
| |
| void | validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage) |
| | Validates property modifiers and notifies handlers.
|
| |
Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes.
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.
For details on the render target texture, see CreateInfoRenderTarget.
Texture can optionally maintain CPU accessible copy of texture data. See CreateInfoHostCopy2D for CPU accessible texture data details.
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.
Examples - Creating Textures with Kanzi C++ API
To create a two dimensional texture from image:
TextureSharedPtr texture = Texture::create(domain, Texture::CreateInfo2D(kanzi::move(image)),
"Texture");
To load image from file and create texture:
To access the image data after you create a texture:
unique_ptr<uint8_t[]> sourceData(new uint8_t[512 * 512 * 4]);
for (unsigned it = 0; it < 512 * 512 * 4; it += 4)
{
sourceData[it + 0] = 255u;
sourceData[it + 1] = 0u;
sourceData[it + 2] = 0u;
sourceData[it + 3] = 255u;
}
BitmapImageUniquePtr image = BitmapImage::createFromMemory(512, 512, GraphicsFormatR8G8B8A8_UNORM,
reinterpret_cast<const byte*
>(sourceData.get()),
"image");
BitmapImage* imagePtr = image.get();
Texture::CreateInfo2D createInfo(kanzi::move(image));
createInfo.memoryType = GPUResource::GpuAndRam;
To create a two dimensional texture from image with custom sampler settings:
Texture::CreateInfo2D createInfo(kanzi::move(image));
createInfo.minificationFilter = Sampler::FilterLinear;
createInfo.magnificationFilter = Sampler::FilterLinear;
createInfo.mipmapMode = Sampler::MipmapModeLinear;
createInfo.updateShapeAndFormatFromImages();
To create a cubemap texture from 6 face images:
Texture::CreateInfoCubemap createInfo(kanzi::move(images));
createInfo.minificationFilter = Sampler::FilterLinear;
createInfo.magnificationFilter = Sampler::FilterLinear;
createInfo.mipmapMode = Sampler::MipmapModeLinear;
createInfo.updateShapeAndFormatFromImages();
Examples - Loading textures with Kanzi C++ API using ResourceManager
To load texture with ResourceManager using file URL:
To load texture with ResourceManager:
Examples - Updating texture data with Kanzi C++ API
To update texture data of two dimensional texture base level image:
unsigned int width = 512;
TextureSharedPtr texture = Texture::create(domain, Texture::CreateInfoHostCopy2D(width, height, GraphicsFormatR8G8B8A8_UNORM),
"Texture");
{
vector<byte> data = generateTextureData(width, height, 0);
texture->setData(data.data());
}
{
unsigned int updateWidth =
width / 2;
unsigned int updateHeight =
height / 2;
vector<byte> data = generateTextureData(updateWidth, updateHeight, 0);
unsigned int mipmapLevel = 0;
texture->setData(mipmapLevel, width - updateWidth, 0, updateWidth, updateHeight, data.data());
}
To update texture data of cubemap texture all mipmap level images:
Texture::CreateInfo createInfo;
createInfo.width = 512;
createInfo.height = 512;
createInfo.memoryType = Texture::GpuAndRam;
createInfo.mipmapMode = Sampler::MipmapModeLinear;
auto width = texture->getWidth();
auto height = texture->getHeight();
for (size_t mipmapLevel = 0; mipmapLevel < createInfo.mipmapLevelCount; ++mipmapLevel)
{
for (size_t faceIndex = 0; faceIndex < 6; ++faceIndex)
{
Surface::Face face = static_cast<Surface::Face>(faceIndex);
vector<byte> data = generateTextureData(width, height, faceIndex);
texture->setData(face, mipmapLevel, 0, 0, width, height, data.data());
}
}
Examples - Use texture as render target for node 2D or renderpass using Kanzi C++ API
To use texture as render target for 2D node:
screen->attach();
screen->addChild(node);
ColorBrushSharedPtr brush = ColorBrush::create(domain,
"brush", ColorRGBA(0.4f, 0.4f, 0.9f, 1.0f));
node->setBackgroundBrush(brush);
Texture::CreateInfoRenderTarget textureCreateInfo(width, height, GraphicsFormatR8G8B8A8_UNORM);
TextureSharedPtr renderTarget = Texture::create(domain, textureCreateInfo,
"texture");
node->setRenderTarget(renderTarget);
node->setOffscreenRendering(true);
{
CompositionStack& compositionStack = renderer->getCompositionStack();
screen->setAllocatedSize(Vector2(static_cast<float>(width), static_cast<float>(height)));
screen->setArrangeTransform(Matrix3x3());
screen->layout();
compositionStack.pushCompositionActiveGraphicsOutput(screen->getAllocatedSize());
screen->render(*renderer);
compositionStack.popComposition();
}
screen->detach();
To use texture as render target for renderpass:
screen->attach();
screen->addChild(viewport);
viewport->setScene(scene);
scene->addChild(camera);
scene->setCamera(camera);
Texture::CreateInfoRenderTarget textureCreateInfo(width, height, GraphicsFormatR8G8B8A8_UNORM);
TextureSharedPtr texture = Texture::create(domain, textureCreateInfo,
"Texture");
RenderPassTemplateSharedPtr clearTemplate = RenderPassTemplate::create(ClearRenderPass::getStaticMetaclass()->getName(),
"clear render pass");
ColorRGBA lightBlue(0.4f, 0.4f, 0.9f, 1.0f);
clearTemplate->addPropertyValue(ClearRenderPass::ClearColor0Property, Variant(lightBlue));
RenderPassTemplateSharedPtr drawTemplate = RenderPassTemplate::create(DrawObjectsRenderPass::getStaticMetaclass()->getName(),
"draw render pass");
RenderPassTemplateSharedPtr rootTemplate = RenderPassTemplate::create(CompositionTargetRenderPass::getStaticMetaclass()->getName(),
"composition render pass");
rootTemplate->addPropertyValue(CompositionTargetRenderPass::CompositionTarget0Property, Variant(static_pointer_cast<Resource>(texture)));
rootTemplate->addChild(clearTemplate);
rootTemplate->addChild(drawTemplate);
viewport->setRenderPassPrefab(rootPrefab);
{
CompositionStack& compositionStack = renderer->getCompositionStack();
screen->setAllocatedSize(Vector2(static_cast<float>(width), static_cast<float>(height)));
screen->setArrangeTransform(Matrix3x3());
screen->layout();
compositionStack.pushCompositionActiveGraphicsOutput(screen->getAllocatedSize());
screen->render(*renderer);
compositionStack.popComposition();
}
screen->detach();
Examples - Render to texture with framebuffer (OpenGL and OpenGL ES only) using Kanzi C++ API
To create a two dimensional texture and render to it through framebuffer:
Texture::CreateInfoRenderTarget textureCreateInfo(512, 512, GraphicsFormatR8G8B8A8_UNORM);
textureCreateInfo.minificationFilter = Sampler::FilterLinear;
textureCreateInfo.magnificationFilter = Sampler::FilterLinear;
textureCreateInfo.depthStencilFormat = renderer->getDepthStencilFormatForRenderbuffer(true, false);
TextureSharedPtr texture = Texture::create(domain, textureCreateInfo,
"Texture");
auto& compositionStack = renderer->getCompositionStack();
compositionStack.pushComposition(*texture);
renderer->setOrthographicProjection();
auto& commandRecorder = renderer->getCommandRecorder();
optional<ColorRGBA> clearColor = ColorRGBA(0.5f, 0.6f, 0.7f, 1.0f);
commandRecorder.clearFramebuffer(
asSpan(clearColor));
compositionStack.popComposition();
To create a two dimensional texture with mipmaps and render to it through framebuffer:
Texture::CreateInfoRenderTarget textureCreateInfo(512, 512, GraphicsFormatR8G8B8A8_UNORM);
textureCreateInfo.minificationFilter = Sampler::FilterLinear;
textureCreateInfo.magnificationFilter = Sampler::FilterNearest;
textureCreateInfo.mipmapMode = Sampler::MipmapModeLinear;
TextureSharedPtr texture = Texture::create(domain, textureCreateInfo,
"Texture");
auto& compositionStack = renderer->getCompositionStack();
compositionStack.pushComposition(*texture);
renderer->setOrthographicProjection();
auto& commandRecorder = renderer->getCommandRecorder();
optional<ColorRGBA> clearColor = ColorRGBA(0.5f, 0.6f, 0.7f, 1.0f);
commandRecorder.clearFramebuffer(
asSpan(clearColor));
compositionStack.popComposition();
texture->generateMipmaps();
To create a cubemap texture with mipmaps and render to it through framebuffers:
Texture::CreateInfo textureCreateInfo;
textureCreateInfo.width = 512;
textureCreateInfo.height = 512;
textureCreateInfo.usageFlags |= gfx::ImageUsageFlag::Attachment;
textureCreateInfo.minificationFilter = Sampler::FilterLinear;
textureCreateInfo.magnificationFilter = Sampler::FilterLinear;
textureCreateInfo.mipmapMode = Sampler::MipmapModeLinear;
TextureSharedPtr texture = Texture::create(domain, textureCreateInfo,
"Texture");
auto& compositionStack = renderer->getCompositionStack();
array<FramebufferPtr, 6u> faceFramebuffers;
for (unsigned int faceIndex = 0; faceIndex < 6; ++faceIndex)
{
faceFramebuffers[faceIndex] = Framebuffer::create(
"face " +
to_string(faceIndex));
auto& framebuffer = *(faceFramebuffers[faceIndex]);
framebuffer.setColorAttachment(0u, texture, faceIndex);
framebuffer.update(*renderer);
compositionStack.pushComposition(
framebuffer,
Vector2(static_cast<float>(texture->getWidth()), static_cast<float>(texture->getHeight())));
renderer->setOrthographicProjection();
float relativeFace = static_cast<float>(faceIndex) / 5.0f;
auto& commandRecorder = renderer->getCommandRecorder();
optional<ColorRGBA> clearColor = ColorRGBA(relativeFace, relativeFace, relativeFace, 1.0f);
commandRecorder.clearFramebuffer(
asSpan(clearColor));
compositionStack.popComposition();
}
texture->generateMipmaps();
- Since
- Kanzi 4.0.0
- Removed the deployInternalFramebuffers, getNativeFramebufferHandle, getNativeHandle, getRenderTargetMode, makeTexture and makeTextureHandle functions.
- Removed the m_attachedColorRenderbuffer, m_attachedDepthTexture, m_depthStencilRenderbuffer, m_features, m_framebufferHandle, m_msaaRenderbuffer, m_renderTargetMode and m_resolveFramebufferHandle fields.