Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cinder::dx::Texture Class Reference

Represents an OpenGL Texture. Implicitly shared object. More...

#include <DxTexture.h>

Classes

struct  Format
 

Public Member Functions

 ~Texture ()
 
void setDoNotDispose (bool aDoNotDispose=true)
 Constructs a Texture based on an externally initialized OpenGL texture. aDoNotDispose specifies whether the Texture is responsible for disposing of the associated OpenGL resource. More...
 
void setWrap (D3D11_TEXTURE_ADDRESS_MODE wrapS, D3D11_TEXTURE_ADDRESS_MODE wrapT)
 Sets the wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_BORDER and D3D11_TEXTURE_ADDRESS_MIRROR_ONCE. More...
 
void setWrapS (D3D11_TEXTURE_ADDRESS_MODE wrapS)
 Sets the horizontal wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_BORDER and D3D11_TEXTURE_ADDRESS_MIRROR_ONCE. More...
 
void setWrapT (D3D11_TEXTURE_ADDRESS_MODE wrapT)
 Sets the vertical wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_BORDER and D3D11_TEXTURE_ADDRESS_MIRROR_ONCE. More...
 
void setFilter (D3D11_FILTER filter)
 Sets the filtering behavior when a texture is displayed at a different resolution than its native resolution. Way too many to list. Look it up on the MSDN. More...
 
void setCleanTexCoords (float maxU, float maxV)
 
void update (const Surface &surface)
 Replaces the pixels of a texture with contents of surface. Expects surface's size to match the Texture's. More...
 
void update (const Surface32f &surface)
 Replaces the pixels of a texture with contents of surface. Expects surface's size to match the Texture's. More...
 
void update (const Surface &surface, const Area &area)
 Replaces the pixels of a texture with contents of surface. Expects area's size to match the Texture's. More...
 
void update (const Channel &channel)
 Replaces the pixels of a texture with contents of channel. Expects channel's size to match the Texture's. More...
 
void update (const Channel32f &channel)
 Replaces the pixels of a texture with contents of channel. Expects channel's size to match the Texture's. More...
 
void update (const Channel8u &channel, const Area &area)
 Replaces the pixels of a texture with contents of channel. Expects area's size to match the Texture's. More...
 
UINT getWidth () const
 the width of the texture in pixels More...
 
UINT getHeight () const
 the height of the texture in pixels More...
 
UINT getCleanWidth () const
 the width of the texture in pixels accounting for its "clean" area - More...
 
UINT getCleanHeight () const
 the height of the texture in pixels accounting for its "clean" area - More...
 
Vec2i getSize () const
 the size of the texture in pixels More...
 
float getAspectRatio () const
 the aspect ratio of the texture (width / height) More...
 
Area getBounds () const
 the Area defining the Texture's bounds in pixels: [0,0]-[width,height] More...
 
Area getCleanBounds () const
 the Area defining the Texture's clean pixel bounds in pixels: [0,0]-[width*maxU,height*maxV] More...
 
bool hasAlpha () const
 whether the texture has an alpha channel More...
 
float getLeft () const
 These return the right thing even when the texture coordinate space is flipped. More...
 
float getRight () const
 
float getTop () const
 
float getBottom () const
 
float getMaxU () const
 These do not correspond to "top" and "right" when the texture is flipped. More...
 
float getMaxV () const
 
Rectf getAreaTexCoords (const Area &area) const
 Returns the UV coordinates which correspond to the pixels contained in area. Does not compensate for clean coordinates. Does compensate for flipping. More...
 
DXGI_FORMAT 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 More...
 
bool isFlipped () const
 the target associated with texture. Typical values are GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB More...
 
void setFlipped (bool aFlipped=true)
 Marks the texture as being flipped vertically or not. More...
 
void bind (UINT textureUnit=0) const
 Binds the Texture's texture to its target in the multitexturing unit GL_TEXTURE0 + textureUnit. More...
 
void unbind (UINT textureUnit=0) const
 Unbinds the Texture currently bound in the Texture's target. More...
 
ID3D11Texture2D * getDxTexture ()
 
ID3D11ShaderResourceView * getDxShaderResourceView ()
 
 operator ImageSourceRef () const
 Returns an ImageSource pointing to this Texture. More...
 

Static Public Member Functions

static TextureRef create (int width, int height, Format format=Format())
 
static TextureRef create (const unsigned char *data, DXGI_FORMAT dataFormat, int width, int height, Format format=Format())
 
static TextureRef create (const Surface8u &surface, Format format=Format())
 
static TextureRef create (const Surface32f &surface, Format format=Format())
 
