Skip to content

gl::Texture2DArray#

Represents a 2D texture array.

Header:#include <AUI/GL/Texture2DArray.h>
CMake:aui_link(my_target PUBLIC aui::views)

Detailed Description#

A 2D texture array is a texture that contains multiple 2D textures, each accessible by its index. It's useful for storing and accessing multiple textures with the same dimensions.

After creating a 2D texture array, you can use update to update a single texture in the array. You cannot update dimensions of the texture array, so you should create a new one if you want to change the size of the texture array.

Public Methods#

Texture2DArray#


Texture2DArray::Texture2DArray(glm::uvec2 textureSize, unsigned textureCount)

Initializes the 2D texture array with empty data.

Arguments
textureSize
The size of the 2D texture (width and height).
textureCount
The number of layers in the texture array.

This function allocates storage for a 2D texture array with the specified size and texture count. It binds the texture and uses glTexStorage3D to allocate the storage.

update#


void Texture2DArray::update(unsigned texture, AImageView image)

Updates a single texture of the 2D texture array.

Arguments
texture
The index of the texture to be updated.
image
The image to be used as the new texture.

This function binds the texture and uploads the provided image as a texture in the 2D texture array. It uses glTexSubImage3D to update the texture.

This function expects the image to have the same size as the texture size initialized earlier, otherwise, an assertion error is thrown.