62 #include "Texture3DNode.hh"
67 namespace SceneGraph {
72 Texture3DNode::Texture3DNode(
BaseNode * _parent,
73 const std::string & _name )
76 tex_mode_( GL_MODULATE ),
77 border_color_( 0, 0, 0, 0 ),
78 wrap_mode_( GL_CLAMP ),
86 Texture3DNode::~Texture3DNode()
88 if ( glIsTexture( texture_ ) )
89 glDeleteTextures( 1, &texture_ );
99 if ( glIsTexture( texture_ ) )
102 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, tex_mode_);
103 glTexParameterfv( GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, border_color_.data() );
105 glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, wrap_mode_ );
106 glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, wrap_mode_ );
107 glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, wrap_mode_ );
109 glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, filter_ );
110 glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, filter_ );
130 Texture3DNode::set_texture(
unsigned int _width,
131 unsigned int _height,
133 unsigned char * _data )
135 glTexImage3D( GL_PROXY_TEXTURE_3D, 0, GL_RGBA,
136 _width, _height, _depth, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
139 glGetTexLevelParameteriv( GL_PROXY_TEXTURE_3D, 0,
140 GL_TEXTURE_WIDTH, & test_width );
143 glGetTexLevelParameteriv( GL_PROXY_TEXTURE_3D, 0,
144 GL_TEXTURE_HEIGHT, & test_height );
147 glGetTexLevelParameteriv( GL_PROXY_TEXTURE_3D, 0,
148 GL_TEXTURE_DEPTH, & test_depth );
150 if ( ! test_width || ! test_height || ! test_depth )
152 std::cerr <<
"Can't load texture.\n";
156 glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
157 glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
158 glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
159 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
160 glPixelStorei( GL_PACK_ROW_LENGTH, 0 );
161 glPixelStorei( GL_PACK_SKIP_ROWS, 0 );
162 glPixelStorei( GL_PACK_SKIP_PIXELS, 0 );
163 glPixelStorei( GL_PACK_ALIGNMENT, 1 );
166 if ( glIsTexture( texture_ ) )
167 glDeleteTextures( 1, & texture_ );
169 glGenTextures( 1, & texture_ );
172 glTexImage3D( GL_TEXTURE_3D, 0, GL_RGBA,
173 _width, _height, _depth, 0, GL_RGBA, GL_UNSIGNED_BYTE, _data );
Namespace providing different geometric functions concerning angles.
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking
void enter(GLState &_state, const DrawModes::DrawMode &_drawmode)
set texture
void leave(GLState &_state, const DrawModes::DrawMode &_drawmode)
restores original texture (or no-texture)