This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
A wrapper class for an OpenGL texture. More...
#include <ofTexture.h>

Public Member Functions | |
ofTexture () | |
Construct an ofTexture instance. | |
ofTexture (const ofTexture &mom) | |
Construct an ofTexture from an existing ofTexture. | |
ofTexture (ofTexture &&mom) | |
virtual void | allocate (const ofTextureData &textureData) |
Allocate the texture using the given settings. | |
virtual void | allocate (const ofTextureData &textureData, int glFormat, int pixelType) |
Allocate the texture using the given settings and custom format. | |
virtual void | allocate (int w, int h, int glInternalFormat) |
Allocate texture of a given size and format. | |
virtual void | allocate (int w, int h, int glInternalFormat, int glFormat, int pixelType) |
Allocate texture of a given size and format. | |
virtual void | allocate (int w, int h, int glInternalFormat, bool bUseARBExtension) |
Allocate texture of a given size and format. Specify texture type. | |
virtual void | allocate (int w, int h, int glInternalFormat, bool bUseARBExtension, int glFormat, int pixelType) |
Allocate texture of a given size, format, & type. | |
virtual void | allocate (const ofPixels &pix) |
Allocate texture using an ofPixels instance. | |
virtual void | allocate (const ofPixels &pix, bool bUseARBExtension) |
Allocate texture using an ofPixels instance and type. | |
virtual void | allocate (const ofShortPixels &pix) |
Allocate texture using an ofShortPixels instance. | |
virtual void | allocate (const ofShortPixels &pix, bool bUseARBExtension) |
Allocate texture using an ofShortPixels instance and type. | |
virtual void | allocate (const ofFloatPixels &pix) |
Allocate texture using an ofFloatPixels instance. | |
virtual void | allocate (const ofFloatPixels &pix, bool bUseARBExtension) |
Allocate texture using an ofShortPixels instance and type. | |
void | allocateAsBufferTexture (const ofBufferObject &buffer, int glInternalFormat) |
Allocate texture as a Buffer Texture. | |
bool | isAllocated () const |
Determine whether the texture has been allocated. | |
OF_DEPRECATED_MSG ("Use isAllocated instead", bool bAllocated() const) | |
Has the texture been allocated? | |
virtual | ~ofTexture () |
Destroy an ofTexture instance. | |
ofTexture & | operator= (const ofTexture &mom) |
Copy a given ofTexture into this texture. | |
ofTexture & | operator= (ofTexture &&mom) |
void | clear () |
Clears the texture. | |
void | setUseExternalTextureID (GLuint externTexID) |
Set the texture ID. | |
void | loadData (const uint8_t *const data, int w, int h, int glFormat) |
Load byte pixel data. | |
void | loadData (const uint16_t *data, int w, int h, int glFormat) |
Load short (2 byte) pixel data. | |
void | loadData (const uint32_t *data, int w, int h, int glFormat) |
void | loadData (const int8_t *data, int w, int h, int glFormat) |
void | loadData (const int16_t *data, int w, int h, int glFormat) |
void | loadData (const int32_t *data, int w, int h, int glFormat) |
void | loadData (const float *data, int w, int h, int glFormat) |
Load float pixel data. | |
void | loadData (const ofPixels &pix) |
Load pixels from an ofPixels instance. | |
void | loadData (const ofShortPixels &pix) |
Load pixels from an ofShortPixels instance. | |
void | loadData (const ofFloatPixels &pix) |
Load pixels from an ofFloatPixels instance. | |
void | loadData (const ofPixels &pix, int glFormat) |
Load pixels from an ofPixels instance and specify the format. | |
void | loadData (const ofShortPixels &pix, int glFormat) |
Load pixels from an ofShortPixels instance & specify the format. | |
void | loadData (const ofFloatPixels &pix, int glFormat) |
Load pixels from an ofFloatPixels instance and specify the format. | |
void | loadData (const void *data, int w, int h, int glFormat, int glType) |
Load byte pixel data. | |
void | loadData (const ofBufferObject &buffer, int glFormat, int glType) |
Load pixels from an ofBufferObject. | |
void | loadScreenData (int x, int y, int w, int h) |
Copy an area of the screen into this texture. | |
void | draw (float x, float y) const |
void | draw (float x, float y, float z) const |
void | draw (const glm::vec3 &pos) const |
void | draw (float x, float y, float w, float h) const |
Draw at a position with the specified size. | |
void | draw (float x, float y, float z, float w, float h) const |
Draw the texture at a given size witdh and depth. | |
void | draw (const glm::vec3 &pos, float w, float h) const |
void | draw (const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &p3, const glm::vec3 &p4) const |
Draws the texture at 4 points passed in as if you created 4 glVertices. | |
void | drawSubsection (float x, float y, float w, float h, float sx, float sy) const |
Draw a subsection of the texture. | |
void | drawSubsection (float x, float y, float z, float w, float h, float sx, float sy) const |
Draw a subsection of the texture with depth. | |
void | drawSubsection (float x, float y, float w, float h, float sx, float sy, float sw, float sh) const |
Draw a subsection of the texture with an offset. | |
void | drawSubsection (const ofRectangle &drawBounds, const ofRectangle &subsectionBounds) const |
Draw a subsection of the texture with an offset. | |
void | drawSubsection (float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const |
Draw a subsection of the texture with an offset and depth. | |
ofMesh | getQuad (const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &p3, const glm::vec3 &p4) const |
ofMesh | getMeshForSubsection (float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh, bool vflipped, ofRectMode rectMode) const |
Get a mesh that has the texture coordinates set. | |
void | bind (int textureLocation=0) const |
Bind the texture. | |
void | unbind (int textureLocation=0) const |
Unbind the texture. | |
const ofTexture * | getAlphaMask () const |
float | getHeight () const |
Display height of texture. | |
float | getWidth () const |
Display width of texture. | |
void | setAnchorPercent (float xPct, float yPct) |
Set the anchor point the texture is drawn around as a percentage. | |
void | setAnchorPoint (float x, float y) |
Set the anchor point the texture is drawn around in pixels. | |
void | resetAnchor () |
Reset the anchor point to (0, 0). | |
glm::vec2 | getCoordFromPoint (float xPos, float yPos) const |
Helper to convert display coordinate to texture coordinate. | |
glm::vec2 | getCoordFromPercent (float xPts, float yPts) const |
Helper to convert display coordinate to texture coordinate. | |
void | setAlphaMask (ofTexture &mask) |
Set another ofTexture to use as an alpha mask. | |
void | disableAlphaMask () |
Disable the alpha mask. | |
void | setTextureWrap (GLint wrapModeHorizontal, GLint wrapModeVertical) |
Set texture wrapping. | |
void | setTextureMinMagFilter (GLint minFilter, GLint magFilter) |
Set texture minification/magnification scaling filters. | |
void | setTextureMatrix (const glm::mat4 &m) |
Sets a texture matrix to be uploaded whenever the texture is bound. | |
const glm::mat4 & | getTextureMatrix () const |
bool | isUsingTextureMatrix () const |
void | disableTextureMatrix () |
Disable the texture matrix. | |
void | setCompression (ofTexCompression compression) |
Set the texture compression. | |
void | setRGToRGBASwizzles (bool rToRGBSwizzles) |
Swizzle RGBA to grayscale with alpha in the red channel. | |
void | setSwizzle (GLenum srcSwizzle, GLenum dstChannel) |
Swizzle a channel to another. | |
void | readToPixels (ofPixels &pixels) const |
Read current texture data from the GPU into pixels. | |
void | readToPixels (ofShortPixels &pixels) const |
Read current texture data from the GPU into pixels. | |
void | readToPixels (ofFloatPixels &pixels) const |
Read current texture data from the GPU into pixels. | |
void | copyTo (ofBufferObject &buffer) const |
Copy the texture to an ofBufferObject. | |
ofTextureData & | getTextureData () |
Internal texture data access. | |
const ofTextureData & | getTextureData () const |
Const version of getTextureData(). | |
void | enableMipmap () |
Sets flag allowing texture to auto-generate a mipmap. | |
void | disableMipmap () |
Sets flag disallowing texture to auto-generate mipmap. | |
void | generateMipmap () |
Generate mipmap for the current texture. | |
bool | hasMipmap () const |
Find out if a mipmap has been generated for the current texture. | |
virtual void | draw (float x, float y) const |
Draw at a position at the native size. | |
virtual void | draw (float x, float y, float w, float h) const=0 |
Draw at a position with the specified size. | |
virtual void | draw (const glm::vec2 &point) const |
Draw at a position at the native size. | |
virtual void | draw (const ofRectangle &rect) const |
Draw at a position and size specified by a rectangle. | |
virtual void | draw (const glm::vec2 &point, float w, float h) const |
Draw at a position. | |
![]() | |
virtual | ~ofBaseDraws () |
Destroy the abstract object. | |
Public Attributes | |
ofTextureData | texData |
Protected Member Functions | |
void | enableTextureTarget (int textureLocation) const |
Enable a texture target. | |
void | disableTextureTarget (int textureLocation) const |
Disable a texture target. | |
Protected Attributes | |
glm::vec3 | anchor |
The texture's anchor point. | |
bool | bAnchorIsPct |
Detailed Description
A wrapper class for an OpenGL texture.
Constructor & Destructor Documentation
◆ ofTexture() [1/3]
ofTexture::ofTexture | ( | ) |
Construct an ofTexture instance.
and Allocation
◆ ofTexture() [2/3]
ofTexture::ofTexture | ( | const ofTexture & | mom | ) |
◆ ofTexture() [3/3]
ofTexture::ofTexture | ( | ofTexture && | mom | ) |
◆ ~ofTexture()
|
virtual |
Member Function Documentation
◆ allocate() [1/12]
|
virtual |
Allocate texture using an ofFloatPixels instance.
Same as void allocate(const ofPixels& pix), except using ofFloatPixels.
- See also
- allocate(const ofPixels& pix)
- Parameters
-
pix Reference to ofFloatPixels instance.
◆ allocate() [2/12]
|
virtual |
Allocate texture using an ofShortPixels instance and type.
Same as void void allocate(const ofPixels& pix), except using ofShortPixels.
- Parameters
-
pix Reference to ofFloatPixels instance. bUseARBExtension Set to true to use rectangular textures.
◆ allocate() [3/12]
|
virtual |
Allocate texture using an ofPixels instance.
- Todo:
- Not sure how the two texture format parameters are different: glFormat & glInternalFormat.
Pixel type and OpenGL format are determined from pixel settings.
- Parameters
-
pix Reference to ofPixels instance.
◆ allocate() [4/12]
|
virtual |
Allocate texture using an ofPixels instance and type.
This lets you overide the default OF texture type in case you need a square GL_TEXTURE_2D texture.
- Warning
- ARB textures are not available in OpenGL ES.
- Parameters
-
pix Reference to ofPixels instance. bUseARBExtension Set to true to use rectangular textures.
◆ allocate() [5/12]
|
virtual |
Allocate texture using an ofShortPixels instance.
Same as void allocate(const ofPixels& pix), except using ofShortPixels.
- See also
- allocate(const ofPixels& pix)
- Parameters
-
pix Reference to ofShortPixels instance.
◆ allocate() [6/12]
|
virtual |
Allocate texture using an ofShortPixels instance and type.
Same as void void allocate(const ofPixels& pix), except using ofShortPixels.
- Parameters
-
pix Reference to ofShortPixels instance. bUseARBExtension Set to true to use rectangular textures.
◆ allocate() [7/12]
|
virtual |
Allocate the texture using the given settings.
This is useful if you need manual control over loading a number of textures with the same settings. Make sure to set the texture data parameters first.
- Parameters
-
textureData The settings to use when allocating the ofTexture.
◆ allocate() [8/12]
|
virtual |
Allocate the texture using the given settings and custom format.
- Parameters
-
textureData The settings to use when allocating the ofTexture. glFormat GL texture format: GL_RGBA, GL_LUMINANCE, etc. pixelType GL pixel type: GL_UNSIGNED_BYTE, GL_FLOAT, etc.
◆ allocate() [9/12]
|
virtual |
Allocate texture of a given size and format.
The width (w) and height (h) do not necessarily need to be powers of 2, but they do need to be large enough to contain the data you will upload to the texture.
The internal data type glFormat
describes how OpenGL will store this texture internally. For example, if you want a grayscale texture, you can use GL_LUMINANCE
. You can upload what ever type of data you want (using loadData()
) but internally, opengl will store the information as grayscale. Other types include: GL_RGB
, GL_RGBA
.
This method applies the currently set OF texture type and defaults to ARB rectangular textures if they are supported. (They are not supported on OpenGL ES).
- Parameters
-
w Desired width in pixels. h Desired height in pixels. glInternalFormat OpenGL internal data format: GL_RGBA
,GL_LUMINANCE
, etc.
◆ allocate() [10/12]
|
virtual |
Allocate texture of a given size and format. Specify texture type.
This allows to enable the ARBE extension for this texture. This will overide the default OF texture type, in case you need a square texture (GL_TEXTURE_2D
).
- Warning
- ARB textures are not available in OpenGL ES.
- Parameters
-
w Desired width in pixels. h Desired height in pixels. glInternalFormat The internal openGL format. bUseARBExtension Set to true to use rectangular textures.
◆ allocate() [11/12]
|
virtual |
Allocate texture of a given size, format, & type.
- Parameters
-
w Desired width in pixels. h Desired height in pixels. glInternalFormat OpenGL data format: GL_RGBA
,GL_LUMINANCE
, etc.bUseARBExtension Set to true to use rectangular textures. glFormat The OpenGL format. pixelType OpenGL pixel type: GL_UNSIGNED_BYTE
,GL_FLOAT
, etc.
◆ allocate() [12/12]
|
virtual |
Allocate texture of a given size and format.
- Parameters
-
w Desired width in pixels. h Desired height in pixels. glInternalFormat The internal openGL format. glFormat The openGL format. pixelType GL pixel type: GL_UNSIGNED_BYTE, GL_FLOAT, etc.
◆ allocateAsBufferTexture()
void ofTexture::allocateAsBufferTexture | ( | const ofBufferObject & | buffer, |
int | glInternalFormat | ||
) |
Allocate texture as a Buffer Texture.
Uses a GPU buffer as data for the texture instead of pixels in RAM Allows to use texture buffer objects (TBO) which make it easier to send big amounts of data to a shader as a uniform.
Buffer textures are 1D textures, and may only be sampled using texelFetch in GLSL.
See textureBufferInstanceExample and https://www.opengl.org/wiki/Buffer_Texture
- See also
- allocate(const ofBufferObject & buffer, int glInternalFormat)
- Parameters
-
buffer Reference to ofBufferObject instance. glInternalFormat Internal pixel format of the data.
◆ bind()
void ofTexture::bind | ( | int | textureLocation = 0 | ) | const |
Bind the texture.
For advanced users who need to manually manage texture drawing without calling ofTexture::draw.
◆ clear()
void ofTexture::clear | ( | ) |
Clears the texture.
Clears / frees the texture memory, if something was already allocated. Useful if you need to control the memory on the graphics card.
The internal GL texture ID is only released if this is the last texture using it.
◆ copyTo()
void ofTexture::copyTo | ( | ofBufferObject & | buffer | ) | const |
Copy the texture to an ofBufferObject.
- Parameters
-
buffer the target buffer to copy to.
◆ disableAlphaMask()
void ofTexture::disableAlphaMask | ( | ) |
Disable the alpha mask.
◆ disableMipmap()
void ofTexture::disableMipmap | ( | ) |
Sets flag disallowing texture to auto-generate mipmap.
By default, this will set your minFilter to GL_LINEAR_MIPMAP_LINEAR. If you want to change your minFilter later use setTextureMinMagFilter()
If you want to generate a mipmap later, or at a specific point in your code, use ofTexture::generateMipmap() instead.
◆ disableTextureMatrix()
void ofTexture::disableTextureMatrix | ( | ) |
Disable the texture matrix.
Disable the texture matrix.
◆ disableTextureTarget()
|
protected |
Disable a texture target.
- Parameters
-
textureLocation the OpenGL texture ID to enable as a target.
◆ draw() [1/12]
|
virtual |
Draw at a position at the native size.
Native size is determined by getWidth() and getHeight().
- Parameters
-
point Draw position.
Reimplemented from ofBaseDraws.
◆ draw() [2/12]
|
virtual |
Draw at a position.
- Parameters
-
point Draw position. w Draw width. h Draw height.
Reimplemented from ofBaseDraws.
◆ draw() [3/12]
void ofTexture::draw | ( | const glm::vec3 & | p1, |
const glm::vec3 & | p2, | ||
const glm::vec3 & | p3, | ||
const glm::vec3 & | p4 | ||
) | const |
Draws the texture at 4 points passed in as if you created 4 glVertices.
- Parameters
-
p1 Upper left position on the x axis. p2 Upper left position on the y axis. p3 Lower right position on the x axis. p4 Lower right position on the y axis.
ps: maybe if bUsingArbTex is enabled we should use glActiveTextureARB?
◆ draw() [4/12]
void ofTexture::draw | ( | const glm::vec3 & | pos | ) | const |
◆ draw() [5/12]
void ofTexture::draw | ( | const glm::vec3 & | pos, |
float | w, | ||
float | h | ||
) | const |
◆ draw() [6/12]
|
virtual |
Draw at a position and size specified by a rectangle.
- Parameters
-
rect Draw position and size.
Reimplemented from ofBaseDraws.
◆ draw() [7/12]
|
inlinevirtual |
Draw at a position at the native size.
Native size is determined by getWidth() and getHeight().
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis.
Reimplemented from ofBaseDraws.
◆ draw() [8/12]
|
virtual |
Drawing
Reimplemented from ofBaseDraws.
◆ draw() [9/12]
|
virtual |
Draw at a position with the specified size.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. w Draw width. h Draw height.
Implements ofBaseDraws.
◆ draw() [10/12]
|
virtual |
Draw at a position with the specified size.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. w Draw width. h Draw height.
Implements ofBaseDraws.
◆ draw() [11/12]
void ofTexture::draw | ( | float | x, |
float | y, | ||
float | z | ||
) | const |
◆ draw() [12/12]
void ofTexture::draw | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h | ||
) | const |
Draw the texture at a given size witdh and depth.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. z Draw position on the z axis. w Draw width. h Draw height.
◆ drawSubsection() [1/5]
void ofTexture::drawSubsection | ( | const ofRectangle & | drawBounds, |
const ofRectangle & | subsectionBounds | ||
) | const |
Draw a subsection of the texture with an offset.
- See also
- drawSubsection(ofRectangle& drawBounds, ofRectangle& subsectionBounds)
- Parameters
-
drawBounds Draw position and dimensions. subsectionBounds Subsection position and dimensions within the texture.
◆ drawSubsection() [2/5]
void ofTexture::drawSubsection | ( | float | x, |
float | y, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy | ||
) | const |
Draw a subsection of the texture.
Like ofRect() depend on the current OF_RECT_MODE
:
OF_RECT_MODE_CORNER
: drawn with the upper left corner = (x,y)OF_RECT_MODE_CENTER
: drawn centered on (x,y)
- See also
- ofSetRectMode()
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. w Draw width. h Draw height. sx Subsection x axis offset within the texture. sy Subsection y axis offset within the texture.
◆ drawSubsection() [3/5]
void ofTexture::drawSubsection | ( | float | x, |
float | y, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy, | ||
float | sw, | ||
float | sh | ||
) | const |
Draw a subsection of the texture with an offset.
- See also
- drawSubsection(float x, float y, float w, float h, float sx, float sy)
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. w Draw width. h Draw height. sx Subsection x axis offset within the texture. sy Subsection y axis offset within the texture. sw Subsection width within the texture. sh Subsection height within the texture.
◆ drawSubsection() [4/5]
void ofTexture::drawSubsection | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy | ||
) | const |
Draw a subsection of the texture with depth.
- See also
- drawSubsection(float x, float y, float w, float h, float sx, float sy)
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. z Draw position on the z axis. w Draw width. h Draw height. sx Subsection x axis offset within the texture. sy Subsection y axis offset within the texture.
◆ drawSubsection() [5/5]
void ofTexture::drawSubsection | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy, | ||
float | sw, | ||
float | sh | ||
) | const |
Draw a subsection of the texture with an offset and depth.
- See also
- drawSubsection(float x, float y, float w, float h, float sx, float sy)
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. z Draw position on the z axis. w Draw width. h Draw height. sx Subsection x axis offset within the texture. sy Subsection y axis offset within the texture. sw Subsection width within the texture. sh Subsection height within the texture.
◆ enableMipmap()
void ofTexture::enableMipmap | ( | ) |
Sets flag allowing texture to auto-generate a mipmap.
Mipmapping
By default, this will set your minFilter to GL_LINEAR_MIPMAP_LINEAR. If you want to change your minFilter later use setTextureMinMagFilter()
If you want to generate a mipmap later, or at a specific point in your code, use generateMipmap() instead.
◆ enableTextureTarget()
|
protected |
Enable a texture target.
- Parameters
-
textureLocation the OpenGL texture ID to enable as a target.
◆ generateMipmap()
void ofTexture::generateMipmap | ( | ) |
Generate mipmap for the current texture.
- Warning
- Only GL_TEXTURE_RECTANGLE - which is the default openFrameworks texture target - does not support mipmaps, so make sure to call ofDisableArbTex() before loading texture data for a texture you want to generate mipmaps for.
- See also
- ofEnableArbTex()
- ofDisableArbTex()
OpenGL ES only supports mipmap for the following two texture targets:
OpenGL supports mipmaps for additional texture targets:
◆ getAlphaMask()
const ofTexture * ofTexture::getAlphaMask | ( | ) | const |
◆ getCoordFromPercent()
glm::vec2 ofTexture::getCoordFromPercent | ( | float | xPts, |
float | yPts | ||
) | const |
Helper to convert display coordinate to texture coordinate.
- Parameters
-
xPts Horizontal position in a normalized percentage (0 - 1). yPts Vertical position in a normalized percentage (0 - 1).
- Returns
- Texture coordinate or zero if texture is not allocated.
◆ getCoordFromPoint()
glm::vec2 ofTexture::getCoordFromPoint | ( | float | xPos, |
float | yPos | ||
) | const |
Helper to convert display coordinate to texture coordinate.
- Parameters
-
xPos Horizontal position in pixels. yPos Vertical position in pixels.
- Returns
- Texture coordinate or zero if texture is not allocated.
◆ getHeight()
|
virtual |
Display height of texture.
and Coordinates
Return value is pixel size (default) or normalized (0 - 1) if ofEnableNormalizedTextures() is set to true.
- See also
- ofEnabledNormalizedTextures()
- Returns
- Display height of texture in pixels.
Implements ofBaseDraws.
◆ getMeshForSubsection()
ofMesh ofTexture::getMeshForSubsection | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy, | ||
float | sw, | ||
float | sh, | ||
bool | vflipped, | ||
ofRectMode | rectMode | ||
) | const |
Get a mesh that has the texture coordinates set.
- See also
- drawSubsection(float x, float y, float w, float h, float sx, float sy)
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. z Draw position on the z axis. w Draw width. h Draw height. sx Subsection x axis offset within the texture. sy Subsection y axis offset within the texture. sw Subsection width within the texture. sh Subsection height within the texture. vflipped Takes into account the flipped state in OF. rectMode rectMode Taking x,y as the center or the top left corner.
◆ getQuad()
ofMesh ofTexture::getQuad | ( | const glm::vec3 & | p1, |
const glm::vec3 & | p2, | ||
const glm::vec3 & | p3, | ||
const glm::vec3 & | p4 | ||
) | const |
◆ getTextureData() [1/2]
ofTextureData & ofTexture::getTextureData | ( | ) |
◆ getTextureData() [2/2]
const ofTextureData & ofTexture::getTextureData | ( | ) | const |
Const version of getTextureData().
- See also
- ofTextureData::getTextureData()
◆ getTextureMatrix()
const glm::mat4 & ofTexture::getTextureMatrix | ( | ) | const |
◆ getWidth()
|
virtual |
Display width of texture.
Return value is pixel size (default) or normalized (0 - 1) if ofEnableNormalizedTextures() is set to true.
- See also
- ofEnabledNormalizedTextures()
- Returns
- Display width of texture in pixels.
Implements ofBaseDraws.
◆ hasMipmap()
bool ofTexture::hasMipmap | ( | ) | const |
Find out if a mipmap has been generated for the current texture.
- See also
- generateMipmap()
- enableMipmap()
◆ isAllocated()
bool ofTexture::isAllocated | ( | ) | const |
Determine whether the texture has been allocated.
This lets you check if a texture is safe to draw. The texture can both be allocated by using allocate()
or loading it with data loadData()
.
- Returns
- true if the texture has been allocated.
◆ isUsingTextureMatrix()
bool ofTexture::isUsingTextureMatrix | ( | ) | const |
◆ loadData() [1/15]
void ofTexture::loadData | ( | const float * | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
Load float pixel data.
- See also
- loadData(const unsigned char* const data, int w, int h, int glFormat)
- Parameters
-
data Pointer to byte pixel data. Must not be nullptr. w Pixel data width. h Pixel data height. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
◆ loadData() [2/15]
void ofTexture::loadData | ( | const int16_t * | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
◆ loadData() [3/15]
void ofTexture::loadData | ( | const int32_t * | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
◆ loadData() [4/15]
void ofTexture::loadData | ( | const int8_t * | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
◆ loadData() [5/15]
void ofTexture::loadData | ( | const ofBufferObject & | buffer, |
int | glFormat, | ||
int | glType | ||
) |
Load pixels from an ofBufferObject.
This is different to allocate(ofBufferObject,internal). That creates a texture which data lives in GL buffer while this copies the data from the buffer to the texture.
This is usually used to upload data to be shown asynchronously by using a buffer object binded as a PBO
- Parameters
-
buffer The buffer to load. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc. glType the GL type to load.
◆ loadData() [6/15]
void ofTexture::loadData | ( | const ofFloatPixels & | pix | ) |
Load pixels from an ofFloatPixels instance.
Same as loadData(ofPixels &) but for ofFloatPixels.
- See also
- loadData(const ofPixels & pix)
- Parameters
-
pix Reference to ofFloatPixels instance.
◆ loadData() [7/15]
void ofTexture::loadData | ( | const ofFloatPixels & | pix, |
int | glFormat | ||
) |
Load pixels from an ofFloatPixels instance and specify the format.
- Parameters
-
pix Reference to ofFloatPixels instance. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
◆ loadData() [8/15]
void ofTexture::loadData | ( | const ofPixels & | pix | ) |
Load pixels from an ofPixels instance.
- Parameters
-
pix Reference to ofPixels instance.
◆ loadData() [9/15]
void ofTexture::loadData | ( | const ofPixels & | pix, |
int | glFormat | ||
) |
Load pixels from an ofPixels instance and specify the format.
glFormat can be different to the internal format of the texture on each load, ie. we can upload GL_BGRA pixels into a GL_RGBA texture, but the number of channels need to match according to the OpenGL standard.
- Parameters
-
pix Reference to ofPixels instance. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
◆ loadData() [10/15]
void ofTexture::loadData | ( | const ofShortPixels & | pix | ) |
Load pixels from an ofShortPixels instance.
Same as loadData(ofPixels &) but for ofShortPixels.
- See also
- loadData(const ofPixels & pix)
- Parameters
-
pix Reference to ofShortPixels instance.
◆ loadData() [11/15]
void ofTexture::loadData | ( | const ofShortPixels & | pix, |
int | glFormat | ||
) |
Load pixels from an ofShortPixels instance & specify the format.
- Parameters
-
pix Reference to ofShortPixels instance. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
◆ loadData() [12/15]
void ofTexture::loadData | ( | const uint16_t * | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
Load short (2 byte) pixel data.
- See also
- loadData(const unsigned char* const data, int w, int h, int glFormat)
- Parameters
-
data Pointer to byte pixel data. Must not be nullptr. w Pixel data width. h Pixel data height. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
◆ loadData() [13/15]
void ofTexture::loadData | ( | const uint32_t * | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
◆ loadData() [14/15]
void ofTexture::loadData | ( | const uint8_t *const | data, |
int | w, | ||
int | h, | ||
int | glFormat | ||
) |
Load byte pixel data.
glFormat can be different to the internal format of the texture on each load, i.e. we can upload GL_BGRA pixels into a GL_RGBA texture but the number of channels need to match according to the OpenGL standard.
- Parameters
-
data Pointer to byte pixel data. Must not be nullptr. w Pixel data width. h Pixel data height. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
◆ loadData() [15/15]
void ofTexture::loadData | ( | const void * | data, |
int | w, | ||
int | h, | ||
int | glFormat, | ||
int | glType | ||
) |
Load byte pixel data.
glFormat can be different to the internal format of the texture on each load, i.e. we can upload GL_BGRA pixels into a GL_RGBA texture but the number of channels need to match according to the OpenGL standard.
- Parameters
-
data Pointer to byte pixel data. Must not be nullptr. w Pixel data width. h Pixel data height. glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc. glType the OpenGL type of the data.
◆ loadScreenData()
void ofTexture::loadScreenData | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Copy an area of the screen into this texture.
Specifiy the position (x,y) you wish to grab from, with the width (w) and height (h) of the region.
Make sure that you have allocated your texture (using allocate()
) to be large enough to hold the region of the screen you wish to load.
- Parameters
-
x Upper left corner horizontal screen position. y Upper left corner vertical screen position. w Width of the area to copy in pixels. h Height of the area to copy in pixels.
◆ OF_DEPRECATED_MSG()
ofTexture::OF_DEPRECATED_MSG | ( | "Use isAllocated instead" | , |
bool bAllocated() const | |||
) |
Has the texture been allocated?
Legacy function for backwards compatibility.
- Returns
- true if the texture has been allocated.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ readToPixels() [1/3]
void ofTexture::readToPixels | ( | ofFloatPixels & | pixels | ) | const |
Read current texture data from the GPU into pixels.
- Warning
- This is not supported in OpenGL ES and does nothing.
- Parameters
-
pixels Target pixels reference.
◆ readToPixels() [2/3]
void ofTexture::readToPixels | ( | ofPixels & | pixels | ) | const |
◆ readToPixels() [3/3]
void ofTexture::readToPixels | ( | ofShortPixels & | pixels | ) | const |
Read current texture data from the GPU into pixels.
- Warning
- This is not supported in OpenGL ES and does nothing.
- Parameters
-
pixels Target pixels reference.
◆ resetAnchor()
|
virtual |
Reset the anchor point to (0, 0).
Reimplemented from ofBaseDraws.
◆ setAlphaMask()
void ofTexture::setAlphaMask | ( | ofTexture & | mask | ) |
Set another ofTexture to use as an alpha mask.
Settings
- Parameters
-
mask The texture to use as alpha mask.
◆ setAnchorPercent()
|
virtual |
Set the anchor point the texture is drawn around as a percentage.
This can be useful if you want to rotate an image around a particular point.
- Parameters
-
xPct Horizontal texture position as a percentage (0 - 1). yPct Vertical texture position as a percentage (0 - 1).
Reimplemented from ofBaseDraws.
◆ setAnchorPoint()
|
virtual |
Set the anchor point the texture is drawn around in pixels.
This can be useful if you want to rotate an image around a particular point.
- Parameters
-
x Horizontal texture position in pixels. y Vertical texture position in pixels.
Reimplemented from ofBaseDraws.
◆ setCompression()
void ofTexture::setCompression | ( | ofTexCompression | compression | ) |
◆ setRGToRGBASwizzles()
void ofTexture::setRGToRGBASwizzles | ( | bool | rToRGBSwizzles | ) |
Swizzle RGBA to grayscale with alpha in the red channel.
- Todo:
- Define Swizzle in the documentation.
Use 1 channel GL_R as luminance instead of red channel in OpenGL 3+.
- Warning
- This is not supported in OpenGL ES and does nothing.
◆ setSwizzle()
void ofTexture::setSwizzle | ( | GLenum | srcSwizzle, |
GLenum | dstChannel | ||
) |
Swizzle a channel to another.
Example:
will make channel 0 appear as alpha in the shader.
- Warning
- This is not supported in OpenGL ES and does nothing.
◆ setTextureMatrix()
void ofTexture::setTextureMatrix | ( | const glm::mat4 & | m | ) |
Sets a texture matrix to be uploaded whenever the texture is bound.
- Parameters
-
m The 4x4 texture matrix.
Sets a texture matrix that will be uploaded whenever the texture is binded.
◆ setTextureMinMagFilter()
void ofTexture::setTextureMinMagFilter | ( | GLint | minFilter, |
GLint | magFilter | ||
) |
Set texture minification/magnification scaling filters.
Controls how OpenGL will scale this texture.
- See also
- http://www.opengl.org/sdk/docs/man4/html/glTexParameter.xhtml
- ofTextureSetMinMagFilters()
- Warning
- May be overridden.
- Parameters
-
minFilter minifying filter for scaling a pixel to a smaller area. magFilter magnifying filter for scaling a pixel to a larger area.
◆ setTextureWrap()
void ofTexture::setTextureWrap | ( | GLint | wrapModeHorizontal, |
GLint | wrapModeVertical | ||
) |
Set texture wrapping.
By default, textures are clamped to their edges with GL_CLAMP_TO_EDGE
. Setting a repeat mode like GL_REPEAT
allows you to create tiled backgrounds with small textures.
- See also
- ofTextureSetWrap()
- http://www.opengl.org/sdk/docs/man4/html/glTexParameter.xhtml
- Warning
- May be overridden.
- Parameters
-
wrapModeHorizontal wrap parameter for texture coordinate s. wrapModeVertical wrap parameter for texture coordinate t.
◆ setUseExternalTextureID()
void ofTexture::setUseExternalTextureID | ( | GLuint | externTexID | ) |
Set the texture ID.
Allows you to point the texture id to an externally allocated id (perhaps from another texture). It's up to you to set the rest of the textData parameters manually.
- Warning
- When setting an external texture ID, the user must set the remaining ofTextureData parameters manually.
- Parameters
-
externTexID New texture ID.
◆ unbind()
void ofTexture::unbind | ( | int | textureLocation = 0 | ) | const |
Unbind the texture.
For advanced users who need to manually manage texture drawing without calling ofTexture::draw.
Member Data Documentation
◆ anchor
|
protected |
The texture's anchor point.
◆ bAnchorIsPct
|
protected |
Is the anchor point represented as a normalized (0 - 1) coordinate?
◆ texData
ofTextureData ofTexture::texData |
Internal texture data access. For backwards compatibility.
The documentation for this class was generated from the following files:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/gl/ofTexture.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/gl/ofTexture.cpp