Changeset 301 for trunk/src/gl/gl_context.cc
- Timestamp:
- 08/07/14 12:11:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_context.cc
r300 r301 8 8 #include "nv/lib/gl.hh" 9 9 #include "nv/lib/sdl.hh" 10 #include "nv/gl/gl_ texture2d.hh"10 #include "nv/gl/gl_device.hh" 11 11 #include "nv/gl/gl_program.hh" 12 12 #include "nv/gl/gl_vertex_buffer.hh" … … 14 14 using namespace nv; 15 15 16 void gl_context::bind( texture2d* texture, texture_slot slot ) 17 { 18 GLuint id = static_cast< gl_texture2d* >( texture )->glid; 19 glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) ); 20 glBindTexture( GL_TEXTURE_2D, id ); 16 void gl_context::bind( texture t, texture_slot slot ) 17 { 18 const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); 19 if ( info ) 20 { 21 glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) ); 22 glBindTexture( GL_TEXTURE_2D, info->glid ); 23 } 21 24 } 22 25 … … 94 97 } 95 98 96 void gl_context::update( texture2d* texture, void* data ) 97 { 98 GLuint id = static_cast< gl_texture2d* >( texture )->glid; 99 image_format format = texture->get_format(); 100 ivec2 size = texture->get_size(); 101 102 glBindTexture( GL_TEXTURE_2D, id ); 103 glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data ); 99 void nv::gl_context::update( texture t, void* data ) 100 { 101 const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); 102 if ( info ) 103 { 104 image_format format = info->format; 105 ivec2 size = info->size; 106 107 glBindTexture( GL_TEXTURE_2D, info->glid ); 108 glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data ); 109 } 104 110 } 105 111
Note: See TracChangeset
for help on using the changeset viewer.