refactor: Change launcher cvar names
Some checks failed
Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Has been cancelled
Some checks failed
Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
parent
e25dde131a
commit
03f61b31ec
@ -1,6 +1,6 @@
|
||||
rt_Renderer = vk
|
||||
rt_WindowTitle = rtengine
|
||||
rt_WindowWidth = 1024
|
||||
rt_WindowHeight = 768
|
||||
rt_WindowMode = 0
|
||||
rt_GameLib = (null)
|
||||
l_Renderer = vk
|
||||
l_WindowTitle = rtengine
|
||||
l_WindowWidth = 1024
|
||||
l_WindowHeight = 768
|
||||
l_WindowMode = 0
|
||||
l_GameLib = (null)
|
||||
|
@ -30,21 +30,24 @@
|
||||
|
||||
#include "game_api.h"
|
||||
|
||||
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);
|
||||
RT_CVAR_I(rt_WindowHeight, "The window height. (Default: 768)", 768);
|
||||
RT_CVAR_I(rt_WindowMode, "The window mode. Available options: 0 (=Windowed), 1 (=Borderless Fullscreen), 2 (=Exclusive Fullscreen) (Default: 0)", 0);
|
||||
RT_CVAR_I(rt_FullscreenRefreshRate, "Requested refresh rate for exclusive fullscreen. Set to 0 to use the monitors current setting. (Default: 0)", 0);
|
||||
RT_CVAR_S(rt_Monitor, "Name of the monitor on which the window should be created. Leave empty to use the primary monitor. (Default: "")", "");
|
||||
/* This is a launcher cvar, because launcher must configure this _before_ the renderer is initialized. */
|
||||
RT_CVAR_S(l_Renderer, "The used renderer. Available options: vk, dx11. (Default: vk)", "vk");
|
||||
|
||||
RT_CVAR_F(rt_Framerate, "Target framerate in FPS. (Default: 60.0)", 60.0);
|
||||
RT_CVAR_S(l_WindowTitle, "The title used for the game window. (Default: rtengine)", "rtengine");
|
||||
RT_CVAR_I(l_WindowWidth, "The window width. (Default: 1024)", 1024);
|
||||
RT_CVAR_I(l_WindowHeight, "The window height. (Default: 768)", 768);
|
||||
RT_CVAR_I(l_WindowMode, "The window mode. Available options: 0 (=Windowed), 1 (=Borderless Fullscreen), 2 (=Exclusive Fullscreen) (Default: 0)", 0);
|
||||
RT_CVAR_I(l_FullscreenRefreshRate, "Requested refresh rate for exclusive fullscreen. Set to 0 to use the monitors current setting. (Default: 0)", 0);
|
||||
RT_CVAR_S(l_Monitor, "Name of the monitor on which the window should be created. Leave empty to use the primary monitor. (Default: "")", "");
|
||||
|
||||
RT_CVAR_F(l_Framerate, "Target framerate in FPS. (Default: 60.0)", 60.0);
|
||||
|
||||
/* These are for experiments and debugging */
|
||||
RT_CVAR_I(rt_LauncherCreateGLContext, "Create an OpenGL context in the launcher. 1: on, 0: off. (Default: 0)", 0);
|
||||
RT_CVAR_I(rt_LauncherGLContextMajor, "OpenGL Major version. (Default: 4)", 4);
|
||||
RT_CVAR_I(rt_LauncherGLContextMinor, "OpenGL minor version. (Default: 5)", 5);
|
||||
RT_CVAR_I(l_CreateGLContext, "Create an OpenGL context in the launcher. 1: on, 0: off. (Default: 0)", 0);
|
||||
RT_CVAR_I(l_GLContextMajor, "OpenGL Major version. (Default: 4)", 4);
|
||||
RT_CVAR_I(l_GLContextMinor, "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(l_GameLib, "Path to the game library. Only usable in internal builds. (Default: (null))", "(null)");
|
||||
|
||||
enum {
|
||||
WINDOW_MODE_WINDOWED,
|
||||
@ -69,19 +72,20 @@ static HINSTANCE _hInstance;
|
||||
#endif
|
||||
|
||||
static void SetupConfig(void) {
|
||||
rtRegisterCVAR(&rt_WindowTitle);
|
||||
rtRegisterCVAR(&rt_WindowWidth);
|
||||
rtRegisterCVAR(&rt_WindowHeight);
|
||||
rtRegisterCVAR(&rt_WindowMode);
|
||||
rtRegisterCVAR(&rt_Monitor);
|
||||
rtRegisterCVAR(&l_Renderer);
|
||||
rtRegisterCVAR(&l_WindowTitle);
|
||||
rtRegisterCVAR(&l_WindowWidth);
|
||||
rtRegisterCVAR(&l_WindowHeight);
|
||||
rtRegisterCVAR(&l_WindowMode);
|
||||
rtRegisterCVAR(&l_Monitor);
|
||||
|
||||
rtRegisterCVAR(&rt_Framerate);
|
||||
rtRegisterCVAR(&l_Framerate);
|
||||
|
||||
rtRegisterCVAR(&rt_LauncherCreateGLContext);
|
||||
rtRegisterCVAR(&rt_LauncherGLContextMajor);
|
||||
rtRegisterCVAR(&rt_LauncherGLContextMinor);
|
||||
rtRegisterCVAR(&l_CreateGLContext);
|
||||
rtRegisterCVAR(&l_GLContextMajor);
|
||||
rtRegisterCVAR(&l_GLContextMinor);
|
||||
|
||||
rtRegisterCVAR(&rt_GameLib);
|
||||
rtRegisterCVAR(&l_GameLib);
|
||||
|
||||
rt_file_id config_fid = rtAddFile("cfg/launcher.cfg");
|
||||
if (rtProcessConfigFiles(1, &config_fid) != RT_SUCCESS) {
|
||||
@ -150,8 +154,8 @@ static rt_game_api _null_api = {
|
||||
static rt_game_api LoadGame(const char *cmdline_gamelib) {
|
||||
const char *game_lib = RT_GAME_LIB_PATH;
|
||||
#ifdef RT_DEBUG
|
||||
if (strlen(rt_GameLib.s) > 0) {
|
||||
game_lib = rt_GameLib.s;
|
||||
if (strlen(l_GameLib.s) > 0) {
|
||||
game_lib = l_GameLib.s;
|
||||
}
|
||||
if (cmdline_gamelib && strlen(cmdline_gamelib) > 0) {
|
||||
game_lib = cmdline_gamelib;
|
||||
@ -215,13 +219,13 @@ static GLFWmonitor *ChooseMonitor(void) {
|
||||
GLFWmonitor *monitor = glfwGetPrimaryMonitor();
|
||||
int count = 0;
|
||||
|
||||
if (strcmp(rt_Monitor.s, "") == 0) {
|
||||
if (strcmp(l_Monitor.s, "") == 0) {
|
||||
return monitor;
|
||||
}
|
||||
GLFWmonitor **monitors = glfwGetMonitors(&count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const char *name = glfwGetMonitorName(monitors[i]);
|
||||
if (strcmp(name, rt_Monitor.s) == 0)
|
||||
if (strcmp(name, l_Monitor.s) == 0)
|
||||
return monitors[i];
|
||||
}
|
||||
return monitor;
|
||||
@ -272,29 +276,29 @@ static int Entry(int argc, char **argv) {
|
||||
GLFWmonitor *monitor = ChooseMonitor();
|
||||
|
||||
GLFWwindow *window = NULL;
|
||||
if (!rt_LauncherCreateGLContext.i) {
|
||||
if (!l_CreateGLContext.i) {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
} else {
|
||||
rtLog("LAUNCHER", "Creating an OpenGL %d.%d context", rt_LauncherGLContextMajor.i, rt_LauncherGLContextMinor.i);
|
||||
rtLog("LAUNCHER", "Creating an OpenGL %d.%d context", l_GLContextMajor.i, l_GLContextMinor.i);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, rt_LauncherGLContextMajor.i);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, rt_LauncherGLContextMinor.i);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, l_GLContextMajor.i);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, l_GLContextMinor.i);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
}
|
||||
glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_CENTER_CURSOR, GLFW_TRUE);
|
||||
|
||||
if (rt_WindowMode.i == WINDOW_MODE_BORDERLESS_FULLSCREEN) {
|
||||
if (l_WindowMode.i == WINDOW_MODE_BORDERLESS_FULLSCREEN) {
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
||||
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
||||
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
||||
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
||||
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
||||
window = glfwCreateWindow(mode->width, mode->height, rt_WindowTitle.s, monitor, NULL);
|
||||
window = glfwCreateWindow(mode->width, mode->height, l_WindowTitle.s, monitor, NULL);
|
||||
}
|
||||
else if (rt_WindowMode.i == WINDOW_MODE_FULLSCREEN) {
|
||||
int refresh_rate = rt_FullscreenRefreshRate.i;
|
||||
else if (l_WindowMode.i == WINDOW_MODE_FULLSCREEN) {
|
||||
int refresh_rate = l_FullscreenRefreshRate.i;
|
||||
if (refresh_rate == 0) {
|
||||
refresh_rate = glfwGetVideoMode(glfwGetPrimaryMonitor())->refreshRate;
|
||||
}
|
||||
@ -317,10 +321,10 @@ static int Entry(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
glfwWindowHint(GLFW_REFRESH_RATE, refresh_rate);
|
||||
window = glfwCreateWindow(rt_WindowWidth.i, rt_WindowHeight.i, rt_WindowTitle.s, monitor, NULL);
|
||||
window = glfwCreateWindow(l_WindowWidth.i, l_WindowHeight.i, l_WindowTitle.s, monitor, NULL);
|
||||
}
|
||||
else {
|
||||
window = glfwCreateWindow(rt_WindowWidth.i, rt_WindowHeight.i, rt_WindowTitle.s, NULL, NULL);
|
||||
window = glfwCreateWindow(l_WindowWidth.i, l_WindowHeight.i, l_WindowTitle.s, NULL, NULL);
|
||||
}
|
||||
|
||||
if (!window) {
|
||||
@ -334,7 +338,7 @@ static int Entry(int argc, char **argv) {
|
||||
_window.type = RT_WINDOW_TYPE_GLFW;
|
||||
_window.glfw = window;
|
||||
|
||||
if (rt_LauncherCreateGLContext.i) {
|
||||
if (l_CreateGLContext.i) {
|
||||
glfwMakeContextCurrent(window);
|
||||
}
|
||||
|
||||
@ -347,7 +351,7 @@ static int Entry(int argc, char **argv) {
|
||||
renderer_init_info.display = glfwGetX11Display();
|
||||
renderer_init_info.window = glfwGetX11Window(window);
|
||||
#endif
|
||||
renderer_init_info.is_fullscreen = rt_WindowMode.i != WINDOW_MODE_WINDOWED;
|
||||
renderer_init_info.is_fullscreen = l_WindowMode.i != WINDOW_MODE_WINDOWED;
|
||||
glfwGetFramebufferSize(window, (int*)&renderer_init_info.width, (int*)&renderer_init_info.height);
|
||||
if (rtInitRenderer(&renderer_init_info) != RT_SUCCESS) {
|
||||
rtReportError("LAUNCHER", "Failed to initialize the renderer.");
|
||||
@ -367,7 +371,7 @@ static int Entry(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_time_delta time_per_update = 1.0 / (double)rt_Framerate.f;
|
||||
rt_time_delta time_per_update = 1.0 / (double)l_Framerate.f;
|
||||
rt_timestamp previous = rtTimeNow();
|
||||
rt_time_delta lag = time_per_update;
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
@ -389,7 +393,7 @@ static int Entry(int argc, char **argv) {
|
||||
glfwGetFramebufferSize(window, &disp_w, &disp_h);
|
||||
_game.Render(&_launcher_api, _game_obj);
|
||||
|
||||
if (rt_LauncherCreateGLContext.i) {
|
||||
if (l_CreateGLContext.i) {
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,10 @@
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <runtime/config.h>
|
||||
|
||||
RT_CVAR_S(rt_Renderer, "The used renderer. Available options: vk, dx11. (Default: vk)", "vk");
|
||||
extern rt_cvar r_MaxRenderResources;
|
||||
|
||||
RT_DLLEXPORT void rtRegisterRenderCVARs(void) {
|
||||
rtRegisterCVAR(&rt_Renderer);
|
||||
rtRegisterCVAR(&r_MaxRenderResources);
|
||||
}
|
||||
|
||||
RT_DLLEXPORT void rtRegisterRenderBackendCVARs(void) {
|
||||
|
@ -20,13 +20,13 @@ static rt_dynlib _renderer_lib;
|
||||
|
||||
RT_DLLEXPORT rt_result rtLoadRenderBackend(void) {
|
||||
rt_load_renderer_impl_fn *LoadRenderBackendImpl = NULL;
|
||||
rt_cvar *rt_Renderer = rtGetCVAR("rt_Renderer");
|
||||
rt_cvar *l_Renderer = rtGetCVAR("l_Renderer");
|
||||
const char *renderer = DEFAULT_RENDERER;
|
||||
if (!rt_Renderer) {
|
||||
if (!l_Renderer) {
|
||||
rtReportError("RENDERER", "rt_Renderer CVAR is not registered. Falling back to '%s'.", DEFAULT_RENDERER);
|
||||
}
|
||||
else {
|
||||
renderer = rt_Renderer->s;
|
||||
renderer = l_Renderer->s;
|
||||
}
|
||||
|
||||
#ifdef RT_STATIC_LIB
|
||||
|
Loading…
Reference in New Issue
Block a user