- cinder::gl::TextureBase
- cinder::gl::Texture2d
Public Member Functions
-
voidsetCleanBounds (const Area &cleanBounds)
Allows specification of some Area other than the Texture's full area for cases where not all pixels in the Texture are usable / "clean"; common in video decoding pipelines in particular. Specified in pixels, and relative to upper-left origin coordinate system regardless of whether Textre is top-down or not.
-
voidupdate (const void *data, GLenum dataFormat, GLenum dataType, int mipLevel, int width, int height, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with the data pointed to by data , of format dataFormat (Ex: GL_RGB), and type dataType (Ex: GL_UNSIGNED_BYTE) of size ( width , height ). destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const Surface8u &surface, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with contents of surface . Expects surface's size to match the Texture's at mipLevel . destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const Channel8u &channel, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with contents of channel . Expects channel's size to match the Texture's at mipLevel . destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const Surface16u &surface, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with contents of surface . Expects surface's size to match the Texture's at mipLevel . destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const Channel16u &channel, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with contents of channel . Expects channel's size to match the Texture's at mipLevel . destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const Surface32f &surface, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with contents of surface . Expects surface's size to match the Texture's at mipLevel . destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const Channel32f &channel, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0))
Updates the pixels of a Texture with contents of channel . Expects channel's size to match the Texture's at mipLevel . destLowerLeftOffset specifies a texel offset to copy to within the Texture.
-
voidupdate (const TextureData &textureData)
Updates the pixels of a Texture with contents of textureData . Inefficient if the bounds of textureData don't match those of this .
-
voidupdate (const PboRef &pbo, GLenum format, GLenum type, int mipLevel=0, size_t pboByteOffset=0)
Updates the pixels of a Texture with the contents of a PBO (whose target must be
GL_PIXEL_UNPACK_BUFFER) at mipmap level mipLevel . format and type correspond to parameters of glTexSubImage2D, and would often be GL_RGB and GL_UNSIGNED_BYTE respectively. Reads from the PBO starting at pboByteOffset . -
voidupdate (const PboRef &pbo, GLenum format, GLenum type, const Area &destArea, int mipLevel=0, size_t pboByteOffset=0)
Updates a subregion (measured as origin upper-left) of the pixels of a Texture with the contents of a PBO (whose target must be
GL_PIXEL_UNPACK_BUFFER) at mipmap level mipLevel . format and type correspond to parameters of glTexSubImage2D, and would often be GL_RGB and GL_UNSIGNED_BYTE respectively. Reads from the PBO starting at pboByteOffset . -
voidupdateFromKtx (const DataSourceRef &dataSource, const PboRef &intermediatePbo=PboRef())
Updates a Texture from a KTX file. Uses intermediatePbo if supplied; requires it to be large enough to hold all MIP levels and throws if it is not.
-
voidupdateFromDds (const DataSourceRef &dataSource, const PboRef &intermediatePbo=PboRef())
Updates a Texture from a DDS file. Uses intermediatePbo if supplied; requires it to be large enough to hold all MIP levels and throws if it is not.
-
voidreplace (const TextureData &textureData)
Replaces the pixels (and data store) of a Texture with contents of textureData . Use update() instead if the bounds of this match those of textureData .
-
GLintgetWidth () const override
Returns the width of the texture in pixels.
-
GLintgetHeight () const override
Returns the height of the texture in pixels.
-
GLintgetDepth () const override
Returns the depth of the texture in pixels.
-
GLintgetActualWidth () const
Returns the true width of the texture in pixels, which may be larger than it's "clean" area.
-
GLintgetActualHeight () const
Returns the true height of the texture in pixels, which may be larger than it's "clean" area.
-
ivec2getSize () const
Returns size of the texture in pixels, igonring clean bounds.
-
getAreaTexCoords (const Area &area) const
Returns the UV coordinates which correspond to the pixels contained in area (as expressed with an upper-left origin, relative to clean bounds). Accounts for top-down storage and target (0-1 for
GL_TEXTURE_2Dand pixels forGL_TEXTURE_RECTANGLE) -
boolisTopDown () const
Returns whether the scanlines of the image are stored top-down in memory relative to the base address. Default is
false. -
voidsetTopDown (bool topDown=true)
Marks whether the scanlines of the image are stored top-down in memory relative to the base address. Default is
false. -
voidregenerateMipmap ()
Explicitly regenerate mipmaps assuming mipmapping is enabled.
-
createSource ()
Returns an ImageSource pointing to this Texture.
-
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_RGBAandGL_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_2DandGL_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_REPEATandGL_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_NEARESTGL_LINEARGL_NEAREST_MIPMAP_NEARESTGL_LINEAR_MIPMAP_NEARESTGL_NEAREST_MIPMAP_LINEARGL_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_NEARESTGL_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 (int width, int height, const Format &format=Format())
Constructs a texture of size( width , height ) and allocates storage.
-
create (const void *data, GLenum dataFormat, int width, int height, const Format &format=Format())
Constructs a texture of size( width , height ). Pixel data is provided by data in format dataFormat (Ex:
GL_RGB,GL_RGBA). Use format.setDataType() to specify a dataType other thanGL_UNSIGNED_CHAR. Ignores format.loadTopDown() . -
create (const Surface8u &surface, const Format &format=Format())
Constructs a Texture based on the contents of surface .
-
create (const Channel8u &channel, const Format &format=Format())
Constructs a Texture based on the contents of channel . Sets swizzle mask to {R,R,R,1} where supported unless otherwise specified in format .
-
create (const Surface16u &surface, const Format &format=Format())
Constructs a Texture based on the contents of surface .
-
create (const Channel16u &channel, const Format &format=Format())
Constructs a Texture based on the contents of channel . Sets swizzle mask to {R,R,R,1} where supported unless otherwise specified in format .
-
create (const Surface32f &surface, const Format &format=Format())
Constructs a Texture based on the contents of surface .
-
create (const Channel32f &channel, const Format &format=Format())
Constructs a texture based on the contents of channel . A default value of -1 for internalFormat chooses an appropriate internal format automatically.
-
create (ImageSourceRef imageSource, const Format &format=Format())
Constructs a Texture based on imageSource . A default value of -1 for internalFormat chooses an appropriate internal format based on the contents of imageSource . Uses a Format 's intermediate PBO when available, which is resized as necessary.
-
create (GLenum target, GLuint textureID, int width, int height, bool doNotDispose, const std::function< void(Texture2d *)> &deleter=std::function< void(Texture2d *)>())
Constructs a Texture based on an externally initialized OpenGL texture. doNotDispose specifies whether the Texture is responsible for disposing of the associated OpenGL resource. Supports a custom deleter.
-
create (const TextureData &data, const Format &format)
Constructs a Texture based on an instance of TextureData .
-
createFromKtx (const DataSourceRef &dataSource, const Format &format=Format())
Constructs a Texture from an optionally compressed KTX file. Enables mipmapping if KTX file contains mipmaps and Format has not specified
falsefor mipmapping. Uses Format 's intermediate PBO if supplied; requires it to be large enough to hold all MIP levels and throws if it is not. ( http://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ ) -
createFromDds (const DataSourceRef &dataSource, const Format &format=Format())
Constructs a Texture from a DDS file. Supports DXT1, DTX3, and DTX5. Supports BC7 in the presence of
GL_ARB_texture_compression_bptc. Enables mipmapping if DDS contains mipmaps and Format has not specifiedfalsefor mipmapping. ANGLE version requires textures to be a multiple of 4 due to DX limitation. -
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)
Protected Member Functions
-
Texture2d (int width, int height, Format format=Format())
-
Texture2d (const void *data, GLenum dataFormat, int width, int height, Format format=Format())
-
Texture2d (const Surface8u &surface, Format format=Format())
-
Texture2d (const Surface16u &surface, Format format=Format())
-
Texture2d (const Surface32f &surface, Format format=Format())
-
Texture2d (const Channel8u &channel, Format format=Format())
-
Texture2d (const Channel16u &channel, Format format=Format())
-
Texture2d (const Channel32f &channel, Format format=Format())
-
Texture2d (const ImageSourceRef &imageSource, Format format=Format())
-
Texture2d (GLenum target, GLuint textureId, int width, int height, bool doNotDispose)
-
Texture2d (const TextureData &data, Format format)
-
voidprintDims (std::ostream &os) const override
-
voidinitParams (Format &format, GLint defaultInternalFormat, GLint defaultDataType)
-
voidinitMaxMipmapLevel ()
-
voidsetData (const SurfaceT< T > &surface, bool createStorage, int mipLevel, const ivec2 &offset)
-
voidsetData (const ChannelT< T > &channel, bool createStorage, int mipLevel, const ivec2 &offset)
-
voidinitData (const void *data, GLenum dataFormat, const Format &format)
-
voidinitData (const ImageSourceRef &imageSource, const Format &format)
-
voidinitDataImageSourceWithPboImpl (const ImageSourceRef &imageSource, const Format &format, GLint dataFormat, GLint dataType, ImageIo::ChannelOrder channelOrder, bool isGray, const PboRef &pbo)
-
voidinitDataImageSourceImpl (const ImageSourceRef &imageSource, const Format &format, GLint dataFormat, GLint dataType, ImageIo::ChannelOrder channelOrder, bool isGray)
-
voidinitParams (Format &format, GLint defaultInternalFormat, GLint defaultDataType)