commit 0f494ed3df7c8769b52a8b3754ce41e3e8a38626 parent 1b2bf27372d43108af913aa774d1c37cb125aaec Author: Michael Savage <mikejsavage@gmail.com> Date: Sat Sep 2 13:16:31 +0300 Update medfall to use the new uniforms API Diffstat:
hm.cc | | | 30 | ++++++++++++------------------ |
diff --git a/hm.cc b/hm.cc @@ -29,9 +29,6 @@ static NetAddress server_addr; static u64 sid; static double last_connection_attempt = -5.0; // TODO static bool connected = false; -static UB ub_view; -static UB ub_model; -static UB ub_sun; static VB instance_data; static u32 num_trees; @@ -77,10 +74,6 @@ GAME_INIT( game_init ) { game->sun_angle = 0.3f; - ub_view = renderer_new_ub(); - ub_model = renderer_new_ub(); - ub_sun = renderer_new_ub(); - const size_t triangles = 65536; ImmediateTriangle * immediate_memory = memarena_push_many( &mem->persistent_arena, ImmediateTriangle, triangles ); immediate_init( &game->test_immediate, immediate_memory, triangles ); @@ -157,7 +150,8 @@ GAME_FRAME( game_frame ) { { PROFILE_BLOCK( "renderer_begin_frame" ); - renderer_begin_frame( RENDERER_CLEAR_COLOUR_DONT ); + renderer_begin_frame(); + renderer_begin_pass( RENDERER_CLEAR_COLOUR_DONT, RENDERER_CLEAR_DEPTH_DO ); } float fb = float( input->keys[ KEY_W ] - input->keys[ KEY_S ] ); @@ -346,18 +340,15 @@ GAME_FRAME( game_frame ) { skybox_render( &game->skybox, Vsky, P, game->sun_angle, sun_dir ); terrain_render( &game->tm, V, P, game->sun_angle, sun_dir, current_time ); - renderer_ub_easy( ub_view, V, P ); + UniformBinding view_uniforms = renderer_uniforms( V, P ); { RenderState render_state; render_state.shader = get_shader( SHADER_TREE ); - render_state.ubs[ UB_VIEW ] = ub_view; - render_state.ubs[ UB_MODEL ] = ub_model; - render_state.ubs[ UB_SUN ] = ub_sun; + render_state.uniforms[ UB_VIEW ] = view_uniforms; + render_state.uniforms[ UB_SUN ] = renderer_uniforms( sun_dir ); render_state.cull_face = CULLFACE_FRONT; - renderer_ub_easy( ub_sun, sun_dir ); - renderer_draw_instances( tree_mesh, render_state, num_trees, instance_data ); } @@ -381,7 +372,7 @@ GAME_FRAME( game_frame ) { RenderState impact_render_state; impact_render_state.shader = get_shader( SHADER_FLAT_VERTEX_COLOURS ); - impact_render_state.ubs[ UB_VIEW ] = ub_view; + impact_render_state.uniforms[ UB_VIEW ] = view_uniforms; immediate_render( &imm, impact_render_state ); } @@ -422,7 +413,7 @@ GAME_FRAME( game_frame ) { RenderState fireball_render_state; fireball_render_state.shader = get_shader( SHADER_FLAT_VERTEX_COLOURS ); - fireball_render_state.ubs[ UB_VIEW ] = ub_view; + fireball_render_state.uniforms[ UB_VIEW ] = view_uniforms; immediate_render( &imm, fireball_render_state ); immediate_init( &imm, asdf, ARRAY_COUNT( asdf ) ); @@ -441,7 +432,7 @@ GAME_FRAME( game_frame ) { RenderState explosion_render_state; explosion_render_state.shader = get_shader( SHADER_FLAT_VERTEX_COLOURS ); - explosion_render_state.ubs[ UB_VIEW ] = ub_view; + explosion_render_state.uniforms[ UB_VIEW ] = view_uniforms; immediate_render( &imm, explosion_render_state ); } @@ -546,7 +537,7 @@ GAME_FRAME( game_frame ) { RenderState impact_render_state; impact_render_state.shader = get_shader( SHADER_FLAT_VERTEX_COLOURS ); - impact_render_state.ubs[ UB_VIEW ] = ub_view; + impact_render_state.uniforms[ UB_VIEW ] = view_uniforms; immediate_render( &imm, impact_render_state ); } @@ -559,4 +550,7 @@ GAME_FRAME( game_frame ) { draw_text( str< 128 >( "velocity = {.1}, speed = {.2}, sun_angle = {.2}", game->velocity, length( game->velocity.xy() ), game->sun_angle ).c_str(), 2, 20, 16 ); } + + renderer_end_pass(); + renderer_end_frame(); }