Cinder  0.9.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
cinder::gl::TextureBase Class Referenceabstract

#include <Texture.h>

Inherited by cinder::gl::Texture1d, cinder::gl::Texture2d, cinder::gl::Texture3d, and cinder::gl::TextureCubeMap.

Classes

struct  Format
 

Public Member Functions

virtual ~TextureBase ()
 
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
 
virtual GLint getWidth () const =0
 
virtual GLint getHeight () const =0
 
virtual GLint getDepth () const =0
 
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 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

 TextureBase ()
 
 TextureBase (GLenum target, GLuint textureId, GLint internalFormat)
 
void initParams (Format &format, GLint defaultInternalFormat, GLint defaultDataType)
 
virtual void printDims (std::ostream &os) const =0
 

Protected Attributes

GLenum mTarget
 
GLuint mTextureId
 
GLint mInternalFormat
 
bool mMipmapping
 
GLint mBaseMipmapLevel
 
GLint mMaxMipmapLevel
 
bool mDoNotDispose
 
std::array< GLint, 4 > mSwizzleMask
 
std::string mLabel
 

Friends

std::ostream & operator<< (std::ostream &os, const TextureBase &rhs)
 

Constructor & Destructor Documentation

cinder::gl::TextureBase::~TextureBase ( )
virtual
cinder::gl::TextureBase::TextureBase ( )
protected
cinder::gl::TextureBase::TextureBase ( GLenum  target,
GLuint  textureId,
GLint  internalFormat 
)
protected

Member Function Documentation

void cinder::gl::TextureBase::setDoNotDispose ( bool  aDoNotDispose = true)

Determines whether the Texture will call glDeleteTextures() to free the associated texture objects on destruction.

GLint cinder::gl::TextureBase::getInternalFormat ( ) 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 and GL_LUMINANCE

GLuint cinder::gl::TextureBase::getId ( ) const

the ID number for the texture, appropriate to pass to calls like glBindTexture()

GLenum cinder::gl::TextureBase::getTarget ( ) const

the target associated with texture. Typical values are GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB

void cinder::gl::TextureBase::bind ( uint8_t  textureUnit = 0) const

Binds the Texture's texture to its target in the multitexturing unit GL_TEXTURE0 + textureUnit.

void cinder::gl::TextureBase::unbind ( uint8_t  textureUnit = 0) const

Unbinds the Texture currently bound in the Texture's target.

virtual GLint cinder::gl::TextureBase::getWidth ( ) const
pure virtual

Returns the width of the texture in pixels, ignoring clean bounds.

Implemented in cinder::gl::TextureCubeMap, cinder::gl::Texture3d, cinder::gl::Texture2d, and cinder::gl::Texture1d.

virtual GLint cinder::gl::TextureBase::getHeight ( ) const
pure virtual

Returns the height of the texture in pixels, ignoring clean bounds.

Implemented in cinder::gl::TextureCubeMap, cinder::gl::Texture3d, cinder::gl::Texture2d, and cinder::gl::Texture1d.

virtual GLint cinder::gl::TextureBase::getDepth ( ) const
pure virtual

Returns the depth of the texture in pixels, ignoring clean bounds.

Implemented in cinder::gl::TextureCubeMap, cinder::gl::Texture3d, cinder::gl::Texture2d, and cinder::gl::Texture1d.

float cinder::gl::TextureBase::getAspectRatio ( ) const

Returns the 2D aspect ratio of the texture (width / height), ignoring clean bounds.

Area cinder::gl::TextureBase::getBounds ( ) const

Returns the Area defining the Texture's bounds in pixels, ignoring clean bounds.

bool cinder::gl::TextureBase::hasAlpha ( ) const

Returns whether the Texture has an alpha channel based on its internal format.