static TextureRef create (const Channel8u &channel, Format format=Format())
 Constructs a Texture based on the contents of channel. More...
 
static TextureRef create (const Channel32f &channel, Format format=Format())
 Constructs a Texture based on the contents of channel. More...
 
static TextureRef create (ImageSourceRef imageSource, Format format=Format())
 Constructs a texture based on imageSource. More...
 
static TextureRef loadDds (IStreamRef ddsStream, Format format)
 Creates a new Texture from raw DirectDraw Stream data. More...
 
static void SurfaceChannelOrderToDataFormatAndType (const SurfaceChannelOrder &sco, DXGI_FORMAT *dataFormat, CinderDxgiChannel *type, bool isSurface32f=false)
 Converts a SurfaceChannelOrder into an appropriate DXGI dataFormat and type. More...
 
static bool dataFormatHasAlpha (DXGI_FORMAT dataFormat)
 Returns whether a given DXGI dataFormat contains an alpha channel. More...
 
static bool dataFormatHasColor (DXGI_FORMAT dataFormat)
 Returns whether a give OpenGL dataFormat contains color channels. More...
 
static uint32_t dataFormatNumChannels (DXGI_FORMAT dataFormat)
 Returns the number of channels for the given DXGI dataFormat. More...
 

Protected Member Functions

 Texture ()
 
 Texture (int width, int height, Format format=Format())
 Constructs a texture of size(aWidth, aHeight), storing the data in internal format aInternalFormat. More...
 
 Texture (const unsigned char *data, DXGI_FORMAT dataFormat, int aWidth, int aHeight, Format format=Format())
 Constructs a texture of size(aWidth, aHeight), storing the data in internal format aInternalFormat. Pixel data is provided by data and is expected to be interleaved and in format dataFormat, for which GL_RGB or GL_RGBA would be typical values. More...
 
 Texture (const Surface8u &surface, Format format=Format())
 Constructs a texture based on the contents of surface. A default value of -1 for internalFormat chooses an appropriate internal format automatically. More...
 
 Texture (const Surface32f &surface, Format format=Format())
 Constructs a texture based on the contents of surface. A default value of -1 for internalFormat chooses an appropriate internal format automatically. More...
 
 Texture (const Channel8u &channel, 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. More...
 
 Texture (const Channel32f &channel, 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. More...
 
 Texture (ImageSourceRef imageSource, 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. More...
 
void init (int width, int height)
 
void init (const unsigned char *srcData, DXGI_FORMAT srcDataFormat, const Format &format)
 
void init (const float *srcData, DXGI_FORMAT srcDataFormat, const Format &format)
 
void init (ImageSourceRef imageSource, const Format &format)
 

Protected Attributes

UINT mWidth
 
UINT mHeight
 
UINT mCleanWidth
 
UINT mCleanHeight
 
float mMaxU
 
float mMaxV
 
DXGI_FORMAT mInternalFormat
 
bool mDoNotDispose
 
bool mFlipped
 
ID3D11Texture2D * mDxTexture
 
D3D11_SAMPLER_DESC mSamplerDesc
 
ID3D11SamplerState * mSamplerState
 
ID3D11ShaderResourceView * mSRV
 

Detailed Description

Represents an OpenGL Texture. Implicitly shared object.

See also
Images in Cinder

Constructor & Destructor Documentation

cinder::dx::Texture::~Texture ( )
cinder::dx::Texture::Texture ( )
protected
cinder::dx::Texture::Texture ( int  width,
int  height,
Format  format = Format() 
)
protected

Constructs a texture of size(aWidth, aHeight), storing the data in internal format aInternalFormat.

cinder::dx::Texture::Texture ( const unsigned char *  data,
DXGI_FORMAT  dataFormat,
int  aWidth,
int  aHeight,
Format  format = Format() 
)
protected

Constructs a texture of size(aWidth, aHeight), storing the data in internal format aInternalFormat. Pixel data is provided by data and is expected to be interleaved and in format dataFormat, for which GL_RGB or GL_RGBA would be typical values.

cinder::dx::Texture::Texture ( const Surface8u surface,
Format  format = Format() 
)
protected

Constructs a texture based on the contents of surface. A default value of -1 for internalFormat chooses an appropriate internal format automatically.

cinder::dx::Texture::Texture ( const Surface32f surface,
Format  format = Format() 
)
protected

Constructs a texture based on the contents of surface. A default value of -1 for internalFormat chooses an appropriate internal format automatically.

cinder::dx::Texture::Texture ( const Channel8u channel,
Format  format = Format() 
)
protected

Constructs a texture based on the contents of channel. A default value of -1 for internalFormat chooses an appropriate internal format automatically.

cinder::dx::Texture::Texture ( const Channel32f channel,
Format  format = Format() 
)
protected

Constructs a texture based on the contents of channel. A default value of -1 for internalFormat chooses an appropriate internal format automatically.

cinder::dx::Texture::Texture ( ImageSourceRef  imageSource,
Format  format = Format() 
)
protected

Constructs a texture based on imageSource. A default value of -1 for internalFormat chooses an appropriate internal format based on the contents of imageSource.

Member Function Documentation

static TextureRef cinder::dx::Texture::create ( int  width,
int  height,
Format  format = Format() 
)
static

Constructs a texture of size(width, height)

static TextureRef cinder::dx::Texture::create ( const unsigned char *  data,
DXGI_FORMAT  dataFormat,
int  width,
int  height,
Format  format = Format() 
)
static

Constructs a texture of size(width, height). Pixel data is provided by data and is expected to be interleaved and in format dataFormat

static TextureRef cinder::dx::Texture::create ( const Surface8u surface,
Format  format = Format() 
)
static

Constructs a texture based on the contents of surface

static TextureRef cinder::dx::Texture::create ( const Surface32f surface,
Format  format = Format() 
)
static

Constructs a texture based on the contents of surface.

static TextureRef cinder::dx::Texture::create ( const Channel8u channel,
Format  format = Format() 
)
static

Constructs a Texture based on the contents of channel.

static TextureRef cinder::dx::Texture::create ( const Channel32f channel,
Format  format = Format() 
)
static

Constructs a Texture based on the contents of channel.

static TextureRef cinder::dx::Texture::create ( ImageSourceRef  imageSource,
Format  format = Format() 
)
static

Constructs a texture based on imageSource.

void cinder::dx::Texture::setDoNotDispose ( bool  aDoNotDispose = true)

Constructs a Texture based on an externally initialized OpenGL texture. aDoNotDispose specifies whether the Texture is responsible for disposing of the associated OpenGL resource.

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

void cinder::dx::Texture::setWrap ( D3D11_TEXTURE_ADDRESS_MODE  wrapS,
D3D11_TEXTURE_ADDRESS_MODE  wrapT 
)

Sets the wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_BORDER and D3D11_TEXTURE_ADDRESS_MIRROR_ONCE.

void cinder::dx::Texture::setWrapS ( D3D11_TEXTURE_ADDRESS_MODE  wrapS)

Sets the horizontal wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_BORDER and D3D11_TEXTURE_ADDRESS_MIRROR_ONCE.

void cinder::dx::Texture::setWrapT ( D3D11_TEXTURE_ADDRESS_MODE  wrapT)

Sets the vertical wrapping behavior when a texture coordinate falls outside the range of [0,1]. Possible values are D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_BORDER and D3D11_TEXTURE_ADDRESS_MIRROR_ONCE.

void cinder::dx::Texture::setFilter ( D3D11_FILTER  filter)

Sets the filtering behavior when a texture is displayed at a different resolution than its native resolution. Way too many to list. Look it up on the MSDN.

void cinder::dx::Texture::setCleanTexCoords ( float  maxU,
float  maxV 
)

Designed to accommodate texture where not all pixels are "clean", meaning the maximum texture coordinate value may not be 1.0 (or the texture's width in GL_TEXTURE_RECTANGLE_ARB)

void cinder::dx::Texture::update ( const Surface surface)

Replaces the pixels of a texture with contents of surface. Expects surface's size to match the Texture's.

void cinder::dx::Texture::update ( const Surface32f surface)

Replaces the pixels of a texture with contents of surface. Expects surface's size to match the Texture's.

void cinder::dx::Texture::update ( const Surface surface,
const Area area 
)

Replaces the pixels of a texture with contents of surface. Expects area's size to match the Texture's.

void cinder::dx::Texture::update ( const Channel channel)

Replaces the pixels of a texture with contents of channel. Expects channel's size to match the Texture's.

void cinder::dx::Texture::update ( const Channel32f channel)

Replaces the pixels of a texture with contents of channel. Expects channel's size to match the Texture's.

void cinder::dx::Texture::update ( const Channel8u channel,
const Area area 
)

Replaces the pixels of a texture with contents of channel. Expects area's size to match the Texture's.

UINT cinder::dx::Texture::getWidth ( ) const

the width of the texture in pixels

UINT cinder::dx::Texture::getHeight ( ) const

the height of the texture in pixels

UINT cinder::dx::Texture::getCleanWidth ( ) const

the width of the texture in pixels accounting for its "clean" area -

See also
getCleanBounds()
UINT cinder::dx::Texture::getCleanHeight ( ) const

the height of the texture in pixels accounting for its "clean" area -

See also
getCleanBounds()
Vec2i cinder::dx::Texture::getSize ( ) const

the size of the texture in pixels

float cinder::dx::Texture::getAspectRatio ( ) const

the aspect ratio of the texture (width / height)

Area cinder::dx::Texture::getBounds ( ) const

the Area defining the Texture's bounds in pixels: [0,0]-[width,height]

Area cinder::dx::Texture::getCleanBounds ( ) const

the Area defining the Texture's clean pixel bounds in pixels: [0,0]-[width*maxU,height*maxV]

bool cinder::dx::Texture::hasAlpha ( ) const

whether the texture has an alpha channel

float cinder::dx::Texture::getLeft ( ) const

These return the right thing even when the texture coordinate space is flipped.

float cinder::dx::Texture::getRight ( ) const
float cinder::dx::Texture::getTop ( ) const
float cinder::dx::Texture::getBottom ( ) const
float cinder::dx::Texture::getMaxU ( ) const

These do not correspond to "top" and "right" when the texture is flipped.

float cinder::dx::Texture::getMaxV ( ) const
Rectf cinder::dx::Texture::getAreaTexCoords ( const Area area) const

Returns the UV coordinates which correspond to the pixels contained in area. Does not compensate for clean coordinates. Does compensate for flipping.

DXGI_FORMAT cinder::dx::Texture::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

bool cinder::dx::Texture::isFlipped ( ) const

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

whether the texture is flipped vertically

void cinder::dx::Texture::setFlipped ( bool  aFlipped = true)

Marks the texture as being flipped vertically or not.

void cinder::dx::Texture::bind ( UINT  textureUnit = 0) const

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

void cinder::dx::Texture::unbind ( UINT  textureUnit = 0) const

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

TextureRef cinder::dx::Texture::loadDds ( IStreamRef  ddsStream,
Format  format 
)
static

Creates a new Texture from raw DirectDraw Stream data.

void cinder::dx::Texture::SurfaceChannelOrderToDataFormatAndType ( const SurfaceChannelOrder sco,
DXGI_FORMAT *  dataFormat,
CinderDxgiChannel type,
bool  isSurface32f = false 
)
static

Converts a SurfaceChannelOrder into an appropriate DXGI dataFormat and type.

bool cinder::dx::Texture::dataFormatHasAlpha ( DXGI_FORMAT  dataFormat)
static

Returns whether a given DXGI dataFormat contains an alpha channel.

bool cinder::dx::Texture::dataFormatHasColor ( DXGI_FORMAT  dataFormat)
static

Returns whether a give OpenGL dataFormat contains color channels.

uint32_t cinder::dx::Texture::dataFormatNumChannels ( DXGI_FORMAT  dataFormat)
static

Returns the number of channels for the given DXGI dataFormat.

ID3D11Texture2D* cinder::dx::Texture::getDxTexture ( )
ID3D11ShaderResourceView* cinder::dx::Texture::getDxShaderResourceView ( )
cinder::dx::Texture::operator ImageSourceRef ( ) const

Returns an ImageSource pointing to this Texture.

void cinder::dx::Texture::init ( int  width,
int  height 
)
protected
void cinder::dx::Texture::init ( const unsigned char *  srcData,
DXGI_FORMAT  srcDataFormat,
const Format format 
)
protected
void cinder::dx::Texture::init ( const float *  srcData,
DXGI_FORMAT  srcDataFormat,
const Format format 
)
protected
void cinder::dx::Texture::init ( ImageSourceRef  imageSource,
const Format format 
)
protected

Member Data Documentation

UINT cinder::dx::Texture::mWidth
mutableprotected
UINT cinder::dx::Texture::mHeight
mutableprotected
UINT cinder::dx::Texture::mCleanWidth
mutableprotected
UINT cinder::dx::Texture::mCleanHeight
mutableprotected
float cinder::dx::Texture::mMaxU
protected
float cinder::dx::Texture::mMaxV
protected
DXGI_FORMAT cinder::dx::Texture::mInternalFormat
protected
bool cinder::dx::Texture::mDoNotDispose
protected
bool cinder::dx::Texture::mFlipped
protected
ID3D11Texture2D* cinder::dx::Texture::mDxTexture
protected
D3D11_SAMPLER_DESC cinder::dx::Texture::mSamplerDesc
protected
ID3D11SamplerState* cinder::dx::Texture::mSamplerState
protected
ID3D11ShaderResourceView* cinder::dx::Texture::mSRV
protected

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