renderstack::texture Class Reference

can be used as texture, can be rendered to if attached to render_target

#include <texture.hpp>

Public Member Functions

 texture ()
 texture (int width, int height, int gl_bind_target, int gl_teximage_target, int gl_minification_filter, int gl_magnification_filter, int gl_wrap, int gl_format)
void set (int width, int height, int gl_bind_target, int gl_teximage_target, int gl_minification_filter, int gl_magnification_filter, int gl_wrap, int gl_format)
void set_data (std::vector< unsigned char > const &data)
void set_data (int format, unsigned char *data)
void update ()
int width () const
int height () const
int gl_bind_target () const
int gl_teximage_target () const
int gl_texture_object () const
int gl_minification_filter () const
int gl_magnification_filter () const
int gl_wrap () const
int gl_format () const

Detailed Description

Definition at line 53 of file texture.hpp.


Constructor & Destructor Documentation

renderstack::texture::texture (  ) 

Definition at line 78 of file texture.cpp.

00079 {
00080     m_gl_texture_object = (unsigned int)(~0);
00081 }

renderstack::texture::texture ( int  width,
int  height,
int  gl_bind_target,
int  gl_teximage_target,
int  gl_minification_filter,
int  gl_magnification_filter,
int  gl_wrap,
int  gl_format 
)

Definition at line 83 of file texture.cpp.

00093 {
00094     m_gl_texture_object = (unsigned int)(~0);
00095     set(width, height, gl_bind_target, gl_teximage_target, gl_minification_filter, gl_magnification_filter, gl_wrap, gl_format);
00096 }


Member Function Documentation

void renderstack::texture::set ( int  width,
int  height,
int  gl_bind_target,
int  gl_teximage_target,
int  gl_minification_filter,
int  gl_magnification_filter,
int  gl_wrap,
int  gl_format 
)

Definition at line 98 of file texture.cpp.

00108 {
00109     m_width                     = width;
00110     m_height                    = height;
00111     m_gl_bind_target            = gl_bind_target;
00112     m_gl_teximage_target        = gl_teximage_target;
00113     m_gl_minification_filter    = gl_minification_filter;
00114     m_gl_magnification_filter   = gl_magnification_filter;
00115     m_gl_wrap                   = gl_wrap;
00116     m_gl_format                 = gl_format;
00117 
00118     ::GLboolean is_texture = ::rs_gl_is_texture(m_gl_texture_object);
00119 
00120     if(is_texture != GL_FALSE)
00121     {
00122         rs_gl_delete_textures(1, &m_gl_texture_object);
00123     }
00124 
00125     ::rs_gl_gen_textures(1, &m_gl_texture_object);
00126     ::rs_gl_bind_texture(m_gl_bind_target, m_gl_texture_object);
00127     ::rs_gl_tex_image_2d(
00128         m_gl_teximage_target, 
00129         0, 
00130         m_gl_format, 
00131         m_width, 
00132         m_height, 
00133         0, 
00134         GL_RGB,             /*  TODO mustfix  */ 
00135         GL_UNSIGNED_BYTE,   /*  TODO mustfix  */ 
00136         NULL
00137     );
00138 }

void renderstack::texture::set_data ( std::vector< unsigned char > const &  data  ) 

Definition at line 140 of file texture.cpp.

00141 {
00142     ::rs_gl_bind_texture(m_gl_bind_target, m_gl_texture_object);
00143     ::rs_gl_tex_image_2d(
00144         m_gl_teximage_target, 
00145         0, 
00146         m_gl_format, 
00147         m_width, 
00148         m_height, 
00149         0, 
00150         GL_RGB,             /*  TODO mustfix  */ 
00151         GL_UNSIGNED_BYTE,   /*  TODO mutsfix  */ 
00152         &data[0]
00153     );
00154 }

void renderstack::texture::set_data ( int  format,
unsigned char *  data 
)

Definition at line 156 of file texture.cpp.

00157 {
00158     ::rs_gl_bind_texture(m_gl_bind_target, m_gl_texture_object);
00159     ::rs_gl_tex_image_2d(
00160         m_gl_teximage_target, 
00161         0, 
00162         m_gl_format, 
00163         m_width, 
00164         m_height, 
00165         0, 
00166         format,             /*  TODO mustfix  */ 
00167         GL_UNSIGNED_BYTE,   /*  TODO mustfix  */ 
00168         data
00169     );
00170 }

void renderstack::texture::update (  ) 

Definition at line 172 of file texture.cpp.

00173 {
00174     ::rs_gl_bind_texture   (m_gl_bind_target, m_gl_texture_object);
00175     ::rs_gl_tex_parameter_i(m_gl_bind_target, GL_TEXTURE_MAG_FILTER, m_gl_magnification_filter);
00176     ::rs_gl_tex_parameter_i(m_gl_bind_target, GL_TEXTURE_MIN_FILTER, m_gl_minification_filter);
00177     ::rs_gl_tex_parameter_i(m_gl_bind_target, GL_TEXTURE_WRAP_S, m_gl_wrap);
00178     ::rs_gl_tex_parameter_i(m_gl_bind_target, GL_TEXTURE_WRAP_T, m_gl_wrap);
00179 }

int renderstack::texture::width (  )  const [inline]

Definition at line 85 of file texture.hpp.

00085 { return m_width; }

int renderstack::texture::height (  )  const [inline]

Definition at line 86 of file texture.hpp.

00086 { return m_height; }

int renderstack::texture::gl_bind_target (  )  const [inline]

Definition at line 87 of file texture.hpp.

00087 { return m_gl_bind_target; }

int renderstack::texture::gl_teximage_target (  )  const [inline]

Definition at line 88 of file texture.hpp.

00088 { return m_gl_teximage_target; }

int renderstack::texture::gl_texture_object (  )  const [inline]

Definition at line 89 of file texture.hpp.

00089 { return m_gl_texture_object; }

int renderstack::texture::gl_minification_filter (  )  const [inline]

Definition at line 90 of file texture.hpp.

00090 { return m_gl_minification_filter; }

int renderstack::texture::gl_magnification_filter (  )  const [inline]

Definition at line 91 of file texture.hpp.

00091 { return m_gl_magnification_filter; }

int renderstack::texture::gl_wrap (  )  const [inline]

Definition at line 92 of file texture.hpp.

00092 { return m_gl_wrap; }

int renderstack::texture::gl_format (  )  const [inline]

Definition at line 93 of file texture.hpp.

00093 { return m_gl_format; }


The documentation for this class was generated from the following files:
Generated on Sun Apr 11 12:23:12 2010 for RenderStack by  doxygen 1.6.3