![]() |
Cinder
0.9.1
|
#include <Texture.h>
Inherits cinder::gl::TextureBase.
Classes | |
struct | Format |
Public Member Functions | |
void | setCleanBounds (const Area &cleanBounds) |
void | update (const void *data, GLenum dataFormat, GLenum dataType, int mipLevel, int width, int height, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const Surface8u &surface, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const Channel8u &channel, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const Surface16u &surface, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const Channel16u &channel, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const Surface32f &surface, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const Channel32f &channel, int mipLevel=0, const ivec2 &destLowerLeftOffset=ivec2(0, 0)) |
void | update (const TextureData &textureData) |
void | update (const PboRef &pbo, GLenum format, GLenum type, int mipLevel=0, size_t pboByteOffset=0) |
void | update (const PboRef &pbo, GLenum format, GLenum type, const Area &destArea, int mipLevel=0, size_t pboByteOffset=0) |
void | updateFromKtx (const DataSourceRef &dataSource, const PboRef &intermediatePbo=PboRef()) |
void | updateFromDds (const DataSourceRef &dataSource, const PboRef &intermediatePbo=PboRef()) |
void | replace (const TextureData &textureData) |
GLint | getWidth () const override |
GLint | getHeight () const override |
GLint | getDepth () const override |
GLint | getActualWidth () const |
GLint | getActualHeight () const |
ivec2 | getSize () const |
Rectf | getAreaTexCoords (const Area &area) const |
bool | isTopDown () const |
void | setTopDown (bool topDown=true) |
ImageSourceRef | createSource () |
void | setDoNotDispose (bool aDoNotDispose=true) |
GLint | getInternalFormat () const |
GLuint | getId () const |
GLenum | getTarget () const |
void | bind (uint8_t textureUnit=0) const |
void | unbind (uint8_t textureUnit=0) const |
float | getAspectRatio () const |
Area | getBounds () const |
bool | hasAlpha () const |
void | setWrap (GLenum wrapS, GLenum wrapT) |
void | setWrap (GLenum wrapS, GLenum wrapT, GLenum wrapR) |
void | setWrapS (GLenum wrapS) |
void | setWrapT (GLenum wrapT) |
void | setWrapR (GLenum wrapR) |
void | setMinFilter (GLenum minFilter) |
void | setMagFilter (GLenum magFilter) |
void | setMaxAnisotropy (GLfloat maxAnisotropy) |
bool | hasMipmapping () const |
void | setCompareMode (GLenum compareMode) |
void | setCompareFunc (GLenum compareFunc) |
std::array< GLint, 4 > | getSwizzleMask () const |
const std::string & | getLabel () const |
void | setLabel (const std::string &label) |
Static Public Member Functions | |
static Texture2dRef | create (int width, int height, const Format &format=Format()) |
static Texture2dRef | create (const void *data, GLenum dataFormat, int width, int height, const Format &format=Format()) |
static Texture2dRef | create (const Surface8u &surface, const Format &format=Format()) |
static Texture2dRef | create (const Channel8u &channel, const Format &format=Format()) |
static Texture2dRef | create (const Surface16u &surface, const Format &format=Format()) |
static Texture2dRef | create (const Channel16u &channel, const Format &format=Format()) |
static Texture2dRef | create (const Surface32f &surface, const Format &format=Format()) |
static Texture2dRef | create (const Channel32f &channel, const Format &format=Format()) |
static Texture2dRef | create (ImageSourceRef imageSource, const Format &format=Format()) |
static Texture2dRef | create (GLenum target, GLuint textureID, int width, int height, bool doNotDispose, const std::function< void(Texture2d *)> &deleter=std::function< void(Texture2d *)>()) |
static Texture2dRef | create (const TextureData &data, const Format &format) |
static Texture2dRef | createFromKtx (const DataSourceRef &dataSource, const Format &format=Format()) |
static Texture2dRef | createFromDds (const DataSourceRef &dataSource, const Format &format=Format()) |
static GLenum | getBindingConstantForTarget (GLenum target) |
static void | getInternalFormatInfo (GLint internalFormat, GLenum *outDataFormat, GLenum *outDataType, bool *outAlpha=nullptr, bool *outCompressed=nullptr, bool *outSrgb=nullptr) |
static int | requiredMipLevels (GLint width, GLint height, GLint depth) |
template<typename T > | |
static bool | surfaceRequiresIntermediate (int32_t width, uint8_t pixelBytes, int32_t rowBytes, SurfaceChannelOrder surfaceChannelOrder) |
template<typename T > | |
static void | SurfaceChannelOrderToDataFormatAndType (const SurfaceChannelOrder &sco, GLint *dataFormat, GLenum *type) |
static ivec2 | calcMipLevelSize (int level, GLint width, GLint height) |
static GLfloat | getMaxAnisotropyMax () |
static bool | supportsHardwareSwizzle () |
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) | |
void | printDims (std::ostream &os) const override |
void | initParams (Format &format, GLint defaultInternalFormat, GLint defaultDataType) |
void | initMaxMipmapLevel () |
template<typename T > | |
void | setData (const SurfaceT< T > &surface, bool createStorage, int mipLevel, const ivec2 &offset) |
template<typename T > | |
void | setData (const ChannelT< T > &channel, bool createStorage, int mipLevel, const ivec2 &offset) |
void | initData (const void *data, GLenum dataFormat, const Format &format) |
void | initData (const ImageSourceRef &imageSource, const Format &format) |
void | initDataImageSourceWithPboImpl (const ImageSourceRef &imageSource, const Format &format, GLint dataFormat, GLint dataType, ImageIo::ChannelOrder channelOrder, bool isGray, const PboRef &pbo) |
void | initDataImageSourceImpl (const ImageSourceRef &imageSource, const Format &format, GLint dataFormat, GLint dataType, ImageIo::ChannelOrder channelOrder, bool isGray) |
void | initParams (Format &format, GLint defaultInternalFormat, GLint defaultDataType) |
Protected Attributes | |
ivec2 | mActualSize |
Area | mCleanBounds |
bool | mTopDown |
GLenum | mTarget |
GLuint | mTextureId |
GLint | mInternalFormat |
bool | mMipmapping |
GLint | mBaseMipmapLevel |
GLint | mMaxMipmapLevel |
bool | mDoNotDispose |
std::array< GLint, 4 > | mSwizzleMask |
std::string | mLabel |
Friends | |
class | Texture2dCache |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
Constructs a texture of size(width, height) and allocates storage.
|
static |
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 than GL_UNSIGNED_CHAR
. Ignores format.loadTopDown().
|
static |
Constructs a Texture based on the contents of surface.
|
static |
Constructs a Texture based on the contents of channel. Sets swizzle mask to {R,R,R,1} where supported unless otherwise specified in format.
|
static |
Constructs a Texture based on the contents of surface.
|
static |
Constructs a Texture based on the contents of channel. Sets swizzle mask to {R,R,R,1} where supported unless otherwise specified in format.
|
static |
Constructs a Texture based on the contents of surface.
|
static |
Constructs a texture based on the contents of channel. A default value of -1 for internalFormat chooses an appropriate internal format automatically.
|
static |
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.
|
static |
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.
|
static |
Constructs a Texture based on an instance of TextureData.
|
static |
Constructs a Texture from an optionally compressed KTX file. Enables mipmapping if KTX file contains mipmaps and Format has not specified false
for 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/)
|
static |
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 specified false
for mipmapping. ANGLE version requires textures to be a multiple of 4 due to DX limitation.
void cinder::gl::Texture2d::setCleanBounds | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::update | ( | 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.
void cinder::gl::Texture2d::updateFromKtx | ( | 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.
void cinder::gl::Texture2d::updateFromDds | ( | 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.
void cinder::gl::Texture2d::replace | ( | 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.
|
overridevirtual |
Returns the width of the texture in pixels.
Implements cinder::gl::TextureBase.
|
overridevirtual |
Returns the height of the texture in pixels.
Implements cinder::gl::TextureBase.
|
overridevirtual |
Returns the depth of the texture in pixels.
Implements cinder::gl::TextureBase.
GLint cinder::gl::Texture2d::getActualWidth | ( | ) | const |
Returns the true width of the texture in pixels, which may be larger than it's "clean" area.
GLint cinder::gl::Texture2d::getActualHeight | ( | ) | const |
Returns the true height of the texture in pixels, which may be larger than it's "clean" area.
ivec2 cinder::gl::Texture2d::getSize | ( | ) | const |
Returns size of the texture in pixels, igonring clean bounds.
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_2D
and pixels for GL_TEXTURE_RECTANGLE
)
bool cinder::gl::Texture2d::isTopDown | ( | ) | const |
Returns whether the scanlines of the image are stored top-down in memory relative to the base address. Default is false
.
void cinder::gl::Texture2d::setTopDown | ( | bool | topDown = true | ) |
Marks whether the scanlines of the image are stored top-down in memory relative to the base address. Default is false
.
ImageSourceRef cinder::gl::Texture2d::createSource | ( | ) |
Returns an ImageSource pointing to this Texture.
|
overrideprotectedvirtual |
Implements cinder::gl::TextureBase.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
inherited |
Determines whether the Texture will call glDeleteTextures() to free the associated texture objects on destruction.
|
inherited |
the Texture's internal format, which is the format that OpenGL stores the texture data in memory. Common values include GL_RGB
, GL_RGBA
and GL_LUMINANCE
|
inherited |
the ID number for the texture, appropriate to pass to calls like glBindTexture()
|
inherited |
the target associated with texture. Typical values are GL_TEXTURE_2D
and GL_TEXTURE_RECTANGLE_ARB
|
inherited |
Binds the Texture's texture to its target in the multitexturing unit GL_TEXTURE0
+ textureUnit.
|
inherited |
Unbinds the Texture currently bound in the Texture's target.
|
inherited |
Returns the 2D aspect ratio of the texture (width / height), ignoring clean bounds.
|
inherited |
Returns the Area defining the Texture's bounds in pixels, ignoring clean bounds.
|
inherited |
Returns whether the Texture has an alpha channel based on its internal format.
|
inherited |
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 is GL_CLAMP_TO_EDGE
.
|
inherited |
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 is GL_CLAMP_TO_EDGE
.
|
inherited |
Sets the horizontal wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are GL_REPEAT
and GL_CLAMP_TO_EDGE
, etc. Default is GL_CLAMP_TO_EDGE
.
|
inherited |
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 is GL_CLAMP_TO_EDGE
.
|
inherited |
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 is GL_CLAMP_TO_EDGE
.
|
inherited |
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
|
inherited |
Sets the filtering behavior when a texture is displayed at a higher resolution than its native resolution. Possible values are
GL_NEAREST
GL_LINEAR
|
inherited |
Sets the anisotropic filtering amount. A value greater than 1.0 "enables" anisotropic filtering. Maximum of getMaxAnisotropyMax();.
|
inherited |
Returns whether the Texture has Mipmapping enabled.
|
inherited |
|
inherited |
|
staticinherited |
Returns the appropriate parameter to glGetIntegerv() for a specific target; ie GL_TEXTURE_2D -> GL_TEXTURE_BINDING_2D. Returns 0 on failure.
|
staticinherited |
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.
|
staticinherited |
Returns the number of mip levels necessary to represent a texture of width, height and depth.
|
staticinherited |
Returns whether a Surface of width, rowBytes and surfaceChannelOrder would require an intermediate Surface in order to be copied into a GL Texture.
|
staticinherited |
Converts a SurfaceChannelOrder into an appropriate OpenGL dataFormat and type.
|
staticinherited |
calculate the size of mipMap for the corresponding level
|
staticinherited |
Returns the maximum anisotropic filtering maximum allowed by the hardware.
|
inherited |
Returns the Texture's swizzle mask (corresponding to GL_TEXTURE_SWIZZLE_RGBA
)
|
staticinherited |
Returns whether this hardware supports texture swizzling (via GL_TEXTURE_SWIZZLE_RGBA
)
|
inherited |
Returns the debugging label associated with the Texture.
|
inherited |
Sets the debugging label associated with the Texture. Calls glObjectLabel() when available.
|
protectedinherited |
|
friend |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
mutableprotectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |