Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes.
More...
|
void | generateMipmaps () |
| Generates the mipmaps from the base level image. More...
|
|
GraphicsFormat | getDepthStencilFormat () const |
| Returns depth/stencil format of the texture. More...
|
|
RenderbufferSharedPtr | getDepthStencilRenderbuffer () const |
| Returns internal depth/stencil renderbuffer. More...
|
|
unsigned int | getHeightDivisor () const |
| Gets height divisor for automatic sizes. 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...
|
|
NativeDeploymentTarget | getNativeDeploymentTarget () const |
| Returns the native deployment target. More...
|
|
NativeFramebufferHandle | getNativeFramebufferHandle () const |
| Gets native framebuffer handle for the texture. More...
|
|
NativeTextureHandle | getNativeHandle () const |
| Gets native texture handle for the texture. More...
|
|
RenderTargetMode | getRenderTargetMode () const |
| Returns rendertarget mode of the texture. More...
|
|
const Sampler & | getSampler () const |
| Returns the Sampler used by the texture. More...
|
|
TextureType | getType () const |
| Returns type of the texture. More...
|
|
unsigned int | getWidthDivisor () const |
| Gets width divisor for automatic sizes. More...
|
|
bool | hasAutomaticHeight () const |
| Indicates whether height is or should be automatically calculated. More...
|
|
bool | hasAutomaticWidth () const |
| Indicates whether width is or should be automatically calculated. 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 | recreate (CreateInfo &createInfo) |
| Validates the CreateInfo texture descriptor, creates a new texture and swaps it in place. More...
|
|
void | resize (unsigned width, unsigned height) |
| Changes the size of the texture. 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...
|
|
void | setHeightDivisor (unsigned int divisor) |
| Sets the height divisor. More...
|
|
void | setWidthDivisor (unsigned int divisor) |
| Sets the wight divisor. More...
|
|
void | attach (Usage usage, APIAttachment apiAttachment, Face face, unsigned int mipmapLevel) |
| Attach surface to framebuffer. More...
|
|
unsigned int | getFaceCount () const |
| Get number of faces. This should be six for cubemaps and one for everything else. More...
|
|
unsigned int | getFeatures () const |
| Get features for Surface. More...
|
|
GraphicsFormat | getFormat () const |
| Get GraphicsFormat of Surface. More...
|
|
unsigned int | getHeight () const |
| Get height in pixels. More...
|
|
unsigned int | getMipmapLevelCount () const |
| Get number of mipmap levels. More...
|
|
unsigned int | getRenderTargetSampleCount () const |
| Get number of multisample samples for Surface. More...
|
|
unsigned int | getSliceCount () const |
| Get number of slices. More...
|
|
unsigned int | getWidth () const |
| Get width in pixels. More...
|
|
unsigned int | getGPUMemoryUsage () const |
|
Renderer * | getRenderer () const |
|
void | invalidate () |
| Notify resource that graphics context was lost and all GPU resources are invalid. More...
|
|
bool | isDeployed () const |
|
| ~GPUResource () override |
|
virtual unsigned int | getCPUMemoryUsage () const |
| Function for getting the memory usage of a resource. More...
|
|
const string & | getName () const |
| Gets the resource name. More...
|
|
const string & | getUrl () const |
| Gets the resource URL. More...
|
|
bool | isKeepAlive () const |
| Tells if the resource has keep alive flag set. More...
|
|
void | reload () |
|
void | reloadFromFile (string_view filePath) |
|
void | reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) |
|
void | setKeepAlive (bool keepAlive) |
| Sets the keep alive flag. More...
|
|
void | setUrl (string_view url) |
| Sets the resource URL. More...
|
|
| ~Resource () override |
| Destructor. More...
|
|
AppliedStyleEntrySharedPtr | applyObjectStyle (kanzi::StyleSharedPtr style) |
| Applies a style to an object. More...
|
|
void | applyObjectStyles () |
| Apply all styles for an object node. More...
|
|
Domain * | getDomain () const |
| Returns the domain the object belongs to. More...
|
|
const Metaclass * | getDynamicMetaclass () const override |
| Returns the metaclass of the dynamic type of the object. More...
|
|
MainLoopScheduler * | getMainLoopScheduler () const |
| Returns the MainLoopScheduler instance of the associated Domain. More...
|
|
detail::MessageDispatcher * | getMessageDispatcher () const |
| Returns the message dispatcher of the object. More...
|
|
ResourceManager * | getResourceManager () const |
| Returns the resource manager of the object. More...
|
|
ScriptingContextSharedPtr | getScriptingContext () const |
| Gets the scripting context of the object. More...
|
|
| Object (Domain *domain) |
|
void | setScriptingContext (ScriptingContextSharedPtr context) |
| Sets the scripting context of the object. More...
|
|
void | unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
|
void | unapplyObjectStyles () |
| Unapplies and removes all applied styles. More...
|
|
| ~Object () override |
|
bool | isTypeOf (const Metaclass *objectType) const |
| Determines if the type of this object is the given type or derived from it. More...
|
|
virtual | ~MetaObject () |
|
template<typename DataType > |
void | addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
|
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, void *ownerPointer) |
|
template<typename DataType > |
void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner) |
|
PropertyStorageContainer::iterator | beginPropertyStorage () |
| Returns the begin iterator to the internal property storage container. More...
|
|
PropertyStorageContainer::const_iterator | beginPropertyStorage () const |
| Returns the begin iterator to the internal property storage container. More...
|
|
void | clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
|
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...
|
|
PropertyStorageContainer::iterator | endPropertyStorage () |
| Returns the end iterator to the internal property storage container. More...
|
|
PropertyStorageContainer::const_iterator | endPropertyStorage () const |
| Returns the end iterator to the internal property storage container. More...
|
|
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. More...
|
|
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. More...
|
|
template<typename DataType > |
PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property type. 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 > |
size_t | getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const |
| Gets number of current notification handlers for given property type. 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...
|
|
bool | hasValue (AbstractPropertyType propertyType) const |
| Evaluates whether there are any inputs into the property value. More...
|
|
bool | isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const |
|
virtual void | onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) |
| Virtual function to handle property change notifications. More...
|
|
| PropertyObject () |
|
void | removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties) |
| Remove all KZB properties that are not included in a given set. More...
|
|
void | removeKzbProperties () |
| Remove all KZB properties. More...
|
|
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. More...
|
|
template<typename DataType > |
void | removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
|
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. More...
|
|
void | setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
|
void | validatePropertyModifiers (AbstractPropertyType propertyType) |
|
virtual | ~PropertyObject () |
|
|
void | attachOverride (Usage usage, APIAttachment apiAttachment, Face face, unsigned int mipmapLevel) override |
| Surface::attachOverride() implementation. More...
|
|
void | deployImages (Renderer &renderer, const vector< BitmapImageSharedPtr > &images) |
| Helper function to setup GL texture object state and initial data. More...
|
|
void | deployInternalFramebuffers (Renderer &renderer, RenderbufferSharedPtr colorRenderbuffer, TextureSharedPtr depthTexture) |
| Helper function to setup GL framebuffer and renderbuffer state Called as part of texture construction. More...
|
|
unsigned int | getCPUMemoryUsageOverride () const override |
| Resource::getCPUMemoryUsageOverride() implementation. More...
|
|
unsigned int | getFaceCountOverride () const override |
| Surface::getFaceCountOverride() implementation. More...
|
|
unsigned int | getFeaturesOverride () const override |
| Surface::getFeaturesOverride() implementation. More...
|
|
GraphicsFormat | getFormatOverride () const override |
| Surface::getFormatOverride() implementation. More...
|
|
unsigned int | getGPUMemoryUsageOverride () const override |
| GpuResource::getGPUMemoryUsageOverride() implementation. More...
|
|
unsigned int | getHeightOverride () const override |
| Surface::getHeightOverride() implementation. More...
|
|
unsigned int | getMipmapLevelCountOverride () const override |
| Surface::getMipmapLevelCountOverride() implementation. More...
|
|
unsigned int | getRenderTargetSampleCountOverride () const override |
| Surface::getRenderTargetSampleCountOverride() implementation. More...
|
|
unsigned int | getSliceCountOverride () const override |
| Surface::getSliceCountOverride() implementation. More...
|
|
unsigned int | getWidthOverride () const override |
| Surface::getWidthOverride() implementation. More...
|
|
void | invalidateOverride () override |
| GPUResource::invalidateOverride() implementation. More...
|
|
bool | isDeployedOverride () const override |
| GpuResource::isDeployed() implementation. More...
|
|
void | reloadFromFileOverride (string_view filePath) override |
| Resource::reloadFromFileOverride() implementation. More...
|
|
void | reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) override |
| Resource::reloadFromKzbOverride() implementation. More...
|
|
void | reloadOverride () override |
| Resource::reloadOverride() implementation. More...
|
|
| Texture (Domain *domain, const CreateInfo &createInfo, string_view name) |
| Creates texture from CreateInfo. More...
|
|
| Texture (Domain *domain, TextureType type, int glHandle, bool takeOwnership, GraphicsFormat format, unsigned int mipmapLevelCount, unsigned int width, unsigned int height, string_view name) |
| Creates texture from an existing GL object handle. More...
|
|
| Surface (Domain *domain, string_view name) |
|
| GPUResource (Domain *domain, string_view name="") |
| Constructor. More...
|
|
| Resource (Domain *domain, string_view name) |
| Constructor. More...
|
|
void | initialize () |
|
void | onCopy (const Object &other) |
|
void | initialize () |
|
| MetaObject () |
|
AbstractPropertyTypeDescriptor::ValueSourceEntry * | acquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage) |
| Acquires a local value source entry that is free for the assignment of a value. More...
|
|
AbstractPropertyTypeDescriptor::ModifierStorage * | acquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) |
|
AbstractPropertyTypeDescriptor::NotificationStorage * | acquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) |
|
PropertyStoragePtr | acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor) |
|
void | addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer) |
| Internally adds a property value source. More...
|
|
void | addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner) |
| Internally adds a property value source. More...
|
|
AbstractPropertyTypeDescriptor::ValueSourceEntry * | constructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) |
|
PropertyStoragePtr | constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) |
|
void | copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage) |
| Copy local value from property storage. More...
|
|
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. More...
|
|
PropertyStoragePtr | findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const |
| Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation. More...
|
|
AbstractPropertyTypeDescriptor * | findPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const |
| Finds a property type descriptor by name and data type. More...
|
|
AbstractPropertyTypeDescriptor * | findPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const |
| Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names. More...
|
|
AbstractPropertyTypeDescriptor * | findPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const |
| Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names. More...
|
|
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. More...
|
|
virtual void | notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason) |
|
void | onCopy (const PropertyObject &other) |
|
void | removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage) |
| Removes a local value from the given property storage. More...
|
|
void | removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner) |
| Removes a property value source. More...
|
|
void | validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage) |
|
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 RenderTargetMode, CreateInfoNode2DRenderTarget, and CreateInfoRenderpassRenderTarget. Note that the CreateInfoRenderpassRenderTarget is intended for use with the deprecated LegacyRenderPass. For all other render passes, use CreateInfoNode2DRenderTarget, or to acquire the composition targets use the CompositionManager.
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:
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;
}
BitmapImage* imagePtr = image.get();
Texture::CreateInfo2D createInfo(kanzi::move(image));
To create a two dimensional texture from image with custom sampler settings:
Texture::CreateInfo2D createInfo(kanzi::move(image));
createInfo.updateShapeAndFormatFromImages();
To create a cubemap texture from 6 face images:
Texture::CreateInfoCubemap createInfo(kanzi::move(images));
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;
unsigned int height = 512;
{
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;
unsigned int width = texture->getWidth();
unsigned int height = texture->getHeight();
for (unsigned int mipmapLevel = 0; mipmapLevel < createInfo.mipmapLevelCount; ++mipmapLevel)
{
for (unsigned int faceIndex = 0; faceIndex < 6; ++faceIndex)
{
vector<byte> data = generateTextureData(width, height, faceIndex);
texture->setData(face, mipmapLevel, 0, 0, width, height, data.data());
}
width /= 2;
height /= 2;
}
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);
node->setBackgroundBrush(brush);
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.pushComposition(0, screen->getAllocatedSize());
screen->render(*renderer, compositionStack);
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);
ColorRGBA lightBlue(0.4f, 0.4f, 0.9f, 1.0f);
rootTemplate->addChild(clearTemplate);
rootTemplate->addChild(drawTemplate);
viewport->setRenderPassPrefab(rootPrefab);
{
CompositionStack& compositionStack = renderer3D->getCompositionStack();
screen->setAllocatedSize(Vector2(static_cast<float>(width), static_cast<float>(height)));
screen->setArrangeTransform(Matrix3x3());
screen->layout();
compositionStack.pushComposition(0, screen->getAllocatedSize());
screen->render(*renderer3D, compositionStack);
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:
textureCreateInfo.depthStencilFormat = renderer->getDepthStencilFormatForRenderbuffer(true, false);
renderer->bindFramebuffer(texture->getNativeFramebufferHandle());
renderer->setViewport(
ViewportRectangle(0, 0, texture->getWidth(), texture->getHeight()));
renderer->resetClearTarget();
renderer->addClearColor(0, 0.5f, 0.6f, 0.7f, 1.0f);
renderer->clear();
renderer->resetClearTarget();
renderer->resetActiveFramebuffer();
To create a two dimensional texture with mipmaps and render to it through framebuffer:
renderer->bindFramebuffer(texture->getNativeFramebufferHandle());
renderer->setViewport(
ViewportRectangle(0, 0, texture->getWidth(), texture->getHeight()));
renderer->resetClearTarget();
renderer->addClearColor(0, 0.5f, 0.6f, 0.7f, 1.0f);
renderer->clear();
renderer->resetClearTarget();
renderer->resetActiveFramebuffer();
texture->generateMipmaps();
To create a cubemap texture with mipmaps and render to it through framebuffers:
Texture::CreateInfo textureCreateInfo;
textureCreateInfo.width = 512;
textureCreateInfo.height = 512;
renderer->bindFramebuffer(texture->getNativeFramebufferHandle());
renderer->setViewport(
ViewportRectangle(0, 0, texture->getWidth(), texture->getHeight()));
for (unsigned int faceIndex = 0; faceIndex < 6; ++faceIndex)
{
{
}
float relativeFace = static_cast<float>(faceIndex) / 5.0f;
renderer->resetClearTarget();
renderer->addClearColor(0, relativeFace, relativeFace, relativeFace, 1.0f);
renderer->clear();
renderer->resetClearTarget();
}
renderer->resetActiveFramebuffer();
texture->generateMipmaps();