ofDocsdocumentation gl ofTexture

ofTexture

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.


allocate( ... )

void allocate(const ofPixels &pix)

Allocate texture using an ofPixels instance.

Pixel type and OpenGL format are determined from pixel settings.

Parameters:

pix Reference to ofPixels instance.


allocate( ... )

void allocate(const ofShortPixels &pix)

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 allocate(const ofFloatPixels &pix)

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 allocate(const ofPixels &pix, bool bUseARBExtension)

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 allocate(const ofShortPixels &pix, bool bUseARBExtension)

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 allocate(const ofFloatPixels &pix, bool bUseARBExtension)

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 allocate(const ofTextureData &textureData)

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 allocate(const ofTextureData &textureData, int glFormat, int pixelType)

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 allocate(int w, int h, int glInternalFormat)

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.

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


allocate( ... )

void allocate(int w, int h, int glInternalFormat, bool bUseARBExtension)

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.

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


allocate( ... )

void allocate(int w, int h, int glInternalFormat, bool bUseARBExtension, int glFormat, int pixelType)

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 allocate(int w, int h, int glInternalFormat, int glFormat, int pixelType)

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 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 bind(int textureLocation=0)

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

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.


bindAsImage( ... )

void bindAsImage(GLuint unit, GLenum access, GLint level=0, GLboolean layered, GLint layer=0)

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 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.

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


copyTo( ... )

void copyTo(ofBufferObject &buffer)

Copy the texture to an ofBufferObject.

Parameters:

buffer the target buffer to copy to.


disableAlphaMask( )

void disableAlphaMask()

Disable the alpha mask.


disableMipmap( )

void 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.

See also: generateMipmap()

See also: enableMipmap()

See also: setTextureMinMagFilter()


disableTextureMatrix( )

void disableTextureMatrix()

Disable the texture matrix. Disable the texture matrix.


disableTextureTarget( ... )

void disableTextureTarget(int textureLocation)

Disable a texture target.

Parameters:

textureLocation the OpenGL texture ID to enable as a target.


draw( ... )

void draw(const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &p3, const glm::vec3 &p4)

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 draw(const glm::vec3 &pos)

draw( ... )

void 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 draw(float x, float y)

\section Drawing

Draws the texture at a given point (x,y), using the textures true width and height. Draws the texture at the point passed in.


draw( ... )

void 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 draw(float x, float y, float z)

Draws the texture at the point passed in in 3D space.


draw( ... )

void draw(float x, float y, float z, float w, float h)

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.

Draws the texture at the x, y, z in 3D space with the width and height at w,h.


drawSubsection( ... )

void drawSubsection(const ofRectangle &drawBounds, const ofRectangle &subsectionBounds)

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 drawSubsection(float x, float y, float w, float h, float sx, float sy)

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 drawSubsection(float x, float y, float w, float h, float sx, float sy, float sw, float sh)

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 drawSubsection(float x, float y, float z, float w, float h, float sx, float sy)

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 drawSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)

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 enableMipmap()

\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()


enableTextureTarget( ... )

void enableTextureTarget(int textureLocation)

Enable a texture target.

Parameters:

textureLocation the OpenGL texture ID to enable as a target.


generateMipmap( )

void 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()

See also: ofDisableArbTex()


getAlphaMask( )

const ofTexture * getAlphaMask()

getCoordFromPercent( ... )

glm::vec2 getCoordFromPercent(float xPts, float yPts)

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 getCoordFromPoint(float xPos, float yPos)

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.

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


getHeight( )

float getHeight()

\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.

Returns the height of the texture. This will be in pixels unless you've set your application to use normalized coordinates.


getMeshForSubsection( ... )

ofMesh getMeshForSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh, bool vflipped, ofRectMode rectMode)

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 getQuad(const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &p3, const glm::vec3 &p4)

getTextureData( )

ofTextureData & getTextureData()

\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 & getTextureData()

Const version of getTextureData().

See also: ofTextureData::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.


getTextureMatrix( )

