reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofTexture.h File Reference
#include "ofGraphicsBaseTypes.h"
#include "ofConstants.h"
#include "glm/mat4x4.hpp"

Go to the source code of this file.

Classes

class  ofTextureData
 Internal texture data structure. More...
 
class  ofTexture
 A wrapper class for an OpenGL texture. More...
 

Typedefs

typedef ofPixels_< unsigned char > ofPixels
 
typedef ofPixels_< unsigned short > ofShortPixels
 
typedef ofPixels_< float > ofFloatPixels
 

Enumerations

enum  ofTexCompression { OF_COMPRESS_NONE , OF_COMPRESS_SRGB , OF_COMPRESS_ARB }
 Texture compression types. More...
 

Functions

bool ofGetUsingArbTex ()
 Check whether OF is using GL_TEXTURE_RECTANGLE rectangular or GL_TEXTURE_2D textures.
 
void ofEnableArbTex ()
 Use GL_TEXTURE_RECTANGLE textures.
 
void ofDisableArbTex ()
 Use GL_TEXTURE_2D textures.
 
bool ofGetUsingNormalizedTexCoords ()
 Check whether OF is using normalized or pixel texture coordinates.
 
void ofEnableNormalizedTexCoords ()
 Use normalized (0 - 1) texture coordinates.
 
void ofDisableNormalizedTexCoords ()
 Use pixel-based texture coordinates.
 
 OF_DEPRECATED_MSG ("Use member method ofTexture::setTextureWrap() instead.", void ofSetTextureWrap(GLfloat wrapS=GL_CLAMP_TO_EDGE, GLfloat wrapT=GL_CLAMP_TO_EDGE))
 Set custom global texture wrapping.
 
 OF_DEPRECATED_MSG ("Use member method ofTexture::setTextureWrap() instead.", bool ofGetUsingCustomTextureWrap())
 Check whether OF is using custom global texture wrapping.
 
 OF_DEPRECATED_MSG ("Use member method ofTexture::setTextureWrap() instead.", void ofRestoreTextureWrap())
 Removes global custom texture wrapping.
 
 OF_DEPRECATED_MSG ("Use member method ofTexture::setTextureMinMagFilter() instead.", void ofSetMinMagFilters(GLfloat minFilter=GL_LINEAR, GLfloat magFilter=GL_LINEAR))
 Set custom global texture minification/magnification scaling filters.
 
 OF_DEPRECATED_MSG ("Use member method ofTexture::setTextureMinMagFilter() instead.", bool ofGetUsingCustomMinMagFilters())
 Check whether OF is using custom global texture scaling filters.
 
 OF_DEPRECATED_MSG ("Use member method ofTexture::setTextureMinMagFilter() instead.", void ofRestoreMinMagFilters())
 Removes global custom texture wrapping.
 
void ofEnableTextureEdgeHack ()
 Enable the global texture "edge hack" to compensate for edge artifacts.
 
void ofDisableTextureEdgeHack ()
 Disable global texture "edge hack".
 
bool ofIsTextureEdgeHackEnabled ()
 Check whether OF is using the texture "edge hack".
 

Detailed Description

ofTexture is used to create OpenGL textures that live on your graphics card (GPU). While you can certainly use ofTexture directly to manipulate and textures, more often ofTexture will be used internally by classes like ofImage or ofVideoGrabber. That said, ofImage and other classes that use ofTexture internally often provide access to the ofTexture.

ofTexture allows use of non-power of 2 textures in OpenGL and has a set of functions simplify the process of transfering pixel data to and from the GPU in various formats.

Users must allocate the texture before drawing it or loading data into it.

Typedef Documentation

◆ ofFloatPixels

typedef ofPixels_<float> ofFloatPixels

◆ ofPixels

typedef ofPixels_<unsigned char> ofPixels

◆ ofShortPixels

typedef ofPixels_<unsigned short> ofShortPixels

Enumeration Type Documentation

◆ ofTexCompression

Texture compression types.

Compression is only available through OpenGL for textures using GL_TEXTURE_2D, not GL_TEXTURE_RECTANGLE, also note that most compression algorithms work on blocks of 4x4 pixels, and therefore expect compressed textures to have multiple-of-four dimensions.

Enumerator
OF_COMPRESS_NONE 

No compression.

