medfall

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

commit 6e48e148cb88f67f010e9a6d0f52fa1a91b55318
parent 17a1a7fa8825604d2f6c6cd61889ef2c2fcc277c
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Sep 10 18:17:09 -0700

Start calling GameState game instead of state

Diffstat:
bsp.cc | 48++++++++++++++++++++++++------------------------
game.h | 4++--
hm.cc | 100++++++++++++++++++++++++++++++++++++++++----------------------------------------
mod_btt.cc | 80++++++++++++++++++++++++++++++++++++++++----------------------------------------
shadow_map.cc | 8++++----
5 files changed, 120 insertions(+), 120 deletions(-)
diff --git a/bsp.cc b/bsp.cc @@ -286,19 +286,19 @@ glm::vec3 angles_to_vector( const glm::vec3 & angles ) { static const glm::mat4 P( glm::perspective( glm::radians( 120.0f ), 640.0f / 480.0f, 0.1f, 10000.0f ) ); extern "C" GAME_INIT( game_init ) { - bsp_init( &state->bsp, "acidwdm2.bsp" ); + bsp_init( &game->bsp, "acidwdm2.bsp" ); MemoryArena arena = memarena_push_arena( &mem->persistent_arena, megabytes( 10 ) ); - state->pos = glm::vec3( 0, -100, 450 ); - state->angles = glm::radians( ( glm::vec3( -90, 135, 0 ) ) ); + game->pos = glm::vec3( 0, -100, 450 ); + game->angles = glm::radians( ( glm::vec3( -90, 135, 0 ) ) ); - state->test_shader = compile_shader( vert_src, frag_src, "screen_colour" ); - state->test_at_position = glGetAttribLocation( state->test_shader, "position" ); - state->test_at_colour = glGetAttribLocation( state->test_shader, "colour" ); - state->test_un_VP = glGetUniformLocation( state->test_shader, "VP" ); + game->test_shader = compile_shader( vert_src, frag_src, "screen_colour" ); + game->test_at_position = glGetAttribLocation( game->test_shader, "position" ); + game->test_at_colour = glGetAttribLocation( game->test_shader, "colour" ); + game->test_un_VP = glGetUniformLocation( game->test_shader, "VP" ); - bspr_init( &state->bspr, &arena, &state->bsp, state->test_at_position, state->test_at_colour ); + bspr_init( &game->bspr, &arena, &game->bsp, game->test_at_position, game->test_at_colour ); } extern "C" GAME_FRAME( game_frame ) { @@ -311,49 +311,49 @@ extern "C" GAME_FRAME( game_frame ) { const int pitch = input->keys[ KEY_UPARROW ] - input->keys[ KEY_DOWNARROW ]; const int yaw = input->keys[ KEY_RIGHTARROW ] - input->keys[ KEY_LEFTARROW ]; - state->angles.x += pitch * dt * 2; - state->angles.y += yaw * dt * 2; + game->angles.x += pitch * dt * 2; + game->angles.y += yaw * dt * 2; - const glm::vec3 forward = angles_to_vector( state->angles ); - state->pos += forward * 100.0f * dt * ( float ) fb; - const glm::vec3 sideways = glm::vec3( -cosf( state->angles.y ), sinf( state->angles.y ), 0 ); - state->pos += sideways * 100.0f * dt * ( float ) lr; - state->pos.z += ( float ) dz * 100.0f * dt; + const glm::vec3 forward = angles_to_vector( game->angles ); + game->pos += forward * 100.0f * dt * ( float ) fb; + const glm::vec3 sideways = glm::vec3( -cosf( game->angles.y ), sinf( game->angles.y ), 0 ); + game->pos += sideways * 100.0f * dt * ( float ) lr; + game->pos.z += ( float ) dz * 100.0f * dt; const glm::mat4 VP = glm::translate( glm::rotate( glm::rotate( P, - state->angles.x, + game->angles.x, glm::vec3( 1, 0, 0 ) ), - state->angles.y, + game->angles.y, glm::vec3( 0, 0, 1 ) ), - -state->pos + -game->pos ); - glUseProgram( state->test_shader ); - glUniformMatrix4fv( state->test_un_VP, 1, GL_FALSE, glm::value_ptr( VP ) ); + glUseProgram( game->test_shader ); + glUniformMatrix4fv( game->test_un_VP, 1, GL_FALSE, glm::value_ptr( VP ) ); - bspr_render( &state->bspr, state->pos ); + bspr_render( &game->bspr, game->pos ); immediate_init( &imm, triangles, array_count( triangles ) ); immediate_sphere( &imm, glm::vec3( 0, 0, 0 ), 128, glm::vec4( 1, 1, 0, 1 ) ); if( input->keys[ 't' ] ) { fix = true; - fix_start = state->pos; + fix_start = game->pos; fix_end = fix_start + forward * 1000.0f; } if( fix ) { Intersection is; - bool hit = state->bspr.bsp->trace_seg( fix_start, fix_end, is ); + bool hit = game->bspr.bsp->trace_seg( fix_start, fix_end, is ); if( hit ) { immediate_sphere( &imm, is.pos, 16, glm::vec4( 1, 0, 0, 1 ) ); } } - immediate_render( &imm, state->test_at_position, state->test_at_colour ); + immediate_render( &imm, game->test_at_position, game->test_at_colour ); } diff --git a/game.h b/game.h @@ -87,10 +87,10 @@ struct GameInput { bool keys[ KEY_COUNT ]; }; -#define GAME_INIT( name ) void name( GameState * const state, GameMemory * const mem ) +#define GAME_INIT( name ) void name( GameState * const game, GameMemory * const mem ) typedef GAME_INIT( GameInit ); -#define GAME_FRAME( name ) void name( GameState * const state, GameMemory * const mem, const GameInput * const input, const float dt ) +#define GAME_FRAME( name ) void name( GameState * const game, GameMemory * const mem, const GameInput * const input, const float dt ) typedef GAME_FRAME( GameFrame ); #endif // _GAME_H_ diff --git a/hm.cc b/hm.cc @@ -114,51 +114,51 @@ static WORK_QUEUE_CALLBACK( testwq ) { } extern "C" GAME_INIT( game_init ) { - state->pos = glm::vec3( 15000, 3000, 50 ); - state->angles = glm::radians( glm::vec3( -90, 45, 0 ) ); - terrain_init( &state->tm, "terrains/Srtm_ramp2.world.21600x10800.jpg.parts", &mem->persistent_arena ); - terrain_teleport( &state->tm, state->pos ); + game->pos = glm::vec3( 15000, 3000, 50 ); + game->angles = glm::radians( glm::vec3( -90, 45, 0 ) ); + terrain_init( &game->tm, "terrains/Srtm_ramp2.world.21600x10800.jpg.parts", &mem->persistent_arena ); + terrain_teleport( &game->tm, game->pos ); - workqueue_init( &state->background_tasks, &mem->persistent_arena, 2 ); + workqueue_init( &game->background_tasks, &mem->persistent_arena, 2 ); u32 nums[ 10 ]; for( u32 i = 0; i < 10; i++ ) { nums[ i ] = i; - workqueue_enqueue( &state->background_tasks, testwq, &nums[ i ] ); + workqueue_enqueue( &game->background_tasks, testwq, &nums[ i ] ); } - workqueue_exhaust( &state->background_tasks ); + workqueue_exhaust( &game->background_tasks ); - state->test_shader = compile_shader( vert_src, frag_src, "screen_colour" ); - state->test_at_position = glGetAttribLocation( state->test_shader, "position" ); - state->test_at_colour = glGetAttribLocation( state->test_shader, "colour" ); + game->test_shader = compile_shader( vert_src, frag_src, "screen_colour" ); + game->test_at_position = glGetAttribLocation( game->test_shader, "position" ); + game->test_at_colour = glGetAttribLocation( game->test_shader, "colour" ); const size_t triangles = 65536; ImmediateTriangle * immediate_memory = memarena_push_many( &mem->persistent_arena, ImmediateTriangle, triangles ); - immediate_init( &state->test_immediate, immediate_memory, triangles ); + immediate_init( &game->test_immediate, immediate_memory, triangles ); const float aspect = float( WIDTH ) / float( HEIGHT ); const float crosshair_thickness = 0.0025; const float crosshair_length = 0.01; const glm::vec4 red( 1, 0, 0, 1 ); - immediate_triangle( &state->test_immediate, + immediate_triangle( &game->test_immediate, glm::vec3( -crosshair_length, -crosshair_thickness, 0 ), glm::vec3( -crosshair_length, crosshair_thickness, 0 ), glm::vec3( crosshair_length, crosshair_thickness, 0 ), red ); - immediate_triangle( &state->test_immediate, + immediate_triangle( &game->test_immediate, glm::vec3( crosshair_length, crosshair_thickness, 0 ), glm::vec3( crosshair_length, -crosshair_thickness, 0 ), glm::vec3( -crosshair_length, -crosshair_thickness, 0 ), red ); - immediate_triangle( &state->test_immediate, + immediate_triangle( &game->test_immediate, glm::vec3( -crosshair_thickness / aspect, crosshair_length * aspect, 0 ), glm::vec3( crosshair_thickness / aspect, crosshair_length * aspect, 0 ), glm::vec3( crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), red ); - immediate_triangle( &state->test_immediate, + immediate_triangle( &game->test_immediate, glm::vec3( crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), glm::vec3( -crosshair_thickness / aspect, -crosshair_length * aspect, 0 ), glm::vec3( -crosshair_thickness / aspect, crosshair_length * aspect, 0 ), @@ -172,7 +172,7 @@ extern "C" GAME_INIT( game_init ) { u8 * const font_memory = memarena_push_size( &mem->persistent_arena, 512 * 256 ); const int offset = stbtt_GetFontOffsetForIndex( arial, 0 ); - const int ok = stbtt_BakeFontBitmap( arial, offset, 48, font_memory, 512, 512, ' ', 127 - ' ', state->test_chars ); + const int ok = stbtt_BakeFontBitmap( arial, offset, 48, font_memory, 512, 512, ' ', 127 - ' ', game->test_chars ); assert( ok > 0 ); free( arial ); @@ -192,24 +192,24 @@ extern "C" GAME_INIT( game_init ) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, font_bitmap.width, font_bitmap.height, 0, GL_RED, GL_UNSIGNED_BYTE, font_memory ); - state->assets[ ASSET_FONT ] = font_asset; + game->assets[ ASSET_FONT ] = font_asset; - state->test_tex_shader = compile_shader( textured_vert_src, textured_frag_src, "screen_colour" ); - state->test_tex_at_pos = glGetAttribLocation( state->test_tex_shader, "position" ); - state->test_tex_at_colour = glGetAttribLocation( state->test_tex_shader, "colour" ); - state->test_tex_at_uv = glGetAttribLocation( state->test_tex_shader, "uv" ); - state->test_tex_un_tex = glGetUniformLocation( state->test_tex_shader, "tex" ); + game->test_tex_shader = compile_shader( textured_vert_src, textured_frag_src, "screen_colour" ); + game->test_tex_at_pos = glGetAttribLocation( game->test_tex_shader, "position" ); + game->test_tex_at_colour = glGetAttribLocation( game->test_tex_shader, "colour" ); + game->test_tex_at_uv = glGetAttribLocation( game->test_tex_shader, "uv" ); + game->test_tex_un_tex = glGetUniformLocation( game->test_tex_shader, "tex" ); - state->font_shader = compile_shader( font_vert_src, font_frag_src, "screen_colour" ); - state->font_at_position = glGetAttribLocation( state->font_shader, "position" ); - state->font_at_colour = glGetAttribLocation( state->font_shader, "colour" ); - state->font_at_uv = glGetAttribLocation( state->font_shader, "uv" ); - state->font_un_atlas = glGetUniformLocation( state->font_shader, "atlas" ); + game->font_shader = compile_shader( font_vert_src, font_frag_src, "screen_colour" ); + game->font_at_position = glGetAttribLocation( game->font_shader, "position" ); + game->font_at_colour = glGetAttribLocation( game->font_shader, "colour" ); + game->font_at_uv = glGetAttribLocation( game->font_shader, "uv" ); + game->font_un_atlas = glGetUniformLocation( game->font_shader, "atlas" ); - skybox_init( &state->skybox ); + skybox_init( &game->skybox ); } -static void draw_string( const GameState * state, +static void draw_string( const GameState * game, float x, float y, const char * str, const GLint at_pos, const GLint at_colour, const GLint at_uv, const GLint un_atlas @@ -221,11 +221,11 @@ static void draw_string( const GameState * state, ImmediateTriangle triangles[ 256 ]; immediate_init( &imm, triangles, array_count( triangles ) ); - glBindTexture( GL_TEXTURE_2D, state->assets[ ASSET_FONT ].texture ); + glBindTexture( GL_TEXTURE_2D, game->assets[ ASSET_FONT ].texture ); while( *str != '\0' ) { stbtt_aligned_quad q; - stbtt_GetBakedQuad( ( stbtt_bakedchar * ) state->test_chars, 512, 256, *str - ' ', &x, &y, &q, true ); + stbtt_GetBakedQuad( ( stbtt_bakedchar * ) game->test_chars, 512, 256, *str - ' ', &x, &y, &q, true ); const ImmediateVertex v1A = { glm::vec3( q.x0 * scale, -q.y0 * scale, 0 ), white, glm::vec2( q.s0, q.t0 ) }; const ImmediateVertex v2A = { glm::vec3( q.x1 * scale, -q.y0 * scale, 0 ), white, glm::vec2( q.s1, q.t0 ) }; @@ -253,45 +253,45 @@ extern "C" GAME_FRAME( game_frame ) { const int pitch = input->keys[ KEY_UPARROW ] - input->keys[ KEY_DOWNARROW ]; const int yaw = input->keys[ KEY_RIGHTARROW ] - input->keys[ KEY_LEFTARROW ]; - state->angles.x += pitch * dt * 2; - state->angles.y += yaw * dt * 2; + game->angles.x += pitch * dt * 2; + game->angles.y += yaw * dt * 2; // const float speed = 6.0f; const float speed = 100.0f; - state->pos += angles_to_vector_xy( state->angles ) * speed * dt * ( float ) fb; - const glm::vec3 sideways = glm::vec3( -cosf( state->angles.y ), sinf( state->angles.y ), 0 ); - state->pos += sideways * speed * dt * ( float ) lr; - // state->pos.z = terrain_height( &state->tm, state->pos ) + 2; - state->pos.z += dz * 50.0f * dt; + game->pos += angles_to_vector_xy( game->angles ) * speed * dt * ( float ) fb; + const glm::vec3 sideways = glm::vec3( -cosf( game->angles.y ), sinf( game->angles.y ), 0 ); + game->pos += sideways * speed * dt * ( float ) lr; + // game->pos.z = terrain_height( &game->tm, game->pos ) + 2; + game->pos.z += dz * 50.0f * dt; - terrain_update( &state->tm, state->pos ); + terrain_update( &game->tm, game->pos ); const glm::mat4 V = glm::translate( glm::rotate( glm::rotate( glm::mat4(), - state->angles.x, + game->angles.x, glm::vec3( 1, 0, 0 ) ), - state->angles.y, + game->angles.y, glm::vec3( 0, 0, 1 ) ), - -state->pos + -game->pos ); const glm::mat4 VP = P * V; - terrain_render( &state->tm, V, VP, 0.3f ); - skybox_render( &state->skybox, state->angles ); + terrain_render( &game->tm, V, VP, 0.3f ); + skybox_render( &game->skybox, game->angles ); glDisable( GL_DEPTH_TEST ); - glUseProgram( state->test_shader ); - immediate_render( &state->test_immediate, state->test_at_position, state->test_at_colour ); + glUseProgram( game->test_shader ); + immediate_render( &game->test_immediate, game->test_at_position, game->test_at_colour ); glEnable( GL_DEPTH_TEST ); glDisable( GL_DEPTH_TEST ); glEnable( GL_BLEND ); - glUseProgram( state->test_tex_shader ); + glUseProgram( game->test_tex_shader ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); ImmediateContext imm; ImmediateTriangle asdf[ 32 ]; @@ -327,13 +327,13 @@ extern "C" GAME_FRAME( game_frame ) { immediate_triangle( &imm, v1, v2, v3 ); immediate_triangle( &imm, v3, v2, v4 ); - immediate_render( &imm, state->test_tex_at_pos, state->test_tex_at_colour, true, state->test_tex_at_uv, state->test_tex_un_tex ); + immediate_render( &imm, game->test_tex_at_pos, game->test_tex_at_colour, true, game->test_tex_at_uv, game->test_tex_un_tex ); glDeleteTextures( 1, &tex ); glBindTexture( GL_TEXTURE_2D, 0 ); - glUseProgram( state->font_shader ); + glUseProgram( game->font_shader ); // TODO: the positions don't make sense - draw_string( state, -140, -100, "hello", state->font_at_position, state->font_at_colour, state->font_at_uv, state->font_un_atlas ); + draw_string( game, -140, -100, "hello", game->font_at_position, game->font_at_colour, game->font_at_uv, game->font_un_atlas ); glUseProgram( 0 ); glDisable( GL_BLEND ); diff --git a/mod_btt.cc b/mod_btt.cc @@ -131,35 +131,35 @@ static void draw_btt( static const glm::mat4 P( glm::perspective( glm::radians( 120.0f ), ( float ) WIDTH / ( float ) HEIGHT, NEAR_PLANE_DEPTH, FAR_PLANE_DEPTH ) ); extern "C" GAME_INIT( game_init ) { - state->pos = glm::vec3( 100, 200, 100 ); - state->angles = glm::radians( glm::vec3( -90, 45, 0 ) ); + game->pos = glm::vec3( 100, 200, 100 ); + game->angles = glm::radians( glm::vec3( -90, 45, 0 ) ); - state->test_sun = 0.3f; + game->test_sun = 0.3f; - state->test_shader = compile_shader( vert_src, frag_src, "screen_colour" ); - state->test_at_position = glGetAttribLocation( state->test_shader, "position" ); - state->test_un_VP = glGetUniformLocation( state->test_shader, "vp" ); - state->test_un_sun = glGetUniformLocation( state->test_shader, "sun" ); - state->test_un_normals = glGetUniformLocation( state->test_shader, "normals" ); - state->test_un_dimensions = glGetUniformLocation( state->test_shader, "dimensions" ); + game->test_shader = compile_shader( vert_src, frag_src, "screen_colour" ); + game->test_at_position = glGetAttribLocation( game->test_shader, "position" ); + game->test_un_VP = glGetUniformLocation( game->test_shader, "vp" ); + game->test_un_sun = glGetUniformLocation( game->test_shader, "sun" ); + game->test_un_normals = glGetUniformLocation( game->test_shader, "normals" ); + game->test_un_dimensions = glGetUniformLocation( game->test_shader, "dimensions" ); - state->test_outline_shader = compile_shader( vert_outline_src, frag_outline_src, "screen_colour" ); - state->test_outline_at_position = glGetAttribLocation( state->test_outline_shader, "position" ); - state->test_outline_at_colour = glGetAttribLocation( state->test_outline_shader, "colour" ); - state->test_outline_un_vp = glGetUniformLocation( state->test_outline_shader, "vp" ); + game->test_outline_shader = compile_shader( vert_outline_src, frag_outline_src, "screen_colour" ); + game->test_outline_at_position = glGetAttribLocation( game->test_outline_shader, "position" ); + game->test_outline_at_colour = glGetAttribLocation( game->test_outline_shader, "colour" ); + game->test_outline_un_vp = glGetUniformLocation( game->test_outline_shader, "vp" ); int w, h; u8 * pixels = stbi_load( "terrains/mountains512.png", &w, &h, NULL, 1 ); - heightmap_init( &state->hm, pixels, w, h ); + heightmap_init( &game->hm, pixels, w, h ); - state->btt = btt_from_heightmap( &state->hm, &mem->persistent_arena ); + game->btt = btt_from_heightmap( &game->hm, &mem->persistent_arena ); - const OffsetHeightmap ohm = { state->hm, 0, 0 }; - gpubtt_init( &mem->persistent_arena, &state->gpubtt, &ohm, state->btt, state->test_at_position ); + const OffsetHeightmap ohm = { game->hm, 0, 0 }; + gpubtt_init( &mem->persistent_arena, &game->gpubtt, &ohm, game->btt, game->test_at_position ); glClearColor( 0, 0.5, 0.7, 1 ); - skybox_init( &state->skybox ); + skybox_init( &game->skybox ); } extern "C" GAME_FRAME( game_frame ) { @@ -170,55 +170,55 @@ extern "C" GAME_FRAME( game_frame ) { const int dz = input->keys[ KEY_SPACE ] - input->keys[ KEY_LEFTSHIFT ]; const float dsun = ( input->keys[ KEY_EQUALS ] - input->keys[ KEY_MINUS ] ) * dt; - state->test_sun += dsun; - if( dsun != 0 ) printf( "sun: %.4f\n", state->test_sun ); + game->test_sun += dsun; + if( dsun != 0 ) printf( "sun: %.4f\n", game->test_sun ); const int pitch = input->keys[ KEY_UPARROW ] - input->keys[ KEY_DOWNARROW ]; const int yaw = input->keys[ KEY_RIGHTARROW ] - input->keys[ KEY_LEFTARROW ]; - state->angles.x += pitch * dt * 2; - state->angles.y += yaw * dt * 2; + game->angles.x += pitch * dt * 2; + game->angles.y += yaw * dt * 2; // const float speed = 6.0f; const float speed = 100.0f; - state->pos += angles_to_vector_xy( state->angles ) * speed * dt * ( float ) fb; - const glm::vec3 sideways = glm::vec3( -cosf( state->angles.y ), sinf( state->angles.y ), 0 ); - state->pos += sideways * speed * dt * ( float ) lr; - state->pos.z += dz * 50.0f * dt; + game->pos += angles_to_vector_xy( game->angles ) * speed * dt * ( float ) fb; + const glm::vec3 sideways = glm::vec3( -cosf( game->angles.y ), sinf( game->angles.y ), 0 ); + game->pos += sideways * speed * dt * ( float ) lr; + game->pos.z += dz * 50.0f * dt; const glm::mat4 VP = glm::translate( glm::rotate( glm::rotate( P, - state->angles.x, + game->angles.x, glm::vec3( 1, 0, 0 ) ), - state->angles.y, + game->angles.y, glm::vec3( 0, 0, 1 ) ), - -state->pos + -game->pos ); const glm::vec3 sun = glm::normalize( glm::vec3( 1, 0, -0.3 ) ); - glUseProgram( state->test_shader ); - glUniformMatrix4fv( state->test_un_VP, 1, GL_FALSE, glm::value_ptr( VP ) ); - glUniform1f( state->test_un_sun, state->test_sun ); - glUniform2f( state->test_un_dimensions, state->hm.width, state->hm.height ); - gpubtt_render( &state->gpubtt, state->test_un_normals ); + glUseProgram( game->test_shader ); + glUniformMatrix4fv( game->test_un_VP, 1, GL_FALSE, glm::value_ptr( VP ) ); + glUniform1f( game->test_un_sun, game->test_sun ); + glUniform2f( game->test_un_dimensions, game->hm.width, game->hm.height ); + gpubtt_render( &game->gpubtt, game->test_un_normals ); glUseProgram( 0 ); immediate_init( &imm, triangles, array_count( triangles ) ); - draw_btt( state->btt.left_root, &state->hm, &imm, glm::ivec2( 0, 0 ), glm::ivec2( 0, state->hm.height - 1 ), glm::ivec2( state->hm.width - 1, state->hm.height - 1 ) ); - draw_btt( state->btt.right_root, &state->hm, &imm, glm::ivec2( state->hm.width - 1, state->hm.height - 1 ), glm::ivec2( state->hm.width - 1, 0 ), glm::ivec2( 0, 0 ) ); + 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 ) ); + draw_btt( game->btt.right_root, &game->hm, &imm, glm::ivec2( game->hm.width - 1, game->hm.height - 1 ), glm::ivec2( game->hm.width - 1, 0 ), glm::ivec2( 0, 0 ) ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - glUseProgram( state->test_outline_shader ); - glUniformMatrix4fv( state->test_outline_un_vp, 1, GL_FALSE, glm::value_ptr( VP ) ); - immediate_render( &imm, state->test_outline_at_position, state->test_outline_at_colour ); + glUseProgram( game->test_outline_shader ); + glUniformMatrix4fv( game->test_outline_un_vp, 1, GL_FALSE, glm::value_ptr( VP ) ); + immediate_render( &imm, game->test_outline_at_position, game->test_outline_at_colour ); glUseProgram( 0 ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - skybox_render( &state->skybox, state->angles ); + skybox_render( &game->skybox, game->angles ); // benchmark_print_timers(); } diff --git a/shadow_map.cc b/shadow_map.cc @@ -126,16 +126,16 @@ extern "C" GAME_INIT( game_init ) { glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); - state->pos = glm::vec3( -10, -10, 5 ); - state->angles = glm::radians( ( glm::vec3( -90, 45, 0 ) ) ); + game->pos = glm::vec3( -10, -10, 5 ); + game->angles = glm::radians( ( glm::vec3( -90, 45, 0 ) ) ); } extern "C" GAME_FRAME( game_frame ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - update_camera( input, dt, state->pos, state->angles, &state->pos, &state->angles ); + update_camera( input, dt, game->pos, game->angles, &game->pos, &game->angles ); glm::mat4 vp; - camera_to_vp( state->pos, state->angles, &vp ); + camera_to_vp( game->pos, game->angles, &vp ); glUseProgram( prog ); glUniformMatrix4fv( un_vp, 1, GL_FALSE, glm::value_ptr( vp ) );