medfall

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

commit 0493db5b6c24c2189ba4fe2111796c76f4ba0ee0
parent c30ccc7846685421e995a397693a5ab27f1098b2
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Sep 10 18:27:00 -0700

Const madness

Diffstat:
gpubtt.cc | 23+++++++++++------------
gpubtt.h | 9++++-----
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/gpubtt.cc b/gpubtt.cc @@ -9,7 +9,7 @@ #include "heightmap.h" #include "gpubtt.h" -static u32 btt_count_leaves( const BTT * const btt ) { +static u32 btt_count_leaves( const BTT * btt ) { if( btt->left ) { return btt_count_leaves( btt->left ) + btt_count_leaves( btt->right ); } @@ -18,9 +18,8 @@ static u32 btt_count_leaves( const BTT * const btt ) { } static void gpubtt_build( - glm::vec3 * const verts, u32 * i, - const OffsetHeightmap * ohm, const BTT * btt, - const glm::ivec2 iv0, const glm::ivec2 iv1, const glm::ivec2 iv2 + glm::vec3 * verts, u32 * i, const OffsetHeightmap * ohm, const BTT * btt, + glm::ivec2 iv0, glm::ivec2 iv1, glm::ivec2 iv2 ) { const glm::vec3 offset( ohm->x_offset, ohm->y_offset, 0.0f ); @@ -85,16 +84,16 @@ void compute_horizons( } void gpubtt_init( - MemoryArena * const arena, GPUBTT * const gpubtt, - const OffsetHeightmap * const ohm, const BTTs btts, - const GLuint at_position + MemoryArena * arena, GPUBTT * gpubtt, const OffsetHeightmap * ohm, BTTs btts, + GLuint at_position ) { MEMARENA_SCOPED_CHECKPOINT( arena ); const u32 num_leaves = btt_count_leaves( btts.left_root ) + btt_count_leaves( btts.right_root ); - glm::vec3 * const verts = memarena_push_many( arena, glm::vec3, num_leaves * 3 ); + // printf( "%u to %u verts\n", ohm->hm.width * ohm->hm.height * 2, num_leaves ); + glm::vec3 * verts = memarena_push_many( arena, glm::vec3, num_leaves * 3 ); u32 i = 0; // bottom left, bottom right, top left, top right @@ -115,7 +114,7 @@ void gpubtt_init( glEnableVertexAttribArray( at_position ); glVertexAttribPointer( at_position, 3, GL_FLOAT, GL_FALSE, 0, 0 ); - glm::vec3 * const normals = memarena_push_many( arena, glm::vec3, ohm->hm.width * ohm->hm.height ); + glm::vec3 * normals = memarena_push_many( arena, glm::vec3, ohm->hm.width * ohm->hm.height ); for( u32 y = 0; y < ohm->hm.height; y++ ) { for( u32 x = 0; x < ohm->hm.width; x++ ) { @@ -130,7 +129,7 @@ void gpubtt_init( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F, ohm->hm.width, ohm->hm.height, 0, GL_RGB, GL_FLOAT, normals ); - float * const horizons = memarena_push_many( arena, float, ohm->hm.width * ohm->hm.height ); + float * horizons = memarena_push_many( arena, float, ohm->hm.width * ohm->hm.height ); for( u32 i = 0; i < ohm->hm.height; i++ ) { compute_horizons( arena, &ohm->hm, horizons, glm::ivec2( 0, i ), glm::ivec2( 1, 0 ) ); @@ -147,7 +146,7 @@ void gpubtt_init( gpubtt->num_verts = i; } -void gpubtt_destroy( GPUBTT * const gpubtt ) { +void gpubtt_destroy( GPUBTT * gpubtt ) { glDeleteTextures( 1, &gpubtt->tex_normals ); glDeleteBuffers( 1, &gpubtt->vbo_verts ); glDeleteVertexArrays( 1, &gpubtt->vao ); @@ -155,7 +154,7 @@ void gpubtt_destroy( GPUBTT * const gpubtt ) { gpubtt->vbo_verts = 0; } -void gpubtt_render( const GPUBTT * const gpubtt, const GLuint un_normals ) { +void gpubtt_render( const GPUBTT * gpubtt, GLuint un_normals ) { if( gpubtt->vbo_verts == 0 ) return; glBindVertexArray( gpubtt->vao ); diff --git a/gpubtt.h b/gpubtt.h @@ -14,12 +14,11 @@ struct GPUBTT { u32 num_verts; }; -void gpubtt_init( MemoryArena * const arena, GPUBTT * const gpubtt, - const OffsetHeightmap * const ohm, const BTTs btts, - const GLuint at_position ); +void gpubtt_init( MemoryArena * arena, GPUBTT * gpubtt, + const OffsetHeightmap * ohm, BTTs btts, GLuint at_position ); -void gpubtt_destroy( GPUBTT * const gpubtt ); +void gpubtt_destroy( GPUBTT * gpubtt ); -void gpubtt_render( const GPUBTT * const gpubtt, const GLuint un_normals ); +void gpubtt_render( const GPUBTT * gpubtt, GLuint un_normals ); #endif // _GPUBTT_H_