refactor(launcher): Remove api for live-recompilation
All checks were successful
Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Successful in 1m36s

This commit is contained in:
Kevin Trogant 2024-07-24 17:44:05 +02:00
parent ca5d8ad8f0
commit 25006139f1
3 changed files with 19 additions and 32 deletions

View File

@ -234,7 +234,5 @@ LOAD_GAME_API_FUNC {
.Update = MeshletsUpdate,
.Render = MeshletsRender,
.OnGameObjectFree = NULL,
.OnReload = NULL,
.OnUnload = NULL,
};
}

View File

@ -66,12 +66,6 @@ typedef struct {
/* Called by rt_laucher_api::AllocGameObject, if an old object is freed. */
rt_game_on_game_object_free_fn *OnGameObjectFree;
/* Called after the game was reloaded during live re-compilation */
rt_game_on_reload_fn *OnReload;
/* Called before the game gets unloaded during live re-compilation */
rt_game_on_unload_fn *OnUnload;
} rt_game_api;

View File

@ -17,11 +17,15 @@
#include <runtime/config.h>
#include <runtime/dynamic_libs.h>
#include <renderer/common/renderer_api.h>
#include <runtime/fsutils.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include "game_api.h"
RT_CVAR_S(rt_Renderer, "The used renderer. Available options: vk, dx11. (Default: vk)", "vk");
RT_CVAR_S(rt_WindowTitle, "The title used for the game window. (Default: rtengine)", "rtengine");
RT_CVAR_I(rt_WindowWidth, "The window width. (Default: 1024)", 1024);
@ -37,7 +41,7 @@ RT_CVAR_I(rt_LauncherCreateGLContext, "Create an OpenGL context in the launcher.
RT_CVAR_I(rt_LauncherGLContextMajor, "OpenGL Major version. (Default: 4)", 4);
RT_CVAR_I(rt_LauncherGLContextMinor, "OpenGL minor version. (Default: 5)", 5);
RT_CVAR_S(rt_GameLib, "Path to the game library. Only usable in internal builds. (Default: "")", "");
RT_CVAR_S(rt_GameLib, "Path to the game library. Only usable in internal builds. (Default: \"\")", "");
enum {
WINDOW_MODE_WINDOWED,
@ -52,6 +56,10 @@ enum {
#endif
static rt_dynlib *_game_lib = NULL;
static rt_game_api _game;
static rt_window _window;
static void *_game_obj = NULL;
static rt_launcher_api _launcher_api;
#ifdef _WIN32
static HINSTANCE _hInstance;
@ -128,6 +136,15 @@ static void __NullGame_Shutdown(rt_launcher_api *api, void *game_obj) {}
static void __NullGame_Update(rt_launcher_api *api, rt_time_delta delta, void *game_obj) { RT_UNUSED(delta); }
static void __NullGame_Render(rt_launcher_api *api, void *game_obj) {}
static rt_game_api _null_api = {
.RegisterCVARs = __NullGame_RegisterCVARs,
.Init = __NullGame_Init,
.Shutdown = __NullGame_Shutdown,
.Update = __NullGame_Update,
.Render = __NullGame_Render,
.OnGameObjectFree = NULL,
};
static rt_game_api LoadGame(const char *cmdline_gamelib) {
const char *game_lib = RT_GAME_LIB_PATH;
#ifdef RT_DEBUG
@ -140,9 +157,6 @@ static rt_game_api LoadGame(const char *cmdline_gamelib) {
#endif
if (strcmp(game_lib, "(null)") != 0) {
#if defined(RT_DEBUG) && !defined(RT_DISABLE_LIVE_RECOMPILATION)
/* Copy to temporary location to enable rebuilds */
#endif
_game_lib = rtOpenLib(game_lib);
if (!_game_lib) {
rtReportError("LAUNCHER", "Failed to open game library: %s", game_lib);
@ -160,23 +174,9 @@ static rt_game_api LoadGame(const char *cmdline_gamelib) {
out:
/* Fall back to null implementation. */
return (rt_game_api){
.RegisterCVARs = __NullGame_RegisterCVARs,
.Init = __NullGame_Init,
.Shutdown = __NullGame_Shutdown,
.Update = __NullGame_Update,
.Render = __NullGame_Render,
.OnGameObjectFree = NULL,
.OnReload = NULL,
.OnUnload = NULL,
};
return _null_api;
}
static rt_game_api _game;
static rt_window _window;
static void *_game_obj = NULL;
static rt_launcher_api _launcher_api;
static rt_window LauncherAPIGetWindow(void) {
return _window;
}
@ -367,10 +367,6 @@ static int Entry(int argc, char **argv) {
rt_timestamp previous = rtTimeNow();
rt_time_delta lag = time_per_update;
while (!glfwWindowShouldClose(window)) {
#ifdef RT_DEBUG
#endif
glfwPollEvents();
rt_timestamp current = rtTimeNow();
@ -387,7 +383,6 @@ static int Entry(int argc, char **argv) {
int disp_w, disp_h;
glfwGetFramebufferSize(window, &disp_w, &disp_h);
rtLog("LAUNCHER", "%d %d", disp_w, disp_h);
_game.Render(&_launcher_api, _game_obj);
if (rt_LauncherCreateGLContext.i) {