From 6cc8bf42629ff163acc1935a194852fd61c7df0c Mon Sep 17 00:00:00 2001 From: Caleb Burke Date: Sun, 4 Oct 2026 01:03:47 -0700 Subject: [PATCH] adding in sandbox --- CMakeLists.txt | 1 + bin/dev | 14 ++++++++++++++ engine/src/window.hpp | 2 +- sandbox/CMakeLists.txt | 22 ++++++++++++++++++++++ sandbox/main.cpp | 28 ++++++++++++++++++++++++++++ sandbox/shaders/.gitkeep | 0 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 sandbox/CMakeLists.txt create mode 100644 sandbox/main.cpp create mode 100644 sandbox/shaders/.gitkeep diff --git a/CMakeLists.txt b/CMakeLists.txt index 89400a2..2170f36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,4 +39,5 @@ add_subdirectory(third_party) add_subdirectory(engine) add_subdirectory(editor) add_subdirectory(testbed) +add_subdirectory(sandbox) add_subdirectory(examples) diff --git a/bin/dev b/bin/dev index ccd8c2c..b1d1455 100755 --- a/bin/dev +++ b/bin/dev @@ -80,6 +80,20 @@ class DevCommand(GiteaCommand, RenderDocCommand, ShadersCommand, TracyCommand): os.chdir(preset_dir) os.execv(binary, [binary, *args]) + ## + # Builds the debug preset (incrementally), then runs the raw Vulkan + # sandbox from build/debug. Any arguments are passed through. + # dev sandbox [args...] + def sandbox(self, *args, **kwargs): + preset = self.DEFAULT_PRESET + self._build_preset(preset, fresh=False) + + preset_dir = os.path.join(self._project_root(), "build", preset) + binary = os.path.join(preset_dir, "bin", "sandbox") + print(f"Running: {shlex.join([binary, *args])}") + os.chdir(preset_dir) + os.execv(binary, [binary, *args]) + # Custom helpers def ownit(self, *args, **kwargs): diff --git a/engine/src/window.hpp b/engine/src/window.hpp index 672215d..29da336 100644 --- a/engine/src/window.hpp +++ b/engine/src/window.hpp @@ -15,7 +15,7 @@ class Window { Window(const Window&) = delete; Window& operator=(const Window&) = delete; - Window(int width, int height, const std::string& name = "sophiahaestus"); + Window(int width, int height, const std::string& name = "sophia"); ~Window(); bool shouldClose() { return glfwWindowShouldClose(window); } diff --git a/sandbox/CMakeLists.txt b/sandbox/CMakeLists.txt new file mode 100644 index 0000000..0dd2b8e --- /dev/null +++ b/sandbox/CMakeLists.txt @@ -0,0 +1,22 @@ +# Vulkan playground. Links the engine (and its third-party libraries), and +# can also include the engine's internal headers from engine/src. +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.cpp) + +add_executable(sandbox ${SOURCES}) + +target_compile_definitions(sandbox PRIVATE + SANDBOX_SHADER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/shaders" +) + +# engine/include comes in through the engine's public include path. +target_include_directories(sandbox PRIVATE + "${CMAKE_SOURCE_DIR}/engine/src" +) + +# The engine publicly provides vulkan, vma, shaderc, glfw, glm, imgui, entt +# and Tracy, plus the GLM defines. The rest are engine-private. +target_link_libraries(sandbox PRIVATE + ${PROJECT_NAME} + imguizmo + stb_image +) diff --git a/sandbox/main.cpp b/sandbox/main.cpp new file mode 100644 index 0000000..b8415e1 --- /dev/null +++ b/sandbox/main.cpp @@ -0,0 +1,28 @@ +#define GLFW_INCLUDE_VULKAN +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VK_CHECK(expr) \ + do { \ + vk::Result result_ = (expr); \ + if (result_ != vk::Result::eSuccess) { \ + std::fprintf(stderr, "%s:%d: %s -> %d\n", __FILE__, __LINE__, #expr, \ + result_); \ + std::abort(); \ + } \ + } while (0) + +constexpr uint32_t WIDTH = 1280; +constexpr uint32_t HEIGHT = 720; +constexpr const char* NAME = ""; + +int main() { return EXIT_SUCCESS; } diff --git a/sandbox/shaders/.gitkeep b/sandbox/shaders/.gitkeep new file mode 100644 index 0000000..e69de29