From: Randy McShandy Date: Sun, 26 May 2024 15:15:13 +0000 (-0500) Subject: Turns out loading screen generation has been completely fucked since it started.... X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=82f27c7a77d477e421e5b76485a1c9718716880a;p=barrow_crawler Turns out loading screen generation has been completely fucked since it started. Overhaul to not load generated resources until the system actually signals that it's done. Also stop tracking builds --- diff --git a/bin/barrow.exe b/bin/barrow.exe deleted file mode 100755 index 72819e5..0000000 Binary files a/bin/barrow.exe and /dev/null differ diff --git a/bin/libraylib.dll b/bin/libraylib.dll deleted file mode 100755 index b7f7438..0000000 Binary files a/bin/libraylib.dll and /dev/null differ diff --git a/bin/libssp-0.dll b/bin/libssp-0.dll deleted file mode 100755 index fc16892..0000000 Binary files a/bin/libssp-0.dll and /dev/null differ diff --git a/bin/libwinpthread-1.dll b/bin/libwinpthread-1.dll deleted file mode 100755 index c71c67e..0000000 Binary files a/bin/libwinpthread-1.dll and /dev/null differ diff --git a/bin/posix_BC b/bin/posix_BC index bcae109..abf54b7 100755 Binary files a/bin/posix_BC and b/bin/posix_BC differ diff --git a/src/main.c b/src/main.c index 9d60b64..ec96a38 100755 --- a/src/main.c +++ b/src/main.c @@ -38,13 +38,10 @@ int main(int argc, char** argv) start_render_loop(); pthread_join(generator_thread, NULL); #else - resource_generation_finished = 1; + resource_state = 1; start_render_loop(); #endif /* ENABLE_BARROWGEN */ - - - return 0; } diff --git a/src/render_raylib.c b/src/render_raylib.c index d0b8d09..dac0778 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -9,6 +10,8 @@ #include "structs.h" +#define VEC3_UNROLL(v3) v3.x, v3.y, v3.z + Vector2 fscreen_dims; Camera3D cam; Image barrow_image; @@ -80,7 +83,7 @@ int map_visible = 0; typedef void(*renderfunc)(); typedef void(*controlfunc)(); -#define MAX_RENDERFUNCS 2U +#define MAX_RENDERFUNCS 3U renderfunc renderfuncs[MAX_RENDERFUNCS]; controlfunc controlfuncs[MAX_RENDERFUNCS]; @@ -100,10 +103,8 @@ void drawing_game_mode() BeginMode3D(cam); BeginShaderMode(shader); - // DrawModelEx(coffin_model, coffin_position, coffin_rotation_axis, coffin_rotation, coffin_scale, DARKGRAY); DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_scale, DARKGRAY); DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_scale, DARKGRAY); - // DrawRay(player_collide_ray, WHITE); EndShaderMode(); EndMode3D(); @@ -116,21 +117,28 @@ void drawing_game_mode() Rectangle minimap_dest = {.width = 64.0f*img_export_scale.x, .height = 64.0f*img_export_scale.y, .x = 0.0f, .y = 0.0f}; Rectangle minimap_src = {.width = barrow_texture.width, .height = barrow_texture.height, .x = 0.0f, .y = 0.0f}; + if(map_visible) { + DrawFPS(fscreen_dims.x - 80, 10); DrawTexturePro(floor_texture, minimap_src, minimap_dest, (Vector2){0.0f, 0.0f}, 0.0f, RAYWHITE); + DrawText(TextFormat("cam x %f\ncam y %f\ncam z %f", cam.position.x, cam.position.y, cam.position.z), 0, 128, 16, GREEN); + DrawText(TextFormat("tgt x %f\ntgt y %f\ntgt z %f", cam.target.x, cam.target.y, cam.target.z), 0, 128+64, 16, GREEN); + DrawText(TextFormat("rot x %f\nrot y %f\nrot z %f", player_angles.x, player_angles.y, player_angles.z), 0, 128+(64*2), 16, GREEN); + DrawText(TextFormat("ray hit %d\nlength %f", player_collision.hit, player_collision.distance), 0, 128+(64*3), 16, GREEN); } +} -#define DEBUG_GAME_INFO 0 -#if DEBUG_GAME_INFO==1 +void drawing_resource_ready_mode() +{ + static int status_phase = 0; + const float font_size =32.0f; + const char format_string[] = "%s\n\n%3.2f%%"; + const char tribute_string[] = "This game is dedicated to the North American Muskrat, Ondatra Zibethicus"; - DrawFPS(fscreen_dims.x - 80, 10); - DrawTexturePro(floor_texture, minimap_src, minimap_dest, (Vector2){0.0f, 0.0f}, 0.0f, RAYWHITE); - DrawText(TextFormat("cam x %f\ncam y %f\ncam z %f", cam.position.x, cam.position.y, cam.position.z), 0, 128, 16, GREEN); - DrawText(TextFormat("tgt x %f\ntgt y %f\ntgt z %f", cam.target.x, cam.target.y, cam.target.z), 0, 128+64, 16, GREEN); - DrawText(TextFormat("rot x %f\nrot y %f\nrot z %f", player_angles.x, player_angles.y, player_angles.z), 0, 128+(64*2), 16, GREEN); - DrawText(TextFormat("ray hit %d\nlength %f", player_collision.hit, player_collision.distance), 0, 128+(64*3), 16, GREEN); -#endif /* DEBUG_GAME_INFO */ + ClearBackground(LIGHTGRAY); + DrawText(tribute_string, + (fscreen_dims.x/2.0f) - (MeasureText(tribute_string, font_size)/2.0f), 3.0f * (fscreen_dims.y/4.0f), font_size, BLACK); } /* Something to render while waiting on resources to be generated. @@ -225,6 +233,7 @@ void control_game_mode() player_collide_ray = (Ray){cam.position, vec3_up}; player_collision = GetRayCollisionMesh(player_collide_ray, barrow_model.meshes[0U], barrow_mat); player_rotation = new_player_rotation; + if (player_collision.distance >= 0.3f) { player_velocity = new_player_velocity; @@ -291,13 +300,12 @@ void wait_initialize_resources() { floor_image = LoadImage("./floor.png"); floor_albedo = LoadTexture("./floor_albedo.png"); + while(!IsImageReady(floor_image)){} floor_scale = (Vector3){floor_image.width/6.0f, 3.0f, floor_image.height/6.0f}; floor_position = (Vector3){0.0f, -3.0f, -floor_scale.z}; floor_rotation_axis = (Vector3){0.0f, 0.0f, floor_image.width}; floor_rotation = 0.0f; - while(!IsImageReady(floor_image)){} while(!IsTextureReady(floor_albedo)){} - floor_texture = LoadTextureFromImage(floor_image); while(!IsTextureReady(floor_texture)){} @@ -327,25 +335,6 @@ void wait_initialize_resources() hand_position = (Vector2){0, fscreen_dims.y - (hand_01_image.height * hand_scale)}; hand_rotation = 0.0f; } - - /* Mode handler setup */ - { - renderfuncs[0U] = drawing_resource_wait_mode; - renderfuncs[1U] = drawing_game_mode; - controlfuncs[0U] = control_resource_wait_mode; - controlfuncs[1U] = control_game_mode; - } -} - -/* Values that are required to initialize Raylib. */ -void initialize_prerenderer() -{ - fscreen_dims = (Vector2){.x=screen_dims.x, .y=screen_dims.y}; - - map_center = barrow_scale; - map_center.x /= 2.0f; - map_center.z /= -2.0f; - map_center.y = -3.0f; } /* Values and things to do that have to have to be done after Raylib is initialized. */ @@ -365,22 +354,52 @@ void initialize_renderer() SetWindowState(FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); } +void control_resource_ready_mode() +{ + if(resource_state == 1) + { + wait_initialize_resources(); + initialize_renderer(); + resource_state = 2; + } +} + +/* Values that are required to initialize Raylib. */ +void initialize_prerenderer() +{ + fscreen_dims = (Vector2){.x=screen_dims.x, .y=screen_dims.y}; + + map_center = barrow_scale; + map_center.x /= 2.0f; + map_center.z /= -2.0f; + map_center.y = -3.0f; + + /* Mode handler setup */ + { + renderfuncs[0U] = drawing_resource_wait_mode; + renderfuncs[1U] = drawing_resource_ready_mode; + renderfuncs[2U] = drawing_game_mode; + controlfuncs[0U] = control_resource_wait_mode; + controlfuncs[1U] = control_resource_ready_mode; + controlfuncs[2U] = control_game_mode; + } +} + void start_render_loop() { initialize_prerenderer(); SetTraceLogLevel(LOG_ALL); InitWindow(fscreen_dims.x, fscreen_dims.y, screen_title); - wait_initialize_shaders(); - wait_initialize_resources(); - initialize_renderer(); SetTargetFPS(target_fps); while (!WindowShouldClose()) { + int func_idx = resource_state; + player_collide_point = cam.position; player_collide_point.y -= 1.0f; - controlfuncs[resource_generation_finished](); + controlfuncs[func_idx](); Matrix mat_trans = MatrixTranslate(barrow_position.x, barrow_position.y, barrow_position.z); Matrix mat_rot = MatrixRotate(barrow_rotation_axis, DEG2RAD * barrow_rotation); @@ -396,7 +415,7 @@ void start_render_loop() UpdateCameraPro(&cam, player_velocity, player_rotation, 0.0f); BeginDrawing(); - renderfuncs[resource_generation_finished](); + renderfuncs[func_idx](); EndDrawing(); /* Decay forward velocity and rotation */ diff --git a/src/shaders/lighting.fs b/src/shaders/lighting.fs index 946a863..2867801 100644 --- a/src/shaders/lighting.fs +++ b/src/shaders/lighting.fs @@ -146,5 +146,4 @@ void main() // All single color channel variations with this looks cool as FUCK // turns this into three levels going b-r-g //finalColor.b = 0.0f; - } diff --git a/src/structs.c b/src/structs.c index 95885b8..78c825f 100644 --- a/src/structs.c +++ b/src/structs.c @@ -78,5 +78,5 @@ const int target_fps = 60; const IVec2 img_export_scale = {.x = 2, .y = 2}; float resource_generation_progress = 0.0f; -int resource_generation_finished = 0; +int resource_state = 0; diff --git a/src/structs.h b/src/structs.h index b56696c..3be86c1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -84,7 +84,7 @@ extern const int target_fps; extern const IVec2 img_export_scale; extern float resource_generation_progress; -extern int resource_generation_finished; +extern int resource_state; //int generate_rd(int worker_count, RD_Opts active_opt, FVec2 **grid_buffer, IVec2 pgrid_size); void* generate_rd(void* args); diff --git a/src/utils.c b/src/utils.c index 89bdd4e..33be2eb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -249,7 +249,7 @@ void* generate_rd(void* args) stbi_write_png(floor_albedo_name, grid_size.x*img_export_scale.x, grid_size.y*img_export_scale.y, 4, large_albedo_buffer, grid_size.x * sizeof(uint32_t)*img_export_scale.x); cleanup(); - resource_generation_finished = 1; + resource_state = 1; return 0; }