GLTexture class
#include <nCine/Graphics/GL/GLTexture.h>
Wraps an OpenGL texture object.
Manages the lifetime of a single OpenGL texture object of a given target (e.g. GL_TEXTURE_2D). Binding is cached per texture unit, and the currently active unit is tracked, so that redundant glActiveTexture() and glBindTexture() calls are skipped. Provides image upload, immutable storage allocation, readback and parameter setting.
Public static variables
-
static std::
uint32_t MaxTextureUnits constexpr - Number of texture units tracked by the bind cache.
Public static functions
-
static auto Unbind(GLenum target,
std::
uint32_t textureUnit) -> bool - Unbinds any texture of the given target from the specified texture unit.
-
static auto Unbind(std::
uint32_t textureUnit) -> bool - Unbinds any
GL_TEXTURE_2Dtexture from the specified texture unit.
Constructors, destructors, conversion operators
- GLTexture(GLenum target_) explicit
- ~GLTexture()
- GLTexture(const GLTexture&) deleted
Public functions
- auto operator=(const GLTexture&) -> GLTexture& deleted
- auto GetGLHandle() const -> GLuint
- Returns the OpenGL handle of the texture object.
- auto GetTarget() const -> GLenum
- Returns the target of the texture (e.g.
GL_TEXTURE_2D). -
auto Bind(std::
uint32_t textureUnit) const -> bool - Binds the texture to the specified texture unit.
- auto Bind() const -> bool
- Binds the texture to texture unit 0.
- auto Unbind() const -> bool
- Unbinds the texture from the unit it was last bound to.
- void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data)
- Specifies a two-dimensional image for the given mipmap level.
- void TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data)
- Updates a rectangular subregion of a two-dimensional mipmap level.
- void CompressedTexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei imageSize, const void* data)
- Specifies a compressed two-dimensional image for the given mipmap level.
- void CompressedTexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
- Updates a rectangular subregion of a compressed two-dimensional mipmap level.
- void TexStorage2D(GLsizei levels, GLint internalFormat, GLsizei width, GLsizei height)
- Allocates an immutable two-dimensional storage with the given number of mipmap levels.
- void GetTexImage(GLint level, GLenum format, GLenum type, void* pixels)
- Reads back a mipmap level of the texture into client memory.
- void TexParameterf(GLenum pname, GLfloat param)
- Sets a floating-point texture parameter.
- void TexParameteri(GLenum pname, GLint param)
- Sets an integer texture parameter (e.g. filter or wrap mode).
- void SetObjectLabel(StringView label)
- Sets an OpenGL object label for the texture, for debugging.
Function documentation
bool nCine:: GLTexture:: Bind(std:: uint32_t textureUnit) const
Binds the texture to the specified texture unit.
| Returns | true if a glBindTexture() call was issued, false if it was already bound |
|---|