OF_COMPRESS_SRGB 

sRGB compression.

OF_COMPRESS_ARB 

ARB compression.

Function Documentation

◆ OF_DEPRECATED_MSG() [1/6]

OF_DEPRECATED_MSG ( "Use member method ofTexture::setTextureMinMagFilter() instead."  ,
bool   ofGetUsingCustomMinMagFilters() 
)

Check whether OF is using custom global texture scaling filters.

Returns
true if OF is currently using custom texture scaling filters.
Warning
Deprecated. Use member methods instead.

◆ OF_DEPRECATED_MSG() [2/6]

OF_DEPRECATED_MSG ( "Use member method ofTexture::setTextureMinMagFilter() instead."  ,
void   ofRestoreMinMagFilters() 
)

Removes global custom texture wrapping.

Restores individual ofTexture min mag filter settings.

Warning
Deprecated. Use member methods instead.

◆ OF_DEPRECATED_MSG() [3/6]

OF_DEPRECATED_MSG ( "Use member method ofTexture::setTextureMinMagFilter() instead."  ,
void   ofSetMinMagFiltersGLfloat minFilter=GL_LINEAR, GLfloat magFilter=GL_LINEAR 
)

Set custom global texture minification/magnification scaling filters.

This setting allows global control over how OpenGL scales textures. It overrides individual ofTexture min & mag filter settings.

Warning
Deprecated. Use member methods instead.
See also
ofTexture::setTextureMinMagFilter()
Parameters
minFilterminifying filter for scaling a pixel to a smaller area.
magFiltermagnifying filter for scaling a pixel to a larger area.

◆ OF_DEPRECATED_MSG() [4/6]

OF_DEPRECATED_MSG ( "Use member method ofTexture::setTextureWrap() instead."  ,
bool   ofGetUsingCustomTextureWrap() 
)

Check whether OF is using custom global texture wrapping.

Warning
Deprecated. Use member methods instead.
See also
ofSetTextureWrap()
Returns
true if OF is currently using custom global texture wrapping.

◆ OF_DEPRECATED_MSG() [5/6]

OF_DEPRECATED_MSG ( "Use member method ofTexture::setTextureWrap() instead."  ,
void   ofRestoreTextureWrap() 
)

Removes global custom texture wrapping.

Restores individual ofTexture wrap settings.

Warning
Deprecated. Use member methods instead.
See also
ofSetTextureWrap()

◆ OF_DEPRECATED_MSG() [6/6]

OF_DEPRECATED_MSG ( "Use member method ofTexture::setTextureWrap() instead."  ,
void   ofSetTextureWrapGLfloat wrapS=GL_CLAMP_TO_EDGE, GLfloat wrapT=GL_CLAMP_TO_EDGE 
)

Set custom global 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.

This overrides individual ofTexture wrap settings.

See also
ofTexture::setTextureWrap
http://www.opengl.org/sdk/docs/man4/html/glTexParameter.xhtml
Warning
Deprecated. Use member methods instead.
Parameters
wrapSwrap parameter for texture coordinate s.
wrapTwrap parameter for texture coordinate t.

◆ ofDisableArbTex()

void ofDisableArbTex ( )

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

Use pixel-based texture coordinates.

See also
ofEnableNormalizedTexCoords()

◆ ofDisableTextureEdgeHack()

void ofDisableTextureEdgeHack ( )

Disable global texture "edge hack".

Todo:
Add docs on why the "edge hack" is needed.
See also
ofEnableTextureEdgeHack()

◆ ofEnableArbTex()

void ofEnableArbTex ( )

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.
GL_TEXTURE_RECTANGLE does not support mipmaps.

◆ ofEnableNormalizedTexCoords()

void ofEnableNormalizedTexCoords ( )

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

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

Check whether OF is using GL_TEXTURE_RECTANGLE rectangular or GL_TEXTURE_2D textures.

Texture Settings

See also
ofEnableArbTex()
Returns
true if using GL_TEXTURE_RECTANGLE textures, false if using GL_TEXTURE_2D textures.

◆ ofGetUsingNormalizedTexCoords()

bool ofGetUsingNormalizedTexCoords ( )

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

Check whether OF is using the texture "edge hack".

See also
ofEnableTextureEdgeHack()
Returns
true if OF is currently using the texture "edge hack".