From f36e2b73a74339bd59e6d61758530a905217a2eb Mon Sep 17 00:00:00 2001 From: Charlie Malmqvist Date: Tue, 23 Jul 2024 17:34:03 +0200 Subject: [PATCH] Woopsie cleanup --- build_engine.c | 79 ------------------------------------------ build_game.c | 30 ---------------- build_launcher.c | 36 ------------------- hotload_build_all.bat | 16 --------- hotload_build_game.bat | 8 ----- 5 files changed, 169 deletions(-) delete mode 100644 build_engine.c delete mode 100644 build_game.c delete mode 100644 build_launcher.c delete mode 100644 hotload_build_all.bat delete mode 100644 hotload_build_game.bat diff --git a/build_engine.c b/build_engine.c deleted file mode 100644 index c88a6ce..0000000 --- a/build_engine.c +++ /dev/null @@ -1,79 +0,0 @@ - -/// -// Build config stuff - -#define OOGABOOGA_BUILD_SHARED_LIBRARY 1 - -#include "oogabooga/oogabooga.c" - -/// -/// -// This is the "engine" part of your game, which will call into your game.dll - - -typedef void (*Game_Update_Proc)(f64); -Game_Update_Proc game_update; - -Dynamic_Library_Handle dll = 0; - -void load_game_dll(char **argv) { - - // Here we load all the game symbols - - if (dll) { - os_unload_dynamic_library(dll); - } - - string exe_path = STR(argv[0]); - string exe_dir = get_directory_of(exe_path); - - // We need to copy the original and open the copy, so we can recompile the original and then close & replace - // the copy. - string dll_path = string_concat(exe_dir, STR("/game.dll"), get_temporary_allocator()); - string used_dll_path = string_concat(exe_dir, STR("/game-in-use.dll"), get_temporary_allocator()); - - bool ok = os_file_copy(dll_path, used_dll_path, true); - assert(ok, "Could not copy %s to %s", dll_path, used_dll_path); - - dll = os_load_dynamic_library(used_dll_path); - assert(dll, "Failed loading game dll"); - - game_update = os_dynamic_library_load_symbol(dll, STR("game_update")); - assert(game_update, "game is missing game_update()"); - - log("Loaded game procedures"); -} - -int entry(int argc, char **argv) { - - load_game_dll(argv); - - window.title = STR("Minimal Game Example"); - window.scaled_width = 1280; // We need to set the scaled size if we want to handle system scaling (DPI) - window.scaled_height = 720; - window.x = 200; - window.y = 90; - window.clear_color = hex_to_rgba(0x6495EDff); - - float64 last_time = os_get_current_time_in_seconds(); - while (!window.should_close) { - float64 now = os_get_current_time_in_seconds(); - float64 delta = now-last_time; - if ((int)now != (int)last_time) log("%.2f FPS\n%.2fms", 1.0/(delta), (delta)*1000); - last_time = now; - - reset_temporary_storage(); - - game_update(delta); - - if (is_key_just_pressed('R')) { - load_game_dll(argv); - play_one_audio_clip(STR("oogabooga/examples/bruh.wav")); - } - - os_update(); - gfx_update(); - } - - return 0; -} \ No newline at end of file diff --git a/build_game.c b/build_game.c deleted file mode 100644 index 266b911..0000000 --- a/build_game.c +++ /dev/null @@ -1,30 +0,0 @@ - - -// !!!!!!!! BUILD CONFIG SHOULD BE DONE IN build_engine.c - -#define OOGABOOGA_LINK_EXTERNAL_INSTANCE 1 -#include "oogabooga/oogabooga.c" - -/// -/// -// This is the game module which is what can be recompiled in the engine runtime - -// For the engine to be able to detect a symbol, it needs to be marked with SHARED_EXPORT -void SHARED_EXPORT -game_update(f64 delta_time) { - - float64 now = os_get_current_time_in_seconds(); - - Matrix4 rect_xform = m4_scalar(1.0); - rect_xform = m4_rotate_z(rect_xform, (f32)now); - rect_xform = m4_translate(rect_xform, v3(-.25f, -.25f, 0)); - draw_rect_xform(rect_xform, v2(.5f, .5f), COLOR_GREEN); - - draw_rect(v2(sin(now), -.8), v2(.5, .25), COLOR_RED); - - float aspect = (f32)window.width/(f32)window.height; - float mx = (input_frame.mouse_x/(f32)window.width * 2.0 - 1.0)*aspect; - float my = input_frame.mouse_y/(f32)window.height * 2.0 - 1.0; - - draw_line(v2(-.75, -.75), v2(mx, my), 0.005, COLOR_WHITE); -} \ No newline at end of file diff --git a/build_launcher.c b/build_launcher.c deleted file mode 100644 index a09639a..0000000 --- a/build_launcher.c +++ /dev/null @@ -1,36 +0,0 @@ - - -// !!!!!!!! BUILD CONFIG SHOULD BE DONE IN build_engine.c - -#define OOGABOOGA_LINK_EXTERNAL_INSTANCE 1 -#include "oogabooga/oogabooga.c" - - -// All we do with the launcher is to launch the engine -// We need to be careful to use oogabooga things because it has not yet been initialized. -// We can use get_temporary_allocator() because that actually gives us the initialization allocator. -// We cannot use log() but we can use print() -int main(int argc, char **argv) { - string exe_path = STR(argv[0]); - string exe_dir = get_directory_of(exe_path); - - Allocator a = get_initialization_allocator(); - string dll_path = string_concat(exe_dir, STR("/engine.dll"), a); - - Dynamic_Library_Handle dll = os_load_dynamic_library(dll_path); - if (!dll) { - os_write_string_to_stdout(STR("Failed loading engine dll from ")); - os_write_string_to_stdout(dll_path); - os_write_string_to_stdout(STR("\n")); - return -1; - } - - int (*engine_main)(int, char**) = os_dynamic_library_load_symbol(dll, STR("main")); - if (!engine_main) { - os_write_string_to_stdout(STR("Failed loading engine main\n")); - return -1; - } - - print("Launcher found engine main(), running...\n"); - return engine_main(argc, argv); -} \ No newline at end of file diff --git a/hotload_build_all.bat b/hotload_build_all.bat deleted file mode 100644 index 5c6b13a..0000000 --- a/hotload_build_all.bat +++ /dev/null @@ -1,16 +0,0 @@ -@echo on -if exist build ( - rmdir /s /q build -) -mkdir build - -pushd build - -clang ../build_engine.c -g -shared -o engine.dll -O0 -std=c11 -D_CRT_SECURE_NO_WARNINGS -Wextra -Wno-incompatible-library-redeclaration -Wno-sign-compare -Wno-unused-parameter -Wno-builtin-requires-header -fuse-ld=lld -lkernel32 -lgdi32 -luser32 -lruntimeobject -lwinmm -ld3d11 -ldxguid -ld3dcompiler -lshlwapi -lole32 -lavrt -lksuser -ldbghelp -femit-all-decls -Xlinker /IMPLIB:engine.lib -Xlinker /MACHINE:X64 -Xlinker /SUBSYSTEM:CONSOLE - -clang ../build_launcher.c -g -o launcher.exe -O0 -std=c11 -D_CRT_SECURE_NO_WARNINGS -Wextra -Wno-incompatible-library-redeclaration -Wno-sign-compare -Wno-unused-parameter -Wno-builtin-requires-header -femit-all-decls -luser32 -fuse-ld=lld -L. -lengine -Xlinker /SUBSYSTEM:CONSOLE - -clang ../build_game.c -g -shared -o game.dll -O0 -std=c11 -D_CRT_SECURE_NO_WARNINGS -Wextra -Wno-incompatible-library-redeclaration -Wno-sign-compare -Wno-unused-parameter -Wno-builtin-requires-header -femit-all-decls -luser32 -fuse-ld=lld -L. -lengine -Xlinker /SUBSYSTEM:CONSOLE - - -popd \ No newline at end of file diff --git a/hotload_build_game.bat b/hotload_build_game.bat deleted file mode 100644 index ec99931..0000000 --- a/hotload_build_game.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo on - -pushd build - -clang ../build_game.c -g -shared -o game.dll -O0 -std=c11 -D_CRT_SECURE_NO_WARNINGS -Wextra -Wno-incompatible-library-redeclaration -Wno-sign-compare -Wno-unused-parameter -Wno-builtin-requires-header -femit-all-decls -luser32 -fuse-ld=lld -L. -lengine -Xlinker /SUBSYSTEM:CONSOLE - - -popd \ No newline at end of file