Tucano
0.1
A library for rapid prototyping with modern OpenGL and GLSL
|
An OpenGL texture. It can be a simple texture or an FBO texture. More...
#include <texture.hpp>
Public Member Functions | |
Texture (void) | |
Default Constructor. More... | |
int | getWidth (void) |
Returns the texture width. More... | |
int | getHeight (void) |
Returns the texture height. More... | |
Eigen::Vector2i | getDimensions (void) |
Returns the texture dimensions. More... | |
void | setNumSamples (int num) |
Sets the number of samples for multisampling. More... | |
GLuint | create (GLenum type, GLenum int_format, int w, int h, GLenum fmt, GLenum pix_type, const GLvoid *data=NULL, int dpt=256) |
Creates a texture object and returns its handler. More... | |
GLuint | create (int w, int h, const GLvoid *data=NULL) |
Creates a texture object with typical default parameters and returns its handler. More... | |
void | setTexParameters (GLenum wraps=GL_CLAMP, GLenum wrapt=GL_CLAMP, GLenum magfilter=GL_NEAREST, GLenum minfilter=GL_NEAREST) |
Deletes the texture. More... | |
void | setTexParametersMipMap (int maxlevel, int baselevel=0, GLenum wraps=GL_CLAMP, GLenum wrapt=GL_CLAMP, GLenum magfilter=GL_NEAREST, GLenum minfilter=GL_NEAREST_MIPMAP_NEAREST) |
Sets texture parameters. Sets the Wrap S and T, Min and Mag filter, and MipMap parameters. Also generates the MipMap at the end. More... | |
void | update (const GLvoid *data) |
Updates the data of the texture mantaining all other parameters. More... | |
void | bind (int texture_unit) |
Binds the texture to a given unit. Note that if there is another texture already binded to this unit, no warning is given, and this texture will replace it. More... | |
int | bind (void) |
Binds the texture to the first free texture unit and returns the unit used. Gets the first free unit from the texture manager to bind the texture. More... | |
int | bindImageRW (void) |
Binds the texture as an image texture. Image textures are used for example for atomic counters, compute shaders, and other uses. Binds with READ and WRITE access using the current internal format. Gets the first free unit from the texture manager to bind the texture. More... | |
void | bindImageRW (int texture_unit) |
Binds the texture as an image texture to a given unit. Image textures are used for example for atomic counters, compute shaders, and other uses. Binds with READ and WRITE access. If another texture is using the given unit it will be replaced by the current one. More... | |
int | bindImageFormatRW (GLenum fmt) |
Binds the texture as an image texture with a given format. Binds with READ and WRITE access with a given format that might be different from texture internal format. More... | |
void | bindImageFormatRW (int texture_unit, GLenum fmt) |
Binds the texture as an image texture to a given texture unit with a given internal format. Binds with READ and WRITE access with a given format that might be different from texture internal format. If another texture is using the given unit it will be replaced by the current one. More... | |
void | unbind (void) |
Unbinds this texture and frees the texture unit. More... | |
GLuint | texID (void) const |
Returns the texture handle (texture ID). More... | |
int | textureUnit (void) const |
Returns the texture unit this texture is bound to. More... | |
Private Attributes | |
GLuint | tex_id |
ID handler to texture. More... | |
GLenum | tex_type |
Type of texture (ex. GL_TEXTURE_2D, GL_TEXTURE_3D ...). More... | |
GLenum | internal_format |
Internal format (ex. GL_RGBA, GL_RGBA32F ...). More... | |
int | width |
Width in pixels. More... | |
int | height |
Height in pixels. More... | |
int | depth |
Depth in pixels (for 3D texture). More... | |
GLenum | format |
Format of texture channels (ex. GL_RGBA). More... | |
GLenum | pixel_type |
Type of pixel channel (ex. GL_FLOAT, GL_UNSIGNED_BYTE ...). More... | |
int | lod |
Number of lod levels (1 for textures without lod). More... | |
int | unit |
Texture unit this texture is occupying (if any). More... | |
int | num_samples = 1 |
Number of samples, default is 1 (no multisampling) More... | |
std::shared_ptr< GLuint > | texID_sptr |
shared pointer for maintaing texture id More... | |
An OpenGL texture. It can be a simple texture or an FBO texture.
|
inline |
Default Constructor.
|
inline |
Binds the texture to a given unit. Note that if there is another texture already binded to this unit, no warning is given, and this texture will replace it.
texture_unit | Given texture unit. |
|
inline |
Binds the texture to the first free texture unit and returns the unit used. Gets the first free unit from the texture manager to bind the texture.
|
inline |
Binds the texture as an image texture with a given format. Binds with READ and WRITE access with a given format that might be different from texture internal format.
fmt | Internal elements format (ex. GL_R32UI). |
|
inline |
Binds the texture as an image texture to a given texture unit with a given internal format. Binds with READ and WRITE access with a given format that might be different from texture internal format. If another texture is using the given unit it will be replaced by the current one.
texture_unit | Texture unit to bound. |
fmt | Internal elements format (ex. GL_R32UI). |
|
inline |
Binds the texture as an image texture. Image textures are used for example for atomic counters, compute shaders, and other uses. Binds with READ and WRITE access using the current internal format. Gets the first free unit from the texture manager to bind the texture.
|
inline |
Binds the texture as an image texture to a given unit. Image textures are used for example for atomic counters, compute shaders, and other uses. Binds with READ and WRITE access. If another texture is using the given unit it will be replaced by the current one.
texture_unit | Texture unit to bound. |
|
inline |
Creates a texture object and returns its handler.
type | Type of GL texture (usually GL_TEXTURE_2D) |
int_format | Format of texel (usually GL_RGBA or GL_RGBA32F for precision) |
w | Width of texture |
h | Height of texture |
fmt | Format of texel channels (usually GL_RGBA) |
pix_type | Type of one channel of a texel (usually GL_FLOAT or GL_USIGNED_BYTE) |
data | Pointer to data to fill the texture |
dpt |
|
inline |
Creates a texture object with typical default parameters and returns its handler.
The default parameters are texture type (GL_TEXTURE_2D), internal format (GL_RGBA32F), format (GL_RGBA), pixel type (GL_UNSIGNED_BYTE)
w | Width of texture |
h | Height of texture |
data | Pointer to data to fill the texture |
|
inline |
Returns the texture dimensions.
|
inline |
Returns the texture height.
|
inline |
Returns the texture width.
|
inline |
Sets the number of samples for multisampling.
num | Number of samples |
|
inline |
Deletes the texture.
Sets texture parameters. Sets the Wrap S and T, and Min and Mag filter parameters.
wraps | Wrap S |
wrapt | Wrap T |
magfilter | Mag Filter |
minfilter | Min Filter |
|
inline |
Sets texture parameters. Sets the Wrap S and T, Min and Mag filter, and MipMap parameters. Also generates the MipMap at the end.
maxlevel | Max Mipmap level |
baselevel | Mipmap Base Level |
wraps | Wrap S |
wrapt | Wrap T |
magfilter | Mag Filter |
minfilter | Min Filter |
|
inline |
Returns the texture handle (texture ID).
|
inline |
Returns the texture unit this texture is bound to.
|
inline |
Unbinds this texture and frees the texture unit.
|
inline |
Updates the data of the texture mantaining all other parameters.
data | Pointer to data to fill the texture. |
|
private |
Depth in pixels (for 3D texture).
|
private |
Format of texture channels (ex. GL_RGBA).
|
private |
Height in pixels.
|
private |
Internal format (ex. GL_RGBA, GL_RGBA32F ...).
|
private |
Number of lod levels (1 for textures without lod).
|
private |
Number of samples, default is 1 (no multisampling)
|
private |
Type of pixel channel (ex. GL_FLOAT, GL_UNSIGNED_BYTE ...).
|
private |
ID handler to texture.
|
private |
Type of texture (ex. GL_TEXTURE_2D, GL_TEXTURE_3D ...).
|
private |
shared pointer for maintaing texture id
|
private |
Texture unit this texture is occupying (if any).
|
private |
Width in pixels.