steam flags
authorhgn <hgodden00@gmail.com>
Wed, 29 Dec 2021 13:10:32 +0000 (13:10 +0000)
committerhgn <hgodden00@gmail.com>
Wed, 29 Dec 2021 13:10:32 +0000 (13:10 +0000)
build.sh
fishladder.c
fishladder_resources.h
vg/config.h
vg/vg.h

index b449611c5cbbcb1d6e3ce212996e2c0973925771..aa0d03e0c21f5fa1d6b07d7fa6ac41469bc05692 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -3,7 +3,8 @@
 src="fishladder.c"
 target="fishladder"
 lib="-I. -L./lib -L./"
-libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl -l:steam/libsteam_api.so"
+libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl"
+steam_part="-l:steam/libsteam_api.so"
 flags="-fsanitize=address -ggdb3 -Wno-unused-function"
 build_dir="build.linux"
 steam_api="libsteam_api.so"
@@ -12,7 +13,7 @@ if [[ "$OSTYPE" != "linux-gnu"* ]]; then
        echo "Operating system is not GNU/Linux, windows will be assumed."
 
        target="fishladder.exe"
-       libs="-lglfw3 -lopengl32 -lm -mwindows -l:steam/steam_api.dll"
+       libs="-lglfw3 -lopengl32 -lm -mwindows"
        flags="-ggdb3 -Wno-unused-function"
        build_dir="build.win32"
        steam_api="steam_api.dll"
@@ -33,6 +34,11 @@ while (( "$#" )); do
                        run_after=true 
                        echo "& Run" 
                ;;
+               -s|--no-steam)
+                       steam_part=""
+                       defines="-DNO_STEAM"
+                       echo "no-steam"
+               ;;
                -n|--nobuild)
                        do_build=false
                        echo "no-build"
@@ -57,8 +63,8 @@ done
 if [ "$compile_tools" = true ]; then
        echo "Building tools"
        mkdir tools -p
-       gcc -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs -Wl,-rpath=./ $defines
-       gcc -Wall -Wstrict-aliasing=3 $lib $flags fontcomp.c gl/glad.c -o tools/fontcomp $libs -Wl,-rpath=./ $defines
+       gcc -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs $steam_part -Wl,-rpath=./ $defines
+       gcc -Wall -Wstrict-aliasing=3 $lib $flags fontcomp.c gl/glad.c -o tools/fontcomp $libs $steam_part -Wl,-rpath=./ $defines
        gcc $lib qoiconv.c -std=c99 -O3 -o tools/qoiconv
 fi
 
@@ -81,7 +87,7 @@ done
 
 # Main build
 if [ "$do_build" = true ]; then
-       gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs -Wl,-rpath=./ $defines
+       gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs $steam_part -Wl,-rpath=./ $defines
 
        if [ $? -ne 0 ]; then
                echo "GCC build failed"
index b4c0997b0e6b6247854ef8e73b68828663d6aa65..9d53dc839ab0f6545d22519a75010257207b0562 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
 
 //#define VG_CAPTURE_MODE
-#define VG_STEAM
+//#define VG_STEAM
 #define VG_STEAM_APPID 1218140U
 #include "vg/vg.h"
 #include "fishladder_resources.h"
@@ -307,9 +307,6 @@ static int world_check_pos_ok( v2i co );
 static int cell_interactive( v2i co );
 
 void vg_update(void);
-void leaderboard_found( LeaderboardFindResult_t *pCallback );
-void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback );
-
 static void render_tiles( v2i start, v2i end, v4f const regular_colour, v4f const selected_colour );
 
 void vg_render(void);
@@ -317,11 +314,16 @@ void vg_ui(void);
 
 // Leaderboard stuff
 // -----------------
+#ifdef STEAM_LEADERBOARDS
 void leaderboard_set_score( struct cmp_level *cmp_level, u32 score );
 void leaderboard_dispatch_score(void);
 void leaderboard_found( LeaderboardFindResult_t *pCallback );
 void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback );
 void leaderboard_set_score( struct cmp_level *cmp_level, u32 score );
+#endif
+
+// Console commands
+// ----------------
 static int console_credits( int argc, char const *argv[] );
 static int console_save_map( int argc, char const *argv[] );
 static int console_load_map( int argc, char const *argv[] );
