well yeah i guess
[carveJwlIkooP6JGAAIwe30JlM.git] / world_render.h
index 9693e814dc9c0c07347fd03883f07905265bdc09..a73998a778888c9a573dedf582f89195783059b2 100644 (file)
@@ -19,7 +19,7 @@ vg_tex2d tex_alphatest = { .path = "textures/alphatest.qoi",
 vg_tex2d tex_graffiti = { .path = "textures/graffitibox.qoi",
                                  .flags = VG_TEXTURE_NEAREST };
 
-static void world_render_init(void)
+VG_STATIC void world_render_init(void)
 {
    vg_info( "Loading default world textures\n" );
 
@@ -33,32 +33,19 @@ static void world_render_init(void)
    vg_release_thread_sync();
 }
 
-static void world_render_free(void*_)
-{
-   vg_tex2d_free( (vg_tex2d *[]){ &tex_terrain_colours, 
-                                  &tex_terrain_noise,
-                                  &tex_alphatest,
-                                  &tex_graffiti }, 4 );
-}
-
-
-
-static void render_world_depth( m4x4f projection, m4x3f camera );
-
-
-
+VG_STATIC void render_world_depth( m4x4f projection, m4x3f camera );
 
 /*
  * Rendering
  */
 
-static void bind_terrain_textures(void)
+VG_STATIC void bind_terrain_textures(void)
 {
    vg_tex2d_bind( &tex_terrain_noise, 0 );
    vg_tex2d_bind( &tex_terrain_colours, 1 );
 }
 
-static void render_world_vb( m4x4f projection, v3f camera )
+VG_STATIC void render_world_vb( m4x4f projection, v3f camera )
 {
    m4x3f identity_matrix;
    m4x3_identity( identity_matrix );
@@ -73,21 +60,11 @@ static void render_world_vb( m4x4f projection, v3f camera )
    shader_vblend_uMdl( identity_matrix );
    shader_vblend_uCamera( camera );
 
-   scene_bind( &world.geo );
+   mesh_bind( &world.mesh_geo );
    mdl_draw_submesh( &world.sm_geo_vb );
-
-   mesh_bind( &world.cars );
-
-#if 0
-   for( int i=0; i<vg_list_size(world.van_man); i++ )
-   {
-      shader_vblend_uMdl( world.van_man[i].transform );
-      mdl_draw_submesh( &world.car_holden );
-   }
-#endif
 }
 
-static void render_world_alphatest( m4x4f projection, v3f camera )
+VG_STATIC void render_world_alphatest( m4x4f projection, v3f camera )
 {
    m4x3f identity_matrix;
    m4x3_identity( identity_matrix );
@@ -105,7 +82,7 @@ static void render_world_alphatest( m4x4f projection, v3f camera )
    shader_alphatest_uCamera( camera );
 
    glDisable(GL_CULL_FACE);
-   scene_bind( &world.foliage );
+   mesh_bind( &world.mesh_no_collide );
    mdl_draw_submesh( &world.sm_foliage_alphatest );
 
    vg_tex2d_bind( &tex_graffiti, 1 );
@@ -114,7 +91,7 @@ static void render_world_alphatest( m4x4f projection, v3f camera )
    glEnable(GL_CULL_FACE);
 }
 
-static void render_terrain( m4x4f projection, v3f camera )
+VG_STATIC void render_terrain( m4x4f projection, v3f camera )
 {
    m4x3f identity_matrix;
    m4x3_identity( identity_matrix );
@@ -129,20 +106,20 @@ static void render_terrain( m4x4f projection, v3f camera )
    shader_terrain_uMdl( identity_matrix );
    shader_terrain_uCamera( camera );
 
-   scene_bind( &world.geo );
+   mesh_bind( &world.mesh_geo );
    mdl_draw_submesh( &world.sm_terrain );
    mdl_draw_submesh( &world.sm_geo_std_oob );
    mdl_draw_submesh( &world.sm_geo_std );
    mdl_draw_submesh( &world.sm_subworld );
 
    /* TODO: Dont draw in reflection */
-   glDisable(GL_CULL_FACE);
-   scene_bind( &world.foliage );
+   glDisable( GL_CULL_FACE );
+   mesh_bind( &world.mesh_no_collide );
    mdl_draw_submesh( &world.sm_foliage_main );
-   glEnable(GL_CULL_FACE);
+   glEnable( GL_CULL_FACE );
 }
 
-static void render_lowerdome( m4x3f camera )
+VG_STATIC void render_lowerdome( m4x3f camera )
 {
    m4x4f projection, full;
    pipeline_projection( projection, 0.4f, 1000.0f );
@@ -165,7 +142,7 @@ static void render_lowerdome( m4x3f camera )
    mdl_draw_submesh( &world.dome_lower );
 }
 
-static void render_sky(m4x3f camera)
+VG_STATIC void render_sky(m4x3f camera)
 {
    m4x4f projection, full;
    pipeline_projection( projection, 0.4f, 1000.0f );
@@ -197,14 +174,14 @@ static void render_sky(m4x3f camera)
    glDepthMask( GL_TRUE );
 }
 
-static void render_world_gates( m4x4f projection, v3f playerco, m4x3f camera )
+VG_STATIC void render_world_gates( m4x4f projection, v3f playerco, m4x3f camera )
 {
    float closest = INFINITY;
    int   id = 0;
 
-   for( int i=0; i<world_routes.gate_count; i++ )
+   for( int i=0; i<world.gate_count; i++ )
    {
-      struct route_gate *rg = &world_routes.gates[i];
+      struct route_gate *rg = &world.gates[i];
       float dist = v3_dist2( rg->gate.co[0], camera[3] );
 
       if( dist < closest )
@@ -214,14 +191,14 @@ static void render_world_gates( m4x4f projection, v3f playerco, m4x3f camera )
       }
    }
 
-   render_gate( &world_routes.gates[id].gate, playerco, camera );
+   render_gate( &world.gates[id].gate, playerco, camera );
    v3_lerp( world.render_gate_pos, 
-            world_routes.gates[id].gate.co[0],
+            world.gates[id].gate.co[0],
             1.0f,
             world.render_gate_pos );
 }
 