const glm::mat4 & getTextureMatrix()

getWidth( )

float getWidth()

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.

Returns the width of the texture. This will be in pixels unless you've set your application to use normalized coordinates.


hasMipmap( )

bool hasMipmap()

Find out if a mipmap has been generated for the current texture.

See also: generateMipmap()

See also: enableMipmap()


isAllocated( )

bool isAllocated()

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.

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() ###


isUsingTextureMatrix( )

bool isUsingTextureMatrix()

loadData( ... )

void 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( ... )

void loadData(const ofPixels &pix)

Load pixels from an ofPixels instance.

Parameters:

pix Reference to ofPixels instance.


loadData( ... )

void 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( ... )

void 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( ... )

void 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( ... )

void loadData(const ofShortPixels &pix, int glFormat)

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 loadData(const ofFloatPixels &pix, int glFormat)

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 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( ... )

void loadData(const uint32_t *data, int w, int h, int glFormat)

loadData( ... )

void loadData(const int8_t *data, int w, int h, int glFormat)

loadData( ... )

void loadData(const int16_t *data, int w, int h, int glFormat)

loadData( ... )

void loadData(const int32_t *data, int w, int h, int glFormat)

loadData( ... )

void 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( ... )

void 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.


loadData( ... )

void 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.


loadScreenData( ... )

void 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.

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.

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.


ofTexture( ... )

ofTexture(ofTexture &&mom)

ofTexture( ... )

ofTexture(const ofTexture &mom)

Construct an ofTexture from an existing ofTexture.

Parameters:

mom The ofTexture to copy. Reuses internal GL texture ID.


ofTexture( )

ofTexture()

\section Construction and Allocation Construct an ofTexture instance.

Creates an empty ofTexture instance. You can't draw a texture right after it's been created as it has actually uploaded any data to the graphics card that can be drawn yet.


operator=( ... )

ofTexture & operator=(ofTexture &&mom)

operator=( ... )

ofTexture & operator=(const ofTexture &mom)

\section Update Texture Copy a given ofTexture into this texture.

Parameters:

mom The ofTexture to copy from. Reuses internal GL texture ID.


readToPixels( ... )

void readToPixels(ofPixels &pixels)

\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 readToPixels(ofShortPixels &pixels)

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 readToPixels(ofFloatPixels &pixels)

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 resetAnchor()

Reset the anchor point to (0, 0).


setAlphaMask( ... )

void setAlphaMask(ofTexture &mask)

\section Texture Settings Set another ofTexture to use as an alpha mask.

Parameters:

mask The texture to use as alpha mask.


setAnchorPercent( ... )

void setAnchorPercent(float xPct, float yPct)

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).

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 )


setAnchorPoint( ... )

void setAnchorPoint(float x, float y)

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.

set the anchor point in pixels


setCompression( ... )

void setCompression(ofTexCompression compression)

Set the texture compression.

\warning: not yet implemented.

See also: ofTexCompression


setRGToRGBASwizzles( ... )

void setRGToRGBASwizzles(bool rToRGBSwizzles)

\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 setSwizzle(GLenum srcSwizzle, GLenum dstChannel)

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 setTextureMatrix(const glm::mat4 &m)

Sets a texture matrix to be uploaded whenever the texture is bound.

Parameters:

m The 4x4 texture matrix.


setTextureMinMagFilter( ... )

void 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

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.

Set how the texture is scaled up and down, when it's being drawn larger or smaller than it's actual size.


setTextureWrap( ... )

void 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()

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.

Sets how the texture wraps around the edges of the vertices that the texture is being drawn to.


setUseExternalTextureID( ... )

void 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 unbind(int textureLocation=0)

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

This for the advanced user who wants to draw textures in their own way. This stops vertices from being textured using this texture.


~ofTexture( )

~ofTexture()

Destroy an ofTexture instance.

ofTexture keeps a reference count for the internal OpenGL texture ID. Thus, the texture ID is only released if there are no additional references to the internal texture ID.