@@ -1159,19 +1161,22 @@ static void career_pass_level( struct cmp_level *lvl, int score, int upload )
        {
                if( score < lvl->completed_score || lvl->completed_score == 0 )
                {
+                       #ifdef VG_STEAM
                        if( !lvl->is_tutorial && upload )
                                leaderboard_set_score( lvl, score );
-                       
+                       #endif
+
                        lvl->completed_score = score;
                }
                
                if( lvl->unlock ) career_unlock_level( lvl->unlock );
                
+               #ifdef VG_STEAM
                if( lvl->achievement )
                {
                        sw_set_achievement( lvl->achievement );
                }
-               
+
                // Check ALL maps to trigger master engineer
                for( int i = 0; i < vg_list_size( career_serializable ); i ++ )
                {
@@ -1185,6 +1190,7 @@ static void career_pass_level( struct cmp_level *lvl, int score, int upload )
                }
                
                sw_set_achievement( "MASTER_ENGINEER" );
+               #endif
        }
 }
 
@@ -1762,8 +1768,10 @@ void vg_update(void)
                                                        if( cell_entry->config == k_cell_type_con_r || cell_entry->config == k_cell_type_con_u 
                                                                || cell_entry->config == k_cell_type_con_l || cell_entry->config == k_cell_type_con_d )
                                                        {
+                                                               #ifdef VG_STEAM
                                                                sw_set_achievement( "CAN_DO_THAT" );
-                                                       
+                                                               #endif
+
                                                                fish->state = k_fish_state_soon_alive;
                                                                
                                                                fish->dir[0] = 0;
@@ -1849,8 +1857,10 @@ void vg_update(void)
                                                        
                                                        if( collide_next_frame || collide_this_frame )
                                                        {
+                                                               #ifdef VG_STEAM
                                                                sw_set_achievement( "BANG" );
-                                                       
+                                                               #endif
+
                                                                // Shatter death (+0.5s)
                                                                float death_time = world.sim_internal_time + ( collide_this_frame? 0.0f: 0.5f );
                                                                
@@ -1988,9 +1998,11 @@ void vg_update(void)
                                }
                                else
                                {
+                                       #ifdef VG_STEAM
                                        if( world.sim_run > 0 )
                                                sw_set_achievement( "GOOD_ENOUGH" );
-                                       
+                                       #endif
+
                                        vg_error( "Level failed :(\n" );
                                }
                                
@@ -2101,9 +2113,6 @@ void vg_update(void)
        }
 }
 
-void leaderboard_found( LeaderboardFindResult_t *pCallback );
-void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback );
-
 static void render_tiles( v2i start, v2i end, v4f const regular_colour, v4f const selected_colour )
 {
        v2i full_start = { 0,0 };
@@ -2435,6 +2444,7 @@ void vg_render(void)
        glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_main, "uPv" ), 1, GL_FALSE, (float *)vg_pv );
        glUniform1f( SHADER_UNIFORM( shader_tile_main, "uGhost" ), 0.0f );
        glUniform1f( SHADER_UNIFORM( shader_tile_main, "uForeground" ), 0.0f );
+       //glUniform1f( SHADER_UNIFORM( shader_tile_main, "uVisibility" ), sinf( vg_time ) + 1.0f );
        
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -2857,9 +2867,9 @@ void vg_render(void)
 
 void vg_ui(void) {}
 
+#if STEAM_LEADERBOARDS
 void leaderboard_dispatch_score(void)
 {
-#if STEAM_LEADERBOARDS
        sw_upload_leaderboard_score( 
                ui_data.upload_request.level->steam_leaderboard, 
                k_ELeaderboardUploadScoreMethodKeepBest,
@@ -2871,12 +2881,10 @@ void leaderboard_dispatch_score(void)
        ui_data.upload_request.is_waiting = 0;
        
        vg_success( "Dispatched leaderboard score\n" );
-#endif
 }
 
 void leaderboard_found( LeaderboardFindResult_t *pCallback )
 {
-#ifdef STEAM_LEADERBOARDS
        if( !pCallback->m_bLeaderboardFound )
        {
                vg_error( "Leaderboard could not be found\n" );
@@ -2906,12 +2914,10 @@ void leaderboard_found( LeaderboardFindResult_t *pCallback )
                        }
                }
        }
-#endif
 }
 
 void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback )
 {
-#ifdef STEAM_LEADERBOARDS
        // Update UI if this leaderboard matches what we currently have in view
        if( ui_data.level_selected->steam_leaderboard == pCallback->m_hSteamLeaderboard )
        {
@@ -2946,12 +2952,10 @@ void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback )
                        ui_data.leaderboard_show = 0;
        }
        else vg_warn( "Downloaded leaderboard does not match requested!\n" );