void cinder::gl::TextureBase::setWrap ( 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 is GL_CLAMP_TO_EDGE.

void cinder::gl::TextureBase::setWrap ( 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 is GL_CLAMP_TO_EDGE.

void cinder::gl::TextureBase::setWrapS ( GLenum  wrapS)

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.

void cinder::gl::TextureBase::setWrapT ( 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 is GL_CLAMP_TO_EDGE.

void cinder::gl::TextureBase::setWrapR ( 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 is GL_CLAMP_TO_EDGE.

void cinder::gl::TextureBase::setMinFilter ( 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
void cinder::gl::TextureBase::setMagFilter ( 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
void cinder::gl::TextureBase::setMaxAnisotropy ( GLfloat  maxAnisotropy)

Sets the anisotropic filtering amount. A value greater than 1.0 "enables" anisotropic filtering. Maximum of getMaxAnisotropyMax();.

bool cinder::gl::TextureBase::hasMipmapping ( ) const

Returns whether the Texture has Mipmapping enabled.

void cinder::gl::TextureBase::setCompareMode ( GLenum  compareMode)
void cinder::gl::TextureBase::setCompareFunc ( GLenum  compareFunc)
GLenum cinder::gl::TextureBase::getBindingConstantForTarget ( GLenum  target)
static

Returns the appropriate parameter to glGetIntegerv() for a specific target; ie GL_TEXTURE_2D -> GL_TEXTURE_BINDING_2D. Returns 0 on failure.

void cinder::gl::TextureBase::getInternalFormatInfo ( GLint  internalFormat,
GLenum *  outDataFormat,
GLenum *  outDataType,
bool *  outAlpha = nullptr,
bool *  outCompressed = nullptr,
bool *  outSrgb = nullptr 
)
static

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.

int cinder::gl::TextureBase::requiredMipLevels ( GLint  width,
GLint  height,
GLint  depth 
)
static

Returns the number of mip levels necessary to represent a texture of width, height and depth.

template<typename T >
bool cinder::gl::TextureBase::surfaceRequiresIntermediate ( int32_t  width,
uint8_t  pixelBytes,
int32_t  rowBytes,
SurfaceChannelOrder  surfaceChannelOrder 
)
static

Returns whether a Surface of width, rowBytes and surfaceChannelOrder would require an intermediate Surface in order to be copied into a GL Texture.

template<typename T >
void cinder::gl::TextureBase::SurfaceChannelOrderToDataFormatAndType ( const SurfaceChannelOrder sco,
GLint *  dataFormat,
GLenum *  type 
)
static

Converts a SurfaceChannelOrder into an appropriate OpenGL dataFormat and type.

ivec2 cinder::gl::TextureBase::calcMipLevelSize ( int  level,
GLint  width,
GLint  height 
)
static

calculate the size of mipMap for the corresponding level

GLfloat cinder::gl::TextureBase::getMaxAnisotropyMax ( )
static

Returns the maximum anisotropic filtering maximum allowed by the hardware.

std::array<GLint,4> cinder::gl::TextureBase::getSwizzleMask ( ) const

Returns the Texture's swizzle mask (corresponding to GL_TEXTURE_SWIZZLE_RGBA)

bool cinder::gl::TextureBase::supportsHardwareSwizzle ( )
static

Returns whether this hardware supports texture swizzling (via GL_TEXTURE_SWIZZLE_RGBA)

const std::string& cinder::gl::TextureBase::getLabel ( ) const

Returns the debugging label associated with the Texture.

void cinder::gl::TextureBase::setLabel ( const std::string &  label)

Sets the debugging label associated with the Texture. Calls glObjectLabel() when available.

void cinder::gl::TextureBase::initParams ( Format format,
GLint  defaultInternalFormat,
GLint  defaultDataType 
)
protected
virtual void cinder::gl::TextureBase::printDims ( std::ostream &  os) const
protectedpure virtual

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const TextureBase rhs 
)
friend

Member Data Documentation

GLenum cinder::gl::TextureBase::mTarget
protected
GLuint cinder::gl::TextureBase::mTextureId
protected
GLint cinder::gl::TextureBase::mInternalFormat
mutableprotected
bool cinder::gl::TextureBase::mMipmapping
protected
GLint cinder::gl::TextureBase::mBaseMipmapLevel
protected
GLint cinder::gl::TextureBase::mMaxMipmapLevel
protected
bool cinder::gl::TextureBase::mDoNotDispose
protected
std::array<GLint,4> cinder::gl::TextureBase::mSwizzleMask
protected
std::string cinder::gl::TextureBase::mLabel
protected

The documentation for this class was generated from the following files: