![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/Texture.h>
Wrapper of an OpenGL Texture to store image data on the GPU. More...
Inheritance diagram for Texture:Wrapper of an OpenGL Texture to store image data on the GPU.
A texture is defined by its size and an internal format. Optionally, you can define a custom OpenGL texture Target type if you don't want to rely on the automatic deduction from the size.
The following default texture parameters will be set:
Linear for normalized textures, Nearest for integer texturesClampToBorder for all dimensions{R, R, R, 1} for single channel textures, {R, G, B, A} for all other texturesPublic Types | |
| enum class | Target { Tex1D = 0x0DE0 , Tex1DArray = 0x8C18 , Tex2D = 0x0DE1 , Tex2DArray = 0x8C1A , Tex3D = 0x806F } |
| Enumeration of supported target types. More... | |
Public Member Functions | |
| Texture (Target type, const vec3i &size, InternalFormat internalFormat) | |
| Creates a new OpenGL texture of given type, size and internal format. | |
| Texture (const vec3i &size, InternalFormat internalFormat) | |
| Creates a new OpenGL texture of given size and internal format. | |
| Texture (Texture &&rhs) noexcept | |
| void | bind (int unit=0) const |
| Binds the image to a texture unit. | |
| template<typename T> | |
| void | upload (const T *data, PixelFormat pixelFormat) |
| Uploads pixel data to the OpenGL texture. | |
| template<typename T> | |
| void | download (T *outData, PixelFormat pixelFormat) const |
| Downloads pixel data from the OpenGL texture into an existing buffer. | |
| template<typename T> | |
| std::unique_ptr< T[]> | download (PixelFormat pixelFormat, size_t *outNumElementsInReturnValue=nullptr) const |
| Downloads pixel data from the OpenGL texture into a newly allocated buffer. | |
| template<typename T> | |
| void | clear (const Eigen::Matrix< T, 4, 1 > &color) |
| Fills the entire texture with a constant value. | |
| void | generateMipmaps () |
| Generates mipmaps for this texture. | |
| void | setFiltering (Sampler::MinFilter min, Sampler::MagFilter mag) |
| Sets the minification and magnification filters. | |
| void | setWrapping (Sampler::Wrap s, Sampler::Wrap t, Sampler::Wrap r) |
| Sets the wrapping parameters for each dimension. | |
| void | setWrapping (Sampler::Wrap all) |
| Sets all wrapping parameters for all dimensions to the same value. | |
| void | setBorderColor (const vec4f &color) |
| Sets the border color that is used for ClampToBorder. | |
| uint32_t | id () const |
| Returns the internal OpenGL texture ID. | |
| const vec3i & | size () const |
| Returns the dimensions (number of pixels) of this texture. | |
| int | width () const |
| Returns the width (number of pixels) of this texture. | |
| int | height () const |
| Returns the height (number of pixels) of this texture. | |
| int | slices () const |
| Returns the depth (number of slices) of this texture. | |
| const vec3i & | dimensions () const |
| Returns the dimensions of this texture. | |
| Target | target () const |
| Returns the target type this texture is bound to. | |
| InternalFormat | internalFormat () const |
| Returns the requested internal format of this texture. | |
Static Public Member Functions | |
| static void | unbind (uint32_t textureUnit, Target target) |
| Unbinds any potentially bound texture from the specified texture unit (binds 0). | |
| static std::unique_ptr< Texture > | createFromExisting (Target type, uint32_t glTexId) |
| Creates a new Texture instance wrapping around an already existing OpenGL texture object and taking ownership. | |
| static std::unique_ptr< Texture > | createFromExisting (Target type, uint32_t glTexId, InternalFormat internalFormat) |
| Creates a new Texture instance wrapping around an already existing OpenGL texture object with specified internal format and taking ownership. | |
|
strong |
| Texture | ( | Target | type, |
| const vec3i & | size, | ||
| InternalFormat | internalFormat ) |
Creates a new OpenGL texture of given type, size and internal format.
| std::runtime_error | if the corresponding OpenGL texture object could not be created. |
| Texture | ( | const vec3i & | size, |
| InternalFormat | internalFormat ) |
Creates a new OpenGL texture of given size and internal format.
The texture's target type will Tex1D, Tex2D, or Tex3D based on the dimensionality of size.
| std::runtime_error | if the corresponding OpenGL texture object could not be created. |
|
static |
Creates a new Texture instance wrapping around an already existing OpenGL texture object and taking ownership.
glTexId must point to a valid OpenGL texture object matching the provided target type.
|
static |
Creates a new Texture instance wrapping around an already existing OpenGL texture object with specified internal format and taking ownership.
glTexId must point to a valid OpenGL texture object matching the provided target type.
| void upload | ( | const T * | data, |
| PixelFormat | pixelFormat ) |
Uploads pixel data to the OpenGL texture.
Format conversion will operated as specified by OpenGL.
| data | Pointer to the raw pixel data, must match the given pixel format and type and be of sufficient size |
| pixelFormat | Pixel format of the raw pixel buffer in data. |
| void download | ( | T * | outData, |
| PixelFormat | pixelFormat ) const |
Downloads pixel data from the OpenGL texture into an existing buffer.
Format conversion will operated as specified by OpenGL.
| outData | Pointer to the raw pixel data, must match the given pixel format and type and be of sufficient size |
| pixelFormat | Pixel format of the raw pixel buffer in data. |
| std::unique_ptr< T[]> download | ( | PixelFormat | pixelFormat, |
| size_t * | outNumElementsInReturnValue = nullptr ) const |
Downloads pixel data from the OpenGL texture into a newly allocated buffer.
Format conversion will operated as specified by OpenGL.
| outNumElementsInReturnValue | Optional output value returning the number of elements in the return value. |
| pixelFormat | Pixel format of the raw pixel buffer in data. |
| void clear | ( | const Eigen::Matrix< T, 4, 1 > & | color | ) |
Fills the entire texture with a constant value.
Format conversion will be operated as specified by OpenGL.
| color | RGBA pixel value to assign to all pixels, extra channels will be ignored. |
| void setFiltering | ( | Sampler::MinFilter | min, |
| Sampler::MagFilter | mag ) |
Sets the minification and magnification filters.
Mipmap types will only work when the texture has mipmap levels (see generateMipmaps()).
| void setWrapping | ( | Sampler::Wrap | s, |
| Sampler::Wrap | t, | ||
| Sampler::Wrap | r ) |
Sets the wrapping parameters for each dimension.
| void setWrapping | ( | Sampler::Wrap | all | ) |
Sets all wrapping parameters for all dimensions to the same value.
| void setBorderColor | ( | const vec4f & | color | ) |
Sets the border color that is used for ClampToBorder.