fix routes
[carveJwlIkooP6JGAAIwe30JlM.git] / world_water.h
index 11d9594d6fada5c0729b066d172db2cb7467b73a..a4f69672973a2676ce520756f7494e4158b7d7f1 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
+ */
+
 #ifndef WATER_H
 #define WATER_H
 
@@ -26,28 +30,20 @@ wrender =
    .fbdepth   = { .format = GL_RGBA, .div = 4 }
 };
 
-static int world_water_init(void)
+static void world_water_init(void)
 {
    vg_info( "world_water_init\n" );
    shader_water_register();
    
-   if( vg_acquire_thread_sync(1) )
+   vg_acquire_thread_sync();
    {
-      if( !fb_init( &wrender.fbreflect ) ||
-          !fb_init( &wrender.fbdepth ) )
-      {
-         vg_release_thread_sync(1);
-         return 0;
-      }
+      fb_init( &wrender.fbreflect );
+      fb_init( &wrender.fbdepth );
 
       vg_tex2d_init( (vg_tex2d *[]){&tex_water_surf}, 1 );
-
       vg_success( "done\n" );
-      vg_release_thread_sync(1);
-      return 1;
    }
-   else
-      return 0;
+   vg_release_thread_sync();
 }
 
 static void world_water_free(void *_)
@@ -112,7 +108,7 @@ static void render_water_texture( m4x3f camera )
    m4x4f projection;
    m4x4_projection( projection,
          gpipeline.fov,
-         (float)vg_window_x / (float)vg_window_y, 
+         (float)vg.window_x / (float)vg.window_y, 
          0.1f, 900.0f );
    plane_clip_projection( projection, clippa );
    m4x4_mul( projection, view, projection );
@@ -136,14 +132,14 @@ static void render_water_texture( m4x3f camera )
 
    m4x4_projection( projection,
          gpipeline.fov,
-         (float)vg_window_x / (float)vg_window_y, 
+         (float)vg.window_x / (float)vg.window_y, 
          0.1f, 900.0f );
 
    plane_clip_projection( projection, clippb );
    m4x4_mul( projection, view, projection );
    render_world_depth( projection, camera );
    
-   glViewport( 0, 0, vg_window_x, vg_window_y );
+   glViewport( 0, 0, vg.window_x, vg.window_y );
 }
 
 static void render_water_surface( m4x4f pv, m4x3f camera )
@@ -160,14 +156,14 @@ static void render_water_surface( m4x4f pv, m4x3f camera )
    vg_tex2d_bind( &tex_water_surf, 1 );
    shader_water_uTexDudv( 1 );
    shader_water_uInvRes( (v2f){
-         1.0f / (float)vg_window_x,
-         1.0f / (float)vg_window_y });
+         1.0f / (float)vg.window_x,
+         1.0f / (float)vg.window_y });
 
    shader_link_standard_ub( _shader_water.id, 2 );
 
    fb_bindtex( &wrender.fbdepth, 3 );
    shader_water_uTexBack( 3 );
-   shader_water_uTime( vg_time );
+   shader_water_uTime( vg.time );
    shader_water_uCamera( camera[3] );
    shader_water_uSurfaceY( wrender.height );