Public Member Functions
-
voidupdate (const Surface8u &surface, int mipLevel=0)
Updates the Texture1d using the top row of surface .
-
voidupdate (const void *data, GLenum dataFormat, GLenum dataType, int mipLevel, int width, int offset=0)
Updates the pixels of a Texture1d with the data pointed to by data , of format dataFormat (Ex: GL_RGB), and type dataType (Ex: GL_UNSIGNED_BYTE) of size width .
-
GLintgetWidth () const override
Returns the width of the texture in pixels.
-
GLintgetHeight () const override
Returns the height of the texture in pixels, which is always
1
. -
GLintgetDepth () const override
Returns the depth of the texture, which is always
1
. -
voidsetDoNotDispose (bool aDoNotDispose=true)
Determines whether the Texture will call glDeleteTextures() to free the associated texture objects on destruction.
-
GLintgetInternalFormat () const
the Texture's internal format, which is the format that OpenGL stores the texture data in memory. Common values include
GL_RGB
,GL_RGBA
andGL_LUMINANCE
-
GLuintgetId () const
the ID number for the texture, appropriate to pass to calls like
glBindTexture()
-
GLenumgetTarget () const
the target associated with texture. Typical values are
GL_TEXTURE_2D
andGL_TEXTURE_RECTANGLE_ARB
-
voidbind (uint8_t textureUnit=0) const
Binds the Texture's texture to its target in the multitexturing unit
GL_TEXTURE0
+ textureUnit . -
voidunbind (uint8_t textureUnit=0) const
Unbinds the Texture currently bound in the Texture's target.
-
floatgetAspectRatio () const
Returns the 2D aspect ratio of the texture (width / height), ignoring clean bounds.
-
getBounds () const
Returns the Area defining the Texture's bounds in pixels, ignoring clean bounds.
-
boolhasAlpha () const
Returns whether the Texture has an alpha channel based on its internal format.
-
voidsetWrap (GLenum wrapS, GLenum wrapT)
Sets the wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are
GL_REPEAT
,GL_CLAMP_TO_EDGE
, etc. Default isGL_CLAMP_TO_EDGE
. -
voidsetWrap (GLenum wrapS, GLenum wrapT, GLenum wrapR)
Sets the wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are
GL_REPEAT
,GL_CLAMP_TO_EDGE
, etc. Default isGL_CLAMP_TO_EDGE
. -
voidsetWrapS (GLenum wrapS)
Sets the horizontal wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are
GL_REPEAT
andGL_CLAMP_TO_EDGE
, etc. Default isGL_CLAMP_TO_EDGE
. -
voidsetWrapT (GLenum wrapT)
Sets the vertical wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are
GL_REPEAT
,GL_CLAMP_TO_EDGE
, etc. Default isGL_CLAMP_TO_EDGE
. -
voidsetWrapR (GLenum wrapR)
Sets the depth wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are
GL_REPEAT
,GL_CLAMP_TO_EDGE
, etc. Default isGL_CLAMP_TO_EDGE
. -
voidsetMinFilter (GLenum minFilter)
Sets the filtering behavior when a texture is displayed at a lower resolution than its native resolution. Possible values are.
GL_NEAREST
GL_LINEAR
GL_NEAREST_MIPMAP_NEAREST
GL_LINEAR_MIPMAP_NEAREST
GL_NEAREST_MIPMAP_LINEAR
GL_LINEAR_MIPMAP_LINEAR
-
voidsetMagFilter (GLenum magFilter)
Sets the filtering behavior when a texture is displayed at a higher resolution than its native resolution. Possible values are
GL_NEAREST
GL_LINEAR
-
voidsetMaxAnisotropy (GLfloat maxAnisotropy)
Sets the anisotropic filtering amount. A value greater than 1.0 "enables" anisotropic filtering. Maximum of getMaxAnisotropyMax() ;.
-
boolhasMipmapping () const
Returns whether the Texture has Mipmapping enabled.
-
voidsetCompareMode (GLenum compareMode)
-
voidsetCompareFunc (GLenum compareFunc)
-
std::array< GLint, 4 >getSwizzleMask () const
Returns the Texture's swizzle mask (corresponding to
GL_TEXTURE_SWIZZLE_RGBA
) -
const std::string &getLabel () const
Returns the debugging label associated with the Texture.
-
voidsetLabel (const std::string &label)
Sets the debugging label associated with the Texture. Calls glObjectLabel() when available.
Static Public Member Functions
-
create (GLint width, const Format &format=Format())
-
create (const Surface8u &surface, const Format &format=Format())
Constructs a Texture1d using the top row of surface .
-
create (const void *data, GLenum dataFormat, int width, const Format &format=Format())
Constructs a Texture1d using the data pointed to by data , in format dataFormat . For a dataType other than
GL_UNSIGNED_CHAR
use format.setDataType() -
GLenumgetBindingConstantForTarget (GLenum target)
Returns the appropriate parameter to glGetIntegerv() for a specific target; ie GL_TEXTURE_2D -> GL_TEXTURE_BINDING_2D. Returns 0 on failure.
-
voidgetInternalFormatInfo (GLint internalFormat, GLenum *outDataFormat, GLenum *outDataType, bool *outAlpha=nullptr, bool *outCompressed=nullptr, bool *outSrgb=nullptr)
Returns the corresponding legal values for glTexImage*D() calls for dataFormat and dataType based on internalFormat , as well as whether the internal format contains an alpha channel, is compressed, and is in the sRGB color space.
-
intrequiredMipLevels (GLint width, GLint height, GLint depth)
Returns the number of mip levels necessary to represent a texture of width , height and depth .
-
boolsurfaceRequiresIntermediate (int32_t width, uint8_t pixelBytes, ptrdiff_t rowBytes, SurfaceChannelOrder surfaceChannelOrder)
Returns whether a Surface of width , rowBytes and surfaceChannelOrder would require an intermediate Surface in order to be copied into a GL Texture.
-
voidSurfaceChannelOrderToDataFormatAndType (const SurfaceChannelOrder &sco, GLint *dataFormat, GLenum *type)
Converts a SurfaceChannelOrder into an appropriate OpenGL dataFormat and type.
-
ivec2calcMipLevelSize (int level, GLint width, GLint height)
calculate the size of mipMap for the corresponding level
-
GLfloatgetMaxAnisotropyMax ()
Returns the maximum anisotropic filtering maximum allowed by the hardware.
-
boolsupportsHardwareSwizzle ()
Returns whether this hardware supports texture swizzling (via
GL_TEXTURE_SWIZZLE_RGBA
)