// ---------------------------------------------------------------------------- // bind all kinds of buffer void vertex_buffer_render_setup ( vertex_buffer_t *self, GLenum mode ) { size_t i; if( self->state != CLEAN ) { vertex_buffer_upload( self ); self->state = CLEAN; } glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );// bind attribute as a whole for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i ) { vertex_attribute_t *attribute = self->attributes[i]; if ( attribute == 0 ) { continue; } else { vertex_attribute_enable( attribute ); } } if( self->indices->size ) { glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );// index? } self->mode = mode; }
// ---------------------------------------------------------------------------- void vertex_buffer_render_setup ( vertex_buffer_t *self, GLenum mode ) { size_t i; #ifdef FREETYPE_GL_USE_VAO // Unbind so no existing VAO-state is overwritten, // (e.g. the GL_ELEMENT_ARRAY_BUFFER-binding). glBindVertexArray( 0 ); #endif if( self->state != CLEAN ) { vertex_buffer_upload( self ); self->state = CLEAN; } #ifdef FREETYPE_GL_USE_VAO if( self->VAO_id == 0 ) { // Generate and set up VAO glGenVertexArrays( 1, &self->VAO_id ); glBindVertexArray( self->VAO_id ); glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id ); for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i ) { vertex_attribute_t *attribute = self->attributes[i]; if( attribute == 0 ) { continue; } else { vertex_attribute_enable( attribute ); } } glBindBuffer( GL_ARRAY_BUFFER, 0 ); if( self->indices->size ) { glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id ); } } // Bind VAO for drawing glBindVertexArray( self->VAO_id ); #else glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id ); for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i ) { vertex_attribute_t *attribute = self->attributes[i]; if ( attribute == 0 ) { continue; } else { vertex_attribute_enable( attribute ); } } if( self->indices->size ) { glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id ); } #endif self->mode = mode; }