-#endif
 }
 
 void leaderboard_set_score( struct cmp_level *cmp_level, u32 score )
 {
-#ifdef STEAM_LEADERBOARDS
        if( ui_data.upload_request.is_waiting )
                vg_warn( "You are uploading leaderboard entries too quickly!\n" );
                
@@ -2964,8 +2968,8 @@ void leaderboard_set_score( struct cmp_level *cmp_level, u32 score )
                leaderboard_dispatch_score();
        else
                sw_find_leaderboard( cmp_level->map_name );
-#endif
 }
+#endif
 
 // CONSOLE COMMANDS
 // ===========================================================================================================
@@ -3358,7 +3362,10 @@ void vg_start(void)
 
 void vg_free(void)
 {
+#ifdef VG_STEAM
        sw_free_opengl();
+#endif
+
        console_save_map( 0, NULL );
        career_serialize();
 
index bfdf3a212025dfb1f5f60adab21f2e2d6d2b2b9a..ef9dcd1fe89f8179bad737a9aa08c70ca6009dd5 100644 (file)
@@ -361,6 +361,7 @@ SHADER_DEFINE( shader_tile_main,
        "uniform vec4 uOffset;" // Tile x/y, uv x/y
        "uniform mat3 uPv;"
        "uniform mat2 uSubTransform;"
+       //"uniform float uVisibility;"
        ""
        "out vec4 aTexCoords;"
        "out vec2 aWorldCoords;"
@@ -374,13 +375,16 @@ SHADER_DEFINE( shader_tile_main,
        ""
        "void main()"
        "{"
+               "vec2 hash_val = hash22(uOffset.xy);"
+               //"float scaling_factor = smoothstep( hash_val.x, hash_val.x+1.0, uVisibility );"
+
                // Vertex transform
                "vec2 subtransform = uSubTransform * (a_co-0.5) + 0.5;"
                "vec3 worldpos = vec3( subtransform + uOffset.xy, 1.0 );"
                "gl_Position = vec4( uPv * worldpos, 1.0 );"
 
                // Create texture coords
-               "vec2 random_offset = floor(hash22(uOffset.xy) * 4.0) * 0.25;"
+               "vec2 random_offset = floor(hash_val * 4.0) * 0.25;"
                "vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
                "aTexCoords = vec4((edge_safe_coords + uOffset.zw) * 0.25, edge_safe_coords * 0.25 + random_offset );"
                "aWorldCoords = worldpos.xy;"           
@@ -417,7 +421,7 @@ SHADER_DEFINE( shader_tile_main,
                "FragColor = mix( output_regular, output_ghost, uGhost ) * uColour;"
        "}"
        ,
-       UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour", "uForeground" })
+       UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour", "uForeground", "uVisibility" })
 )
 
 SHADER_DEFINE( shader_background,
@@ -651,8 +655,10 @@ struct cmp_level
        
        int serial_id;
        int is_tutorial;
-       
+
+       #ifdef VG_STEAM
        SteamLeaderboard_t steam_leaderboard;
+       #endif
 };
 
 static struct cmp_level cmp_levels_tutorials[] = 
index b9aef412206d479e92cbf18d464ba1e94c484121..34df41fd60aa06c9226ab807d5b8c3652000c989 100644 (file)
@@ -18,6 +18,7 @@ static struct axis_binding vg_axis_binds[] =
        { .name = "vertical",   .positive = GLFW_KEY_W,                                         .negative = GLFW_KEY_S }
 };
 
+#ifdef VG_STEAM
 static struct vg_achievement vg_achievements[] =
 {
        { .name = "CAN_DO_THAT" },
@@ -29,3 +30,4 @@ static struct vg_achievement vg_achievements[] =
        { .name = "SQUEEZE" },
        { .name = "MASTER_ENGINEER" }
 };
+#endif
diff --git a/vg/vg.h b/vg/vg.h
index b7ebb2f0545558fd1d53f394d956c1d043db5081..190b9e96f0e9b34f6db165fb19b1d36a9e7f4828 100644 (file)
--- a/vg/vg.h
+++ b/vg/vg.h
@@ -64,7 +64,9 @@ float vg_time_delta;
 #include "vg/vg_console.h"
 #include "vg/vg_debug.h"
 
+#ifdef VG_STEAM
 #include "vg/vg_steamworks.h"
+#endif
 
 // Engine main
 // ===========================================================================================================