Public Member Functions | Protected Member Functions | Protected Attributes

OpenTissue::texture::Texture2D Class Reference

#include <texture_texture2D.h>

List of all members.

Public Member Functions

unsigned int get_texture_ID () const
unsigned int get_texture_target () const
int width () const
int height () const
int get_internal_format () const
bool rectangular () const
 Texture2D (int internal_format, int width, int height, int format, int type, const void *pixels, bool rectangular=false, int border=0)
 Texture2D ()
 Texture2D (int w, int h, bool r=false)
 ~Texture2D ()
void bind () const
template<typename T >
void load (T const *pixels)
void set_repeating (bool flag)
void set_mipmapping (bool flag)
void parameter (GLenum pname, GLint i)
void parameter (GLenum pname, GLfloat f)
void parameter (GLenum pname, GLint *ip)
void parameter (GLenum pname, GLfloat *fp)
bool is_valid_sampler_type (std::string const &sampler_type) const

Protected Member Functions

void create (unsigned int texture_ID=0)

Protected Attributes

GLuint m_texture_ID
 The ID of the texture object.
int m_internal_format
 The internal format of the texture, i.e. how many color compoents (and their size).
bool m_owned
 Boolean flag indicating whether this texture instance owns the texture object.
int m_width
 The width In pixels of texture.
int m_height
 The height In pixels of texture.
unsigned int m_format
 External pixel format, i.e how many components.
unsigned int m_type
 External pixel type, i.e. unsigned char, unsigned short etc..
bool m_rectangular
 If true texture coordiates are in the range [0..width]x[0..height] otherwise they are in the range [0..1]x[0..1].
unsigned int m_texture_target
 The texture target.

Detailed Description

A 2D Texture convenience Class. This class encapsylates all openGL technicalities in dealing with 2D textures.


Constructor & Destructor Documentation

OpenTissue::texture::Texture2D::Texture2D ( int  internal_format,
int  width,
int  height,
int  format,
int  type,
const void *  pixels,
bool  rectangular = false,
int  border = 0 
) [inline]

Texture2D Constructor.

Parameters:
internal_format The number of color components in the texture. Must be 1, 2, 3, or 4, or one of the following symbolic constants: GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_ALPHA12, GL_ALPHA16, GL_LUMINANCE, GL_LUMINANCE4, GL_LUMINANCE8, GL_LUMINANCE12, GL_LUMINANCE16, GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE6_ALPHA2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE12_ALPHA4, GL_LUMINANCE12_ALPHA12, GL_LUMINANCE16_ALPHA16, GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8, GL_INTENSITY12, GL_INTENSITY16, GL_R3_G3_B2, GL_RGB, GL_RGB4, GL_RGB5, GL_RGB8, GL_RGB10, GL_RGB12, GL_RGB16, GL_RGBA, GL_RGBA2, GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2, GL_RGBA12, or GL_RGBA16.
width The width of the texture image.
height The height of the texture image.
format The format of the pixel data. It can assume one of the symbolic values: GL_COLOR_INDEX, GL_RED, GL_GREEN,GL_BLUE,GL_ALPHA,GL_RGB,GL_RGBA,GL_BGR_EXT,GL_BGR_EXT GL_BGRA_EXT,GL_LUMINANCE,GL_LUMINANCE_ALPHA
type The data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE, GL_BYTE, GL_BITMAP, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, and GL_FLOAT.
pixels A pointer to the image data in memory.
rectangular Set to true if a rectangular texture is wanted, default is false.
border Set border value, default is zero
OpenTissue::texture::Texture2D::Texture2D (  )  [inline]
OpenTissue::texture::Texture2D::Texture2D ( int  w,
int  h,
bool  r = false 
) [inline]
OpenTissue::texture::Texture2D::~Texture2D (  )  [inline]

Member Function Documentation

void OpenTissue::texture::Texture2D::bind (  )  const [inline]

Bind Texture. This method makes sure that the texture target is enabled and the texture object is bound.

void OpenTissue::texture::Texture2D::create ( unsigned int  texture_ID = 0  )  [inline, protected]
int OpenTissue::texture::Texture2D::get_internal_format (  )  const [inline]
unsigned int OpenTissue::texture::Texture2D::get_texture_ID (  )  const [inline]
unsigned int OpenTissue::texture::Texture2D::get_texture_target (  )  const [inline]
int OpenTissue::texture::Texture2D::height (  )  const [inline]
bool OpenTissue::texture::Texture2D::is_valid_sampler_type ( std::string const &  sampler_type  )  const [inline]

Validate Sampler Type. This method tests if sampler type is compatible with this 2D texture. This method is invoked by Program when setting an input texture for a Cg program.

Parameters:
sampler_type A textutual representation of the Cg sampler type.
Returns:
If the sampler type is valid the return value is true other wise it is false.
template<typename T >
void OpenTissue::texture::Texture2D::load ( T const *  pixels  )  [inline]

Load Texture From Memory.

Parameters:
pixels A pointer to the contiguos memory location where texture data should be loaded from.
void OpenTissue::texture::Texture2D::parameter ( GLenum  pname,
GLfloat  f 
) [inline]
void OpenTissue::texture::Texture2D::parameter ( GLenum  pname,
GLfloat fp 
) [inline]
void OpenTissue::texture::Texture2D::parameter ( GLenum  pname,
GLint ip 
) [inline]
void OpenTissue::texture::Texture2D::parameter ( GLenum  pname,
GLint  i 
) [inline]
bool OpenTissue::texture::Texture2D::rectangular (  )  const [inline]
void OpenTissue::texture::Texture2D::set_mipmapping ( bool  flag  )  [inline]
void OpenTissue::texture::Texture2D::set_repeating ( bool  flag  )  [inline]

Set Texture Wrapping Mode.

Parameters:
flag If true texture wrapping is set to GL_REPEAT otherwise it is set to GL_CLAMP.
int OpenTissue::texture::Texture2D::width (  )  const [inline]

Member Data Documentation

unsigned int OpenTissue::texture::Texture2D::m_format [protected]

External pixel format, i.e how many components.

int OpenTissue::texture::Texture2D::m_height [protected]

The height In pixels of texture.

int OpenTissue::texture::Texture2D::m_internal_format [protected]

The internal format of the texture, i.e. how many color compoents (and their size).

bool OpenTissue::texture::Texture2D::m_owned [protected]

Boolean flag indicating whether this texture instance owns the texture object.

bool OpenTissue::texture::Texture2D::m_rectangular [protected]

If true texture coordiates are in the range [0..width]x[0..height] otherwise they are in the range [0..1]x[0..1].

GLuint OpenTissue::texture::Texture2D::m_texture_ID [protected]

The ID of the texture object.

unsigned int OpenTissue::texture::Texture2D::m_texture_target [protected]

The texture target.

unsigned int OpenTissue::texture::Texture2D::m_type [protected]

External pixel type, i.e. unsigned char, unsigned short etc..

int OpenTissue::texture::Texture2D::m_width [protected]

The width In pixels of texture.


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