class methods
- allocate()
- allocateAsBufferTexture()
- bind()
- bindAsImage()
- clear()
- copyTo()
- disableAlphaMask()
- disableMipmap()
- disableTextureMatrix()
- draw()
- drawSubsection()
- enableMipmap()
- generateMipmap()
- getAlphaMask()
- getCoordFromPercent()
- getCoordFromPoint()
- getHeight()
- getMeshForSubsection()
- getQuad()
- getTextureData()
- getTextureMatrix()
- getWidth()
- hasMipmap()
- isAllocated()
- isUsingTextureMatrix()
- loadData()
- loadScreenData()
- operator=()
- readToPixels()
- resetAnchor()
- setAlphaMask()
- setAnchorPercent()
- setAnchorPoint()
- setCompression()
- setRGToRGBASwizzles()
- setSwizzle()
- setTextureMatrix()
- setTextureMinMagFilter()
- setTextureWrap()
- setUseExternalTextureID()
- unbind()
global functions
Extends
This class extends others, you can call their methods on an instance of ofTexture too:
ofTexture is used to create textures that live on your graphics card from bitmap data that can then be used to fill other drawn objects, like a bitmap fill on a rectangle. When you draw an ofImage, you're actually just drawing a rectangle of points and then using an ofTexture to fill the space between those points. At it's core, ofTexture is a wrapper for OpenGL textures. It allows use of non-power of 2 textures in opengl, and to upload and draw graphical data.
Documentation from code comments
A wrapper class for an OpenGL texture.
ofTexture(...)
ofTexture::ofTexture(const ofTexture &mom)
allocate(...)
void ofTexture::allocate(const ofFloatPixels &pix)
Documentation from code comments
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(...)
void ofTexture::allocate(const ofFloatPixels &pix, bool bUseARBExtension)
Documentation from code comments
Allocate texture using an ofShortPixels instance and type.
Same as void void allocate(const ofPixels& pix), except using ofShortPixels.
See also: allocate(const ofFloatPixels& pix)
Parameters:
pix Reference to ofFloatPixels instance.
bUseARBExtension Set to true to use rectangular textures.
allocate(...)
void ofTexture::allocate(const ofPixels &pix)
allocate(...)
void ofTexture::allocate(const ofPixels &pix, bool bUseARBExtension)
Documentation from code comments
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.
See also: ofEnableArbTex()
See also: allocate(const ofPixels& pix)
Parameters:
pix Reference to ofPixels instance.
bUseARBExtension Set to true to use rectangular textures.
allocate(...)
void ofTexture::allocate(const ofShortPixels &pix)
Documentation from code comments
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(...)
void ofTexture::allocate(const ofShortPixels &pix, bool bUseARBExtension)
Documentation from code comments
Allocate texture using an ofShortPixels instance and type.
Same as void void allocate(const ofPixels& pix), except using ofShortPixels.
See also: allocate(const ofShortPixels& pix)
Parameters:
pix Reference to ofShortPixels instance.
bUseARBExtension Set to true to use rectangular textures.
allocate(...)
void ofTexture::allocate(const ofTextureData &textureData)
Documentation from code comments
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(...)
void ofTexture::allocate(const ofTextureData &textureData, int glFormat, int pixelType)
Documentation from code comments
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(...)
void ofTexture::allocate(int w, int h, int glInternalFormat)
This is the call to allocate opengl texture. 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 describes how opengl will store this texture internally. For example, if you want a grayscale texture, you can use "GL_LUMINANCE". You can uplaod 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. You need to allocate the texture before drawing it or loading data into it. uses the currently set OF texture type - default ARB texture
Documentation from code comments
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(...)
void ofTexture::allocate(int w, int h, int glInternalFormat, bool bUseARBExtension)
See previous allocate for knowing the behaviour of this function. The parameter bUseARBEExtension allow the user to enable the ARBE extension for this texture. You need to allocate the texture before drawing it or loading data into it, lets you overide the default OF texture type
Documentation from code comments
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.
See also: ofEnableArbTex()
See also: allocate(int w, int h, int glInternalFormat)
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(...)
void ofTexture::allocate(int w, int h, int glInternalFormat, bool bUseARBExtension, int glFormat, int pixelType)
Documentation from code comments
Allocate texture of a given size, format, & type.
See also: allocate(int w, int h, int glInternalFormat)
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(...)
void ofTexture::allocate(int w, int h, int glInternalFormat, int glFormat, int pixelType)
Documentation from code comments
Allocate texture of a given size and format.
See also: allocate(int w, int h, int glInternalFormat)
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)
Documentation from code comments
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)
This is for the advanced user who wants to draw textures in their own way. Each set of vertices that you draw after calling bind() will be textured using this texture.
Documentation from code comments
Bind the texture.
For advanced users who need to manually manage texture drawing without calling ofTexture::draw.
See also: http://www.opengl.org/sdk/docs/man4/html/glBindTexture.xhtml
bindAsImage(...)
void ofTexture::bindAsImage(GLuint unit, GLenum access, GLint level=0, GLboolean layered, GLint layer=0)
Documentation from code comments
Calls glBindImageTexture on the texture
Binds the texture as an read or write image, only available since OpenGL 4.2
Warning: This is not available in OpenGLES
See also: http://www.opengl.org/wiki/GLAPI/glBindImageTexture
clear()
void ofTexture::clear()
clears / frees the texture memory, if something was already allocated. useful if you need to control the memory on the graphics card. Clears all the data from the texture
Documentation from code comments
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)
Documentation from code comments
Copy the texture to an ofBufferObject.
Parameters:
buffer the target buffer to copy to.
disableAlphaMask()
void ofTexture::disableAlphaMask()
Documentation from code comments
Disable the alpha mask.
disableMipmap()
void ofTexture::disableMipmap()
Documentation from code comments
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.
See also: generateMipmap()
See also: enableMipmap()
See also: setTextureMinMagFilter()
disableTextureMatrix()
void ofTexture::disableTextureMatrix()
Documentation from code comments
Disable the texture matrix. Disable the texture matrix.
draw(...)
void ofTexture::draw(const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &p3, const glm::vec3 &p4)
Documentation from code comments
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.
draw(...)
void ofTexture::draw(const glm::vec3 &pos, float w, float h)
Draws the texture at 4 points passed in as if you created 4 glVertices.
draw(...)
void ofTexture::draw(float x, float y)
Draws the texture at a given point (x,y), using the textures true width and height. Draws the texture at the point passed in.
Documentation from code comments
\section Drawing
draw(...)
void ofTexture::draw(float x, float y, float w, float h)
draws the texture at a given point (x,y), with a given width (w) and height (h). Draws the texture at the x, y and w, h.
draw(...)
void ofTexture::draw(float x, float y, float z)
Draws the texture at the point passed in in 3D space.
draw(...)
void ofTexture::draw(float x, float y, float z, float w, float h)
Draws the texture at the x, y, z in 3D space with the width and height at w,h.
Documentation from code comments
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(...)
void ofTexture::drawSubsection(const ofRectangle &drawBounds, const ofRectangle &subsectionBounds)
Documentation from code comments
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(...)
void ofTexture::drawSubsection(float x, float y, float w, float h, float sx, float sy)
Documentation from code comments
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(...)
void ofTexture::drawSubsection(float x, float y, float w, float h, float sx, float sy, float sw, float sh)
Documentation from code comments
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(...)
void ofTexture::drawSubsection(float x, float y, float z, float w, float h, float sx, float sy)
Documentation from code comments
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(...)
void ofTexture::drawSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)
Documentation from code comments
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()
Documentation from code comments
\section Mipmapping Sets flag allowing texture to auto-generate a 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 generateMipmap() instead.
See also: generateMipmap()
See also: disableMipmap()
See also: setTextureMinMagFilter()
generateMipmap()
void ofTexture::generateMipmap()
Documentation from code comments
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()
See also: ofDisableArbTex()
getCoordFromPercent(...)
glm::vec2 ofTexture::getCoordFromPercent(float xPts, float yPts)
Documentation from code comments
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)
these are helpers to allow you to get points for the texture ala "glTexCoordf" but are texture type independent. use them for immediate or non immediate mode
Documentation from code comments
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()
float ofTexture::getHeight()
Returns the height of the texture. This will be in pixels unless you've set your application to use normalized coordinates.
Documentation from code comments
\section Size and Coordinates Display height of texture.
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.
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)
Documentation from code comments
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)
getTextureData()
ofTextureData & ofTexture::getTextureData()
Documentation from code comments
\section Texture Data Internal texture data access.
This returns the internal texture data for this texture, for instance, its textureID, type of texture, whether it's been allocated and other data about the state of the texture.
Returns: a reference to the internal texture data struct.
getTextureData()
const ofTextureData & ofTexture::getTextureData()
This returns the internal texture data for this texture, for instance, its textureID, type of texture, whether it's been allocated, and other data about the state of the texture.
Documentation from code comments
Const version of getTextureData().
See also: ofTextureData::getTextureData()
getWidth()
float ofTexture::getWidth()
Returns the width of the texture. This will be in pixels unless you've set your application to use normalized coordinates.
Documentation from code comments
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.
hasMipmap()
bool ofTexture::hasMipmap()
Documentation from code comments
Find out if a mipmap has been generated for the current texture.
See also: generateMipmap()
See also: enableMipmap()
isAllocated()
bool ofTexture::isAllocated()
Get whether the texture has been allocated. ofTextureData getTextureData() ### // reference to the actual textureData inside the smart pointer // for backwards compatibility ofTextureData texData ### float getHeight() ### float getWidth() ###
Documentation from code comments
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.
loadData(...)
void ofTexture::loadData(const float *data, int w, int h, int glFormat)
Documentation from code comments
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(...)
void ofTexture::loadData(const ofBufferObject &buffer, int glFormat, int glType)
Documentation from code comments
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(...)
void ofTexture::loadData(const ofFloatPixels &pix)
loadData(...)
void ofTexture::loadData(const ofFloatPixels &pix, int glFormat)
Documentation from code comments
Load pixels from an ofFloatPixels instance and specify the format.
See also: loadData(const ofPixels & pix, int glFormat)
Parameters:
pix Reference to ofFloatPixels instance.
glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
loadData(...)
void ofTexture::loadData(const ofPixels &pix)
loadData(...)
void ofTexture::loadData(const ofPixels &pix, int glFormat)
Documentation from code comments
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(...)
void ofTexture::loadData(const ofShortPixels &pix)
loadData(...)
void ofTexture::loadData(const ofShortPixels &pix, int glFormat)
Documentation from code comments
Load pixels from an ofShortPixels instance & specify the format.
See also: loadData(const ofPixels & pix, int glFormat)
Parameters:
pix Reference to ofShortPixels instance.
glFormat GL pixel type: GL_RGBA, GL_LUMINANCE, etc.
loadData(...)
void ofTexture::loadData(const uint16_t *data, int w, int h, int glFormat)
Documentation from code comments
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(...)
void ofTexture::loadData(const uint8_t *const data, int w, int h, int glFormat)
Documentation from code comments
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(...)
void ofTexture::loadData(const void *data, int w, int h, int glFormat, int glType)
Documentation from code comments
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)
Grabs a region of the screen and loads it into the 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. Load data from the current screen into this texture. Grabs a region of the screen and loads it into the 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.
Documentation from code comments
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.
See also: http://www.opengl.org/sdk/docs/man4/html/glCopyTexSubImage2D.xhtml
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.
operator=(...)
ofTexture & ofTexture::operator=(const ofTexture &mom)
readToPixels(...)
void ofTexture::readToPixels(ofFloatPixels &pixels)
Documentation from code comments
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(...)
void ofTexture::readToPixels(ofPixels &pixels)
Documentation from code comments
\section Read Pixel Data Read current texture data from the GPU into pixels.
Warning: This is not supported in OpenGL ES and does nothing.
Parameters:
pixels Target ofPixels reference.
readToPixels(...)
void ofTexture::readToPixels(ofShortPixels &pixels)
Documentation from code comments
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()
void ofTexture::resetAnchor()
Documentation from code comments
Reset the anchor point to (0, 0).
setAlphaMask(...)
void ofTexture::setAlphaMask(ofTexture &mask)
Documentation from code comments
\section Texture Settings Set another ofTexture to use as an alpha mask.
Parameters:
mask The texture to use as alpha mask.
setAnchorPercent(...)
void ofTexture::setAnchorPercent(float xPct, float yPct)
The anchor is the point the image is drawn around. This can be useful if you want to rotate an image around a particular point, allowing you to set the anchor as a percentage of the image width/height ( 0.0-1.0 range )
Documentation from code comments
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).
setAnchorPoint(...)
void ofTexture::setAnchorPoint(float x, float y)
set the anchor point in pixels
Documentation from code comments
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.
setCompression(...)
void ofTexture::setCompression(ofTexCompression compression)
Documentation from code comments
Set the texture compression.
\warning: not yet implemented.
See also: ofTexCompression
setRGToRGBASwizzles(...)
void ofTexture::setRGToRGBASwizzles(bool rToRGBSwizzles)
Documentation from code comments
\todo Define Swizzle in the documentation. Swizzle RGBA to grayscale with alpha in the red channel.
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.
See also: https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)
setSwizzle(...)
void ofTexture::setSwizzle(GLenum srcSwizzle, GLenum dstChannel)
Documentation from code comments
Swizzle a channel to another
Example:
ofTexture tex;
tex.setSwizzle(GL_TEXTURE_SWIZZLE_R,GL_ALPHA);
will make channel 0 appear as alpha in the shader.
Warning: This is not supported in OpenGL ES and does nothing.
See also: https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)
setTextureMatrix(...)
void ofTexture::setTextureMatrix(const glm::mat4 &m)
Documentation from code comments
Sets a texture matrix to be uploaded whenever the texture is bound.
Parameters:
m The 4x4 texture matrix.
setTextureMinMagFilter(...)
void ofTexture::setTextureMinMagFilter(GLint minFilter, GLint magFilter)
Set how the texture is scaled up and down, when it's being drawn larger or smaller than it's actual size.
Documentation from code comments
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
See also: 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)
Sets how the texture wraps around the edges of the vertices that the texture is being drawn to.
Documentation from code comments
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()
See also: 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)
Documentation from code comments
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)
This for the advanced user who wants to draw textures in their own way. This stops vertices from being textured using this texture.
Documentation from code comments
Unbind the texture.
For advanced users who need to manually manage texture drawing without calling ofTexture::draw.
See also: http://www.opengl.org/sdk/docs/man4/html/glBindTexture.xhtml
ofDisableArbTex()
void ofDisableArbTex()
Documentation from code comments
Use GL_TEXTURE_2D textures.
GL_TEXTURE_2D is OpenGL's default way of handling textures and supports a wider range of core OpenGL features such as mipmaps.
See also: ofEnableArbTex()
ofDisableNormalizedTexCoords()
void ofDisableNormalizedTexCoords()
Documentation from code comments
Use pixel-based texture coordinates.
See also: ofEnableNormalizedTexCoords()
ofDisableTextureEdgeHack()
void ofDisableTextureEdgeHack()
Documentation from code comments
Disable global texture "edge hack".
See also: ofEnableTextureEdgeHack()
ofEnableArbTex()
void ofEnableArbTex()
ofEnableArbText enables the use of ARB textures. ARB textures enable the creation of non power of 2 sized textures.
Documentation from code comments
Use GL_TEXTURE_RECTANGLE textures.
GL_TEXTURE_RECTANGLE textures are more intuitive since they allow pixel based coordinates and are enabled by default.
GL_TEXTURE_2D textures use normalised texture coordinates (a float value between 0 and 1 is used to express texture coordinates along width and height).
GL_TEXTURE_2D textures are more widely supported and allow advanced features such as mipmaps and texture compression.
See also: ofDisableArbTex()
Warning: GL_TEXTURE_RECTANGLE is not available in OpenGL ES.
Warning: GL_TEXTURE_RECTANGLE does not support mipmaps.
ofEnableNormalizedTexCoords()
void ofEnableNormalizedTexCoords()
Documentation from code comments
Use normalized (0 - 1) texture coordinates.
By default, textures in OF work with pixel-based coordinates based on given content dimensions (images size, fbo size, etc). Normalized (0 - 1) coordinates are the traditional OpenGL default as they allow working with internal texture data without having to worry about specific dimensions of the content.
This overrides individual ofTexture wrap settings.
See also: http://www.opengl.org/sdk/docs/man4/html/glTexParameter.xhtml
ofEnableTextureEdgeHack()
void ofEnableTextureEdgeHack()
Documentation from code comments
Enable the global texture "edge hack" to compensate for edge artifacts.
Adds a 2 pixel offset to avoid possible edge artifacts (typically a black or white border). This very slightly alters the image by scaling. This is enabled by default.
ofGetUsingArbTex()
bool ofGetUsingArbTex()
Documentation from code comments
\section Global Texture Settings Check whether OF is using GL_TEXTURE_RECTANGLE rectangular or GL_TEXTURE_2D textures.
See also: ofEnableArbTex()
Returns: true if using GL_TEXTURE_RECTANGLE textures, false if using GL_TEXTURE_2D textures.
ofGetUsingNormalizedTexCoords()
bool ofGetUsingNormalizedTexCoords()
Documentation from code comments
Check whether OF is using normalized or pixel texture coordinates.
See also: ofEnableNormalizedTexCoords()
Returns: true if using normalized (0 - 1) texture coordinates.
ofIsTextureEdgeHackEnabled()
bool ofIsTextureEdgeHackEnabled()
Documentation from code comments
Check whether OF is using the texture "edge hack".
See also: ofEnableTextureEdgeHack()
Returns: true if OF is currently using the texture "edge hack".
Last updated 星期二, 19 十一月 2024 17:25:23 UTC - 2537ee49f6d46d5fe98e408849448314fd1f180e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue