1#include "components/EngineCommands.hpp"
3#include "components/DebugConsole.hpp"
4#include "components/HardwareInfo.hpp"
13 static bool parseBool(
const std::string& arg) {
14 return arg ==
"1" || arg ==
"true" || arg ==
"on";
18 static glm::vec3 parseVec3(
const std::vector<std::string>& args,
size_t startIndex) {
19 if (args.size() < startIndex + 3)
return glm::vec3(0.0f);
20 return glm::vec3(std::stof(args[startIndex]), std::stof(args[startIndex+1]), std::stof(args[startIndex+2]));
23 void RegisterEngineCommands(
Engine* engine) {
24 auto& console = DebugConsole::Get();
27 console.RegisterCommand(
"sys_info", [](
auto args) {
28 vex::log(LogLevel::INFO,
"--- SYSTEM ---");
33 vex::log(LogLevel::INFO,
"--- GPU ---");
37 vex::log(LogLevel::INFO,
"--- VULKAN API ---");
42 vex::log(LogLevel::INFO,
"--- ENGINE FEATURES ---");
43 vex::log(LogLevel::INFO,
" Multi-Draw Indirect: %s", feats.multiDraw ?
"ENABLED" :
"DISABLED");
44 vex::log(LogLevel::INFO,
" Indirect Draw: %s", feats.indirectDraw ?
"ENABLED" :
"DISABLED");
45 vex::log(LogLevel::INFO,
" Bindless Textures: %s", feats.bindlessTextures ?
"ENABLED" :
"DISABLED");
46 vex::log(LogLevel::INFO,
" Shader Draw Params: %s", feats.shaderDrawParameters ?
"ENABLED" :
"DISABLED");
51 console.RegisterCommand(
"sys_fps_max", [engine](
auto args) {
53 vex::log(LogLevel::INFO,
"Current FPS Limit: %d", engine->getFrameLimit());
55 int limit = std::stoi(args[0]);
56 engine->setFrameLimit(limit);
57 vex::log(LogLevel::INFO,
"FPS Limit set to %d", limit);
61 console.RegisterCommand(
"sys_vsync", [engine](
auto args) {
63 vex::log(LogLevel::INFO,
"VSync is %s", engine->getVSync() ?
"ON" :
"OFF");
65 bool enable = parseBool(args[0]);
66 engine->setVSync(enable);
67 vex::log(LogLevel::INFO,
"VSync set to %s", enable ?
"ON" :
"OFF");
71 console.RegisterCommand(
"quit", [engine](
auto args) {
76 console.RegisterCommand(
"scene_load", [engine](
auto args) {
78 vex::log(LogLevel::ERROR,
"Usage: scene_load <filename.json>");
81 std::string path = args[0];
82 engine->getSceneManager()->loadScene(path, *engine);
83 vex::log(LogLevel::INFO,
"Loading scene: %s", path.c_str());
86 console.RegisterCommand(
"scene_list", [engine](
auto args) {
87 auto scenes = engine->getSceneManager()->GetAllSceneNames();
88 vex::log(LogLevel::INFO,
"--- Loaded Scenes ---");
89 for (
const auto& name : scenes) {
90 vex::log(LogLevel::INFO,
" > %s", name.c_str());
94 console.RegisterCommand(
"scene_reload", [engine](
auto args) {
95 engine->prepareScenesForHotReload();
96 std::string last = engine->getSceneManager()->getLastSceneName();
98 engine->getSceneManager()->loadScene(last, *engine);
99 vex::log(LogLevel::INFO,
"Reloaded scene: %s", last.c_str());
104 auto modifyEnv = [engine](std::function<void(
environment&)> modFunc) {
105 environment env = engine->getEnvironmentSettings();
107 engine->setEnvironmentSettings(env);
110 console.RegisterCommand(
"r_ps1_jitter", [modifyEnv](
auto args) {
111 if (args.empty())
return;
112 bool val = parseBool(args[0]);
114 e.passiveVertexJitter = val;
115 e.vertexSnapping = val;
117 vex::log(LogLevel::INFO,
"PS1 Jitter/Snapping: %s", val ?
"ON" :
"OFF");
120 console.RegisterCommand(
"r_ps1_warp", [modifyEnv](
auto args) {
121 if (args.empty())
return;
122 bool val = parseBool(args[0]);
123 modifyEnv([val](
environment& e) { e.affineWarping = val; });
124 vex::log(LogLevel::INFO,
"Affine Warping: %s", val ?
"ON" :
"OFF");
127 console.RegisterCommand(
"r_dither", [modifyEnv](
auto args) {
128 if (args.empty())
return;
129 bool val = parseBool(args[0]);
130 modifyEnv([val](
environment& e) { e.screenDither = val; });
131 vex::log(LogLevel::INFO,
"Screen Dither: %s", val ?
"ON" :
"OFF");
134 console.RegisterCommand(
"r_crt", [modifyEnv](
auto args) {
135 if (args.empty())
return;
136 bool val = parseBool(args[0]);
137 modifyEnv([val](
environment& e) { e.ntfsArtifacts = val; });
138 vex::log(LogLevel::INFO,
"CRT Artifacts: %s", val ?
"ON" :
"OFF");
141 console.RegisterCommand(
"r_resolution_mode", [engine](
auto args) {
142 if (args.empty())
return;
143 int mode = std::stoi(args[0]);
145 vex::log(LogLevel::INFO,
"Resolution Mode set to: %d", mode);
148 console.RegisterCommand(
"r_ambient", [modifyEnv](
auto args) {
149 if (args.size() < 4) {
150 vex::log(LogLevel::ERROR,
"Usage: r_ambient <r> <g> <b> <strength>");
153 glm::vec3 color = parseVec3(args, 0);
154 float strength = std::stof(args[3]);
156 e.ambientLight = color;
157 e.ambientLightStrength = strength;
159 vex::log(LogLevel::INFO,
"Ambient light updated");
163 console.RegisterCommand(
"phys_debug", [engine](
auto args) {
164 if (args.empty())
return;
165 bool val = parseBool(args[0]);
166 engine->setRenderPhysicsDebug(val);
167 vex::log(LogLevel::INFO,
"Physics Debug Draw: %s", val ?
"ON" :
"OFF");
170 console.RegisterCommand(
"phys_gravity", [engine](
auto args) {
171 if (args.size() < 3) {
172 vex::log(LogLevel::ERROR,
"Usage: phys_gravity <x> <y> <z>");
175 glm::vec3 grav = parseVec3(args, 0);
176 if (
auto* phys = engine->getPhysicsSystem()) {
177 phys->SetGravityVector(grav);
178 vex::log(LogLevel::INFO,
"Gravity set to [%.2f, %.2f, %.2f]", grav.x, grav.y, grav.z);
182 console.RegisterCommand(
"phys_steps", [engine](
auto args) {
183 if (args.empty())
return;
184 int steps = std::stoi(args[0]);
185 if (
auto* phys = engine->getPhysicsSystem()) {
186 phys->setCollisionSteps(steps);
187 vex::log(LogLevel::INFO,
"Physics steps set to %d", steps);
Contains main Engine class.
This file defines SceneManager class.
Class for interaction with engine systems.
static const char * GetBuildHash()
returns engine hash generated during build process.
static std::string GetVulkanDeviceVersion()
Retrieves the Vulkan version supported by the device.
static std::string GetCPUName()
Retrieves the name of the CPU.
static bool HasAVX2()
Checks if the CPU supports the AVX2 instruction set.
static std::string GetVulkanRequestedVersion()
Retrieves the Vulkan version requested by the engine.
static VulkanFeatures GetVulkanFeatures()
Retrieves the active Vulkan features.
static std::string GetGPUName()
Retrieves the name of the GPU.
static std::string GetDriverVersion()
Retrieves the GPU driver version.
static std::string GetSystemMemory()
Retrieves the total amount of system memory.
ResolutionMode
Enumeration representing different resolution modes.
void VEX_EXPORT log(const char *fmt,...)
Logs a formatted message.
Holds the status of various Vulkan features.
This struct is used to hold all environment settings. eg. shading details or lighting setup.