From 789e1e186fc40183dcf7a6343dc9b27b17428603 Mon Sep 17 00:00:00 2001 From: light7734 Date: Tue, 6 Jan 2026 13:42:32 +0330 Subject: [PATCH] add sandbox --- modules/CMakeLists.txt | 4 +++ modules/sandbox/CMakeLists.txt | 3 +++ modules/sandbox/sandbox.cpp | 45 ++++++++++++++++++++++++++++++++++ tools/cmake/options.cmake | 1 + 4 files changed, 53 insertions(+) create mode 100644 modules/sandbox/CMakeLists.txt create mode 100644 modules/sandbox/sandbox.cpp diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index f7922d0..502fc10 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -274,3 +274,7 @@ target_link_libraries( # add_executable_module(mirror entrypoint/mirror.cpp) # target_link_libraries(mirror PRIVATE libmirror input) + +if(ENABLE_SANDBOX) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sandbox/) +endif() diff --git a/modules/sandbox/CMakeLists.txt b/modules/sandbox/CMakeLists.txt new file mode 100644 index 0000000..1a2976c --- /dev/null +++ b/modules/sandbox/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(sandbox sandbox.cpp) +target_link_libraries(sandbox PRIVATE logger bitwise env memory time test lt_debug math assets app ecs surface renderer input mirror) + diff --git a/modules/sandbox/sandbox.cpp b/modules/sandbox/sandbox.cpp new file mode 100644 index 0000000..3cd9027 --- /dev/null +++ b/modules/sandbox/sandbox.cpp @@ -0,0 +1,45 @@ +import test.test; +import time; +import test.expects; +import surface.system; +import surface.events; +import surface.requests; +import ecs.registry; +import memory.scope; +import memory.reference; +import logger; +import math.vec2; +import app.system; +import std; + +constexpr auto title = "TestWindow"; +constexpr auto width = 800u; +constexpr auto height = 600u; +constexpr auto vsync = true; +constexpr auto visible = false; + +int main() +{ + auto registry = lt::memory::create_ref(); + auto system = lt::surface::System { registry }; + + auto entity = registry->create_entity(); + + system.create_surface_component( + entity, + lt::surface::SurfaceComponent::CreateInfo { + .title = title, + .resolution = { width, height }, + .vsync = vsync, + .visible = visible, + } + ); + + auto timer = lt::time::Timer {}; + lt::log::trace("Ticking for 3 seconds..."); + while (timer.elapsed_time() < std::chrono::seconds { 3 }) + { + system.tick({}); + } + lt::log::trace("Three seconds passed, quitting..."); +} diff --git a/tools/cmake/options.cmake b/tools/cmake/options.cmake index 93911c1..991795a 100644 --- a/tools/cmake/options.cmake +++ b/tools/cmake/options.cmake @@ -1,3 +1,4 @@ +add_option(ENABLE_SANDBOX "Enables the building of the sandbox module for experimentation") add_option(ENABLE_UNIT_TESTS "Enables the building of the unit test modules") add_option(ENABLE_FUZZ_TESTS "Enables the building of the fuzz test modules") add_option(