medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 6905c1b8eb2e8a740246f94dfd00c717048410c2
parent d8c1a3d91ad6ba1718225b93500fbb9a4a52f7fe
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri Oct 28 20:01:25 +0300

Don't need 3 buffers with the same data in immediate renderer

Diffstat:
immediate.cc | 15+++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/immediate.cc b/immediate.cc @@ -223,26 +223,21 @@ void immediate_render( ) { GLuint vao; glGenVertexArrays( 1, &vao ); - glBindVertexArray( vao ); - const u32 num_vbos = 3; - GLuint vbos[ num_vbos ]; - glGenBuffers( num_vbos, vbos ); + GLuint vbo; + glGenBuffers( 1, &vbo ); + glBindBuffer( GL_ARRAY_BUFFER, vbo ); - glBindBuffer( GL_ARRAY_BUFFER, vbos[ 0 ] ); glBufferData( GL_ARRAY_BUFFER, ctx->num_triangles * sizeof( ImmediateTriangle ), ctx->triangles, GL_STATIC_DRAW ); + glEnableVertexAttribArray( at_position ); glVertexAttribPointer( at_position, 3, GL_FLOAT, GL_FALSE, sizeof( ImmediateVertex ), 0 ); - glBindBuffer( GL_ARRAY_BUFFER, vbos[ 1 ] ); - glBufferData( GL_ARRAY_BUFFER, ctx->num_triangles * sizeof( ImmediateTriangle ), ctx->triangles, GL_STATIC_DRAW ); glEnableVertexAttribArray( at_colour ); glVertexAttribPointer( at_colour, 3, GL_FLOAT, GL_FALSE, sizeof( ImmediateVertex ), ( GLvoid * ) offsetof( ImmediateVertex, colour ) ); if( textured ) { - glBindBuffer( GL_ARRAY_BUFFER, vbos[ 2 ] ); - glBufferData( GL_ARRAY_BUFFER, ctx->num_triangles * sizeof( ImmediateTriangle ), ctx->triangles, GL_STATIC_DRAW ); glEnableVertexAttribArray( at_uv ); glVertexAttribPointer( at_uv, 2, GL_FLOAT, GL_FALSE, sizeof( ImmediateVertex ), ( GLvoid * ) offsetof( ImmediateVertex, uv ) ); @@ -254,7 +249,7 @@ void immediate_render( glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); - glDeleteBuffers( num_vbos, vbos ); + glDeleteBuffers( 1, &vbo ); glDeleteVertexArrays( 1, &vao ); }