Easy3D 2.6.1
Loading...
Searching...
No Matches
Texture Class Reference

OpenGL texture. More...

#include <easy3d/renderer/texture.h>

Public Types

enum  WrapMode { CLAMP_TO_EDGE , REPEAT }
 The wrap mode of the texture. More...
 
enum  FilterMode { NEAREST , LINEAR }
 The filter mode of the texture. More...
 

Public Member Functions

 ~Texture ()
 Destructor.
 
unsigned int id () const
 Get the OpenGL texture ID.
 
const std::string & name () const
 Get the name of the texture.
 
void bind (int unit=0) const
 Bind the texture to a texture unit.
 
void release () const
 Release the texture.
 
int width () const
 Get the width of the texture.
 
int height () const
 Get the height of the texture.
 
int channels () const
 Get the number of channels of the texture.
 
WrapMode wrap_mode () const
 Get the wrap mode of the texture.
 
FilterMode filter_mode () const
 Get the filter mode of the texture.
 

Static Public Member Functions

static Texturecreate (const std::string &image_file, WrapMode wrap=CLAMP_TO_EDGE, FilterMode filter=LINEAR)
 Creates a texture from an image file.
 
static Texturecreate (const std::vector< unsigned char > &rgb_data, int width, int height, int comp, WrapMode wrap=CLAMP_TO_EDGE, FilterMode filter=LINEAR)
 Creates a texture from the given image data.
 

Friends

class TextureManager
 

Detailed Description

OpenGL texture.

currently only TEXTURE_2D is supported

Examples
Tutorial_305_Texture/main.cpp, and Tutorial_306_ImageViewer/main.cpp.

Member Enumeration Documentation

◆ FilterMode

enum FilterMode

The filter mode of the texture.

Enumerator
NEAREST 

Nearest neighbor interpolation.

LINEAR 

Linear interpolation.

◆ WrapMode

enum WrapMode

The wrap mode of the texture.

Enumerator
CLAMP_TO_EDGE 

Clamp the texture coordinate to the range [0, 1].

REPEAT 

Repeat the texture coordinate.

Member Function Documentation

◆ bind()

void bind ( int unit = 0) const

Bind the texture to a texture unit.

Parameters
unitThe texture unit to bind to.

◆ channels()

int channels ( ) const
inline

Get the number of channels of the texture.

Returns
The number of channels of the texture.

◆ create() [1/2]

Texture * create ( const std::string & image_file,
WrapMode wrap = CLAMP_TO_EDGE,
FilterMode filter = LINEAR )
static

Creates a texture from an image file.

Parameters
image_fileThe full path to the image file.
wrapThe wrap mode of the texture.
filterThe filter mode of the texture.
Returns
The created texture.

◆ create() [2/2]

Texture * create ( const std::vector< unsigned char > & rgb_data,
int width,
int height,
int comp,
WrapMode wrap = CLAMP_TO_EDGE,
FilterMode filter = LINEAR )
static

Creates a texture from the given image data.

Parameters
rgb_dataThe image data.
widthThe width (i.e., number of columns) of the image.
heightThe height (i.e., number of rows) of the image.
compThe number of components for each pixel (e.g., 3 for RGB).
wrapThe wrap mode of the texture.
filterThe filter mode of the texture.
Returns
The created texture.

◆ filter_mode()

FilterMode filter_mode ( ) const
inline

Get the filter mode of the texture.

Returns
The filter mode of the texture.

◆ height()

int height ( ) const
inline

Get the height of the texture.

Returns
The height of the texture.
Examples
Tutorial_305_Texture/main.cpp.

◆ id()

unsigned int id ( ) const
inline

Get the OpenGL texture ID.

Returns
The texture ID.

◆ name()

const std::string & name ( ) const
inline

Get the name of the texture.

Returns
The name of the texture.

◆ width()

int width ( ) const
inline

Get the width of the texture.

Returns
The width of the texture.
Examples
Tutorial_305_Texture/main.cpp.

◆ wrap_mode()

WrapMode wrap_mode ( ) const
inline

Get the wrap mode of the texture.

Returns
The wrap mode of the texture.

The documentation for this class was generated from the following files: