Graphite  Version 3
An experimental 3D geometry processing program
OGF::Texture Class Reference

An OpenGL texture. More...

#include <OGF/renderer/context/texture.h>

Inheritance diagram for OGF::Texture:
GEO::Counted

Public Member Functions

 Texture ()
 Texture constructor.
 
 ~Texture ()
 Texture destructor. More...
 
index_t dimension () const
 Gets the dimension of the texture. More...
 
index_t width () const
 Gets the width. More...
 
index_t height () const
 Gets the height. More...
 
index_t depth () const
 Gets the height. More...
 
void create_from_image (const Image *image, GLint filtering=GL_LINEAR, GLint wrapping=GL_CLAMP_TO_EDGE)
 Creates a texture from an image. More...
 
void create_from_data (Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width, index_t height, index_t depth=1, GLint filtering=GL_LINEAR, GLint wrapping=GL_CLAMP_TO_EDGE)
 Creates a texture from raw data. More...
 
void bind ()
 Binds the texture to its texture target.
 
void unbind ()
 Unbinds the texture from its texture target.
 
GLuint id () const
 Gets the id of the texture. More...
 
void reset_id ()
 Resets the id of this texture. More...
 
GLint get_filtering () const
 
void set_filtering (GLint filtering)
 
GLint get_wrapping () const
 
void set_wrapping (GLint wrapping)
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Protected Member Functions

void create_from_data_1d (Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width)
 Initializes texture data for a 1d texture. More...
 
void create_from_data_2d (Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width, index_t height)
 Initializes texture data for a 2d texture. More...
 
void create_from_data_3d (Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width, index_t height, index_t depth)
 Initializes texture data for a 2d texture. More...
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Static Protected Member Functions

static bool get_GL_formats (Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, GLint &internal_format, GLenum &format, GLenum &type)
 Gets the parameters for specifying OpenGL textures from Image color encoding and component encoding. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Detailed Description

An OpenGL texture.

Definition at line 56 of file texture.h.

Constructor & Destructor Documentation

◆ ~Texture()

OGF::Texture::~Texture ( )

Texture destructor.

Deletes the associated OpenGL texture if it was created.

Member Function Documentation

◆ create_from_data()

void OGF::Texture::create_from_data ( Memory::pointer  ptr,
Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
index_t  width,
index_t  height,
index_t  depth = 1,
GLint  filtering = GL_LINEAR,
GLint  wrapping = GL_CLAMP_TO_EDGE 
)

Creates a texture from raw data.

Parameters
[in]ptra pointer to image data
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[in]widthimage width
[in]heightimage height (or 1 for 1d textures)
[in]depthimage depth (or 1 for 1d and 2d textures)
[in]filteringthe OpenGL filtering mode
[in]wrappingthe wrapping mode for texture coordinates
Note
For now, only 2d textures are implemented, and not all datatypes/storage work (under work...)

◆ create_from_data_1d()

void OGF::Texture::create_from_data_1d ( Memory::pointer  ptr,
Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
index_t  width 
)
protected

Initializes texture data for a 1d texture.

Parameters
[in]ptrpointer to texture data
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[in]widththe width of the texture

◆ create_from_data_2d()

void OGF::Texture::create_from_data_2d ( Memory::pointer  ptr,
Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
index_t  width,
index_t  height 
)
protected

Initializes texture data for a 2d texture.

Parameters
[in]ptrpointer to texture data
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[in]widththe width of the texture
[in]heightthe height of the texture

◆ create_from_data_3d()

void OGF::Texture::create_from_data_3d ( Memory::pointer  ptr,
Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
index_t  width,
index_t  height,
index_t  depth 
)
protected

Initializes texture data for a 2d texture.

Parameters
[in]ptrpointer to texture data
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[in]widththe width of the texture
[in]heightthe height of the texture
[in]depththe height of the texture

◆ create_from_image()

void OGF::Texture::create_from_image ( const Image image,
GLint  filtering = GL_LINEAR,
GLint  wrapping = GL_CLAMP_TO_EDGE 
)

Creates a texture from an image.

Parameters
[in]imagea const pointer to the Image
[in]filteringthe OpenGL filtering mode
[in]wrappingthe wrapping mode for texture coordinates
Note
For now, only 2d textures are implemented, and not all datatypes/storage work (under work...)

◆ depth()

index_t OGF::Texture::depth ( ) const
inline

Gets the height.

Returns
the depth of this texture (or 1 for 1d and 2d textures)

Definition at line 100 of file texture.h.

◆ dimension()

index_t OGF::Texture::dimension ( ) const

Gets the dimension of the texture.

Return values
1for a 1d texture
2for a 2d texture
3for a 3d texture

◆ get_GL_formats()

static bool OGF::Texture::get_GL_formats ( Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
GLint &  internal_format,
GLenum &  format,
GLenum &  type 
)
staticprotected

Gets the parameters for specifying OpenGL textures from Image color encoding and component encoding.

Parameters
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[out]internal_formatthe internal format used by OpenGL texture (parameter of glTexImagenD())
[out]formatthe OpenGL format used to pass image data to the OpenGL texture (parameter of glTexImagenD())
[out]typethe type to specify the image components to the OpenGL texture (parameter of glTexImagenD())

◆ height()

index_t OGF::Texture::height ( ) const
inline

Gets the height.

Returns
the height of this texture (or 1 for a 1d texture)

Definition at line 92 of file texture.h.

◆ id()

GLuint OGF::Texture::id ( ) const
inline

Gets the id of the texture.

Returns
the OpenGL opaque id of the texture

Definition at line 156 of file texture.h.

◆ reset_id()

void OGF::Texture::reset_id ( )
inline

Resets the id of this texture.

If a texture was created, then the association with this Texture is forgotten, and this Texture's destructor no longer destroys the OpenGL texture.

Definition at line 166 of file texture.h.

◆ width()

index_t OGF::Texture::width ( ) const
inline

Gets the width.

Returns
the width of this texture

Definition at line 84 of file texture.h.


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