class
AbstractTextureBase for textures.
Contents
Encapsulates one OpenGL texture object. See Texture, TextureArray, CubeMapTexture, CubeMapTextureArray, RectangleTexture, BufferTexture and MultisampleTexture documentation for more information and usage examples.
WebGL restrictions
WebGL puts some restrictions on type of data submitted to *Texture::
Performance optimizations and security
The engine tracks currently bound textures and images in all available texture units to avoid unnecessary calls to glActiveTexture(), glBindTexture() and glBindImageTexture(). Texture configuration functions use dedicated highest available texture unit to not affect active bindings in user units. Texture limits and implementation-defined values (such as maxColorSamples()) are cached, so repeated queries don't result in repeated glGet() calls. See also Context::
If ARB_
In addition, if either ARB_
If ARB_
If either ARB_
Pixel storage mode defined by PixelStorage and CompressedPixelStorage is applied either right before doing image upload (such as various setImage(), setSubImage(), setCompressedImage() or setCompressedSubImage() functions) using glPixelStore() with GL_UNPACK_*
parameters or right before doing image download (such as various image(), subImage(), compressedImage(), or compressedSubImage() functions) using glPixelStore() with GL_PACK_*
. The engine tracks currently used pixel pack/unpack parameters to avoid unnecessary calls to glPixelStore(). See also Context::
To achieve least state changes, fully configure each texture in one run – method chaining comes in handy — and try to have often used textures in dedicated units, not occupied by other textures. First configure the texture and then set the data, so OpenGL can optimize them to match the settings. To avoid redundant consistency checks and memory reallocations when updating texture data, set texture storage at once using setStorage() and then set data using setSubImage().
Function setStorage() creates immutable texture storage, removing the need for additional consistency checks and memory reallocations when updating the data later. If OpenGL 4.2, ARB_
You can use functions invalidateImage() and invalidateSubImage() if you don't need texture data anymore to avoid unnecessary memory operations performed by OpenGL in order to preserve the data. If running on OpenGL ES or extension ARB_
Base classes
- class AbstractObject
- Base for all OpenGL objects.
Derived classes
- class BufferTexture
- Buffer texture.
- class CubeMapTexture
- Cube map texture.
- class CubeMapTextureArray
- Cube map texture array.
-
template<UnsignedInt dimensions>class MultisampleTexture
- Mulitsample texture.
- class RectangleTexture
- Rectangle texture.
-
template<UnsignedInt dimensions>class Texture
- Texture.
-
template<UnsignedInt dimensions>class TextureArray
- Texture array.
-
template<UnsignedInt dimensions>class Texture
- Texture.
Public static functions
- static auto maxLodBias() -> Float
- Max level-of-detail bias.
- static auto maxColorSamples() -> Int
- Max supported color sample count.
- static auto maxDepthSamples() -> Int
- Max supported depth sample count.
- static auto maxIntegerSamples() -> Int
- Max supported integer sample count.
- static void unbind(Int textureUnit)
- Unbind any texture from given texture unit.
-
static void unbind(Int firstTextureUnit,
std::
size_t count) - Unbind textures in given range of texture units.
-
static void bind(Int firstTextureUnit,
std::
initializer_list<AbstractTexture*> textures) - Bind textures to given range of texture units.
- static void unbindImage(Int imageUnit)
- Unbind any image from given image unit.
-
static void unbindImages(Int firstImageUnit,
std::
size_t count) - Unbind images in given range of image units.
-
static void bindImages(Int firstImageUnit,
std::
initializer_list<AbstractTexture*> textures) - Bind textures to given range of texture units.
Constructors, destructors, conversion operators
- AbstractTexture(const AbstractTexture&) deleted
- Copying is not allowed.
- AbstractTexture(AbstractTexture&& other) noexcept
- Move constructor.
- ~AbstractTexture()
- Destructor.
Public functions
- auto operator=(const AbstractTexture&) -> AbstractTexture& deleted
- Copying is not allowed.
- auto operator=(AbstractTexture&& other) -> AbstractTexture& noexcept
- Move assignment.
- auto id() const -> GLuint
- OpenGL texture ID.
- auto release() -> GLuint
- Release OpenGL object.
-
auto label() -> std::
string - Texture label.
-
auto setLabel(const std::
string& label) -> AbstractTexture& - Set texture label.
-
template<std::auto setLabel(const char(&label)[size]) -> AbstractTexture&
size_t size> - void bind(Int textureUnit)
- Bind texture to given texture unit.
Function documentation
static Float Magnum:: GL:: AbstractTexture:: maxLodBias()
Max level-of-detail bias.
The result is cached, repeated queries don't result in repeated OpenGL calls.
static Int Magnum:: GL:: AbstractTexture:: maxColorSamples()
Max supported color sample count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: AbstractTexture:: maxDepthSamples()
Max supported depth sample count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: AbstractTexture:: maxIntegerSamples()
Max supported integer sample count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static void Magnum:: GL:: AbstractTexture:: unbind(Int textureUnit)
Unbind any texture from given texture unit.
If neither ARB_
static void Magnum:: GL:: AbstractTexture:: unbind(Int firstTextureUnit,
std:: size_t count)
Unbind textures in given range of texture units.
Unbinds all textures in the range . If ARB_
static void Magnum:: GL:: AbstractTexture:: bind(Int firstTextureUnit,
std:: initializer_list<AbstractTexture*> textures)
Bind textures to given range of texture units.
Binds first texture in the list to firstTextureUnit
, second to firstTextureUnit + 1
etc. If any texture is nullptr
, given texture unit is unbound. If ARB_
static void Magnum:: GL:: AbstractTexture:: unbindImage(Int imageUnit)
Unbind any image from given image unit.
static void Magnum:: GL:: AbstractTexture:: unbindImages(Int firstImageUnit,
std:: size_t count)
Unbind images in given range of image units.
Unbinds all texture in the range .
static void Magnum:: GL:: AbstractTexture:: bindImages(Int firstImageUnit,
std:: initializer_list<AbstractTexture*> textures)
Bind textures to given range of texture units.
Binds first level of given texture in the list to firstImageUnit
, second to firstTextureUnit + 1
etc. 3D, cube map and array textures are bound as layered targets. If any texture is nullptr
, given image unit is unbound.
GLuint Magnum:: GL:: AbstractTexture:: release()
Release OpenGL object.
Releases ownership of OpenGL texture object and returns its ID so it is not deleted on destruction. The internal state is then equivalent to moved-from state.
std:: string Magnum:: GL:: AbstractTexture:: label()
Texture label.
The result is not cached, repeated queries will result in repeated OpenGL calls. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_
AbstractTexture& Magnum:: GL:: AbstractTexture:: setLabel(const std:: string& label)
Set texture label.
Returns | Reference to self (for method chaining) |
---|
Default is empty string. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_
template<std:: size_t size>
AbstractTexture& Magnum:: GL:: AbstractTexture:: setLabel(const char(&label)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractTexture:: bind(Int textureUnit)
Bind texture to given texture unit.
If neither ARB_