commit 584654fa32e513b30e7c2783e39ba9d987997e17 parent bf2ea05f320597a8ce6b47c6adfdbc87de0b5035 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Dec 4 11:06:57 +0200 Purge glad from mod_btt Diffstat:
game.h | | | 4 | ---- |
mod_btt.cc | | | 65 | ++++++++++++++++++++++++++++++++++++----------------------------- |
diff --git a/game.h b/game.h @@ -1,8 +1,6 @@ #ifndef _GAME_H_ #define _GAME_H_ -#include "glad.h" - // TODO: this whole file blows #include "intrinsics.h" #include "linear_algebra.h" @@ -39,9 +37,7 @@ struct GameState { WorkQueue background_tasks; Shader test_shader; - Shader test_outline_shader; - GLint test_outline_un_vp; Skybox skybox; diff --git a/mod_btt.cc b/mod_btt.cc @@ -1,5 +1,3 @@ -#include "glad.h" - #include "game.h" #include "intrinsics.h" #include "immediate.h" @@ -89,7 +87,9 @@ static const char * vert_outline_src = GLSL( out vec3 frag_colour; - uniform mat4 vp; + layout( std140 ) uniform v_hot { + mat4 vp; + }; void main() { frag_colour = colour; @@ -163,7 +163,6 @@ extern "C" GAME_INIT( game_init ) { game->test_shader = renderer_new_shader( terrain_config ); game->test_outline_shader = renderer_new_shader( vert_outline_src, frag_outline_src ); - game->test_outline_un_vp = glGetUniformLocation( game->test_outline_shader, "vp" ); ub_vs = renderer_new_ub(); ub_fs = renderer_new_ub(); @@ -274,33 +273,41 @@ extern "C" GAME_FRAME( game_frame ) { render_state.ubs[ UB_FS_HOT ] = ub_fs; gpubtt_render( &game->gpubtt, render_state ); - immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); - for( size_t i = 0; i < game->hm.width; i++ ) { - v3 origin = v3( i, 1, game->hm.point( i, 1 ).z ); - v3 direction = normalize( v3( -1, 0, horizons[ 1 * game->hm.width + i ] ) ); - v4 white( 1, 1, 1, 1 ); - immediate_arrow( &imm, origin, direction, 2, white ); + { + immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); + for( size_t i = 0; i < game->hm.width; i++ ) { + v3 origin = v3( i, 1, game->hm.point( i, 1 ).z ); + v3 direction = normalize( v3( -1, 0, horizons[ 1 * game->hm.width + i ] ) ); + v4 white( 1, 1, 1, 1 ); + immediate_arrow( &imm, origin, direction, 2, white ); + } + + float t; + if( ray_vs_quadtree( &qt, game->pos, angles_to_vector( game->angles ), &t ) ) { + v3 impact = game->pos + angles_to_vector( game->angles ) * t; + printf( "impact (%f) %f %f %f\n", t, impact.x, impact.y, impact.z ); + immediate_sphere( &imm, impact, 4, v4( 1, 0, 0, 1 ) ); + } + else printf( "nope\n" ); + + RenderState impact_render_state = { }; + impact_render_state.shader = game->test_outline_shader; + impact_render_state.ubs[ UB_VS_HOT ] = ub_vs; + immediate_render( &imm, impact_render_state ); } - glUseProgram( game->test_outline_shader ); - glUniformMatrix4fv( game->test_outline_un_vp, 1, GL_FALSE, ( float * ) &VP ); - - float t; - if( ray_vs_quadtree( &qt, game->pos, angles_to_vector( game->angles ), &t ) ) { - v3 impact = game->pos + angles_to_vector( game->angles ) * t; - printf( "impact (%f) %f %f %f\n", t, impact.x, impact.y, impact.z ); - immediate_sphere( &imm, impact, 4, v4( 1, 0, 0, 1 ) ); + + { + immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); + v3u32 mins = v3u32( 0, 0, qt.nodes[ 0 ].min_z ); + v3u32 maxs = v3u32( qt.dim, qt.dim, qt.nodes[ 0 ].max_z ); + draw_qt( &imm, AABBu32( mins, maxs ), qt.nodes, 0 ); + + RenderState qt_render_state = { }; + qt_render_state.shader = game->test_outline_shader; + qt_render_state.ubs[ UB_VS_HOT ] = ub_vs; + qt_render_state.wireframe = true; + immediate_render( &imm, qt_render_state ); } - else printf( "nope\n" ); - immediate_render( &imm, game->test_outline_shader ); - - immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); - v3u32 mins = v3u32( 0, 0, qt.nodes[ 0 ].min_z ); - v3u32 maxs = v3u32( qt.dim, qt.dim, qt.nodes[ 0 ].max_z ); - draw_qt( &imm, AABBu32( mins, maxs ), qt.nodes, 0 ); - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - immediate_render( &imm, game->test_outline_shader ); - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - glUseProgram( 0 ); // immediate_init( &imm, triangles, ARRAY_COUNT( triangles ) ); // draw_btt( game->btt.left_root, &game->hm, &imm, glm::ivec2( 0, 0 ), glm::ivec2( 0, game->hm.height - 1 ), glm::ivec2( game->hm.width - 1, game->hm.height - 1 ) );