Changeset 299 for trunk/src/gl/gl_vertex_buffer.cc
- Timestamp:
- 08/07/14 10:10:24 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_vertex_buffer.cc
r191 r299 13 13 : vertex_buffer( hint, size ), m_name() 14 14 { 15 bind();15 glBindBuffer( GL_ARRAY_BUFFER, m_name.get_value() ); 16 16 glBufferData( GL_ARRAY_BUFFER, (GLsizeiptr)m_size, data, buffer_hint_to_enum( m_hint ) ); 17 unbind();18 }19 20 void gl_vertex_buffer::update( const void* data, size_t offset, size_t size )21 {22 // IMPORTANT - THIS DOES NOT BIND, SHOULD IT?23 glBufferSubData( GL_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data );24 }25 26 27 void gl_vertex_buffer::bind()28 {29 glBindBuffer( GL_ARRAY_BUFFER, m_name.get_value() );30 }31 32 void gl_vertex_buffer::unbind()33 {34 17 glBindBuffer( GL_ARRAY_BUFFER, 0 ); 35 }36 37 bool gl_vertex_buffer::is_valid() const38 {39 return m_name.is_valid();40 18 } 41 19 … … 43 21 : index_buffer( hint, size ), m_name() 44 22 { 45 bind();23 glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_name.get_value() ); 46 24 glBufferData( GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)m_size, data, buffer_hint_to_enum( m_hint ) ); 47 unbind();48 }49 50 void gl_index_buffer::update( const void* data, size_t offset, size_t size )51 {52 glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data );53 }54 55 void gl_index_buffer::bind()56 {57 glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_name.get_value() );58 }59 60 void gl_index_buffer::unbind()61 {62 25 glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); 63 26 } 64 27 65 bool gl_index_buffer::is_valid() const66 {67 return m_name.is_valid();68 }69 70 gl_vertex_array::gl_vertex_array()71 {72 73 }74 75 void gl_vertex_array::bind()76 {77 for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); i != m_map.end(); ++i )78 {79 uint32 location = static_cast<uint32>( i->first );80 vertex_buffer_attribute* va = i->second;81 vertex_buffer* vb = va->get_buffer();82 glEnableVertexAttribArray( location );83 vb->bind();84 glVertexAttribPointer(85 location,86 static_cast<GLint>( va->get_components() ),87 nv::datatype_to_gl_enum( va->get_datatype() ),88 GL_FALSE,89 static_cast<GLsizei>( va->get_stride() ),90 (void*)va->get_offset()91 );92 vb->unbind();93 }94 95 if ( m_index )96 {97 m_index->bind();98 }99 }100 101 void gl_vertex_array::unbind()102 {103 if ( m_index )104 {105 m_index->unbind();106 }107 108 for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); i != m_map.end(); ++i )109 {110 glDisableVertexAttribArray( static_cast<uint32>( i->first ) );111 }112 }
Note: See TracChangeset
for help on using the changeset viewer.