-static void render_world( m4x4f projection, m4x3f camera )
+VG_STATIC void render_world( m4x4f projection, m4x3f camera )
 {
    render_sky( camera );
    render_world_routes( projection, camera[3] );
@@ -232,9 +209,9 @@ static void render_world( m4x4f projection, m4x3f camera )
    int closest = 0;
    float min_dist = INFINITY;
 
-   for( int i=0; i<world_routes.route_count; i++ )
+   for( int i=0; i<world.route_count; i++ )
    {
-      float dist = v3_dist2( world_routes.routes[i].scoreboard_transform[3],
+      float dist = v3_dist2( world.routes[i].scoreboard_transform[3],
                               camera[3] );
 
       if( dist < min_dist )
@@ -244,11 +221,11 @@ static void render_world( m4x4f projection, m4x3f camera )
       }
    }
 
-   sfd_render( &world.sfd.tester, projection, camera[3], 
-         world_routes.routes[closest].scoreboard_transform );
+   sfd_render( projection, camera[3], 
+         world.routes[closest].scoreboard_transform );
 }
 
-static void render_world_depth( m4x4f projection, m4x3f camera )
+VG_STATIC void render_world_depth( m4x4f projection, m4x3f camera )
 {
    m4x3f identity_matrix;
    m4x3_identity( identity_matrix );
@@ -258,8 +235,8 @@ static void render_world_depth( m4x4f projection, m4x3f camera )
    shader_gpos_uPv( projection );
    shader_gpos_uMdl( identity_matrix );
    
-   scene_bind( &world.geo );
-   scene_draw( &world.geo );
+   mesh_bind( &world.mesh_geo );
+   mesh_draw( &world.mesh_geo );
 
 #if 0
    glDisable(GL_CULL_FACE);