├── Extra ├── luajit │ ├── src │ │ ├── jit │ │ │ ├── .gitignore │ │ │ ├── dis_arm64be.lua │ │ │ ├── dis_mips64.lua │ │ │ ├── dis_x64.lua │ │ │ ├── dis_mipsel.lua │ │ │ ├── dis_mips64el.lua │ │ │ ├── dis_mips64r6.lua │ │ │ ├── dis_mips64r6el.lua │ │ │ └── zone.lua │ │ ├── host │ │ │ ├── .gitignore │ │ │ └── README │ │ ├── libluajit.a │ │ ├── .gitignore │ │ ├── lua.hpp │ │ ├── lj_bc.c │ │ ├── lj_asm.h │ │ ├── lj_ff.h │ │ ├── lj_udata.h │ │ ├── lj_alloc.h │ │ ├── lj_parse.h │ │ ├── lj_profile.h │ │ ├── lj_gdbjit.h │ │ ├── lj_assert.c │ │ ├── lj_ccallback.h │ │ ├── lj_ffrecord.h │ │ ├── lj_prng.h │ │ ├── lj_mcode.h │ │ ├── lj_func.h │ │ ├── lj_clib.h │ │ ├── lj_serialize.h │ │ ├── lj_str.h │ │ ├── lj_snap.h │ │ ├── lj_carith.h │ │ ├── lj_strscan.h │ │ ├── lualib.h │ │ ├── lj_state.h │ │ ├── lj_obj.c │ │ └── lib_init.c │ ├── prebuilt │ │ ├── win32 │ │ │ ├── luajit_relver.txt │ │ │ ├── buildvm.lib │ │ │ ├── lua51.lib │ │ │ ├── luajit.lib │ │ │ ├── minilua.lib │ │ │ └── vc140.pdb │ │ └── linux │ │ │ └── libluajit.a │ ├── dynasm │ │ ├── dasm_x64.lua │ │ └── dasm_mips64.lua │ └── README ├── stb │ ├── CMakeLists.txt │ └── stb.c └── rapidjson │ ├── include_dirs.js │ ├── .gitmodules │ ├── RapidJSONConfig.cmake.in │ ├── RapidJSON.pc.in │ ├── docker │ └── debian │ │ └── Dockerfile │ ├── library.json │ ├── .gitignore │ ├── RapidJSONConfigVersion.cmake.in │ ├── .gitattributes │ ├── package.json │ ├── CMakeModules │ └── FindGTestSrc.cmake │ └── appveyor.yml ├── LDCore ├── Profiler │ ├── Lib │ │ └── Profiler.cpp │ └── CMakeLists.txt ├── Camera │ ├── Lib │ │ └── CameraCommon.h │ ├── Test │ │ ├── CameraTest.cpp │ │ ├── TestOrthographic.h │ │ └── TestPerspective.h │ └── CMakeLists.txt ├── Asset │ ├── Test │ │ └── AssetTest.cpp │ └── Lib │ │ ├── Template │ │ └── UITemplateObj.h │ │ ├── AssetWatcher.cpp │ │ ├── AssetWatcher.h │ │ └── AssetType │ │ └── UITemplateAsset.cpp ├── Media │ ├── Test │ │ ├── MediaTest.cpp │ │ └── BitmapTest.cpp │ └── Lib │ │ ├── Format │ │ ├── MP3.cpp │ │ ├── WAV.cpp │ │ └── TinygltfLoader.h │ │ ├── AudioDataObj.h │ │ └── ModelObj.h ├── Scene │ ├── Test │ │ └── SceneTest.cpp │ ├── Lib │ │ └── LuaScript.h │ └── CMakeLists.txt ├── Project │ ├── Test │ │ └── ProjectTest.cpp │ ├── Lib │ │ └── ProjectSettingsDefault.h │ └── CMakeLists.txt ├── AudioBackend │ ├── Test │ │ ├── AudioBackendTest.cpp │ │ └── MiniAudioTest.cpp │ ├── Lib │ │ └── AudioBackend.cpp │ └── CMakeLists.txt ├── Lua │ └── Test │ │ ├── LuaTest.h │ │ └── LuaTest.cpp ├── CommandLine │ ├── Test │ │ └── CommandLineTest.cpp │ └── CMakeLists.txt ├── Serial │ ├── Lib │ │ ├── Serial.cpp │ │ ├── Value.cpp │ │ └── Compress.cpp │ ├── Test │ │ ├── PacketTest.cpp │ │ └── CompressionTest.cpp │ └── CMakeLists.txt ├── RenderBackend │ ├── Test │ │ └── RBackendTest.h │ └── Lib │ │ ├── RUtilCommon.h │ │ ├── RData.h │ │ └── RUtilGL.h ├── DSA │ ├── Test │ │ ├── DSATest.cpp │ │ ├── GapBufferTest.cpp │ │ └── DSATest.h │ └── CMakeLists.txt ├── AudioMixer │ ├── Lib │ │ ├── AudioEffect.cpp │ │ ├── AudioPlaybackObj.h │ │ └── AudioCommand.cpp │ └── Test │ │ ├── AudioMixerTest.h │ │ └── AudioMixerTest.cpp ├── Application │ ├── Lib │ │ ├── WindowLinux.cpp │ │ └── InputInternal.h │ └── CMakeLists.txt ├── Log │ └── CMakeLists.txt ├── Gizmo │ └── CMakeLists.txt ├── Text │ └── CMakeLists.txt ├── UI │ ├── Lib │ │ ├── UITheme.cpp │ │ └── UIAnimation.cpp │ ├── Sandbox │ │ ├── UISandboxMain.cpp │ │ └── UISandbox.h │ └── Test │ │ └── UIInputTest.cpp ├── AudioServer │ └── CMakeLists.txt ├── RenderGraph │ └── CMakeLists.txt ├── RenderServer │ └── CMakeLists.txt ├── RenderComponent │ └── Lib │ │ └── Layout │ │ ├── PipelineLayouts.cpp │ │ ├── SetLayouts.cpp │ │ └── VertexLayouts.cpp ├── DSP │ ├── CMakeLists.txt │ └── Lib │ │ └── BiquadFilterCoeff.cpp ├── Lexer │ └── CMakeLists.txt ├── DataRegistry │ ├── Test │ │ └── DataRegistryTest.cpp │ └── CMakeLists.txt ├── JobSystem │ └── CMakeLists.txt ├── System │ └── Lib │ │ └── Timer.cpp └── Header │ └── Test │ └── TestColor.h ├── .gitmodules ├── LDEditor ├── EditorContext │ ├── Test │ │ ├── EditorContextTest.h │ │ ├── EditorContextTest.cpp │ │ └── EditorActionTest.cpp │ └── Lib │ │ ├── EditorContextCommand.h │ │ ├── EditorContextCommand.cpp │ │ ├── EditorAction.cpp │ │ └── EditorIconAtlas.cpp ├── EInspectorWindow │ ├── Lib │ │ ├── InspectComponent.h │ │ └── EInspectorWindowObj.h │ └── CMakeLists.txt ├── EditorWidget │ ├── Lib │ │ ├── UIDraw.cpp │ │ └── UIAssetSlotWidget.cpp │ └── CMakeLists.txt ├── EConsoleWindow │ └── CMakeLists.txt ├── EOutlinerWindow │ ├── CMakeLists.txt │ └── Lib │ │ └── ComponentMenu.h ├── EViewportWindow │ ├── CMakeLists.txt │ └── Lib │ │ └── ViewportToolbar.h └── EditorMain │ ├── CMakeLists.txt │ └── Lib │ ├── EditorBottomBar.h │ ├── EditorBottomBar.cpp │ └── EditorTopBar.h ├── Include ├── Ludens │ ├── Header │ │ ├── Version.h │ │ ├── Directional.h │ │ ├── Types.h │ │ ├── Class.h │ │ ├── SIMD.h │ │ ├── Handle.h │ │ ├── Platform.h │ │ ├── Bitwise.h │ │ ├── Impulse.h │ │ ├── Assert.h │ │ └── GLSL │ │ │ └── Common.h │ ├── Profiler │ │ └── Profiler.h │ ├── RenderComponent │ │ ├── Layout │ │ │ ├── PipelineLayouts.h │ │ │ ├── RMaterial.h │ │ │ └── RMesh.h │ │ ├── Pipeline │ │ │ ├── LinePipeline.h │ │ │ ├── SkyboxPipeline.h │ │ │ ├── OutlinePipeline.h │ │ │ ├── EquirectangularPipeline.h │ │ │ └── RMeshPipeline.h │ │ ├── DualKawaseComponent.h │ │ ├── ScreenPickComponent.h │ │ ├── OutlineComponent.h │ │ └── Embed │ │ │ └── GizmoMesh.h │ ├── Lexer │ │ └── Token.h │ ├── Media │ │ └── Format │ │ │ ├── WAV.h │ │ │ └── MP3.h │ ├── Asset │ │ ├── AssetType │ │ │ ├── UITemplateAsset.h │ │ │ ├── LuaScriptAsset.h │ │ │ ├── MeshAsset.h │ │ │ ├── BlobAsset.h │ │ │ ├── AudioClipAsset.h │ │ │ ├── FontAsset.h │ │ │ └── Texture2DAsset.h │ │ ├── AssetSchema.h │ │ ├── Template │ │ │ └── UITemplateSchema.h │ │ └── Asset.h │ ├── AudioMixer │ │ ├── Effect │ │ │ ├── AudioEffectLowPassFilter.h │ │ │ └── AudioEffectHighPassFilter.h │ │ ├── AudioEffectInfo.h │ │ ├── AudioMixer.h │ │ ├── AudioEffect.h │ │ └── AudioBuffer.h │ ├── RenderBackend │ │ ├── LDShaderCompiler.h │ │ ├── RStager.h │ │ └── KTX.h │ ├── Serial │ │ ├── Compress.h │ │ └── Value.h │ ├── System │ │ ├── DropManager.h │ │ ├── Timer.h │ │ └── FileWatcher.h │ ├── Scene │ │ └── SceneSchema.h │ ├── DSP │ │ ├── Resampler.h │ │ ├── BiquadFilterCoeff.h │ │ └── DSP.h │ ├── Camera │ │ └── CameraController.h │ ├── Text │ │ └── TextBuffer.h │ ├── Project │ │ ├── ProjectSchema.h │ │ └── ProjectSettings.h │ ├── AudioBackend │ │ ├── MiniAudio.h │ │ └── AudioBackend.h │ ├── Application │ │ └── Input.h │ ├── DSA │ │ └── Buffer.h │ └── UI │ │ └── UITheme.h ├── LudensEditor │ ├── EditorWidget │ │ ├── UIDraw.h │ │ ├── UIAssetSlotWidget.h │ │ ├── UITransformEditWidget.h │ │ ├── UIVersionWindow.h │ │ └── UISelectWindow.h │ ├── EditorContext │ │ ├── EditorCallback.h │ │ ├── EditorWindowObj.h │ │ ├── EditorIconAtlas.h │ │ ├── EditorSettings.h │ │ └── EditorAction.h │ ├── EOutlinerWindow │ │ └── EOutlinerWindow.h │ ├── EConsoleWindow │ │ └── EConsoleWindow.h │ └── EInspectorWindow │ │ └── EInspectorWindow.h └── LudensBuilder │ ├── BDocumentCompiler │ └── BDocumentCompiler.h │ └── BAssetUtil │ └── BAssetUtil.h ├── .gitignore ├── .gitattributes ├── LDBuilder ├── BAssetUtil │ └── CMakeLists.txt ├── BDocumentCompiler │ └── CMakeLists.txt ├── CMakeLists.txt └── Main │ ├── MeshUtil.h │ ├── RenderUtil.h │ ├── RunTests.h │ └── AudioUtil.h ├── LDUtil └── LudensLFS │ ├── CMakeLists.txt │ └── Include │ └── LudensLFS.h └── LICENSE /Extra/luajit/src/jit/.gitignore: -------------------------------------------------------------------------------- 1 | vmdef.lua 2 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/win32/luajit_relver.txt: -------------------------------------------------------------------------------- 1 | 1744318430 2 | -------------------------------------------------------------------------------- /LDCore/Profiler/Lib/Profiler.cpp: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /Extra/luajit/src/host/.gitignore: -------------------------------------------------------------------------------- 1 | minilua 2 | buildvm 3 | buildvm_arch.h 4 | -------------------------------------------------------------------------------- /Extra/stb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(stb stb.c stb_image.h stb_image_write.h) -------------------------------------------------------------------------------- /LDCore/Camera/Lib/CameraCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define CAMERA_WORLD_UP Vec3(0.0f, 1.0f, 0.0f) -------------------------------------------------------------------------------- /LDCore/Asset/Test/AssetTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include -------------------------------------------------------------------------------- /LDCore/Media/Test/MediaTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include -------------------------------------------------------------------------------- /LDCore/Scene/Test/SceneTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Extra/LudensLFS"] 2 | path = Extra/LudensLFS 3 | url = https://github.com/x2w-soda/LudensLFS 4 | -------------------------------------------------------------------------------- /LDCore/Project/Test/ProjectTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include 3 | -------------------------------------------------------------------------------- /LDEditor/EditorContext/Test/EditorContextTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /LDCore/AudioBackend/Test/AudioBackendTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include -------------------------------------------------------------------------------- /LDCore/Lua/Test/LuaTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern LD::LuaStateInfo sTestStateInfo; -------------------------------------------------------------------------------- /Extra/rapidjson/include_dirs.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | console.log(path.join(path.relative('.', __dirname), 'include')); 3 | -------------------------------------------------------------------------------- /LDEditor/EditorContext/Test/EditorContextTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include -------------------------------------------------------------------------------- /Extra/rapidjson/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "thirdparty/gtest"] 2 | path = thirdparty/gtest 3 | url = https://github.com/google/googletest.git 4 | -------------------------------------------------------------------------------- /Include/Ludens/Header/Version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define LD_VERSION_MAJOR 0 4 | #define LD_VERSION_MINOR 0 5 | #define LD_VERSION_PATCH 0 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Build/** 2 | build/** 3 | BuildLinux/** 4 | *.o 5 | *.so 6 | *.obj 7 | *.exp 8 | *.dll 9 | *.exe 10 | *.manifest 11 | *.dmp 12 | *.swp -------------------------------------------------------------------------------- /Extra/stb/stb.c: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_IMPLEMENTATION 2 | #include "stb_image.h" 3 | #define STB_IMAGE_WRITE_IMPLEMENTATION 4 | #include "stb_image_write.h" -------------------------------------------------------------------------------- /LDCore/CommandLine/Test/CommandLineTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include 3 | #include "TestArgParser.h" -------------------------------------------------------------------------------- /Extra/luajit/src/libluajit.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b2305f143c0f6446be927d824271c31aa834a481aa0e3dd89f75e84d31d74c78 3 | size 974724 4 | -------------------------------------------------------------------------------- /Extra/luajit/src/.gitignore: -------------------------------------------------------------------------------- 1 | luajit 2 | luajit.h 3 | luajit_relver.txt 4 | lj_bcdef.h 5 | lj_ffdef.h 6 | lj_libdef.h 7 | lj_recdef.h 8 | lj_folddef.h 9 | lj_vm.[sS] 10 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/linux/libluajit.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b2305f143c0f6446be927d824271c31aa834a481aa0e3dd89f75e84d31d74c78 3 | size 974724 4 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/win32/buildvm.lib: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:80b557d1a886a8c510927aa5d843c0f56d2ebebc5974d325e85f50ebdf5d0554 3 | size 33120 4 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/win32/lua51.lib: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:605559f8fd28f6af5f4bb9cf7a359b07050005fa79b838bdb366fcd70c441b13 3 | size 9642758 4 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/win32/luajit.lib: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:29d9cfde65b11bebb468ed22c9f71b6286b38a57cd87b64cbcb706a9383a17c2 3 | size 32932 4 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/win32/minilua.lib: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4a059c1b33e8b5038f40b902dab1bd022804b2d166d2f620a3eb022bd35469d0 3 | size 33120 4 | -------------------------------------------------------------------------------- /Extra/luajit/prebuilt/win32/vc140.pdb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:54b28bc3fa8b8f3dd4bf87af962193337fe0a5f87ead6c9d2e68c8ba1f29e8ef 3 | size 282624 4 | -------------------------------------------------------------------------------- /LDCore/Camera/Test/CameraTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include 3 | #include "TestOrthographic.h" 4 | #include "TestPerspective.h" -------------------------------------------------------------------------------- /Extra/luajit/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.dll filter=lfs diff=lfs merge=lfs -text 3 | *.lib filter=lfs diff=lfs merge=lfs -text 4 | *.a filter=lfs diff=lfs merge=lfs -text 5 | *.pdb filter=lfs diff=lfs merge=lfs -text 6 | -------------------------------------------------------------------------------- /Extra/luajit/src/host/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only used during the build process of LuaJIT. 2 | For cross-compilation, they must be executed on the host, not on the target. 3 | 4 | These files should NOT be installed! 5 | -------------------------------------------------------------------------------- /LDCore/Serial/Lib/Serial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace LD { 4 | 5 | Serializer::Serializer(size_t size) 6 | : mReadPos(0) 7 | { 8 | mBuffer.resize(size); 9 | } 10 | 11 | } // namespace LD 12 | -------------------------------------------------------------------------------- /LDCore/RenderBackend/Test/RBackendTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define BITMAP_MSE_TOLERANCE 0.0001 4 | 5 | namespace LD { 6 | 7 | bool compute_bitmap_mse(const char* lhsPath, const char* rhsPath, double& outMSE); 8 | 9 | } // namespace LD -------------------------------------------------------------------------------- /Extra/rapidjson/RapidJSONConfig.cmake.in: -------------------------------------------------------------------------------- 1 | get_filename_component(RAPIDJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | set(RAPIDJSON_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@") 3 | message(STATUS "RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}") 4 | -------------------------------------------------------------------------------- /LDCore/Project/Lib/ProjectSettingsDefault.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DEFAULT_STARTUP_WINDOW_WIDTH 1600 4 | #define DEFAULT_STARTUP_WINDOW_HEIGHT 900 5 | #define DEFAULT_STARTUP_WINDOW_NAME "Ludens" 6 | #define DEFAULT_STARTUP_DEFAULT_SCENE_PATH {} -------------------------------------------------------------------------------- /Include/LudensEditor/EditorWidget/UIDraw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LD { 4 | 5 | /// @brief Decorator to draw text with background color. 6 | void eui_draw_text_with_bg(UIWidget widget, ScreenRenderComponent renderer, void* user); 7 | 8 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Profiler/Profiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // dragging third party headers and wrap with macros 4 | #include 5 | 6 | #define LD_PROFILE_SCOPE ZoneScoped 7 | #define LD_PROFILE_SCOPE_NAME ZoneScopedN 8 | #define LD_PROFILE_FRAME_MARK FrameMark -------------------------------------------------------------------------------- /Extra/rapidjson/RapidJSON.pc.in: -------------------------------------------------------------------------------- 1 | includedir=@INCLUDE_INSTALL_DIR@ 2 | 3 | Name: @PROJECT_NAME@ 4 | Description: A fast JSON parser/generator for C++ with both SAX/DOM style API 5 | Version: @LIB_VERSION_STRING@ 6 | URL: https://github.com/miloyip/rapidjson 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Layout/PipelineLayouts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | /// @brief pipeline layout for rendering RMeshes 8 | extern RPipelineLayoutInfo sRMeshPipelineLayout; 9 | 10 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensEditor/EditorContext/EditorCallback.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | /// @brief Select an asset in project. 8 | typedef void (*ECBSelectAssetFn)(AssetType type, AUID currentID, void* user); 9 | 10 | } // namespace LD -------------------------------------------------------------------------------- /Extra/rapidjson/docker/debian/Dockerfile: -------------------------------------------------------------------------------- 1 | # BUILD: docker build -t rapidjson-debian . 2 | # RUN: docker run -it -v "$PWD"/../..:/rapidjson rapidjson-debian 3 | 4 | FROM debian:jessie 5 | 6 | RUN apt-get update && apt-get install -y g++ cmake doxygen valgrind 7 | 8 | ENTRYPOINT ["/bin/bash"] 9 | -------------------------------------------------------------------------------- /LDCore/Lua/Test/LuaTest.cpp: -------------------------------------------------------------------------------- 1 | #include "LuaTest.h" 2 | #include 3 | #include 4 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 5 | #include 6 | 7 | LD::LuaStateInfo sTestStateInfo{ 8 | .openLibs = true, 9 | }; 10 | -------------------------------------------------------------------------------- /Include/Ludens/Lexer/Token.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | template 9 | struct Token 10 | { 11 | ETokenType type; 12 | Token* next; 13 | std::string_view span; 14 | }; 15 | 16 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Header/Directional.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LD { 4 | 5 | enum Axis 6 | { 7 | AXIS_X, 8 | AXIS_Y, 9 | AXIS_Z, 10 | }; 11 | 12 | enum Direction 13 | { 14 | DIRECTION_LEFT, 15 | DIRECTION_RIGHT, 16 | DIRECTION_UP, 17 | DIRECTION_DOWN, 18 | }; 19 | 20 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_bc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode instruction modes. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_bc_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_bc.h" 11 | 12 | /* Bytecode offsets and bytecode instruction modes. */ 13 | #include "lj_bcdef.h" 14 | 15 | -------------------------------------------------------------------------------- /Include/LudensEditor/EditorWidget/UIAssetSlotWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | bool eui_asset_slot(EditorTheme theme, AssetType type, AUID assetID, const char* assetName); 10 | 11 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EInspectorWindow/Lib/InspectComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct EInspectorWindowObj; 9 | 10 | void eui_inspect_component(EInspectorWindowObj& self, ComponentType type, void* comp); 11 | 12 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensEditor/EditorWidget/UITransformEditWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct Transform; 10 | 11 | void eui_transform_edit(EditorTheme editorTheme, Transform* transform); 12 | 13 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Header/Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | using byte = unsigned char; 8 | 9 | template 10 | concept IsTrivial = std::is_trivially_constructible_v && 11 | std::is_trivially_destructible_v && 12 | std::is_trivially_copyable_v; 13 | 14 | } // namespace LD -------------------------------------------------------------------------------- /LDBuilder/BAssetUtil/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDBAssetUtil) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/LudensBuilder/BAssetUtil/BAssetUtil.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/BAssetUtil.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PUBLIC 17 | LDCoreLibs 18 | ) -------------------------------------------------------------------------------- /LDUtil/LudensLFS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDLudensLFS) 2 | 3 | set(MODULE_INCLUDE 4 | Include/LudensLFS.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/LudensLFS.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_include_directories(${MODULE_NAME} PRIVATE 17 | ${LUDENS_INCLUDE_DIR} 18 | ${LUDENS_SOURCE_DIR} 19 | ) 20 | -------------------------------------------------------------------------------- /Extra/rapidjson/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RapidJSON", 3 | "keywords": "json, sax, dom, parser, generator", 4 | "description": "A fast JSON parser/generator for C++ with both SAX/DOM style API", 5 | "include": "include", 6 | "examples": "example/*/*.cpp", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/miloyip/rapidjson" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /LDCore/DSA/Test/DSATest.cpp: -------------------------------------------------------------------------------- 1 | #include "DSATest.h" 2 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 3 | #include "HeapStorageTest.h" 4 | #include "StringTest.h" 5 | #include "VectorTest.h" 6 | #include 7 | 8 | int Foo::sCtor = 0; 9 | int Foo::sDtor = 0; 10 | int Foo::sCopyCtor = 0; 11 | int Foo::sCopyAssign = 0; 12 | int Foo::sMoveCtor = 0; 13 | int Foo::sMoveAssign = 0; -------------------------------------------------------------------------------- /LDCore/AudioBackend/Test/MiniAudioTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace LD; 5 | 6 | TEST_CASE("MiniAudio basic") 7 | { 8 | MiniAudioInfo maI{}; 9 | maI.dataCallback = nullptr; 10 | maI.userData = nullptr; 11 | MiniAudio ma = MiniAudio::create(maI); 12 | CHECK(ma); 13 | 14 | MiniAudio::destroy(ma); 15 | } -------------------------------------------------------------------------------- /Include/Ludens/Media/Format/WAV.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct WAVData : AudioData 9 | { 10 | /// @brief Parse WAV data and create handle. 11 | static WAVData create(const void* data, size_t size); 12 | 13 | /// @brief Destroy WAV data. 14 | static void destroy(WAVData data); 15 | }; 16 | 17 | } // namespace LD -------------------------------------------------------------------------------- /LDBuilder/BDocumentCompiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDBDocumentCompiler) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/LudensBuilder/BDocumentCompiler/BDocumentCompiler.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/BDocumentCompiler.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PUBLIC 17 | LDCoreLibs 18 | ) -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Pipeline/LinePipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct LinePipeline : Handle 9 | { 10 | static LinePipeline create(RDevice device); 11 | static void destroy(LinePipeline pipeline); 12 | 13 | RPipeline handle(); 14 | }; 15 | 16 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Media/Format/MP3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct MP3Data : AudioData 9 | { 10 | /// @brief Parse MP3 data and create handle. 11 | static MP3Data create(const void* data, size_t size); 12 | 13 | /// @brief Destroy MP3 data. 14 | static void destroy(MP3Data data); 15 | }; 16 | 17 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/AudioMixer/Lib/AudioEffect.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace LD { 4 | 5 | void AudioEffect::process(float* outFrames, const float* inFrames, uint32_t frameCount) 6 | { 7 | ((AudioEffectObj*)mObj)->process(outFrames, inFrames, frameCount); 8 | } 9 | 10 | void AudioEffect::read(AudioEffectInfo& info) 11 | { 12 | ((AudioEffectObj*)mObj)->read(info); 13 | } 14 | 15 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Application/Lib/WindowLinux.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef LD_PLATFORM_LINUX 3 | #include "Window.h" 4 | 5 | namespace LD { 6 | 7 | void Window::hint_border_color(Color color) 8 | { 9 | } 10 | 11 | void Window::hint_title_bar_color(Color color) 12 | { 13 | } 14 | 15 | void Window::hint_title_bar_text_color(Color color) 16 | { 17 | } 18 | 19 | } // namespace LD 20 | 21 | #endif // LD_PLATFORM_LINUX 22 | -------------------------------------------------------------------------------- /LDCore/Log/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDLog) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/Log/Log.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/Log.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PRIVATE 17 | LDSystem 18 | ) 19 | 20 | target_include_directories(${MODULE_NAME} PRIVATE 21 | ${LUDENS_INCLUDE_DIR} 22 | ) 23 | -------------------------------------------------------------------------------- /Extra/luajit/src/lj_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** IR assembler (SSA IR -> machine code). 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ASM_H 7 | #define _LJ_ASM_H 8 | 9 | #include "lj_jit.h" 10 | 11 | #if LJ_HASJIT 12 | LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); 13 | LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, 14 | MCode *target); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Include/Ludens/Header/Class.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LD { 4 | 5 | struct NonCopyable 6 | { 7 | NonCopyable() = default; 8 | NonCopyable(const NonCopyable&) = delete; 9 | NonCopyable& operator=(const NonCopyable&) = delete; 10 | }; 11 | 12 | struct NonMovable 13 | { 14 | NonMovable() = default; 15 | NonMovable(NonMovable&&) = delete; 16 | NonMovable& operator=(NonMovable&&) = delete; 17 | }; 18 | 19 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Gizmo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDGizmo) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/Gizmo/Gizmo.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/Gizmo.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_include_directories(${MODULE_NAME} PRIVATE 17 | ${LUDENS_INCLUDE_DIR} 18 | ) 19 | 20 | target_link_libraries(${MODULE_NAME} PUBLIC 21 | LDCamera 22 | ) -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/UITemplateAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief UITemplate asset handle. 11 | struct UITemplateAsset : AssetHandle 12 | { 13 | UIWidget load_ui_subtree(UIWidget parent, UITemplateOnLoadCallback callback, void* user); 14 | }; 15 | 16 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_ff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function IDs. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FF_H 7 | #define _LJ_FF_H 8 | 9 | /* Fast function ID. */ 10 | typedef enum { 11 | FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ 12 | FF_C_ = FF_C, /* Regular C function (must be 1). */ 13 | #define FFDEF(name) FF_##name, 14 | #include "lj_ffdef.h" 15 | FF__MAX 16 | } FastFunc; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Pipeline/SkyboxPipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief pipeline for rendering skybox 9 | struct SkyboxPipeline : Handle 10 | { 11 | static SkyboxPipeline create(RDevice device); 12 | static void destroy(SkyboxPipeline pipeline); 13 | 14 | RPipeline handle(); 15 | }; 16 | 17 | } // namespace LD -------------------------------------------------------------------------------- /Extra/rapidjson/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/* 2 | !/bin/data 3 | !/bin/encodings 4 | !/bin/jsonchecker 5 | !/bin/types 6 | /build 7 | /doc/html 8 | /doc/doxygen_*.db 9 | *.a 10 | 11 | # Temporary files created during CMake build 12 | CMakeCache.txt 13 | CMakeFiles 14 | cmake_install.cmake 15 | CTestTestfile.cmake 16 | Makefile 17 | RapidJSON*.cmake 18 | RapidJSON.pc 19 | Testing 20 | /googletest 21 | install_manifest.txt 22 | Doxyfile 23 | Doxyfile.zh-cn 24 | DartConfiguration.tcl 25 | *.nupkg 26 | -------------------------------------------------------------------------------- /Include/Ludens/Header/SIMD.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // clang-format off 6 | 7 | // detect instruction sets, drags platform specific headers 8 | #if defined(LD_ARCH_X64) 9 | # define LD_SSE2 true 10 | #else 11 | # define LD_SSE2 false 12 | #endif 13 | #if defined(__SSE4_1__) 14 | # define LD_SSE4_1 15 | #endif 16 | 17 | #if defined(LD_SSE2) 18 | # include 19 | # include 20 | #endif 21 | 22 | // clang-format on 23 | -------------------------------------------------------------------------------- /Extra/luajit/src/lj_udata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_UDATA_H 7 | #define _LJ_UDATA_H 8 | 9 | #include "lj_obj.h" 10 | 11 | LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); 12 | LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); 13 | #if LJ_64 14 | LJ_FUNC void * LJ_FASTCALL lj_lightud_intern(lua_State *L, void *p); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Pipeline/OutlinePipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct OutlinePipeline : Handle 9 | { 10 | static OutlinePipeline create(RDevice device); 11 | static void destroy(OutlinePipeline pipeline); 12 | 13 | static RPipelineLayoutInfo get_layout(); 14 | 15 | RPipeline handle(); 16 | }; 17 | 18 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Text/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDText) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/Text/TextBuffer.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/TextBuffer.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PUBLIC 17 | LDSystem 18 | LDDSA 19 | ) 20 | 21 | target_include_directories(${MODULE_NAME} PRIVATE 22 | ${LUDENS_INCLUDE_DIR} 23 | ) 24 | 25 | -------------------------------------------------------------------------------- /LDCore/UI/Lib/UITheme.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace LD { 4 | 5 | static const UIThemeInfo sDefaultThemeInfo = { 6 | .surfaceColor = 0x2B2C2FFF, 7 | .onSurfaceColor = 0xDFDFDFFF, 8 | .primaryColor = 0x4DD8E6FF, 9 | .backgroundColor = 0x000000FF, 10 | .fieldColor = 0x1B1B1BFF, 11 | .selectionColor = 0x4D6490FF, 12 | }; 13 | 14 | UIThemeInfo UITheme::get_default_info() 15 | { 16 | return sDefaultThemeInfo; 17 | } 18 | 19 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bundled memory allocator. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_ALLOC_H 7 | #define _LJ_ALLOC_H 8 | 9 | #include "lj_def.h" 10 | 11 | #ifndef LUAJIT_USE_SYSMALLOC 12 | LJ_FUNC void *lj_alloc_create(PRNGState *rs); 13 | LJ_FUNC void lj_alloc_setprng(void *msp, PRNGState *rs); 14 | LJ_FUNC void lj_alloc_destroy(void *msp); 15 | LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /LDCore/AudioServer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDAudioServer) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/AudioServer/AudioServer.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/AudioServer.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PUBLIC 17 | LDAudioBackend 18 | LDAudioMixer 19 | ) 20 | 21 | target_include_directories(${MODULE_NAME} PRIVATE 22 | ${LUDENS_INCLUDE_DIR} 23 | ) 24 | -------------------------------------------------------------------------------- /Include/Ludens/Header/Handle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LD { 4 | 5 | template 6 | class Handle 7 | { 8 | public: 9 | Handle() = default; 10 | Handle(TObject* obj) : mObj(obj) {} 11 | 12 | operator bool() const { return mObj != nullptr; } 13 | operator TObject*() { return mObj; } 14 | operator const TObject*() const { return mObj; } 15 | inline TObject* unwrap() { return mObj; } 16 | 17 | protected: 18 | TObject* mObj; 19 | }; 20 | 21 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/RenderGraph/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDRenderGraph) 2 | 3 | set(MODULE_INCLUDE 4 | "${LUDENS_INCLUDE_DIR}/Ludens/RenderGraph/RGraph.h" 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/RGraph.cpp 9 | Lib/RGraphObj.h 10 | ) 11 | 12 | add_library(${MODULE_NAME} 13 | ${MODULE_INCLUDE} 14 | ${MODULE_LIB} 15 | ) 16 | 17 | target_link_libraries(${MODULE_NAME} PUBLIC 18 | LDRenderBackend 19 | ) 20 | 21 | target_include_directories(${MODULE_NAME} PRIVATE 22 | ${LUDENS_INCLUDE_DIR} 23 | ) -------------------------------------------------------------------------------- /Include/Ludens/Header/Platform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // clang-format off 4 | 5 | // detect OS platform 6 | #ifdef WIN32 7 | # define LD_PLATFORM_WIN32 8 | #elif defined(__linux__) 9 | # define LD_PLATFORM_LINUX 10 | #endif 11 | 12 | // detect compiler 13 | #ifdef LD_PLATFORM_WIN32 14 | # ifdef _MSC_VER 15 | # define LD_COMPILER_MSVC 16 | # endif 17 | #endif 18 | 19 | // detect CPU architecture 20 | #if defined(__x86_64__) || defined(_M_X64) 21 | # define LD_ARCH_X64 22 | #endif 23 | 24 | // clang-format on 25 | -------------------------------------------------------------------------------- /Extra/luajit/src/lj_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua parser (source code -> bytecode). 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PARSE_H 7 | #define _LJ_PARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | LJ_FUNC GCproto *lj_parse(LexState *ls); 13 | LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); 14 | #if LJ_HASFFI 15 | LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /LDCore/RenderServer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDRenderServer) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/RenderServer/RServer.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/RServer.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PUBLIC 17 | LDRenderBackend 18 | LDRenderGraph 19 | LDRenderComponent 20 | ) 21 | 22 | target_include_directories(${MODULE_NAME} PRIVATE 23 | ${LUDENS_INCLUDE_DIR} 24 | ) -------------------------------------------------------------------------------- /LDCore/RenderBackend/Lib/RUtilCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | enum RFormat; 8 | struct RPassInfo; 9 | struct RPassInfoData; 10 | 11 | namespace RUtil { 12 | 13 | uint32_t get_format_texel_size(const RFormat& format); 14 | void save_pass_info(const RPassInfo& inInfo, RPassInfoData& outData); 15 | void load_pass_info(const RPassInfoData& inData, RPassInfo& outInfo); 16 | void print_binding_type(const RBindingType& inType, std::string& outType); 17 | 18 | } // namespace RUtil 19 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/RenderComponent/Lib/Layout/PipelineLayouts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace LD { 6 | 7 | static std::array sMeshPipelineSetLayouts{ 8 | sFrameSetLayout, 9 | sMaterialSetLayout, 10 | }; 11 | 12 | RPipelineLayoutInfo sRMeshPipelineLayout{ 13 | .setLayoutCount = sMeshPipelineSetLayouts.size(), 14 | .setLayouts = sMeshPipelineSetLayouts.data(), 15 | }; 16 | 17 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_profile.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Low-overhead profiling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PROFILE_H 7 | #define _LJ_PROFILE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASPROFILE 12 | 13 | LJ_FUNC void LJ_FASTCALL lj_profile_interpreter(lua_State *L); 14 | #if !LJ_PROFILE_SIGPROF 15 | LJ_FUNC void LJ_FASTCALL lj_profile_hook_enter(global_State *g); 16 | LJ_FUNC void LJ_FASTCALL lj_profile_hook_leave(global_State *g); 17 | #endif 18 | 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Extra/rapidjson/RapidJSONConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | SET(PACKAGE_VERSION "@LIB_VERSION_STRING@") 2 | 3 | IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) 4 | SET(PACKAGE_VERSION_EXACT "true") 5 | ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) 6 | IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) 7 | SET(PACKAGE_VERSION_COMPATIBLE "true") 8 | ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) 9 | SET(PACKAGE_VERSION_UNSUITABLE "true") 10 | ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) 11 | -------------------------------------------------------------------------------- /Include/LudensBuilder/BDocumentCompiler/BDocumentCompiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct DocumentCompilerInfo 9 | { 10 | std::filesystem::path pathToDoxygenXML; /// path to Doxygen index.xml file 11 | }; 12 | 13 | struct DocumentCompiler : Handle 14 | { 15 | static DocumentCompiler create(const DocumentCompilerInfo& compilerInfo); 16 | static void destroy(DocumentCompiler compiler); 17 | }; 18 | 19 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EditorWidget/Lib/UIDraw.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace LD { 6 | 7 | void eui_draw_text_with_bg(UIWidget widget, ScreenRenderComponent renderer, void* user) 8 | { 9 | LD_ASSERT(widget.get_type() == UI_WIDGET_TEXT); 10 | 11 | Color bgColor = widget.get_theme().get_field_color(); 12 | renderer.draw_rect(widget.get_rect(), bgColor); 13 | 14 | UITextWidget::on_draw(widget, renderer); 15 | } 16 | 17 | } // namespace LD -------------------------------------------------------------------------------- /LDBuilder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILDER_NAME LDBuilder) 2 | 3 | set(BUILDER_SOURCE 4 | Main/Main.cpp 5 | Main/AudioUtil.h 6 | Main/AudioUtil.cpp 7 | Main/RenderUtil.h 8 | Main/RenderUtil.cpp 9 | Main/MeshUtil.h 10 | Main/MeshUtil.cpp 11 | Main/RunTests.h 12 | Main/RunTests.cpp 13 | ) 14 | 15 | add_executable(${BUILDER_NAME} 16 | ${BUILDER_SOURCE} 17 | ) 18 | 19 | target_link_libraries(${BUILDER_NAME} PRIVATE 20 | LDCoreLibs 21 | LDBuilderLibs 22 | ) 23 | 24 | target_include_directories(${BUILDER_NAME} PRIVATE 25 | ${LUDENS_INCLUDE_DIR} 26 | ) -------------------------------------------------------------------------------- /LDCore/Media/Lib/Format/MP3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../AudioDataObj.h" 5 | 6 | namespace LD { 7 | 8 | MP3Data MP3Data::create(const void* data, size_t size) 9 | { 10 | AudioDataObj* obj = create_audio_data(data, size, AUDIO_DATA_FORMAT_MP3); 11 | 12 | return {obj}; 13 | } 14 | 15 | void MP3Data::destroy(MP3Data data) 16 | { 17 | AudioDataObj* obj = data.unwrap(); 18 | 19 | destroy_audio_data(obj); 20 | } 21 | 22 | } // namespace LD -------------------------------------------------------------------------------- /Extra/rapidjson/.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.cpp text 7 | *.h text 8 | *.txt text 9 | *.md text 10 | *.cmake text 11 | *.svg text 12 | *.dot text 13 | *.yml text 14 | *.in text 15 | *.sh text 16 | *.autopkg text 17 | Dockerfile text 18 | 19 | # Denote all files that are truly binary and should not be modified. 20 | *.png binary 21 | *.jpg binary 22 | *.json binary -------------------------------------------------------------------------------- /LDEditor/EConsoleWindow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDEConsoleWindow) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EConsoleWindow/EConsoleWindow.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/EConsoleWindow.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} 12 | ${MODULE_LIB} 13 | ${MODULE_INCLUDE} 14 | ) 15 | 16 | target_link_libraries(${MODULE_NAME} PRIVATE 17 | LDCoreLibs 18 | LDEditorContext 19 | LDEditorWidget 20 | ) 21 | 22 | target_include_directories(${MODULE_NAME} PRIVATE 23 | ${LUDENS_SOURCE_DIR} 24 | ${LUDENS_INCLUDE_DIR} 25 | ) 26 | -------------------------------------------------------------------------------- /Extra/luajit/src/lj_gdbjit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Client for the GDB JIT API. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_GDBJIT_H 7 | #define _LJ_GDBJIT_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) 13 | 14 | LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); 15 | LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); 16 | 17 | #else 18 | #define lj_gdbjit_addtrace(J, T) UNUSED(T) 19 | #define lj_gdbjit_deltrace(J, T) UNUSED(T) 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /LDBuilder/Main/MeshUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief 3D Model mesh utilities. 9 | struct MeshUtil : Handle 10 | { 11 | static MeshUtil create(); 12 | static void destroy(MeshUtil util); 13 | 14 | /// @brief Extracts struct MeshVertex and uint32_t face indices into a cpp file. 15 | /// @param path path to 3D model. 16 | /// @return true on success 17 | bool extract_mesh_vertex(const std::filesystem::path& path); 18 | }; 19 | 20 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/AudioMixer/Effect/AudioEffectLowPassFilter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace LD { 5 | 6 | struct AudioEffectLowPassFilterInfo 7 | { 8 | float cutoffFreq; 9 | float sampleRate; 10 | }; 11 | 12 | struct AudioEffectLowPassFilter : AudioEffect 13 | { 14 | /// @brief Create LPF instance. 15 | static AudioEffectLowPassFilter create(const AudioEffectLowPassFilterInfo& info); 16 | 17 | /// @brief Destroy LPF instance. 18 | static void destroy(AudioEffectLowPassFilter filter); 19 | }; 20 | 21 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/AudioMixer/Effect/AudioEffectHighPassFilter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace LD { 5 | 6 | struct AudioEffectHighPassFilterInfo 7 | { 8 | float cutoffFreq; 9 | float sampleRate; 10 | }; 11 | 12 | struct AudioEffectHighPassFilter : AudioEffect 13 | { 14 | /// @brief Create HPF instance. 15 | static AudioEffectHighPassFilter create(const AudioEffectHighPassFilterInfo& info); 16 | 17 | /// @brief Destroy HPF instance. 18 | static void destroy(AudioEffectHighPassFilter filter); 19 | }; 20 | 21 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Media/Lib/Format/WAV.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../AudioDataObj.h" 6 | 7 | 8 | namespace LD { 9 | 10 | WAVData WAVData::create(const void* data, size_t size) 11 | { 12 | AudioDataObj* obj = create_audio_data(data, size, AUDIO_DATA_FORMAT_WAV); 13 | 14 | return {obj}; 15 | } 16 | 17 | void WAVData::destroy(WAVData data) 18 | { 19 | AudioDataObj* obj = data.unwrap(); 20 | 21 | destroy_audio_data(obj); 22 | } 23 | 24 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EOutlinerWindow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDEOutlinerWindow) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EOutlinerWindow/EOutlinerWindow.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/EOutlinerWindow.cpp 9 | Lib/ComponentMenu.h 10 | Lib/ComponentMenu.cpp 11 | ) 12 | 13 | add_library(${MODULE_NAME} 14 | ${MODULE_LIB} 15 | ${MODULE_INCLUDE} 16 | ) 17 | 18 | target_link_libraries(${MODULE_NAME} PRIVATE 19 | LDCoreLibs 20 | LDEditorContext 21 | ) 22 | 23 | target_include_directories(${MODULE_NAME} PRIVATE 24 | ${LUDENS_SOURCE_DIR} 25 | ${LUDENS_INCLUDE_DIR} 26 | ) -------------------------------------------------------------------------------- /LDCore/Media/Lib/AudioDataObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | enum AudioDataFormat 9 | { 10 | AUDIO_DATA_FORMAT_WAV, 11 | AUDIO_DATA_FORMAT_MP3, 12 | }; 13 | 14 | struct AudioDataObj 15 | { 16 | void* samples; 17 | SampleFormat sampleFormat; 18 | uint32_t sampleRate; 19 | uint32_t channels; 20 | uint32_t frameCount; 21 | }; 22 | 23 | AudioDataObj* create_audio_data(const void* data, size_t dataSize, AudioDataFormat dataFormat); 24 | void destroy_audio_data(AudioDataObj* data); 25 | 26 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/RenderBackend/LDShaderCompiler.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace LD { 6 | 7 | /// @brief A ldshader backend that targets SPIRV for Vulkan. 8 | /// The output SPIRV code may be supplied to VkShaderModuleCreateInfo on success. 9 | struct LDShaderCompilerVulkan : Handle 10 | { 11 | static LDShaderCompilerVulkan create(); 12 | static void destroy(LDShaderCompilerVulkan compiler); 13 | 14 | bool compile(LDShaderAST ast, std::vector& spirv); 15 | }; 16 | 17 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/LuaScriptAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | /// @brief Lua script asset handle. 10 | struct LuaScriptAsset : AssetHandle 11 | { 12 | /// @brief Unload asset from RAM. 13 | void unload(); 14 | 15 | /// @brief Get Lua script source string. 16 | const char* get_source(); 17 | 18 | /// @brief Set Lua script source string. 19 | /// @note This only modifies the asset in RAM. 20 | void set_source(const char* src, size_t len); 21 | }; 22 | 23 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Media/Lib/ModelObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | struct ModelObj 11 | { 12 | std::vector textures; 13 | std::vector materials; 14 | std::vector nodes; /// all nodes in this model 15 | std::vector roots; /// the subset of nodes in this model that have no parents 16 | std::vector vertices; 17 | std::vector indices; 18 | bool hasAppliedNodeTransform; 19 | }; 20 | 21 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EViewportWindow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDEViewportWindow) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EViewportWindow/EViewportWindow.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/EViewportWindow.cpp 9 | Lib/ViewportToolbar.h 10 | Lib/ViewportToolbar.cpp 11 | ) 12 | 13 | add_library(${MODULE_NAME} 14 | ${MODULE_LIB} 15 | ${MODULE_INCLUDE} 16 | ) 17 | 18 | target_link_libraries(${MODULE_NAME} PRIVATE 19 | LDCoreLibs 20 | LDEditorContext 21 | LDEditorWidget 22 | ) 23 | 24 | target_include_directories(${MODULE_NAME} PRIVATE 25 | ${LUDENS_SOURCE_DIR} 26 | ${LUDENS_INCLUDE_DIR} 27 | ) 28 | -------------------------------------------------------------------------------- /Extra/luajit/dynasm/dasm_x64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM x64 module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined x86/x64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | x64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_x86") 13 | -------------------------------------------------------------------------------- /Include/Ludens/Serial/Compress.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | size_t zstd_compress_bound(size_t srcSize); 8 | 9 | size_t zstd_compress(void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel); 10 | 11 | void zstd_decompress(void* dst, size_t dstCapacity, const void* src, size_t compressedSize); 12 | 13 | size_t lz4_compress_bound(size_t srcSize); 14 | 15 | size_t lz4_compress(void* dst, size_t dstCapacity, const void* src, size_t srcSize); 16 | 17 | void lz4_decompress(void* dst, size_t dstCapacity, const void* src, size_t compressedSize); 18 | 19 | } // namespace LD 20 | -------------------------------------------------------------------------------- /LDEditor/EditorMain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDEditor) 2 | 3 | set(MODULE_LIB 4 | Lib/Main.cpp 5 | Lib/EditorUI.h 6 | Lib/EditorUI.cpp 7 | Lib/EditorTopBar.h 8 | Lib/EditorTopBar.cpp 9 | Lib/EditorBottomBar.h 10 | Lib/EditorBottomBar.cpp 11 | ) 12 | 13 | add_executable(${MODULE_NAME} 14 | ${MODULE_LIB} 15 | ) 16 | 17 | target_link_libraries(${MODULE_NAME} PRIVATE 18 | LDCoreLibs 19 | LDBuilderLibs 20 | LDEditorLibs 21 | LDLudensLFS # TODO: embed required media instead of fetching from submodule 22 | ) 23 | 24 | target_include_directories(${MODULE_NAME} PRIVATE 25 | ${LUDENS_SOURCE_DIR} 26 | ${LUDENS_INCLUDE_DIR} 27 | ) -------------------------------------------------------------------------------- /Extra/luajit/dynasm/dasm_mips64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM MIPS64 module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined MIPS/MIPS64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | mips64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_mips") 13 | -------------------------------------------------------------------------------- /LDCore/Application/Lib/InputInternal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define PRESSED_BIT 0x1 6 | #define PRESSED_THIS_FRAME_BIT 0x2 7 | #define RELEASED_THIS_FRAME_BIT 0x4 8 | 9 | namespace LD { 10 | namespace Input { 11 | 12 | /// @brief clears "this frame" states for all input. 13 | /// currently the frame boundary is determined by glfwPollEvents. 14 | void frame_boundary(); 15 | 16 | extern uint8_t sKeyState[]; 17 | extern uint8_t sMouseState[]; 18 | extern float sMouseCursorDeltaX; 19 | extern float sMouseCursorDeltaY; 20 | extern float sMouseCursorX; 21 | extern float sMouseCursorY; 22 | 23 | } // namespace Input 24 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensEditor/EditorWidget/UIVersionWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct UIVersionWindowInfo 10 | { 11 | UIContext context; 12 | EditorTheme theme; 13 | Hash32 layer; 14 | }; 15 | 16 | /// @brief Window to display framework version. 17 | struct UIVersionWindow : Handle 18 | { 19 | static UIVersionWindow create(const UIVersionWindowInfo& info); 20 | static void destroy(UIVersionWindow window); 21 | 22 | UIWindow get_handle(); 23 | }; 24 | 25 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EInspectorWindow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDEInspectorWindow) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EInspectorWindow/EInspectorWindow.h 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/EInspectorWindow.cpp 9 | Lib/EInspectorWindowObj.h 10 | Lib/InspectComponent.h 11 | Lib/InspectComponent.cpp 12 | ) 13 | 14 | add_library(${MODULE_NAME} 15 | ${MODULE_LIB} 16 | ${MODULE_INCLUDE} 17 | ) 18 | 19 | target_link_libraries(${MODULE_NAME} PRIVATE 20 | LDCoreLibs 21 | LDEditorContext 22 | LDEditorWidget 23 | ) 24 | 25 | target_include_directories(${MODULE_NAME} PRIVATE 26 | ${LUDENS_SOURCE_DIR} 27 | ${LUDENS_INCLUDE_DIR} 28 | ) 29 | -------------------------------------------------------------------------------- /Include/Ludens/AudioMixer/AudioEffectInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | enum AudioEffectType 9 | { 10 | AUDIO_EFFECT_LOW_PASS_FILTER = 0, 11 | AUDIO_EFFECT_HIGH_PASS_FILTER, 12 | }; 13 | 14 | /// @brief Tagged union to encode all parameters across all types of filters. 15 | struct AudioEffectInfo 16 | { 17 | AudioEffectType type; 18 | union 19 | { 20 | AudioEffectLowPassFilterInfo lowPassFilter; 21 | AudioEffectHighPassFilterInfo highPassFilter; 22 | }; 23 | }; 24 | 25 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Header/Bitwise.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define LD_BIT(B) (1ul << (B)) 6 | 7 | /// @brief round up to the next highest power of 2 8 | /// from Bit Twiddling Hacks https://graphics.stanford.edu/%7Eseander/bithacks.html#RoundUpPowerOf2 9 | /// @param v 32-bit unsigned value to query 10 | /// @return 32-bit power of two value greater or equal to \p v 11 | /// @warning has an edge case where 0 is returned if \p v is 0. 12 | inline uint32_t next_power_of_two(uint32_t v) 13 | { 14 | v--; 15 | v |= v >> 1; 16 | v |= v >> 2; 17 | v |= v >> 4; 18 | v |= v >> 8; 19 | v |= v >> 16; 20 | v++; 21 | return v; 22 | } -------------------------------------------------------------------------------- /Extra/rapidjson/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rapidjson", 3 | "version": "1.0.4", 4 | "description": "![](doc/logo/rapidjson.png)", 5 | "main": "include_dirs.js", 6 | "directories": { 7 | "doc": "doc", 8 | "example": "example", 9 | "test": "test" 10 | }, 11 | "scripts": { 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/miloyip/rapidjson.git" 17 | }, 18 | "author": "", 19 | "license": "ISC", 20 | "bugs": { 21 | "url": "https://github.com/miloyip/rapidjson/issues" 22 | }, 23 | "homepage": "https://github.com/miloyip/rapidjson#readme" 24 | } 25 | -------------------------------------------------------------------------------- /LDCore/AudioMixer/Test/AudioMixerTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace LD { 12 | 13 | struct AudioMixerTest 14 | { 15 | /// @brief In-place test environment startup. 16 | void startup(); 17 | 18 | /// @brief In-place test environment cleanup. 19 | void cleanup(); 20 | 21 | AudioMixer mixer; 22 | MiniAudio miniAudio; 23 | PoolAllocator playbackPA; 24 | }; 25 | 26 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Profiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDProfiler) 2 | 3 | set(MODULE_INCLUDE 4 | "${LUDENS_INCLUDE_DIR}/Ludens/Profiler/Profiler.h" 5 | ) 6 | 7 | set(MODULE_LIB 8 | Lib/Profiler.cpp 9 | ) 10 | 11 | add_library(${MODULE_NAME} STATIC 12 | ${MODULE_INCLUDE} 13 | ${MODULE_LIB} 14 | ) 15 | 16 | target_include_directories(${MODULE_NAME} PUBLIC 17 | ${LUDENS_INCLUDE_DIR} 18 | ${tracy_SOURCE_DIR} 19 | ) 20 | 21 | # see root CMakeLists.txt 22 | if (LD_COMPILE_WITH_PROFILER) 23 | target_link_libraries(${MODULE_NAME} PUBLIC TracyClient) 24 | message(STATUS "LDProfiler linking with TracyClient") 25 | else() 26 | message(STATUS "LDProfiler skipping TracyClient") 27 | endif() -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_arm64be.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT ARM64BE disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- ARM64 instructions are always little-endian. So just forward to the 8 | -- common ARM64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | return require((string.match(..., ".*%.") or "").."dis_arm64") 12 | 13 | -------------------------------------------------------------------------------- /LDCore/AudioBackend/Lib/AudioBackend.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace LD { 4 | 5 | void AudioObject::set_acquired(bool acquired) 6 | { 7 | mAudioThreadAcquired.store(acquired); 8 | } 9 | 10 | bool AudioObject::is_acquired() 11 | { 12 | return mAudioThreadAcquired.load(); 13 | } 14 | 15 | AudioHandle::AudioHandle(AudioObject* obj) 16 | { 17 | mObj = obj; 18 | } 19 | 20 | void AudioHandle::acquire() 21 | { 22 | mObj->set_acquired(true); 23 | } 24 | 25 | void AudioHandle::release() 26 | { 27 | mObj->set_acquired(false); 28 | } 29 | 30 | bool AudioHandle::is_acquired() 31 | { 32 | return mObj->is_acquired(); 33 | } 34 | 35 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetSchema.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Schema for listing all Assets under the current framework version. 11 | struct AssetSchema 12 | { 13 | /// @brief Load asset registry from TOML schema file on disk. 14 | static void load_registry_from_file(AssetRegistry registry, const FS::Path& tomlPath); 15 | 16 | /// @brief Try saving scene as TOML schema file on disk. 17 | static bool save_registry(AssetRegistry registry, const FS::Path& savePath, std::string& err); 18 | }; 19 | 20 | } // namespace LD -------------------------------------------------------------------------------- /LDBuilder/Main/RenderUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct RenderUtil : Handle 9 | { 10 | static RenderUtil create(); 11 | static void destroy(RenderUtil util); 12 | 13 | /// @brief samples an equirectangular environment map and saves 6 cubemap faces on disk 14 | /// @param path path to an equirectangular texture, usually with hdr/hdri file extensions. 15 | /// @param dstDirectory the directory to store 6 cubemap faces 16 | void from_equirectangular_to_faces(const std::filesystem::path& path, const std::filesystem::path& dstDirectory); 17 | }; 18 | 19 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/Template/UITemplateSchema.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | struct UITemplateSchema 8 | { 9 | /// @brief Load a UI template from TOML schema source string. 10 | static void load_ui_template_from_source(UITemplate tmpl, const void* source, size_t len); 11 | 12 | /// @brief Load a UI template from TOML schema file on disk. 13 | static void load_ui_template_from_file(UITemplate tmpl, const FS::Path& tomlPath); 14 | 15 | /// @brief Try saving UI template as TOML schema file on disk. 16 | static bool save_ui_template(UITemplate tmpl, const FS::Path& savePath, std::string& err); 17 | }; 18 | 19 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/DSP/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDDSP) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/DSP/DSP.h 5 | ${LUDENS_INCLUDE_DIR}/Ludens/DSP/Resampler.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/DSP/BiquadFilterCoeff.h 7 | ) 8 | 9 | set(MODULE_LIB 10 | Lib/DSP.cpp 11 | Lib/Resampler.cpp 12 | Lib/BiquadFilterCoeff.cpp 13 | ) 14 | 15 | add_library(${MODULE_NAME} 16 | ${MODULE_INCLUDE} 17 | ${MODULE_LIB} 18 | ) 19 | 20 | target_link_libraries(${MODULE_NAME} PUBLIC 21 | LDSystem 22 | LDProfiler 23 | SampleRate::samplerate 24 | ) 25 | 26 | target_include_directories(${MODULE_NAME} PRIVATE 27 | ${LUDENS_INCLUDE_DIR} 28 | ${samplerate_SOURCE_DIR}/include 29 | ) 30 | -------------------------------------------------------------------------------- /Include/Ludens/Header/Impulse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LD { 4 | 5 | /// @brief The impulse class represents a scalar that is reset after read if non-zero. 6 | /// If the scalar is 'truthy' when read, it is reset to a 'falsy' default state. 7 | template 8 | class TImpulse 9 | { 10 | public: 11 | inline void set(const T& value) 12 | { 13 | mValue = value; 14 | } 15 | 16 | inline T read() 17 | { 18 | if (static_cast(mValue)) 19 | { 20 | T val = mValue; 21 | mValue = static_cast(false); 22 | return val; 23 | } 24 | 25 | return static_cast(false); 26 | } 27 | 28 | private: 29 | T mValue; 30 | }; 31 | 32 | using Impulse = TImpulse; 33 | 34 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/UI/Sandbox/UISandboxMain.cpp: -------------------------------------------------------------------------------- 1 | #include "UISandbox.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace LD; 7 | 8 | int main(int argc, char** argv) 9 | { 10 | { 11 | UISandbox sandbox; 12 | sandbox.run(); 13 | } 14 | 15 | int count = get_memory_leaks(nullptr); 16 | 17 | if (count > 0) 18 | { 19 | std::vector leaks(count); 20 | get_memory_leaks(leaks.data()); 21 | 22 | for (int i = 0; i < count; i++) 23 | std::cout << "memory leak in usage " << get_memory_usage_cstr(leaks[i].usage) << ": " << leaks[i].current << " bytes" << std::endl; 24 | } 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Extra/luajit/src/lj_assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Internal assertions. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_assert_c 7 | #define LUA_CORE 8 | 9 | #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) 10 | 11 | #include 12 | 13 | #include "lj_obj.h" 14 | 15 | void lj_assert_fail(global_State *g, const char *file, int line, 16 | const char *func, const char *fmt, ...) 17 | { 18 | va_list argp; 19 | va_start(argp, fmt); 20 | fprintf(stderr, "LuaJIT ASSERT %s:%d: %s: ", file, line, func); 21 | vfprintf(stderr, fmt, argp); 22 | fputc('\n', stderr); 23 | va_end(argp); 24 | UNUSED(g); /* May be NULL. TODO: optionally dump state. */ 25 | abort(); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /LDCore/AudioMixer/Lib/AudioPlaybackObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace LD { 11 | 12 | struct AudioEffectObj; 13 | 14 | struct AudioPlaybackObj : AudioObject 15 | { 16 | AudioPlaybackObj* next = nullptr; 17 | AudioEffectObj* effectList = nullptr; 18 | PoolAllocator playbackPA; 19 | AudioBuffer buffer; 20 | AudioCommandQueue commandQueue; 21 | uint32_t frameCursor; 22 | std::atomic volumeLinear; 23 | std::atomic pan; 24 | bool isPlaying = false; 25 | }; 26 | 27 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/RenderBackend/Lib/RData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | /// @brief while RPassInfo contains transient pointer members, 12 | /// this data representation is safe to be read at any time. 13 | struct RPassInfoData 14 | { 15 | RSampleCountBit samples = RSAMPLE_COUNT_1_BIT; 16 | uint32_t colorAttachmentCount = 0; 17 | std::vector colorAttachments; 18 | std::vector colorResolveAttachments; 19 | std::optional depthStencilAttachment; 20 | std::optional dependency; 21 | }; 22 | 23 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_ccallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C callback handling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCALLBACK_H 7 | #define _LJ_CCALLBACK_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Really belongs to lj_vm.h. */ 15 | LJ_ASMF void lj_vm_ffi_callback(void); 16 | 17 | LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); 18 | LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); 19 | LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); 20 | LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); 21 | LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Extra/luajit/src/lj_ffrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function call recorder. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FFRECORD_H 7 | #define _LJ_FFRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Data used by handlers to record a fast function. */ 14 | typedef struct RecordFFData { 15 | TValue *argv; /* Runtime argument values. */ 16 | ptrdiff_t nres; /* Number of returned results (defaults to 1). */ 17 | uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ 18 | } RecordFFData; 19 | 20 | LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); 21 | LJ_FUNC void lj_ffrecord_func(jit_State *J); 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /LDCore/Asset/Lib/Template/UITemplateObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | struct UITemplateEntry; 11 | 12 | /// @brief UI template implementation. 13 | struct UITemplateObj 14 | { 15 | PoolAllocator entryPA; 16 | LinearAllocator LA; 17 | std::vector entries; 18 | std::unordered_map> hierarchy; 19 | 20 | void reset() 21 | { 22 | for (auto ite = entryPA.begin(); ite; ++ite) 23 | entryPA.free(ite.data()); 24 | 25 | entries.clear(); 26 | hierarchy.clear(); 27 | LA.free(); 28 | } 29 | }; 30 | 31 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EditorContext/Lib/EditorContextCommand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Command to set associate a Script with a Component in scene. 11 | class AddComponentScriptCommand : public EditCommand 12 | { 13 | public: 14 | AddComponentScriptCommand(Scene scene, CUID compID, AUID scriptAssetID); 15 | 16 | virtual void redo() override; 17 | 18 | virtual void undo() override; 19 | 20 | private: 21 | Scene mScene; 22 | CUID mCompID; 23 | AUID mScriptAssetID; 24 | AUID mPrevScriptAssetID; 25 | }; 26 | 27 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_prng.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Pseudo-random number generation. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PRNG_H 7 | #define _LJ_PRNG_H 8 | 9 | #include "lj_def.h" 10 | 11 | LJ_FUNC int LJ_FASTCALL lj_prng_seed_secure(PRNGState *rs); 12 | LJ_FUNC uint64_t LJ_FASTCALL lj_prng_u64(PRNGState *rs); 13 | LJ_FUNC uint64_t LJ_FASTCALL lj_prng_u64d(PRNGState *rs); 14 | 15 | /* This is just the precomputed result of lib_math.c:random_seed(rs, 0.0). */ 16 | static LJ_AINLINE void lj_prng_seed_fixed(PRNGState *rs) 17 | { 18 | rs->u[0] = U64x(a0d27757,0a345b8c); 19 | rs->u[1] = U64x(764a296c,5d4aa64f); 20 | rs->u[2] = U64x(51220704,070adeaa); 21 | rs->u[3] = U64x(2a2717b5,a7b7b927); 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /LDCore/Application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDApplication) 2 | 3 | set(MODULE_INCLUDE 4 | ${LUDENS_INCLUDE_DIR}/Ludens/Application/Application.h 5 | ${LUDENS_INCLUDE_DIR}/Ludens/Application/Input.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/Application/Event.h 7 | ) 8 | 9 | set(MODULE_LIB 10 | Lib/Application.cpp 11 | Lib/Input.cpp 12 | Lib/InputInternal.h 13 | Lib/Window.h 14 | Lib/Window.cpp 15 | Lib/WindowWin32.cpp 16 | Lib/WindowLinux.cpp 17 | ) 18 | 19 | add_library(${MODULE_NAME} 20 | ${MODULE_INCLUDE} 21 | ${MODULE_LIB} 22 | ) 23 | 24 | target_link_libraries(${MODULE_NAME} PRIVATE 25 | LDSystem 26 | LDLog 27 | LDProfiler 28 | ) 29 | 30 | target_include_directories(${MODULE_NAME} PRIVATE 31 | ${LUDENS_INCLUDE_DIR} 32 | ${glfw_SOURCE_DIR}/include 33 | ) 34 | -------------------------------------------------------------------------------- /LDCore/Lexer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDLexer) 2 | set(MODULE_TEST_NAME LDLexerTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/Lexer/Unicode.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/Lexer/Token.h 7 | ${LUDENS_INCLUDE_DIR}/Ludens/Lexer/Lexer.h 8 | ) 9 | 10 | set(MODULE_LIB 11 | Lib/Unicode.cpp 12 | ) 13 | 14 | add_library(${MODULE_NAME} 15 | ${MODULE_INCLUDE} 16 | ${MODULE_LIB} 17 | ) 18 | 19 | target_include_directories(${MODULE_NAME} PRIVATE 20 | ${LUDENS_INCLUDE_DIR} 21 | ) 22 | 23 | add_executable(${MODULE_TEST_NAME} 24 | Test/LexerTest.cpp 25 | ) 26 | 27 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 28 | ${LUDENS_INCLUDE_DIR} 29 | ${LUDENS_SOURCE_DIR} 30 | ) 31 | 32 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 33 | ${MODULE_NAME} 34 | ) -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_mips64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the big-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create, 14 | disass = dis_mips.disass, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /LDCore/DataRegistry/Test/DataRegistryTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | using namespace LD; 8 | 9 | TEST_CASE("DataRegistry") 10 | { 11 | DataRegistry reg = DataRegistry::create(); 12 | 13 | CUID t1 = reg.create_component(COMPONENT_TYPE_TRANSFORM, "t1", (CUID)0, (CUID)0); 14 | 15 | ComponentType type; 16 | auto* comp = (TransformComponent*)reg.get_component(t1, type); 17 | CHECK(type == COMPONENT_TYPE_TRANSFORM); 18 | comp->transform.position = Vec3(0.0f); 19 | comp->transform.rotation = Vec3(1.0f, 2.0f, 3.0f); 20 | comp->transform.scale = Vec3(1.0f); 21 | 22 | DataRegistry::destroy(reg); 23 | } 24 | -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_x64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT x64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the 64 bit functions from the combined 8 | -- x86/x64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_x86 = require((string.match(..., ".*%.") or "").."dis_x86") 12 | return { 13 | create = dis_x86.create64, 14 | disass = dis_x86.disass64, 15 | regname = dis_x86.regname64 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_mipsel.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPSEL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_el, 14 | disass = dis_mips.disass_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_mips64el.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64EL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_el, 14 | disass = dis_mips.disass_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_mips64r6.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64R6 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the r6 big-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_r6, 14 | disass = dis_mips.disass_r6, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Extra/luajit/src/jit/dis_mips64r6el.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64R6EL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the r6 little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_r6_el, 14 | disass = dis_mips.disass_r6_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /LDEditor/EditorMain/Lib/EditorBottomBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct EditorBottomBarInfo 10 | { 11 | UIContext context; 12 | EditorTheme theme; 13 | Vec2 screenSize; 14 | Hash32 layer; 15 | float barHeight; 16 | }; 17 | 18 | /// @brief Editor bottom bar UI. 19 | class EditorBottomBar 20 | { 21 | public: 22 | /// @brief In-place startup. 23 | void startup(const EditorBottomBarInfo& info); 24 | 25 | /// @brief In-place cleanup. 26 | void cleanup(); 27 | 28 | /// @brief Get window handle. 29 | UIWindow get_handle(); 30 | 31 | private: 32 | UIWindow mRoot; 33 | float mBottomBarHeight; 34 | }; 35 | 36 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_mcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Machine code management. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_MCODE_H 7 | #define _LJ_MCODE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT || LJ_HASFFI 12 | LJ_FUNC void lj_mcode_sync(void *start, void *end); 13 | #endif 14 | 15 | #if LJ_HASJIT 16 | 17 | #include "lj_jit.h" 18 | 19 | LJ_FUNC void lj_mcode_free(jit_State *J); 20 | LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); 21 | LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); 22 | LJ_FUNC void lj_mcode_abort(jit_State *J); 23 | LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); 24 | LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); 25 | 26 | #define lj_mcode_commitbot(J, m) (J->mcbot = (m)) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /LDCore/JobSystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDJobSystem) 2 | set(MODULE_TEST_NAME LDJobSystemTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/JobSystem/JobSystem.h 6 | ) 7 | 8 | set(MODULE_LIB 9 | Lib/JobSystem.cpp 10 | ) 11 | 12 | set(MODULE_TEST 13 | Test/JobSystemTest.cpp 14 | ) 15 | 16 | add_library(${MODULE_NAME} 17 | ${MODULE_INCLUDE} 18 | ${MODULE_LIB} 19 | ) 20 | 21 | target_link_libraries(${MODULE_NAME} PUBLIC 22 | LDSystem 23 | LDProfiler 24 | ) 25 | 26 | target_include_directories(${MODULE_NAME} PRIVATE 27 | ${LUDENS_INCLUDE_DIR} 28 | ) 29 | 30 | add_executable(${MODULE_TEST_NAME} 31 | ${MODULE_TEST} 32 | ) 33 | 34 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 35 | ${MODULE_NAME} 36 | ) 37 | 38 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 39 | ${LUDENS_INCLUDE_DIR} 40 | ${LUDENS_SOURCE_DIR} 41 | ) -------------------------------------------------------------------------------- /LDBuilder/Main/RunTests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief find test executables in a directory recursively. 9 | /// @param directory search directory 10 | /// @param paths output executable paths 11 | /// @param extension filter with file extensions 12 | void find_test_executables(const char* directory, std::vector& paths, const char* extension); 13 | 14 | /// @brief run test executables 15 | /// @param paths paths to executables 16 | /// @return number of processes that return 0 17 | /// @warning we will be running executables with std::system, the builder 18 | /// should not have root/admin privileges and we have no way to 19 | /// check whether the exectables are malicious. 20 | int run_test_exectuables(std::vector& paths); 21 | 22 | } // namespace LD -------------------------------------------------------------------------------- /LDBuilder/Main/AudioUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | struct AudioUtil : Handle 11 | { 12 | static AudioUtil create(); 13 | static void destroy(AudioUtil util); 14 | 15 | /// @brief one-shot function to resample audio file, converting sample rates and sample format. 16 | /// @param srcFile path to source audio file, currently only .wav is supported 17 | /// @param dstFile path to write resampled audio file, currently only .wav is supported 18 | /// @param sampleRate new sample rate 19 | /// @param format new sample format 20 | /// @return true on success 21 | bool resample(const std::filesystem::path& srcFile, const std::filesystem::path& dstFile, uint32_t sampleRate, SampleFormat format); 22 | }; 23 | 24 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Function handling (prototypes, functions and upvalues). 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FUNC_H 7 | #define _LJ_FUNC_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Prototypes. */ 12 | LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); 13 | 14 | /* Upvalues. */ 15 | LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); 16 | LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); 17 | 18 | /* Functions (closures). */ 19 | LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); 20 | LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); 21 | LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); 22 | LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /LDCore/Media/Lib/Format/TinygltfLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct ModelObj; 9 | struct MeshNode; 10 | 11 | class TinygltfLoader 12 | { 13 | public: 14 | bool load_from_file(ModelObj* obj, const char* path); 15 | 16 | private: 17 | bool load_model(); 18 | bool load_images(); 19 | bool load_materials(); 20 | bool load_node(tinygltf::Node& tinyNode, uint32_t nodeIndex, MeshNode* parent); 21 | bool load_mesh(tinygltf::Mesh& tinyMesh, MeshNode* node); 22 | void scan_node_primitives(tinygltf::Node& tinyNode); 23 | 24 | ModelObj* mObj = nullptr; 25 | tinygltf::Model mTinyModel; 26 | tinygltf::TinyGLTF mContext; 27 | uint32_t mVertexCount = 0; 28 | uint32_t mVertexBase = 0; 29 | uint32_t mIndexCount = 0; 30 | uint32_t mIndexBase = 0; 31 | }; 32 | 33 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_clib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C library loader. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CLIB_H 7 | #define _LJ_CLIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | /* Namespace for C library indexing. */ 14 | #define CLNS_INDEX ((1u<env. */ 20 | } CLibrary; 21 | 22 | LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); 23 | LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); 24 | LJ_FUNC void lj_clib_unload(CLibrary *cl); 25 | LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Include/Ludens/System/DropManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct GLFWwindow; 8 | 9 | namespace LD { 10 | 11 | /// @brief Callback when user drags files into application window. 12 | /// This function should not block, copy these paths and defer IO operations. 13 | typedef void (*DropTargetFileCallback)(size_t fileCount, const FS::Path* files); 14 | 15 | struct DropTarget : Handle 16 | { 17 | /// @brief Create drop target for window. Currently only Win32 supports 18 | /// file drag and drop via OLE IDropTarget. 19 | static DropTarget create(GLFWwindow* window, DropTargetFileCallback onDropFile); 20 | 21 | /// @brief Destroy drop target associated with window. 22 | static void destroy(DropTarget target); 23 | }; 24 | 25 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EInspectorWindow/Lib/EInspectorWindowObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | /// @brief Editor inspector window implementation. 10 | struct EInspectorWindowObj : EditorWindowObj 11 | { 12 | virtual ~EInspectorWindowObj() = default; 13 | 14 | CUID subjectID = 0; // subject component being inspected 15 | ECBSelectAssetFn selectAssetFn; 16 | void* user; 17 | bool isSelectingNewAsset = false; 18 | 19 | void inspect_component(CUID compID); 20 | 21 | virtual void on_imgui() override; 22 | 23 | static void on_draw(UIWidget widget, ScreenRenderComponent renderer); 24 | static void on_editor_context_event(const EditorContextEvent* event, void* user); 25 | }; 26 | 27 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/README: -------------------------------------------------------------------------------- 1 | README for LuaJIT 2.1 2 | --------------------- 3 | 4 | LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. 5 | 6 | Project Homepage: https://luajit.org/ 7 | 8 | LuaJIT is Copyright (C) 2005-2025 Mike Pall. 9 | LuaJIT is free software, released under the MIT license. 10 | See full Copyright Notice in the COPYRIGHT file or in luajit.h. 11 | 12 | Documentation for LuaJIT is available in HTML format. 13 | Please point your favorite browser to: 14 | 15 | doc/luajit.html 16 | 17 | Ludens Integration Notes 18 | ------------------------ 19 | LuaJIT has no CMake presets, we are using prebuilt libraies in prebuilt/ folder. 20 | Include directory is same as source directory, LuaJIT headers are in src/ folder. 21 | Make sure we are including src/lua.h instead of some other lua.h installed in system path. 22 | HEAD points to commit eec7a8016c3381b949b5d84583800d05897fa960 23 | -------------------------------------------------------------------------------- /Include/LudensEditor/EditorContext/EditorWindowObj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief Base class for editor window implementations. 9 | struct EditorWindowObj 10 | { 11 | /// Shared context among editor windows. 12 | EditorContext editorCtx; 13 | 14 | /// Root window widget from the UIWindowManager. 15 | /// The user data must be the EditorWindowObj instance pointer. 16 | UIWindow root; 17 | 18 | virtual void on_imgui() {} 19 | 20 | /// @brief Allows derived class to draw additional overlays in a separate pass. 21 | /// @param renderer The screen space renderer, its sampled image should be 22 | /// a blurred version of the entire viewport. 23 | virtual void on_draw_overlay(ScreenRenderComponent renderer) {} 24 | }; 25 | 26 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/CommandLine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDCommandLine) 2 | set(MODULE_TEST_NAME LDCommandLineTest) 3 | 4 | set(MODULE_INCLUDE 5 | "${LUDENS_INCLUDE_DIR}/Ludens/CommandLine/ArgParser.h" 6 | ) 7 | 8 | set(MODULE_LIB 9 | Lib/ArgParser.cpp 10 | ) 11 | 12 | set(MODULE_TEST 13 | Test/CommandLineTest.cpp 14 | Test/TestArgParser.h 15 | ) 16 | 17 | add_library(${MODULE_NAME} 18 | ${MODULE_INCLUDE} 19 | ${MODULE_LIB} 20 | ) 21 | 22 | target_include_directories(${MODULE_NAME} PRIVATE 23 | ${LUDENS_INCLUDE_DIR} 24 | ) 25 | 26 | target_link_libraries(${MODULE_NAME} PUBLIC 27 | LDSystem 28 | ) 29 | 30 | add_executable(${MODULE_TEST_NAME} 31 | ${MODULE_TEST} 32 | ) 33 | 34 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 35 | ${LUDENS_INCLUDE_DIR} 36 | ${LUDENS_SOURCE_DIR} 37 | ) 38 | 39 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 40 | ${MODULE_NAME} 41 | ) -------------------------------------------------------------------------------- /LDCore/Scene/Lib/LuaScript.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | namespace LuaScript { 11 | 12 | /// @brief Get static C string of LuaScript log channel. 13 | const char* get_log_channel_name(); 14 | 15 | /// @brief Create the 'ludens' lua module that contains the scripting interface. 16 | LuaModule create_ludens_module(); 17 | 18 | /// @brief Create lua table for data component 19 | void create_component_table(Scene scene, DataRegistry reg, LuaState L, CUID compID, ComponentType type, void* comp); 20 | 21 | /// @brief Destroy lua table associated with component 22 | void destroy_component_table(Scene scene, DataRegistry reg, LuaState L, CUID compID); 23 | 24 | } // namespace LuaScript 25 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/System/Lib/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace LD { 4 | 5 | void Timer::start() 6 | { 7 | mBegin = std::chrono::high_resolution_clock::now(); 8 | } 9 | 10 | size_t Timer::stop() 11 | { 12 | std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now(); 13 | auto duration = std::chrono::duration_cast(end - mBegin); 14 | 15 | return duration.count(); 16 | } 17 | 18 | ScopeTimer::ScopeTimer(size_t* us) 19 | : mBegin(std::chrono::high_resolution_clock::now()), mUS(us) 20 | { 21 | } 22 | 23 | ScopeTimer::~ScopeTimer() 24 | { 25 | std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now(); 26 | auto duration = std::chrono::duration_cast(end - mBegin); 27 | 28 | if (mUS) 29 | *mUS = (size_t)duration.count(); 30 | } 31 | 32 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/DualKawaseComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct DualKawaseComponentInfo 10 | { 11 | RFormat format; /// color format 12 | Color mixColor; /// mix color RGB, keep alpha channel at 0xFF 13 | float mixFactor; /// lerp factor between blur color and mix color, 0 performs no blur 14 | }; 15 | 16 | struct DualKawaseComponent : Handle 17 | { 18 | /// @brief adds the component to render graph 19 | static DualKawaseComponent add(RGraph graph, const DualKawaseComponentInfo& info); 20 | 21 | inline const char* component_name() const { return "dual_kawase"; } 22 | inline const char* input_name() const { return "input"; } 23 | inline const char* output_name() const { return "output"; } 24 | }; 25 | 26 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Scene/SceneSchema.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | /// @brief Schema for defining a Scene under the current framework version. 12 | struct SceneSchema 13 | { 14 | /// @brief Load a scene from TOML schema source string. 15 | static void load_scene_from_source(Scene scene, const char* source, size_t len); 16 | 17 | /// @brief Load a scene from TOML schema file on disk. 18 | static void load_scene_from_file(Scene scene, const FS::Path& tomlPath); 19 | 20 | /// @brief Try saving scene as TOML schema file on disk. 21 | static bool save_scene(Scene scene, const FS::Path& savePath, std::string& err); 22 | 23 | /// @brief Get default schema TOML text. 24 | static std::string get_default_text(); 25 | }; 26 | 27 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_serialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Object de/serialization. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SERIALIZE_H 7 | #define _LJ_SERIALIZE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_buf.h" 11 | 12 | #if LJ_HASBUFFER 13 | 14 | #define LJ_SERIALIZE_DEPTH 100 /* Default depth. */ 15 | 16 | LJ_FUNC void LJ_FASTCALL lj_serialize_dict_prep_str(lua_State *L, GCtab *dict); 17 | LJ_FUNC void LJ_FASTCALL lj_serialize_dict_prep_mt(lua_State *L, GCtab *dict); 18 | LJ_FUNC SBufExt * LJ_FASTCALL lj_serialize_put(SBufExt *sbx, cTValue *o); 19 | LJ_FUNC char * LJ_FASTCALL lj_serialize_get(SBufExt *sbx, TValue *o); 20 | LJ_FUNC GCstr * LJ_FASTCALL lj_serialize_encode(lua_State *L, cTValue *o); 21 | LJ_FUNC void lj_serialize_decode(lua_State *L, TValue *o, GCstr *str); 22 | #if LJ_HASJIT 23 | LJ_FUNC MSize LJ_FASTCALL lj_serialize_peektype(SBufExt *sbx); 24 | #endif 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Include/Ludens/DSP/Resampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct ResamplerInfo 10 | { 11 | int channels; /// number of channels for input and output 12 | double dstSampleRate; /// output sample rate 13 | }; 14 | 15 | struct ResamplerProcessInfo 16 | { 17 | float srcSampleRate; 18 | SampleFormat srcFormat; 19 | const void* srcSamples; 20 | uint32_t srcFrameCount; 21 | SampleFormat dstFormat; 22 | void* dstSamples; 23 | uint32_t dstFrameCount; 24 | }; 25 | 26 | struct Resampler : Handle 27 | { 28 | static Resampler create(const ResamplerInfo& info); 29 | static void destroy(Resampler resampler); 30 | 31 | uint32_t get_dst_sample_count(uint32_t srcSampleCount, float srcSampleRate) const; 32 | 33 | uint32_t process(const ResamplerProcessInfo& info); 34 | }; 35 | 36 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Camera/CameraController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Camera.h" 4 | 5 | namespace LD { 6 | 7 | struct CameraController : Handle 8 | { 9 | /// @brief create a camera controller for subject camera 10 | /// @subject valid camera handle that will be controlled 11 | /// @moveSpeed camera translation speed 12 | /// @rotSpeed camera rotation speed 13 | /// @return the controller handle 14 | static CameraController create(Camera subject, float moveSpeed, float rotSpeed); 15 | 16 | /// @brief destroy a camera controller 17 | static void destroy(CameraController controller); 18 | 19 | void move_forward(); 20 | void move_backward(); 21 | void move_left(); 22 | void move_right(); 23 | void move_world_up(); 24 | void move_world_down(); 25 | 26 | void view_pitch(float delta); 27 | void view_yaw(float delta); 28 | 29 | void update(float delta); 30 | }; 31 | 32 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Camera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDCamera) 2 | set(MODULE_TEST_NAME LDCameraTest) 3 | 4 | set(MODULE_INCLUDE 5 | "${LUDENS_INCLUDE_DIR}/Ludens/Camera/Camera.h" 6 | "${LUDENS_INCLUDE_DIR}/Ludens/Camera/CameraController.h" 7 | ) 8 | 9 | set(MODULE_LIB 10 | Lib/Camera.cpp 11 | Lib/CameraController.cpp 12 | Lib/CameraCommon.h 13 | ) 14 | 15 | set(MODULE_TEST 16 | Test/CameraTest.cpp 17 | Test/TestPerspective.h 18 | Test/TestOrthographic.h 19 | ) 20 | 21 | add_library(${MODULE_NAME} 22 | ${MODULE_INCLUDE} 23 | ${MODULE_LIB} 24 | ) 25 | 26 | target_include_directories(${MODULE_NAME} PRIVATE 27 | ${LUDENS_INCLUDE_DIR} 28 | ) 29 | 30 | add_executable(${MODULE_TEST_NAME} 31 | ${MODULE_TEST} 32 | ) 33 | 34 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 35 | ${LUDENS_INCLUDE_DIR} 36 | ${LUDENS_SOURCE_DIR} 37 | ) 38 | 39 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 40 | ${MODULE_NAME} 41 | LDSystem 42 | ) -------------------------------------------------------------------------------- /LDEditor/EditorMain/Lib/EditorBottomBar.cpp: -------------------------------------------------------------------------------- 1 | #include "EditorBottomBar.h" 2 | 3 | namespace LD { 4 | 5 | void EditorBottomBar::startup(const EditorBottomBarInfo& info) 6 | { 7 | UIContext ctx = info.context; 8 | mBottomBarHeight = info.barHeight; 9 | 10 | UILayoutInfo layoutI{}; 11 | layoutI.childAxis = UIAxis::UI_AXIS_X; 12 | layoutI.childGap = 6.0f; 13 | layoutI.sizeX = UISize::fixed(info.screenSize.x); 14 | layoutI.sizeY = UISize::fixed(mBottomBarHeight); 15 | UIWindowInfo windowI{}; 16 | windowI.name = "EditorBottomBar"; 17 | windowI.layer = info.layer; 18 | windowI.defaultMouseControls = false; 19 | 20 | mRoot = ctx.add_window(layoutI, windowI, nullptr); 21 | mRoot.set_pos(Vec2(0.0f, info.screenSize.y - mBottomBarHeight)); 22 | mRoot.set_user(this); 23 | } 24 | 25 | void EditorBottomBar::cleanup() 26 | { 27 | } 28 | 29 | UIWindow EditorBottomBar::get_handle() 30 | { 31 | return mRoot; 32 | } 33 | 34 | } // namespace LD -------------------------------------------------------------------------------- /Extra/rapidjson/CMakeModules/FindGTestSrc.cmake: -------------------------------------------------------------------------------- 1 | 2 | SET(GTEST_SEARCH_PATH 3 | "${GTEST_SOURCE_DIR}" 4 | "${CMAKE_CURRENT_LIST_DIR}/../thirdparty/gtest/googletest") 5 | 6 | IF(UNIX) 7 | IF(RAPIDJSON_BUILD_THIRDPARTY_GTEST) 8 | LIST(APPEND GTEST_SEARCH_PATH "/usr/src/gtest") 9 | ELSE() 10 | LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest") 11 | ENDIF() 12 | ENDIF() 13 | 14 | FIND_PATH(GTEST_SOURCE_DIR 15 | NAMES CMakeLists.txt src/gtest_main.cc 16 | PATHS ${GTEST_SEARCH_PATH}) 17 | 18 | 19 | # Debian installs gtest include directory in /usr/include, thus need to look 20 | # for include directory separately from source directory. 21 | FIND_PATH(GTEST_INCLUDE_DIR 22 | NAMES gtest/gtest.h 23 | PATH_SUFFIXES include 24 | HINTS ${GTEST_SOURCE_DIR} 25 | PATHS ${GTEST_SEARCH_PATH}) 26 | 27 | INCLUDE(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args(GTestSrc DEFAULT_MSG 29 | GTEST_SOURCE_DIR 30 | GTEST_INCLUDE_DIR) 31 | -------------------------------------------------------------------------------- /LDCore/RenderBackend/Lib/RUtilGL.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include // hide 6 | 7 | namespace LD { 8 | namespace RUtil { 9 | 10 | void cast_glsl_type_gl(const GLSLType& inType, GLint& outComponentCount, GLenum& outComponentType); 11 | void cast_format_gl(const RFormat& inFormat, GLenum& outInternalFormat, GLenum& outDataFormat, GLenum& outDataType); 12 | void cast_shader_type_gl(const RShaderType& inType, GLenum& outType); 13 | void cast_image_type_gl(const RImageType& inType, GLenum& outTarget); 14 | void cast_filter_gl(const RSamplerInfo& inSampler, GLenum& outMinFilter, GLenum& outMagFilter); 15 | void cast_index_type_gl(const RIndexType& inType, GLenum& outType, size_t& outByteSize); 16 | void cast_sampler_address_mode_gl(const RSamplerAddressMode& inMode, GLenum& outMode); 17 | void cast_primitive_topology_gl(const RPrimitiveTopology& inTopo, GLenum& outTopo); 18 | 19 | } // namespace RUtil 20 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/ScreenPickComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | struct ScreenPickComponentInfo 11 | { 12 | uint32_t pickQueryCount; 13 | const Vec2* pickPositions; 14 | }; 15 | 16 | struct ScreenPickResult 17 | { 18 | Vec2 pos; 19 | uint16_t id; 20 | uint16_t flags; 21 | }; 22 | 23 | struct ScreenPickComponent : Handle 24 | { 25 | static ScreenPickComponent add(RGraph graph, const ScreenPickComponentInfo& componentI); 26 | 27 | void get_results(std::vector& results); 28 | 29 | /// @brief get the name of the component 30 | inline const char* component_name() const { return "screen_pick"; } 31 | 32 | /// @brief get the name of the input ID color attachment 33 | inline const char* input_name() const { return "input"; } 34 | }; 35 | 36 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Text/TextBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | template 9 | struct TextBufferObj; 10 | 11 | /// @brief A buffer of text subject to editing. 12 | template 13 | struct TextBuffer : Handle> 14 | { 15 | /// @brief Create a text buffer 16 | static TextBuffer create(); 17 | 18 | /// @brief Destroy a text buffer 19 | static void destroy(TextBuffer buf); 20 | 21 | /// @brief Set text buffer content to C string. 22 | void set_string(const char* cstr); 23 | 24 | /// @brief Cast to STL string. 25 | std::basic_string to_string(); 26 | 27 | /// @brief Check if text buffer is empty. 28 | bool empty(); 29 | 30 | /// @brief Append a char at the end of buffer. 31 | void push_back(T ch); 32 | 33 | /// @brief Erase the char at the end of buffer, safe even if buffer is empty. 34 | void pop_back(); 35 | }; 36 | 37 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/AudioMixer/AudioMixer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define AUDIO_MIXER_SAMPLE_RATE 48000 7 | #define AUDIO_MIXER_CHANNELS 2 8 | 9 | namespace LD { 10 | 11 | struct AudioMixer : Handle 12 | { 13 | /// @brief Create audio mixer. 14 | static AudioMixer create(); 15 | 16 | /// @brief Destroy audio mixer. 17 | static void destroy(AudioMixer mixer); 18 | 19 | /// @brief Called on the main thread to retrieve command queue. 20 | AudioCommandQueue get_command_queue(); 21 | 22 | /// @brief Called on the audio thread to digest all commands sequentially in queue. 23 | void poll_commands(); 24 | 25 | /// @brief Called on the audio thread to mix all playback instances. 26 | /// @param outFrames Mixer output destination. 27 | /// @param frameCount Number of output frames requested 28 | void mix(float* outFrames, uint32_t frameCount); 29 | }; 30 | 31 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/System/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | class Timer 8 | { 9 | public: 10 | Timer() = default; 11 | Timer(const Timer&) = delete; 12 | 13 | Timer& operator=(const Timer&) = delete; 14 | 15 | /// @brief start the timer 16 | void start(); 17 | 18 | /// @brief stop the timer 19 | /// @return output duration in micro seconds 20 | size_t stop(); 21 | 22 | private: 23 | std::chrono::high_resolution_clock::time_point mBegin; 24 | }; 25 | 26 | class ScopeTimer 27 | { 28 | public: 29 | ScopeTimer() = delete; 30 | 31 | /// @brief begin timing until the timer goes out of scope 32 | /// @param us output duration in micro seconds 33 | ScopeTimer(size_t* us); 34 | ScopeTimer(const ScopeTimer&) = delete; 35 | ~ScopeTimer(); 36 | 37 | ScopeTimer& operator=(const ScopeTimer&) = delete; 38 | 39 | private: 40 | std::chrono::high_resolution_clock::time_point mBegin; 41 | size_t* mUS; 42 | }; 43 | 44 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/AudioBackend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDAudioBackend) 2 | set(MODULE_TEST_NAME LDAudioBackendTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/AudioBackend/AudioBackend.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/AudioBackend/MiniAudio.h 7 | ) 8 | 9 | set(MODULE_LIB 10 | Lib/AudioBackend.cpp 11 | Lib/MiniAudio.cpp 12 | ) 13 | 14 | set(MODULE_TEST 15 | Test/AudioBackendTest.cpp 16 | Test/MiniAudioTest.cpp 17 | ) 18 | 19 | add_library(${MODULE_NAME} 20 | ${MODULE_INCLUDE} 21 | ${MODULE_LIB} 22 | ) 23 | 24 | target_link_libraries(${MODULE_NAME} PUBLIC 25 | LDLog 26 | LDProfiler 27 | LDMedia 28 | ) 29 | 30 | target_include_directories(${MODULE_NAME} PRIVATE 31 | ${LUDENS_INCLUDE_DIR} 32 | ${miniaudio_SOURCE_DIR} 33 | ) 34 | 35 | add_executable(${MODULE_TEST_NAME} 36 | ${MODULE_TEST} 37 | ) 38 | 39 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 40 | LDAudioBackend 41 | ) 42 | 43 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 44 | ${LUDENS_INCLUDE_DIR} 45 | ${LUDENS_SOURCE_DIR} 46 | ) -------------------------------------------------------------------------------- /LDEditor/EditorWidget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDEditorWidget) 2 | 3 | set(MODULE_LIB 4 | Lib/UITransformEditWidget.cpp 5 | Lib/UIAssetSlotWidget.cpp 6 | Lib/UIDropdownWindow.cpp 7 | Lib/UIVersionWindow.cpp 8 | Lib/UISelectWindow.cpp 9 | Lib/UIDraw.cpp 10 | ) 11 | 12 | set(MODULE_INCLUDE 13 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EditorWidget/UITransformEditWidget.h 14 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EditorWidget/UIAssetSlotWidget.h 15 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EditorWidget/UIDropdownWindow.h 16 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EditorWidget/UIVersionWindow.h 17 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EditorWidget/UISelectWindow.h 18 | ${LUDENS_INCLUDE_DIR}/LudensEditor/EditorWidget/UIDraw.h 19 | ) 20 | 21 | add_library(${MODULE_NAME} 22 | ${MODULE_LIB} 23 | ${MODULE_INCLUDE} 24 | ) 25 | 26 | target_link_libraries(${MODULE_NAME} PRIVATE 27 | LDCoreLibs 28 | LDEditorContext 29 | ) 30 | 31 | target_include_directories(${MODULE_NAME} PRIVATE 32 | ${LUDENS_SOURCE_DIR} 33 | ${LUDENS_INCLUDE_DIR} 34 | ) -------------------------------------------------------------------------------- /LDEditor/EOutlinerWindow/Lib/ComponentMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct ComponentMenuInfo 10 | { 11 | UIContext ctx; 12 | EditorTheme theme; 13 | Hash32 layer; 14 | void (*onOptionAddScript)(CUID cuid, void* user); 15 | void* user; 16 | }; 17 | 18 | /// @brief Dropdown menu for options applicable to 19 | /// components inside the Outliner window. 20 | class ComponentMenu 21 | { 22 | public: 23 | void startup(const ComponentMenuInfo& info); 24 | void cleanup(); 25 | 26 | void show(const Vec2& pos, CUID cuid); 27 | void hide(); 28 | 29 | void draw(ScreenRenderComponent renderer); 30 | 31 | private: 32 | static bool on_option(int option, const Rect& optionRect, void* user); 33 | 34 | UIDropdownWindow mDropdown; 35 | ComponentMenuInfo mInfo; 36 | CUID mCUID; 37 | }; 38 | 39 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/DataRegistry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDDataRegistry) 2 | set(MODULE_TEST_NAME LDDataRegistryTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/DataRegistry/DataComponent.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/DataRegistry/DataRegistry.h 7 | ) 8 | 9 | set(MODULE_LIB 10 | Lib/DataRegistry.cpp 11 | ) 12 | 13 | set(MODULE_TEST 14 | Test/DataRegistryTest.cpp 15 | ) 16 | 17 | add_library(${MODULE_NAME} 18 | ${MODULE_INCLUDE} 19 | ${MODULE_LIB} 20 | ) 21 | 22 | target_include_directories(${MODULE_NAME} PRIVATE 23 | ${LUDENS_SOURCE_DIR} 24 | ${LUDENS_INCLUDE_DIR} 25 | ) 26 | 27 | target_link_libraries(${MODULE_NAME} PUBLIC 28 | LDSystem 29 | LDAudioServer 30 | LDRenderServer 31 | LDAsset 32 | ) 33 | 34 | add_executable(${MODULE_TEST_NAME} 35 | ${MODULE_TEST} 36 | ) 37 | 38 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 39 | ${LUDENS_SOURCE_DIR} 40 | ${LUDENS_INCLUDE_DIR} 41 | ) 42 | 43 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 44 | ${MODULE_NAME} 45 | ) -------------------------------------------------------------------------------- /LDCore/UI/Sandbox/UISandbox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace LD { 12 | 13 | /// @brief Sandbox application for experiementing with UI. 14 | class UISandbox 15 | { 16 | public: 17 | UISandbox(); 18 | ~UISandbox(); 19 | 20 | void run(); 21 | 22 | private: 23 | void imgui(); 24 | void render(); 25 | 26 | static void on_event(const Event* event, void* user); 27 | static void on_screen_render(ScreenRenderComponent renderer, void* user); 28 | 29 | private: 30 | Font mFont; 31 | FontAtlas mFontAtlas; 32 | RDevice mRDevice; 33 | RServer mRServer; 34 | RImage mFontAtlasImage; 35 | RImage mIconAtlasImage; 36 | UIWindow mClient; 37 | UIWindowManager mUIWM; 38 | Camera mCamera; 39 | }; 40 | 41 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Media/Test/BitmapTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace LD; 6 | 7 | TEST_CASE("Bitmap MSE") 8 | { 9 | uint32_t pixel1 = 0xFFFFFFFF; 10 | uint32_t pixel2 = 0; 11 | BitmapView view1{1, 1, BITMAP_CHANNEL_RGBA, (const char*)&pixel1}; 12 | BitmapView view2{1, 1, BITMAP_CHANNEL_RGBA, (const char*)&pixel2}; 13 | 14 | double mse; 15 | CHECK(Bitmap::compute_mse(view1, view2, mse)); 16 | CHECK(is_equal_epsilon(mse, 1.0)); 17 | 18 | pixel2 = 0x00FF00FF; 19 | CHECK(Bitmap::compute_mse(view1, view2, mse)); 20 | CHECK(is_equal_epsilon(mse, 0.5)); 21 | 22 | pixel2 = 0xFF00FFFF; 23 | CHECK(Bitmap::compute_mse(view1, view2, mse)); 24 | CHECK(is_equal_epsilon(mse, 0.25)); 25 | 26 | pixel2 = pixel1; 27 | CHECK(Bitmap::compute_mse(view1, view2, mse)); 28 | CHECK(is_equal_epsilon(mse, 0.0)); 29 | 30 | CHECK(Bitmap::compute_mse(view1, view1, mse)); 31 | CHECK(is_equal_epsilon(mse, 0.0)); 32 | } -------------------------------------------------------------------------------- /Include/LudensEditor/EditorContext/EditorIconAtlas.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | /// @brief Early definition of icons for the Editor. 8 | /// These names correspond to Google Material Icons. 9 | enum class EditorIcon 10 | { 11 | Folder, 12 | Description, 13 | Close, 14 | Remove, 15 | Transform, 16 | Refresh, 17 | LinearScale, 18 | PlayArrow, 19 | Code, 20 | ArrowBack, 21 | ArrowDownward, 22 | ArrowForward, 23 | ArrowUpward, 24 | ENUM_COUNT, 25 | }; 26 | 27 | /// @brief Early definition of an icon texture atlas for the Editor. 28 | /// Currently we are using an atlas of fixed-sized icons, but 29 | /// we may switch to using SVGs for individual icons as well. 30 | struct EditorIconAtlas 31 | { 32 | /// @brief Get icon area in the atlas. 33 | static Rect get_icon_rect(EditorIcon icon); 34 | 35 | /// @brief Get icon UV area in the atlas. 36 | static Rect get_icon_rect_uv(EditorIcon icon); 37 | }; 38 | 39 | } // namespace LD -------------------------------------------------------------------------------- /LDUtil/LudensLFS/Include/LudensLFS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | /// @brief Ludens LFS is a git submodule located at https://github.com/x2w-soda/LudensLFS. 8 | /// It contains temporary, intermediate, and binary files that are tracked by Git-LFS. 9 | struct LudensLFS 10 | { 11 | /// @brief Attempts to locate resources in Ludens LFS submodule. 12 | LudensLFS(); 13 | 14 | bool isFound; 15 | 16 | std::filesystem::path lfsPath; 17 | std::filesystem::path materialIconsPath; 18 | std::filesystem::path fontPath; 19 | std::filesystem::path skyboxFolderPath; 20 | std::filesystem::path projectPath; 21 | 22 | struct Audio 23 | { 24 | std::filesystem::path forestAmbiencePath; 25 | std::filesystem::path uiClick1Path; 26 | std::filesystem::path uiClick2Path; 27 | } audio; 28 | }; 29 | 30 | /// @brief If the LDLudensLFS library is linked, this attempts to 31 | /// locate resources during CRT initialization. 32 | extern LudensLFS sLudensLFS; 33 | 34 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_str.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String handling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STR_H 7 | #define _LJ_STR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | /* String helpers. */ 14 | LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); 15 | LJ_FUNC const char *lj_str_find(const char *s, const char *f, 16 | MSize slen, MSize flen); 17 | LJ_FUNC int lj_str_haspattern(GCstr *s); 18 | 19 | /* String interning. */ 20 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); 21 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); 22 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); 23 | LJ_FUNC void LJ_FASTCALL lj_str_init(lua_State *L); 24 | #define lj_str_freetab(g) \ 25 | (lj_mem_freevec(g, g->str.tab, g->str.mask+1, GCRef)) 26 | 27 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) 28 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) 29 | #define lj_str_size(len) (sizeof(GCstr) + (((len)+4) & ~(MSize)3)) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Include/Ludens/Project/ProjectSchema.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | /// @brief Schema for defining a Project under the current engine version. 10 | /// While the Project and ProjectSettings lives in RAM, the Schema is 11 | /// meant to be serialized to disk. 12 | struct ProjectSchema 13 | { 14 | /// @brief Load a project from TOML schema source string. 15 | static void load_project_from_source(Project project, const char* source, size_t len); 16 | 17 | /// @brief Load a project from TOML schema file on disk. 18 | static void load_project_from_file(Project project, const FS::Path& tomlPath); 19 | 20 | /// @brief Try saving project as TOML schema file on disk. 21 | static bool save_project(Project project, const FS::Path& savePath, std::string& err); 22 | 23 | /// @brief Get default schema TOML text. 24 | static std::string get_default_text(const std::string& projectName, const FS::Path& assetSchemaPath); 25 | }; 26 | 27 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_snap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Snapshot handling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SNAP_H 7 | #define _LJ_SNAP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | LJ_FUNC void lj_snap_add(jit_State *J); 14 | LJ_FUNC void lj_snap_purge(jit_State *J); 15 | LJ_FUNC void lj_snap_shrink(jit_State *J); 16 | LJ_FUNC IRIns *lj_snap_regspmap(jit_State *J, GCtrace *T, SnapNo snapno, 17 | IRIns *ir); 18 | LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); 19 | LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); 20 | LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); 21 | LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); 22 | 23 | static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) 24 | { 25 | if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); 26 | } 27 | 28 | static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) 29 | { 30 | if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); 31 | } 32 | 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /LDCore/UI/Test/UIInputTest.cpp: -------------------------------------------------------------------------------- 1 | #include "UITest.h" 2 | #include 3 | #include 4 | 5 | static int sLastKey; 6 | 7 | TEST_CASE("UIWidget BlockInput") 8 | { 9 | UIContext ctx = UITest::create_test_context(); 10 | 11 | UILayoutInfo layoutI{}; 12 | layoutI.childAxis = UI_AXIS_X; 13 | layoutI.sizeX = UISize::fixed(100); 14 | layoutI.sizeY = UISize::fixed(100); 15 | UIWindowInfo windowI{}; 16 | UIWindow window = ctx.add_window(layoutI, windowI, nullptr); 17 | window.set_on_key([](UIWidget widget, KeyCode key, UIEvent event) { 18 | sLastKey = key; 19 | }); 20 | 21 | window.layout(); 22 | 23 | sLastKey = 0; 24 | ctx.input_mouse_position(Vec2(50, 50)); 25 | ctx.input_key_down(KEY_CODE_A); 26 | CHECK(sLastKey == KEY_CODE_A); 27 | 28 | window.block_input(); 29 | ctx.input_key_down(KEY_CODE_B); 30 | CHECK(sLastKey == KEY_CODE_A); 31 | 32 | window.unblock_input(); 33 | ctx.input_key_down(KEY_CODE_C); 34 | CHECK(sLastKey == KEY_CODE_C); 35 | 36 | UIContext::destroy(ctx); 37 | } 38 | -------------------------------------------------------------------------------- /Include/Ludens/AudioMixer/AudioEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct AudioEffectInfo; 9 | 10 | /// @brief Audio effect object base class. 11 | class AudioEffectObj : public AudioObject 12 | { 13 | public: 14 | AudioEffectObj* next = nullptr; 15 | 16 | /// @brief Polymorphic frame processing. 17 | virtual void process(float* outFrames, const float* inFrames, uint32_t frameCount) = 0; 18 | 19 | /// @brief Polymorphic state readback. This reads the complete state of the audio effect. 20 | virtual void read(AudioEffectInfo& info) = 0; 21 | }; 22 | 23 | struct AudioEffect : AudioHandle 24 | { 25 | /// @brief Audio thread processes the input stream with effect. 26 | void process(float* outFrames, const float* inFrames, uint32_t frameCount); 27 | 28 | /// @brief Main thread reads the complete state of the effect 29 | /// @warning Each field is atomically read, but the full tuple of fields may not be atomic. 30 | void read(AudioEffectInfo& info); 31 | }; 32 | 33 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/RenderBackend/RStager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief Utility class to upload CPU data to GPU-local memory via staging buffers 9 | class RStager 10 | { 11 | public: 12 | RStager() = delete; 13 | RStager(const RStager&) = delete; 14 | RStager(RDevice device, RQueueType queueType); 15 | ~RStager(); 16 | 17 | RStager& operator=(const RStager&) = delete; 18 | 19 | /// @brief Add a command to upload buffer memory. 20 | void add_buffer_data(RBuffer dst, const void* data); 21 | 22 | /// @brief Add a command to upload image memory. Performing a layout transition after the transfer. 23 | void add_image_data(RImage dst, const void* data, RImageLayout finalLayout); 24 | 25 | /// @brief Begin uploading, blocks until transfer queue has completed submission. 26 | void submit(RQueue transferQueue); 27 | 28 | private: 29 | RDevice mDevice; 30 | RCommandPool mPool; 31 | RCommandList mList; 32 | std::vector mStagingBuffers; 33 | }; 34 | 35 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Serial/Lib/Value.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace LD { 6 | 7 | // clang-format off 8 | struct 9 | { 10 | ValueType type; 11 | const char* cstr; 12 | size_t byteSize; 13 | } sValueTable[] = { 14 | {VALUE_TYPE_F32, "f32", 4}, 15 | {VALUE_TYPE_F64, "f64", 8}, 16 | {VALUE_TYPE_I8, "i8", 1}, 17 | {VALUE_TYPE_U8, "u8", 1}, 18 | {VALUE_TYPE_I16, "i16", 2}, 19 | {VALUE_TYPE_U16, "u16", 2}, 20 | {VALUE_TYPE_I32, "i32", 4}, 21 | {VALUE_TYPE_U32, "u32", 4}, 22 | {VALUE_TYPE_I64, "i64", 8}, 23 | {VALUE_TYPE_U64, "u64", 8}, 24 | {VALUE_TYPE_BOOL, "bool", 1}, 25 | }; 26 | // clang-format on 27 | 28 | static_assert(IsTrivial); 29 | static_assert(sizeof(sValueTable) / sizeof(*sValueTable) == VALUE_TYPE_ENUM_COUNT); 30 | 31 | size_t get_value_byte_size(ValueType type) 32 | { 33 | return sValueTable[(int)type].byteSize; 34 | } 35 | 36 | const char* get_value_cstr(ValueType type) 37 | { 38 | return sValueTable[(int)type].cstr; 39 | } 40 | 41 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/Asset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | enum AssetType 10 | { 11 | ASSET_TYPE_BLOB = 0, 12 | ASSET_TYPE_FONT, 13 | ASSET_TYPE_MESH, 14 | ASSET_TYPE_UI_TEMPLATE, 15 | ASSET_TYPE_AUDIO_CLIP, 16 | ASSET_TYPE_TEXTURE_2D, 17 | ASSET_TYPE_LUA_SCRIPT, 18 | ASSET_TYPE_ENUM_COUNT, 19 | }; 20 | 21 | /// @brief Asset unique identifier. 22 | typedef uint32_t AUID; 23 | 24 | /// @brief Get byte size of an asset type. 25 | size_t get_asset_byte_size(AssetType type); 26 | 27 | /// @brief Get static C string for asset type. 28 | const char* get_asset_type_cstr(AssetType type); 29 | 30 | struct AssetHandle : Handle 31 | { 32 | AssetHandle() = default; 33 | AssetHandle(AssetObj* obj) 34 | : Handle(obj) {} 35 | 36 | /// @brief Get asset type. 37 | AssetType get_type(); 38 | 39 | /// @brief Get asset name. 40 | const char* get_name(); 41 | 42 | /// @brief Get asset identifier. 43 | AUID get_auid(); 44 | }; 45 | 46 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EditorContext/Test/EditorActionTest.cpp: -------------------------------------------------------------------------------- 1 | #include "EditorContextTest.h" 2 | #include 3 | #include 4 | 5 | using namespace LD; 6 | 7 | static int sUndoCounter = 0; 8 | 9 | TEST_CASE("EditorActionQueue basic") 10 | { 11 | sUndoCounter = 0; 12 | 13 | EditStack stack = EditStack::create(); 14 | EditorActionQueue queue = EditorActionQueue::create(stack, nullptr); 15 | 16 | EditorActionInfo actionI{}; 17 | actionI.name = "Undo"; 18 | actionI.type = EDITOR_ACTION_UNDO; 19 | actionI.action = [](EditStack stack, void* user) { sUndoCounter++; }; 20 | EditorAction::register_action(actionI); 21 | 22 | queue.enqueue(EDITOR_ACTION_UNDO); 23 | 24 | CHECK(sUndoCounter == 0); 25 | queue.poll_actions(); 26 | CHECK(sUndoCounter == 1); 27 | 28 | queue.enqueue(EDITOR_ACTION_UNDO); 29 | queue.enqueue(EDITOR_ACTION_UNDO); 30 | 31 | CHECK(sUndoCounter == 1); 32 | queue.poll_actions(); 33 | CHECK(sUndoCounter == 3); 34 | 35 | EditorActionQueue::destroy(queue); 36 | EditStack::destroy(stack); 37 | } -------------------------------------------------------------------------------- /Include/Ludens/AudioBackend/MiniAudio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief MiniAudio device handle. 9 | struct MiniAudioDevice : Handle 10 | { 11 | /// @brief Get user data specified in MiniAudioInfo. 12 | void* get_user_data(); 13 | 14 | /// @brief Get device sample rate. 15 | uint32_t get_sample_rate(); 16 | }; 17 | 18 | /// @brief Audio thread callback that requests new frames for playback. 19 | typedef void (*MiniAudioDataCallback)(MiniAudioDevice device, void* outFrames, const void* inFrames, uint32_t frameCount); 20 | 21 | /// @brief MiniAudio configuration. 22 | struct MiniAudioInfo 23 | { 24 | MiniAudioDataCallback dataCallback; 25 | void* userData; 26 | }; 27 | 28 | /// @brief MiniAudio context handle. 29 | struct MiniAudio : Handle 30 | { 31 | /// @brief Create miniaudio context. 32 | static MiniAudio create(const MiniAudioInfo& info); 33 | 34 | /// @brief Destroy miniaudio context 35 | static void destroy(MiniAudio ma); 36 | }; 37 | 38 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EditorContext/Lib/EditorContextCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "EditorContextCommand.h" 2 | #include 3 | 4 | namespace LD { 5 | 6 | AddComponentScriptCommand::AddComponentScriptCommand(Scene scene, CUID compID, AUID scriptAssetID) 7 | : mScene(scene), mCompID(compID), mScriptAssetID(scriptAssetID), mPrevScriptAssetID(0) 8 | { 9 | LD_ASSERT(mScene && mCompID && mScriptAssetID); 10 | 11 | ComponentScriptSlot* scriptSlot = mScene.get_component_script_slot(mCompID); 12 | if (scriptSlot) 13 | mPrevScriptAssetID = scriptSlot->assetID; 14 | } 15 | 16 | void AddComponentScriptCommand::redo() 17 | { 18 | mScene.create_component_script_slot(mCompID, mScriptAssetID); 19 | } 20 | 21 | void AddComponentScriptCommand::undo() 22 | { 23 | // update Scene 24 | if (mPrevScriptAssetID != 0) 25 | { 26 | ComponentScriptSlot* slot = mScene.get_component_script_slot(mCompID); 27 | LD_ASSERT(slot); 28 | slot->assetID = mPrevScriptAssetID; 29 | } 30 | else 31 | { 32 | mScene.destroy_component_script_slot(mCompID); 33 | } 34 | } 35 | 36 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/RenderBackend/KTX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct ktxTexture2; 7 | 8 | namespace LD { 9 | 10 | /// @brief KTX texture creation info. 11 | struct KTXTextureInfo 12 | { 13 | const void* data; // raw pixel data, tightly packed rows. 14 | size_t dataSize; // free sanity check, compared against pixel format and image dimensions 15 | RFormat format; 16 | uint32_t layers; 17 | uint32_t width; 18 | uint32_t height; 19 | }; 20 | 21 | /// @brief KTX texture object. 22 | struct KTXTexture 23 | { 24 | ktxTexture2* handle = nullptr; 25 | RFormat format; 26 | uint32_t layers; 27 | uint32_t width; 28 | uint32_t height; 29 | 30 | /// @brief Create KTX texture object. 31 | /// @return True on success. 32 | static bool create(const KTXTextureInfo& info, KTXTexture& texture); 33 | 34 | /// @brief Destroy KTX texture object. 35 | static void destroy(KTXTexture texture); 36 | 37 | /// @brief Write to disk. 38 | bool write_to_disk(const FS::Path& path); 39 | }; 40 | 41 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EditorWidget/Lib/UIAssetSlotWidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | bool eui_asset_slot(EditorTheme theme, AssetType assetType, AUID assetID, const char* assetName) 10 | { 11 | MouseButton btn; 12 | UIEvent event; 13 | bool newAssetRequest = false; 14 | 15 | UILayoutInfo layoutI{}; 16 | layoutI.childAxis = UI_AXIS_X; 17 | layoutI.childGap = 10.0f; 18 | layoutI.sizeX = UISize::grow(); 19 | layoutI.sizeY = UISize::fit(); 20 | ui_push_panel(); 21 | ui_top_layout(layoutI); 22 | 23 | ui_push_text(get_asset_type_cstr(assetType)); 24 | ui_pop(); 25 | 26 | LD_ASSERT(assetName); 27 | ui_push_text(assetName); 28 | ui_top_draw(&eui_draw_text_with_bg); 29 | if (ui_top_mouse_down(btn) && btn == MOUSE_BUTTON_LEFT) 30 | newAssetRequest = true; 31 | ui_pop(); 32 | 33 | ui_pop(); 34 | 35 | return newAssetRequest; 36 | } 37 | 38 | } // namespace LD -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Hanif Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Include/Ludens/Header/Assert.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifndef LD_DEBUG_BREAK 8 | # ifdef LD_PLATFORM_WIN32 9 | # define LD_DEBUG_BREAK __debugbreak() 10 | # elif defined(LD_PLATFORM_LINUX) 11 | # include 12 | # define LD_DEBUG_BREAK raise(SIGTRAP) 13 | # endif 14 | #endif 15 | 16 | #ifndef NDEBUG 17 | #define LD_ASSERT(EXPR) \ 18 | do \ 19 | if (!(EXPR)) \ 20 | { \ 21 | puts("Assertion Failed: " #EXPR); \ 22 | LD_DEBUG_BREAK; \ 23 | } \ 24 | while (0) 25 | #else 26 | #define LD_ASSERT 27 | #endif 28 | 29 | #ifndef LD_UNREACHABLE 30 | #define LD_UNREACHABLE LD_ASSERT(0 && "Unreachable") 31 | #endif 32 | -------------------------------------------------------------------------------- /Include/LudensEditor/EditorContext/EditorSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | /// @brief Editor theme determines the color scheme, typography, UI layouts. 12 | struct EditorTheme : Handle 13 | { 14 | UITheme get_ui_theme(); 15 | Color get_play_button_color() const; 16 | Color get_stop_button_color() const; 17 | float get_font_size() const; 18 | float get_padding() const; 19 | void get_gizmo_colors(Color& axisX, Color& axisY, Color& axisZ) const; 20 | void get_gizmo_highlight_color(Color& hl) const; 21 | }; 22 | 23 | /// @brief Global editor settings that apply to all projects 24 | struct EditorSettings : Handle 25 | { 26 | static EditorSettings create_default(); 27 | static EditorSettings create(JSONDocument doc); 28 | static void destroy(EditorSettings settings); 29 | 30 | /// @brief Get current editor theme 31 | EditorTheme get_theme(); 32 | }; 33 | 34 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Scene/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDScene) 2 | set(MODULE_TEST_NAME LDSceneTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/Scene/Scene.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/Scene/SceneSchema.h 7 | ) 8 | 9 | set(MODULE_LIB 10 | Lib/Scene.cpp 11 | Lib/SceneSchema.cpp 12 | Lib/LuaScript.h 13 | Lib/LuaScript.cpp 14 | ) 15 | 16 | add_library(${MODULE_NAME} 17 | ${MODULE_INCLUDE} 18 | ${MODULE_LIB} 19 | ) 20 | 21 | target_include_directories(${MODULE_NAME} PRIVATE 22 | ${LUDENS_SOURCE_DIR} 23 | ${LUDENS_INCLUDE_DIR} 24 | ) 25 | 26 | target_link_libraries(${MODULE_NAME} PUBLIC 27 | LDProfiler 28 | LDSystem 29 | LDLua 30 | LDMedia 31 | LDCamera 32 | LDDataRegistry 33 | LDApplication 34 | ) 35 | 36 | set(MODULE_TEST 37 | Test/SceneTest.cpp 38 | Test/SceneSchemaTest.cpp 39 | ) 40 | 41 | add_executable(${MODULE_TEST_NAME} 42 | ${MODULE_TEST} 43 | ) 44 | 45 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 46 | ${LUDENS_INCLUDE_DIR} 47 | ${LUDENS_SOURCE_DIR} 48 | ) 49 | 50 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 51 | ${MODULE_NAME} 52 | ) -------------------------------------------------------------------------------- /Include/LudensEditor/EOutlinerWindow/EOutlinerWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace LD { 12 | 13 | struct EOutlinerWindowInfo 14 | { 15 | EditorContext ctx; 16 | UIWindowManager wm; /// window manager handle 17 | UIWMAreaID areaID; /// designated window area 18 | void (*addScriptToComponent)(CUID compID, void* user); 19 | void* user; 20 | }; 21 | 22 | /// @brief Editor outliner window. Displays the scene hierarchy. 23 | struct EOutlinerWindow : Handle 24 | { 25 | /// @brief Create editor outliner window. 26 | /// @param windowInfo Outliner window creation info. 27 | /// @return Editor outliner handle. 28 | static EOutlinerWindow create(const EOutlinerWindowInfo& windowInfo); 29 | 30 | /// @brief Destroy editor outliner window 31 | static void destroy(EOutlinerWindow window); 32 | }; 33 | 34 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Application/Input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | namespace Input { 7 | 8 | /// @brief returns true while the key is pressed down 9 | bool get_key(KeyCode key); 10 | 11 | /// @brief returns true during the exact frame where the user pressed down the key 12 | bool get_key_down(KeyCode key); 13 | 14 | /// @brief returns true during the exact frame the user released the key 15 | bool get_key_up(KeyCode key); 16 | 17 | /// @brief returns true while the mouse button is pressed down 18 | bool get_mouse(MouseButton button); 19 | 20 | /// @brief returns true during the exact frame where the user pressed down the mouse button 21 | bool get_mouse_down(MouseButton button); 22 | 23 | /// @brief returns true during the exact frame where the user released the mouse button 24 | bool get_mouse_up(MouseButton button); 25 | 26 | /// @brief get the mouse cursor position in screen space 27 | void get_mouse_position(float& x, float& y); 28 | 29 | /// @brief get the mouse cursor position difference with the last frame 30 | bool get_mouse_motion(float& dx, float& dy); 31 | 32 | } // namespace Input 33 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Serial/Value.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | enum ValueType : uint16_t 9 | { 10 | VALUE_TYPE_F32 = 0, 11 | VALUE_TYPE_F64, 12 | VALUE_TYPE_I8, 13 | VALUE_TYPE_U8, 14 | VALUE_TYPE_I16, 15 | VALUE_TYPE_U16, 16 | VALUE_TYPE_I32, 17 | VALUE_TYPE_U32, 18 | VALUE_TYPE_I64, 19 | VALUE_TYPE_U64, 20 | VALUE_TYPE_BOOL, 21 | VALUE_TYPE_ENUM_COUNT, 22 | }; 23 | 24 | /// @brief Tagged union of pointers. 25 | struct Value 26 | { 27 | ValueType type; 28 | union 29 | { 30 | bool* b; 31 | float* f32; 32 | double* f64; 33 | int8_t* i8; 34 | int16_t* i16; 35 | int32_t* i32; 36 | int64_t* i64; 37 | uint8_t* u8; 38 | uint16_t* u16; 39 | uint32_t* u32; 40 | uint64_t* u64; 41 | }; 42 | }; 43 | 44 | /// @brief Get byte size of value type, or zero for varying length values. 45 | size_t get_value_byte_size(ValueType type); 46 | 47 | /// @brief Get static C string for value type name. 48 | const char* get_value_cstr(ValueType type); 49 | 50 | } // namespace LD 51 | -------------------------------------------------------------------------------- /LDCore/Header/Test/TestColor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | using namespace LD; 7 | 8 | TEST_CASE("Color") 9 | { 10 | Color c1{}; 11 | CHECK((uint32_t)c1 == 0); 12 | 13 | c1 = Vec4(1.0f, 0.0, 0.0f, 0.0f); 14 | CHECK((uint32_t)c1 == 0xFF000000); 15 | 16 | c1 = Vec4(0.0f, 1.0, 0.0f, 0.0f); 17 | CHECK((uint32_t)c1 == 0x00FF0000); 18 | 19 | c1 = Vec4(0.0f, 0.0, 1.0f, 0.0f); 20 | CHECK((uint32_t)c1 == 0x0000FF00); 21 | 22 | c1 = Vec4(0.0f, 0.0, 0.0f, 1.0f); 23 | CHECK((uint32_t)c1 == 0x000000FF); 24 | 25 | c1 = Vec4(1.0f); 26 | CHECK((uint32_t)c1 == 0xFFFFFFFF); 27 | 28 | c1 = Vec3(1.0f, 0.0f, 0.0f); 29 | CHECK((uint32_t)c1 == 0xFF0000FF); 30 | 31 | c1 = Vec3(0.0f, 1.0f, 0.0f); 32 | CHECK((uint32_t)c1 == 0x00FF00FF); 33 | 34 | c1 = Vec3(0.0f, 0.0f, 1.0f); 35 | CHECK((uint32_t)c1 == 0x0000FFFF); 36 | 37 | c1 = Vec3(1.0f); 38 | CHECK((uint32_t)c1 == 0xFFFFFFFF); 39 | 40 | c1 = 0xCAFEBABE; 41 | CHECK((uint32_t)c1 == 0xCAFEBABE); 42 | 43 | c1.set_alpha(0.2f); 44 | CHECK((uint32_t)c1 == 0xCAFEBA33); 45 | } -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/OutlineComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct OutlineComponentInfo 9 | { 10 | RFormat format; 11 | uint32_t width; 12 | uint32_t height; 13 | }; 14 | 15 | /// @brief A component to draw outline using a post process pass. 16 | struct OutlineComponent : Handle 17 | { 18 | /// @brief add a outline post process pass to render graph 19 | /// @param graph the render graph 20 | /// @param info post process configuration 21 | /// @return the component handle 22 | static OutlineComponent add(RGraph& graph, const OutlineComponentInfo& info); 23 | 24 | /// @brief get the name of the component 25 | /// @warning returned pointer is transient 26 | const char* component_name() const; 27 | 28 | /// @brief get the name of the input ID color attachment 29 | inline const char* input_name() const { return "input"; } 30 | 31 | /// @brief get the name of the IO color attachment 32 | inline const char* io_name() const { return "io"; } 33 | }; 34 | 35 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/MeshAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Mesh asset handle. 11 | struct MeshAsset : AssetHandle 12 | { 13 | /// @brief get mesh binary data 14 | struct ModelBinary* data(); 15 | 16 | /// @brief Unload asset from RAM. The handle becomes null afterwards. 17 | void unload(); 18 | }; 19 | 20 | struct MeshAssetImportInfo 21 | { 22 | std::filesystem::path sourcePath; /// path to load the source format 23 | std::filesystem::path savePath; /// path to save the imported asset 24 | }; 25 | 26 | class MeshAssetImportJob 27 | { 28 | public: 29 | MeshAsset asset; /// subject asset handle 30 | MeshAssetImportInfo info; /// mesh import configuration 31 | 32 | /// @brief Submit to job system. Address of this job instance must not 33 | /// change until the worker thread completes execution. 34 | void submit(); 35 | 36 | private: 37 | static void execute(void*); 38 | 39 | JobHeader mHeader; 40 | }; 41 | 42 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/AudioMixer/AudioBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | struct AudioBufferInfo 12 | { 13 | SampleFormat format; 14 | uint32_t channels; 15 | uint32_t frameCount; 16 | uint32_t sampleRate; 17 | const void* samples; 18 | }; 19 | 20 | struct AudioBuffer : AudioHandle 21 | { 22 | /// @brief Create audio buffer. 23 | static AudioBuffer create(const AudioBufferInfo& bufferI); 24 | 25 | /// @brief Create audio buffer from generic data. 26 | static AudioBuffer create_from_data(AudioData data); 27 | 28 | /// @brief Create audio buffer from wav file on disk. 29 | static AudioBuffer create_from_wav(const FS::Path& path); 30 | 31 | /// @brief Destroy audio buffer. 32 | static void destroy(AudioBuffer buffer); 33 | 34 | /// @brief Get number of frames in buffer. 35 | uint32_t frame_count(); 36 | 37 | /// @brief View frames in buffer. 38 | const float* view_frame(uint32_t frameOffset); 39 | }; 40 | 41 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/DSA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDDSA) 2 | set(MODULE_TEST_NAME LDDSATest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/DSA/Buffer.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/DSA/GapBuffer.h 7 | ${LUDENS_INCLUDE_DIR}/Ludens/DSA/HeapStorage.h 8 | ${LUDENS_INCLUDE_DIR}/Ludens/DSA/Vector.h 9 | ${LUDENS_INCLUDE_DIR}/Ludens/DSA/String.h 10 | ${LUDENS_INCLUDE_DIR}/Ludens/DSA/StringView.h 11 | ) 12 | 13 | set(MODULE_LIB 14 | Lib/Buffer.cpp 15 | ) 16 | 17 | set(MODULE_TEST 18 | Test/HeapStorageTest.h 19 | Test/GapBufferTest.cpp 20 | Test/VectorTest.h 21 | Test/StringTest.h 22 | Test/DSATest.h 23 | Test/DSATest.cpp 24 | ) 25 | 26 | add_library(${MODULE_NAME} 27 | ${MODULE_INCLUDE} 28 | ${MODULE_LIB} 29 | ) 30 | 31 | target_link_libraries(${MODULE_NAME} PRIVATE 32 | LDSystem 33 | ) 34 | 35 | target_include_directories(${MODULE_NAME} PRIVATE 36 | ${LUDENS_INCLUDE_DIR} 37 | ) 38 | 39 | add_executable(${MODULE_TEST_NAME} 40 | ${MODULE_TEST} 41 | ) 42 | 43 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 44 | ${LUDENS_INCLUDE_DIR} 45 | ${LUDENS_SOURCE_DIR} 46 | ) 47 | 48 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 49 | LDSystem 50 | LDDSA 51 | ) -------------------------------------------------------------------------------- /LDCore/Project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDProject) 2 | set(MODULE_TEST_NAME LDProjectTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/Project/Project.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/Project/ProjectSchema.h 7 | ${LUDENS_INCLUDE_DIR}/Ludens/Project/ProjectSettings.h 8 | ${LUDENS_INCLUDE_DIR}/Ludens/Project/ProjectSettingsDefault.h 9 | ) 10 | 11 | set(MODULE_LIB 12 | Lib/Project.cpp 13 | Lib/ProjectSchema.cpp 14 | Lib/ProjectSettings.cpp 15 | ) 16 | 17 | set(MODULE_TEST 18 | Test/ProjectTest.cpp 19 | Test/ProjectSchemaTest.cpp 20 | ) 21 | 22 | add_library(${MODULE_NAME} 23 | ${MODULE_LIB} 24 | ) 25 | 26 | target_link_libraries(${MODULE_NAME} PUBLIC 27 | LDAsset 28 | LDDataRegistry 29 | LDScene 30 | ) 31 | 32 | target_include_directories(${MODULE_NAME} PRIVATE 33 | ${LUDENS_INCLUDE_DIR} 34 | ${LUDENS_EXTRA_DIR} 35 | ) 36 | 37 | add_executable(${MODULE_TEST_NAME} 38 | ${MODULE_TEST} 39 | ) 40 | 41 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 42 | ${LUDENS_INCLUDE_DIR} 43 | ${LUDENS_SOURCE_DIR} 44 | ) 45 | 46 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 47 | LDProject 48 | ) 49 | -------------------------------------------------------------------------------- /Include/LudensEditor/EConsoleWindow/EConsoleWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | struct EConsoleWindowInfo 12 | { 13 | EditorContext ctx; /// editor context handle 14 | UIWindowManager wm; /// window manager handle 15 | UIWMAreaID areaID; /// designated window area 16 | void* user; /// used in callbacks 17 | }; 18 | 19 | /// @brief Editor inspector window. 20 | /// Displays the properties of the selected object. 21 | struct EConsoleWindow : Handle 22 | { 23 | /// @brief Create console window. 24 | static EConsoleWindow create(const EConsoleWindowInfo& windowInfo); 25 | 26 | /// @brief Destroy console window. 27 | static void destroy(EConsoleWindow window); 28 | 29 | /// @brief Registers an observer to dump logs in editor console window. 30 | void observe_channel(const char* channelName); 31 | }; 32 | 33 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/AudioBackend/AudioBackend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | /// @brief Audio object base class. Heap allocations of these objects 9 | /// are done on the main thread. Ownership is transfered to 10 | /// audio thread after acquire and before release. 11 | class AudioObject 12 | { 13 | public: 14 | void set_acquired(bool acquired); 15 | bool is_acquired(); 16 | 17 | private: 18 | std::atomic_bool mAudioThreadAcquired; 19 | }; 20 | 21 | struct AudioHandle : public Handle 22 | { 23 | AudioHandle() = default; 24 | AudioHandle(AudioObject* obj); 25 | 26 | /// @brief Called by audio thread to acquire underyling audio resource. 27 | /// Main thread should no longer access this resource. 28 | void acquire(); 29 | 30 | /// @brief Called by audio thread to release underyling audio resource. 31 | /// Main thread may proceed with accessing or destroying this resource. 32 | void release(); 33 | 34 | /// @brief Check atomically if the resource is currently owned by audio thread. 35 | bool is_acquired(); 36 | }; 37 | 38 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Project/ProjectSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | /// @brief Settings for starting up the game runtime. 10 | struct ProjectStartupSettings : Handle 11 | { 12 | uint32_t get_window_width(); 13 | void set_window_width(uint32_t width); 14 | 15 | uint32_t get_window_height(); 16 | void set_window_height(uint32_t height); 17 | 18 | std::string get_window_name(); 19 | void set_window_name(const std::string& name); 20 | 21 | std::string get_default_scene_path(); 22 | void set_default_scene_path(const std::string& scenePath); 23 | }; 24 | 25 | /// @brief Ground truth data for project-wide settings. 26 | struct ProjectSettings : Handle 27 | { 28 | /// @brief Creates empty project settings with defaults. 29 | static ProjectSettings create(); 30 | 31 | /// @brief Destroy project settings data. 32 | static void destroy(ProjectSettings settings); 33 | 34 | /// @brief Get interface for startup settings. 35 | ProjectStartupSettings get_startup_settings(); 36 | }; 37 | 38 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Asset/Lib/AssetWatcher.cpp: -------------------------------------------------------------------------------- 1 | #include "AssetWatcher.h" 2 | #include 3 | 4 | namespace LD { 5 | 6 | void AssetWatcher::startup(const AssetWatcherInfo& info) 7 | { 8 | mWatcher = FileWatcher::create(); 9 | mUserCallback = info.onAssetModified; 10 | mUser = info.user; 11 | } 12 | 13 | void AssetWatcher::cleanup() 14 | { 15 | FileWatcher::destroy(mWatcher); 16 | mPathToID.clear(); 17 | mUserCallback = nullptr; 18 | mUser = nullptr; 19 | } 20 | 21 | void AssetWatcher::add_watch(const FS::Path& path, AUID auid) 22 | { 23 | Hash32 hash(path.string().c_str()); 24 | 25 | if (mPathToID.contains(hash)) 26 | return; 27 | 28 | mPathToID[hash] = auid; 29 | 30 | mWatcher.add_file(path, &AssetWatcher::on_file_modify, this); 31 | } 32 | 33 | void AssetWatcher::on_file_modify(const FS::Path& path, void* user) 34 | { 35 | AssetWatcher& self = *(AssetWatcher*)user; 36 | 37 | Hash32 hash(path.string().c_str()); 38 | LD_ASSERT(self.mPathToID.contains(hash)); 39 | AUID assetID = self.mPathToID[hash]; 40 | 41 | if (self.mUserCallback) 42 | self.mUserCallback(path, assetID, self.mUser); 43 | } 44 | 45 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/DSA/Buffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | class Buffer 9 | { 10 | public: 11 | Buffer(); 12 | Buffer(const Buffer&); 13 | Buffer(Buffer&&) = delete; 14 | ~Buffer(); 15 | 16 | Buffer& operator=(const Buffer&); 17 | Buffer& operator=(Buffer&&) = delete; 18 | 19 | /// @brief Reserve for capacity, does not effect size. 20 | void reserve(size_t cap); 21 | 22 | /// @brief Set buffer to byte size, reserving memory as necessary. 23 | void resize(size_t size); 24 | 25 | /// @brief Append bytes to buffer. 26 | void write(const byte* bytes, size_t size); 27 | 28 | /// @brief View bytes at position. 29 | void* read(size_t pos); 30 | 31 | /// @brief Get buffer size in bytes. 32 | inline size_t size() const { return mSize; } 33 | 34 | /// @brief Get read only buffer data. 35 | inline const byte* data() const { return mData; } 36 | 37 | /// @brief Get writable buffer data 38 | inline byte* data() { return mData; } 39 | 40 | private: 41 | size_t mSize; 42 | size_t mCap; 43 | byte* mData = nullptr; 44 | }; 45 | 46 | } // namespace LD 47 | -------------------------------------------------------------------------------- /Extra/luajit/src/jit/zone.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT profiler zones. 3 | -- 4 | -- Copyright (C) 2005-2025 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- 8 | -- This module implements a simple hierarchical zone model. 9 | -- 10 | -- Example usage: 11 | -- 12 | -- local zone = require("jit.zone") 13 | -- zone("AI") 14 | -- ... 15 | -- zone("A*") 16 | -- ... 17 | -- print(zone:get()) --> "A*" 18 | -- ... 19 | -- zone() 20 | -- ... 21 | -- print(zone:get()) --> "AI" 22 | -- ... 23 | -- zone() 24 | -- 25 | ---------------------------------------------------------------------------- 26 | 27 | local remove = table.remove 28 | 29 | return setmetatable({ 30 | flush = function(t) 31 | for i=#t,1,-1 do t[i] = nil end 32 | end, 33 | get = function(t) 34 | return t[#t] 35 | end 36 | }, { 37 | __call = function(t, zone) 38 | if zone then 39 | t[#t+1] = zone 40 | else 41 | return (assert(remove(t), "empty zone stack")) 42 | end 43 | end 44 | }) 45 | 46 | -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Pipeline/EquirectangularPipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct EquirectangularPipeline : Handle 9 | { 10 | static EquirectangularPipeline create(RDevice device); 11 | static void destroy(EquirectangularPipeline pipeline); 12 | 13 | RPipeline handle(); 14 | }; 15 | 16 | /// @brief One-shot function to render 6 cube faces from a 2D equirectangular image, 17 | /// submits work to the graphics queue and blocks until completion. 18 | /// @param device render device 19 | /// @param pipeline equirectangular pipeline 20 | /// @param srcImage the equirectangular image to sample from 21 | /// @param dstImages the 6 cubemap faces used as render targets 22 | /// @param dstBuffers if not null, the 6 images are also copied to these (most likely host-visible) 6 buffers. 23 | /// The dstImages are then expected to contain RIMAGE_USAGE_TRANSFER_SRC_BIT. 24 | void equirectangular_cmd_render_to_faces(RDevice device, EquirectangularPipeline pipeline, RImage srcImage, RImage* dstImages, RBuffer* dstBuffers); 25 | 26 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensEditor/EditorWidget/UISelectWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace LD { 11 | 12 | struct EUISelectWindowRow 13 | { 14 | struct EUISelectWindow* window; 15 | int idx; 16 | }; 17 | 18 | struct EUISelectWindow 19 | { 20 | UIWindow client; 21 | EditorTheme theme; 22 | RImage editorIconAtlas; 23 | const char* extensionFilter; 24 | const char* clientName; 25 | std::vector directoryContents; 26 | std::vector rows; 27 | FS::Path directoryPath; 28 | int highlightedItemIndex = -1; 29 | bool isActive; 30 | bool isContentDirty = true; 31 | void (*onSelect)(const FS::Path& selected, void* user) = nullptr; 32 | void* user = nullptr; 33 | }; 34 | 35 | bool eui_select_window(EUISelectWindow* window, FS::Path& selectedPath); 36 | 37 | struct UISelectWindowInfo 38 | { 39 | UIContext context; 40 | EditorContext editorCtx; 41 | FS::Path directory; 42 | }; 43 | 44 | } // namespace LD -------------------------------------------------------------------------------- /Extra/rapidjson/appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2015 CTP 2 | version: 1.1.0.{build} 3 | 4 | configuration: 5 | - Debug 6 | - Release 7 | 8 | environment: 9 | matrix: 10 | # - VS_VERSION: 9 2008 11 | # VS_PLATFORM: win32 12 | # - VS_VERSION: 9 2008 13 | # VS_PLATFORM: x64 14 | - VS_VERSION: 10 2010 15 | VS_PLATFORM: win32 16 | - VS_VERSION: 10 2010 17 | VS_PLATFORM: x64 18 | - VS_VERSION: 11 2012 19 | VS_PLATFORM: win32 20 | - VS_VERSION: 11 2012 21 | VS_PLATFORM: x64 22 | - VS_VERSION: 12 2013 23 | VS_PLATFORM: win32 24 | - VS_VERSION: 12 2013 25 | VS_PLATFORM: x64 26 | - VS_VERSION: 14 2015 27 | VS_PLATFORM: win32 28 | - VS_VERSION: 14 2015 29 | VS_PLATFORM: x64 30 | 31 | before_build: 32 | - git submodule update --init --recursive 33 | - cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%VS_PLATFORM% -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=true -Wno-dev 34 | 35 | build: 36 | project: Build\VS\RapidJSON.sln 37 | parallel: true 38 | verbosity: minimal 39 | 40 | test_script: 41 | - cd Build\VS && if %CONFIGURATION%==Debug (ctest --verbose -E perftest --build-config %CONFIGURATION%) else (ctest --verbose --build-config %CONFIGURATION%) 42 | -------------------------------------------------------------------------------- /Include/Ludens/UI/UITheme.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | // TODO: This is super temporary stuff, haven't really decided 9 | // on default UI styling just yet. Font size and padding 10 | // could also be part of a Theme. 11 | struct UIThemeInfo 12 | { 13 | Color surfaceColor; 14 | Color onSurfaceColor; 15 | Color primaryColor; 16 | Color backgroundColor; 17 | Color fieldColor; 18 | Color selectionColor; 19 | }; 20 | 21 | /// @brief Handle to a UI theme. 22 | struct UITheme : Handle 23 | { 24 | /// @brief Get default UI theme values. 25 | static UIThemeInfo get_default_info(); 26 | 27 | inline Color get_surface_color() const { return mObj->surfaceColor; }; 28 | inline Color get_on_surface_color() const { return mObj->onSurfaceColor; }; 29 | inline Color get_primary_color() const { return mObj->primaryColor; }; 30 | inline Color get_background_color() const { return mObj->backgroundColor; }; 31 | inline Color get_field_color() const { return mObj->fieldColor; } 32 | inline Color get_selection_color() const { return mObj->selectionColor; } 33 | }; 34 | 35 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensBuilder/BAssetUtil/BAssetUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Ludens framework asset utilities. 11 | struct AssetUtil : Handle 12 | { 13 | static AssetUtil create(); 14 | static void destroy(AssetUtil util); 15 | 16 | /// @brief Import a Blob asset from source file. 17 | /// @return True on success. 18 | bool import_blob(const FS::Path& sourcePath); 19 | 20 | /// @brief Import a Texture2D asset from source file. 21 | /// @return True on success. 22 | bool import_texture_2d(const FS::Path& sourcePath); 23 | 24 | /// @brief Import a Mesh asset from source file. 25 | /// @return True on success. 26 | bool import_font(const FS::Path& sourcePath); 27 | 28 | /// @brief Import a Mesh asset from source file. 29 | /// @return True on success. 30 | bool import_mesh(const FS::Path& sourcePath); 31 | 32 | /// @brief Import an AudioClip asset from source file. 33 | /// @return True on success. 34 | bool import_audio_clip(const FS::Path& sourcePath); 35 | }; 36 | 37 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Serial/Test/PacketTest.cpp: -------------------------------------------------------------------------------- 1 | #include "Extra/doctest/doctest.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace LD; 8 | 9 | static PacketSchema create_schema() 10 | { 11 | PacketSchemaBuilder builder; 12 | PacketSchema schema = builder.new_schema("UpdateEntityPosition") 13 | .add_field(VALUE_TYPE_U32, "EntityID") 14 | .add_field(VALUE_TYPE_U16, "DeltaX") 15 | .add_field(VALUE_TYPE_U16, "DeltaY") 16 | .add_field(VALUE_TYPE_U16, "DeltaZ") 17 | .add_field(VALUE_TYPE_BOOL, "OnGround") 18 | .create(); 19 | 20 | assert(schema); 21 | return schema; 22 | } 23 | 24 | TEST_CASE("PacketSchema basic") 25 | { 26 | PacketSchema schema = create_schema(); 27 | CHECK(schema); 28 | CHECK(schema.get_name() == "UpdateEntityPosition"); 29 | CHECK(schema.get_packet_size() == 21); 30 | 31 | std::cout << schema.print() << std::endl; 32 | 33 | PacketSchema::destroy(schema); 34 | int leaks = get_memory_leaks(nullptr); 35 | CHECK(leaks == 0); 36 | } -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Layout/RMaterial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | #define LD_GLSL_MATERIAL_SET(IDX) R"( 9 | layout (set = )" #IDX R"(, binding = 0) uniform Mat { 10 | vec4 colorFactor; 11 | float metallicFactor; 12 | float roughnessFactor; 13 | uint hasColorTexture; 14 | uint hasNormalTexture; 15 | uint hasMetallicRoughnessTexture; 16 | } uMat; 17 | layout (set = )" #IDX R"(, binding = 1) uniform sampler2D uMatColor; 18 | layout (set = )" #IDX R"(, binding = 2) uniform sampler2D uMatNormal; 19 | layout (set = )" #IDX R"(, binding = 3) uniform sampler2D uMatMetallicRoughness; 20 | )" 21 | 22 | /// @brief material parameters in the form of a uniform buffer 23 | struct RMaterialUBO 24 | { 25 | Vec4 colorFactor; 26 | float metallicFactor; 27 | float roughnessFactor; 28 | uint32_t hasColorTexture; 29 | uint32_t hasNormalTexture; 30 | uint32_t hasMetallicRoughnessTexture; 31 | }; 32 | 33 | /// @brief renderer friendly layout of a Material 34 | struct RMaterial 35 | { 36 | RSet set; /// binds a RMaterialUBO and material textures 37 | RBuffer ubo; /// RMaterialUBO on the GPU 38 | }; 39 | 40 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Embed/GizmoMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct EmbeddedGizmoMesh 9 | { 10 | static void get_translation_gizmo_axis(const MeshVertex** vertices, uint32_t& vertexCount, const uint32_t** indices, uint32_t& indexCount); 11 | static void get_translation_gizmo_axis_draw_info(RDrawIndexedInfo& drawInfo); 12 | 13 | static void get_rotation_gizmo_plane(const MeshVertex** vertices, uint32_t& vertexCount, const uint32_t** indices, uint32_t& indexCount); 14 | static void get_rotation_gizmo_plane_draw_info(RDrawIndexedInfo& drawInfo); 15 | 16 | static void get_scale_gizmo_axis(const MeshVertex** vertices, uint32_t& vertexCount, const uint32_t** indices, uint32_t& indexCount); 17 | static void get_scale_gizmo_axis_draw_info(RDrawIndexedInfo& drawInfo); 18 | 19 | static void get_gizmo_plane_xy(const MeshVertex** vertices, uint32_t& vertexCount); 20 | static void get_gizmo_plane_xz(const MeshVertex** vertices, uint32_t& vertexCount); 21 | static void get_gizmo_plane_yz(const MeshVertex** vertices, uint32_t& vertexCount); 22 | static void get_gizmo_plane_draw_info(RDrawInfo& drawInfo); 23 | }; 24 | 25 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/DSA/Test/GapBufferTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace LD; 5 | 6 | TEST_CASE("GapBuffer") 7 | { 8 | GapBuffer buf; 9 | std::string str = buf.to_string(); 10 | 11 | CHECK(buf.size() == 0); 12 | CHECK(str.empty()); 13 | 14 | buf.insert(0, 'H'); 15 | str = buf.to_string(); 16 | 17 | CHECK(buf.size() == 1); 18 | CHECK(str == "H"); 19 | CHECK(buf.at(0) == 'H'); 20 | 21 | buf.at(0) = 'h'; 22 | CHECK(buf.at(0) == 'h'); 23 | 24 | // insert cstr 25 | buf.insert(1, "ello!"); 26 | str = buf.to_string(); 27 | CHECK(str == "hello!"); 28 | 29 | // NOP 30 | buf.insert(1, nullptr); 31 | str = buf.to_string(); 32 | CHECK(str == "hello!"); 33 | 34 | // insert STL string 35 | buf.insert(5, std::string(", world")); 36 | str = buf.to_string(); 37 | CHECK(str == "hello, world!"); 38 | 39 | buf.erase(4, 2); 40 | str = buf.to_string(); 41 | CHECK(str == "hell world!"); 42 | 43 | // NOP 44 | buf.erase(4, 0); 45 | str = buf.to_string(); 46 | CHECK(str == "hell world!"); 47 | 48 | buf.erase(0, 1000); 49 | str = buf.to_string(); 50 | CHECK(str.empty()); 51 | CHECK(buf.size() == 0); 52 | } -------------------------------------------------------------------------------- /Extra/luajit/src/lj_carith.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data arithmetic. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CARITH_H 7 | #define _LJ_CARITH_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); 14 | 15 | #if LJ_32 16 | LJ_FUNC uint64_t lj_carith_shl64(uint64_t x, int32_t sh); 17 | LJ_FUNC uint64_t lj_carith_shr64(uint64_t x, int32_t sh); 18 | LJ_FUNC uint64_t lj_carith_sar64(uint64_t x, int32_t sh); 19 | LJ_FUNC uint64_t lj_carith_rol64(uint64_t x, int32_t sh); 20 | LJ_FUNC uint64_t lj_carith_ror64(uint64_t x, int32_t sh); 21 | #endif 22 | LJ_FUNC uint64_t lj_carith_shift64(uint64_t x, int32_t sh, int op); 23 | LJ_FUNC uint64_t lj_carith_check64(lua_State *L, int narg, CTypeID *id); 24 | 25 | #if LJ_32 && LJ_HASJIT 26 | LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); 27 | #endif 28 | LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); 29 | LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); 30 | LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); 31 | LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); 32 | LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); 33 | LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Extra/luajit/src/lj_strscan.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String scanning. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STRSCAN_H 7 | #define _LJ_STRSCAN_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Options for accepted/returned formats. */ 12 | #define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ 13 | #define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ 14 | #define STRSCAN_OPT_IMAG 0x04 15 | #define STRSCAN_OPT_LL 0x08 16 | #define STRSCAN_OPT_C 0x10 17 | 18 | /* Returned format. */ 19 | typedef enum { 20 | STRSCAN_ERROR, 21 | STRSCAN_NUM, STRSCAN_IMAG, 22 | STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, 23 | } StrScanFmt; 24 | 25 | LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, 26 | uint32_t opt); 27 | LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); 28 | #if LJ_DUALNUM 29 | LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); 30 | #else 31 | #define lj_strscan_number(s, o) lj_strscan_num((s), (o)) 32 | #endif 33 | 34 | /* Check for number or convert string to number/int in-place (!). */ 35 | static LJ_AINLINE int lj_strscan_numberobj(TValue *o) 36 | { 37 | return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /LDCore/RenderComponent/Lib/Layout/SetLayouts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace LD { 4 | 5 | static RSetBindingInfo sFrameBindings[2] = { 6 | {0, RBINDING_TYPE_UNIFORM_BUFFER, 1}, // frame ubo 7 | {1, RBINDING_TYPE_COMBINED_IMAGE_SAMPLER, 1}, // environment cubemap 8 | }; 9 | 10 | RSetLayoutInfo sFrameSetLayout = { 11 | .bindingCount = 2, 12 | .bindings = sFrameBindings, 13 | }; 14 | 15 | static RSetBindingInfo sMaterialSetBindings[4]{ 16 | {0, RBINDING_TYPE_UNIFORM_BUFFER, 1}, 17 | {1, RBINDING_TYPE_COMBINED_IMAGE_SAMPLER, 1}, 18 | {2, RBINDING_TYPE_COMBINED_IMAGE_SAMPLER, 1}, 19 | {3, RBINDING_TYPE_COMBINED_IMAGE_SAMPLER, 1}, 20 | }; 21 | 22 | RSetLayoutInfo sMaterialSetLayout = { 23 | .bindingCount = 4, 24 | .bindings = sMaterialSetBindings, 25 | }; 26 | 27 | static RSetBindingInfo sDoubleSampleSetBindings[2] = { 28 | {0, RBINDING_TYPE_COMBINED_IMAGE_SAMPLER, 1}, 29 | {1, RBINDING_TYPE_COMBINED_IMAGE_SAMPLER, 1}, 30 | }; 31 | 32 | RSetLayoutInfo sSingleSampleSetLayout = { 33 | .bindingCount = 1, 34 | .bindings = sDoubleSampleSetBindings, 35 | }; 36 | 37 | RSetLayoutInfo sDoubleSampleSetLayout = { 38 | .bindingCount = 2, 39 | .bindings = sDoubleSampleSetBindings, 40 | }; 41 | 42 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/BlobAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Blob asset handle. The engine makes no assumptions about the binary contents. 11 | struct BlobAsset : AssetHandle 12 | { 13 | /// @brief Get blob data. 14 | void* get_data(size_t& dataSize); 15 | }; 16 | 17 | struct BlobAssetImportInfo 18 | { 19 | const void* sourceData = nullptr; /// if not null, the address of some blob in memory. 20 | size_t sourceDataSize; /// byte size of blob in memory 21 | FS::Path sourcePath; /// path to load the blob file, used if source data is null. 22 | FS::Path savePath; /// path to save the imported asset 23 | }; 24 | 25 | class BlobAssetImportJob 26 | { 27 | public: 28 | BlobAsset asset; /// subject asset handle 29 | BlobAssetImportInfo info; /// Blob import configuration 30 | 31 | /// @brief Submit to job system. Address of this job instance must not 32 | /// change until the worker thread completes execution. 33 | void submit(); 34 | 35 | private: 36 | static void execute(void*); 37 | 38 | JobHeader mHeader; 39 | }; 40 | 41 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/DSP/Lib/BiquadFilterCoeff.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace LD { 5 | 6 | void BiquadFilterCoeff::normalize(float a0) 7 | { 8 | b0 /= a0; 9 | b1 /= a0; 10 | b2 /= a0; 11 | a1 /= a0; 12 | a2 /= a0; 13 | } 14 | 15 | void BiquadFilterCoeff::as_low_pass_filter(float Q, float cutoffFreq, float sampleFreq) 16 | { 17 | float omega = M_2_PI * cutoffFreq / sampleFreq; 18 | float sinO = LD_SIN(omega); 19 | float cosO = LD_COS(omega); 20 | float alpha = sinO / (2.0f * Q); 21 | float a0 = 1.0f + alpha; 22 | 23 | b0 = (1.0f - cosO) / 2.0f; 24 | b1 = 1.0f - cosO; 25 | b2 = (1.0f - cosO) / 2.0f; 26 | a1 = -2.0f * cosO; 27 | a2 = 1.0 - alpha; 28 | 29 | normalize(a0); 30 | } 31 | 32 | void BiquadFilterCoeff::as_high_pass_filter(float Q, float cutoffFreq, float sampleFreq) 33 | { 34 | float omega = M_2_PI * cutoffFreq / sampleFreq; 35 | float sinO = LD_SIN(omega); 36 | float cosO = LD_COS(omega); 37 | float alpha = sinO / (2.0f * Q); 38 | float a0 = 1.0f + alpha; 39 | 40 | b0 = (1.0f + cosO) / 2.0f; 41 | b1 = -1.0f - cosO; 42 | b2 = (1.0f + cosO) / 2.0f; 43 | a1 = -2.0f * cosO; 44 | a2 = 1.0 - alpha; 45 | 46 | normalize(a0); 47 | } 48 | 49 | } // namespace LD 50 | -------------------------------------------------------------------------------- /LDCore/Serial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MODULE_NAME LDSerial) 2 | set(MODULE_TEST_NAME LDSerialTest) 3 | 4 | set(MODULE_INCLUDE 5 | ${LUDENS_INCLUDE_DIR}/Ludens/Serial/Value.h 6 | ${LUDENS_INCLUDE_DIR}/Ludens/Serial/Serial.h 7 | ${LUDENS_INCLUDE_DIR}/Ludens/Serial/Packet.h 8 | ${LUDENS_INCLUDE_DIR}/Ludens/Serial/Compress.h 9 | ${LUDENS_INCLUDE_DIR}/Ludens/Serial/Endianness.h 10 | ) 11 | 12 | set(MODULE_LIB 13 | Lib/Value.cpp 14 | Lib/Serial.cpp 15 | Lib/Packet.cpp 16 | Lib/Compress.cpp 17 | ) 18 | 19 | add_library(${MODULE_NAME} 20 | ${MODULE_INCLUDE} 21 | ${MODULE_LIB} 22 | ) 23 | 24 | target_link_libraries(${MODULE_NAME} PUBLIC 25 | LDDSA 26 | LDProfiler 27 | libzstd_static 28 | lz4_static 29 | ) 30 | 31 | target_include_directories(${MODULE_NAME} PRIVATE 32 | ${LUDENS_INCLUDE_DIR} 33 | ${zstd_SOURCE_DIR}/lib 34 | ${lz4_SOURCE_DIR}/lib 35 | ) 36 | 37 | set(MODULE_TEST 38 | Test/SerialTest.cpp 39 | Test/PacketTest.cpp 40 | Test/EndiannessTest.cpp 41 | Test/CompressionTest.cpp 42 | ) 43 | 44 | add_executable(${MODULE_TEST_NAME} 45 | ${MODULE_TEST} 46 | ) 47 | 48 | target_link_libraries(${MODULE_TEST_NAME} PRIVATE 49 | ${MODULE_NAME} 50 | LDSystem 51 | LDJobSystem 52 | LDDSA 53 | ) 54 | 55 | target_include_directories(${MODULE_TEST_NAME} PRIVATE 56 | ${LUDENS_INCLUDE_DIR} 57 | ${LUDENS_SOURCE_DIR} 58 | ) 59 | -------------------------------------------------------------------------------- /LDCore/AudioMixer/Test/AudioMixerTest.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include 3 | 4 | #include "AudioMixerTest.h" 5 | 6 | namespace LD { 7 | 8 | /// @brief Does not play any sound, only processes commands on audio thread. 9 | static void mixer_test_data_callback(MiniAudioDevice device, void* outFrames, const void* inFrames, uint32_t frameCount) 10 | { 11 | memset(outFrames, 0, sizeof(float) * 2 * frameCount); 12 | 13 | AudioMixer mixer((AudioMixerObj*)device.get_user_data()); 14 | mixer.poll_commands(); 15 | } 16 | 17 | void AudioMixerTest::startup() 18 | { 19 | PoolAllocatorInfo paI{}; 20 | paI.blockSize = AudioPlayback::byte_size(); 21 | paI.isMultiPage = true; 22 | paI.pageSize = 128; 23 | paI.usage = MEMORY_USAGE_AUDIO; 24 | playbackPA = PoolAllocator::create(paI); 25 | 26 | mixer = AudioMixer::create(); 27 | 28 | MiniAudioInfo maI{}; 29 | maI.dataCallback = &mixer_test_data_callback; 30 | maI.userData = mixer.unwrap(); 31 | miniAudio = MiniAudio::create(maI); 32 | } 33 | 34 | void AudioMixerTest::cleanup() 35 | { 36 | MiniAudio::destroy(miniAudio); 37 | miniAudio = {}; 38 | 39 | AudioMixer::destroy(mixer); 40 | mixer = {}; 41 | 42 | PoolAllocator::destroy(playbackPA); 43 | playbackPA = {}; 44 | } 45 | 46 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Camera/Test/TestOrthographic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace LD; 8 | 9 | TEST_CASE("Orthographic screen_to_world_size") 10 | { 11 | const float screenH = 900.0f; 12 | const float screenW = 1600.0f; 13 | CameraOrthographicInfo camI{}; 14 | camI.top = 0.0f; 15 | camI.left = 0.0f; 16 | camI.bottom = screenH; 17 | camI.right = screenW; 18 | camI.nearClip = 1.0f; 19 | camI.farClip = 100.0f; 20 | Camera cam = Camera::create(camI, Vec3(0.0f)); 21 | cam.set_pos(Vec3(0.0f, 0.0f, 10.0f)); 22 | 23 | // desire half screen height 24 | float worldSize = cam.screen_to_world_size(Vec3(0.0f), screenH, 450.0f); 25 | CHECK(is_equal_epsilon(worldSize, 450.0f)); 26 | 27 | // view position and view depth does not matter in orthographic 28 | cam.set_pos(Vec3(123.0f, 456.0f, 789.0f)); 29 | 30 | // desire one-third of screen height 31 | worldSize = cam.screen_to_world_size(Vec3(987.0f, 654.0f, 321.0f), screenH, 300.0f); 32 | CHECK(is_equal_epsilon(worldSize, 300.0f)); 33 | 34 | // screen height is half of frustum height 35 | worldSize = cam.screen_to_world_size(Vec3(987.0f, 654.0f, 321.0f), screenH / 2.0f, 300.0f); 36 | CHECK(is_equal_epsilon(worldSize, 600.0f)); 37 | } -------------------------------------------------------------------------------- /LDCore/Asset/Lib/AssetWatcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | struct AssetWatcherInfo 11 | { 12 | void (*onAssetModified)(const FS::Path& path, AUID id, void* user); 13 | void* user; 14 | }; 15 | 16 | /// @brief Asset file watcher. 17 | class AssetWatcher 18 | { 19 | public: 20 | /// @brief In-place startup 21 | void startup(const AssetWatcherInfo& info); 22 | 23 | /// @brief In-place cleanup 24 | void cleanup(); 25 | 26 | /// @brief Poll for asset file changes. 27 | inline void poll() 28 | { 29 | if (!mWatcher) 30 | return; 31 | 32 | mWatcher.poll(); 33 | } 34 | 35 | /// @brief Watch an asset path. 36 | /// @param path File path to asset on disk. 37 | /// @param auid Associated asset ID. 38 | void add_watch(const FS::Path& path, AUID auid); 39 | 40 | inline operator bool() const { return (bool)mWatcher; } 41 | 42 | static void on_file_modify(const FS::Path& path, void* user); 43 | 44 | private: 45 | FileWatcher mWatcher = {}; 46 | std::unordered_map mPathToID; 47 | void (*mUserCallback)(const FS::Path& path, AUID id, void* user); 48 | void* mUser; 49 | }; 50 | 51 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | LUALIB_API int luaopen_string_buffer(lua_State *L); 37 | 38 | LUALIB_API void luaL_openlibs(lua_State *L); 39 | 40 | #ifndef lua_assert 41 | #define lua_assert(x) ((void)0) 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /LDEditor/EditorMain/Lib/EditorTopBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace LD { 8 | 9 | struct TopBarMenu; 10 | struct EditorUI; 11 | 12 | struct EditorTopBarInfo 13 | { 14 | UIContext context; 15 | EditorUI* editorUI; 16 | EditorTheme editorTheme; 17 | Vec2 screenSize; 18 | Hash32 layer; 19 | float barHeight; 20 | }; 21 | 22 | /// @brief Editor top bar menu UI. 23 | class EditorTopBar 24 | { 25 | public: 26 | /// @brief In-place startup. 27 | void startup(const EditorTopBarInfo& info); 28 | 29 | /// @brief In-place cleanup. 30 | void cleanup(); 31 | 32 | /// @brief Only one menu window can be active in the top bar. 33 | void set_active_menu(TopBarMenu* menu); 34 | 35 | /// @brief Get window handle. 36 | UIWindow get_handle(); 37 | 38 | private: 39 | static bool on_file_menu_option(int opt, const Rect& rect, void* user); 40 | static bool on_edit_menu_option(int opt, const Rect& rect, void* user); 41 | static bool on_about_menu_option(int opt, const Rect& rect, void* user); 42 | 43 | private: 44 | UIWindow mRoot; 45 | TopBarMenu* mFileMenu; 46 | TopBarMenu* mEditMenu; 47 | TopBarMenu* mAboutMenu; 48 | float mTopBarHeight; 49 | }; 50 | 51 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/AudioClipAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Audio clip asset handle. This is typically a static buffer of 11 | /// audio samples after decoding and resampling from WAV, MP3, etc. 12 | struct AudioClipAsset : AssetHandle 13 | { 14 | /// @brief Get number of frames in this clip. 15 | uint32_t get_frame_count(); 16 | 17 | /// @brief Get number of channels in this clip. 18 | uint32_t get_channel_count(); 19 | 20 | /// @brief Get default sample rate of this clip. 21 | uint32_t get_sample_rate(); 22 | 23 | /// @brief Read frames from offset. 24 | const float* get_frames(uint32_t frameOffset); 25 | }; 26 | 27 | class AudioClipAssetImportJob 28 | { 29 | public: 30 | AudioClipAsset asset; /// subject handle 31 | FS::Path sourcePath; /// path to load the source audio file. 32 | FS::Path savePath; /// path to save the imported asset 33 | 34 | /// @brief Submit to job system. Address of this job instance must not 35 | /// change until the worker thread completes execution. 36 | void submit(); 37 | 38 | private: 39 | static void execute(void*); 40 | 41 | JobHeader mHeader; 42 | }; 43 | 44 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/DSP/BiquadFilterCoeff.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LD { 4 | 5 | /// @brief Biquad filter coefficients for direct form 1. 6 | /// y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2] 7 | struct BiquadFilterCoeff 8 | { 9 | float a1; 10 | float a2; 11 | float b0; 12 | float b1; 13 | float b2; 14 | 15 | /// @brief Divide five other coefficients by a0. 16 | void normalize(float a0); 17 | 18 | /// @brief Prepares coefficients for direct form 1 LPF. 19 | void as_low_pass_filter(float Q, float cutoffFreq, float sampleFreq); 20 | 21 | /// @brief Prepares coefficients for direct form 1 HPF. 22 | void as_high_pass_filter(float Q, float cutoffFreq, float sampleFreq); 23 | }; 24 | 25 | struct BiquadFilterHistory 26 | { 27 | float xn1; // x[n-1] 28 | float xn2; // x[n-2] 29 | float yn1; // y[n-1] 30 | float yn2; // y[n-2] 31 | }; 32 | 33 | /// @brief Compute direct form 1. 34 | inline float biquad_filter_process(const BiquadFilterCoeff& coeff, BiquadFilterHistory& history, float sample) 35 | { 36 | float y = coeff.b0 * sample + coeff.b1 * history.xn1 + coeff.b2 * history.xn2 - coeff.a1 * history.yn1 - coeff.a2 * history.yn2; 37 | history.xn2 = history.xn1; 38 | history.xn1 = sample; 39 | history.yn2 = history.yn1; 40 | history.yn1 = y; 41 | return y; 42 | } 43 | 44 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EViewportWindow/Lib/ViewportToolbar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | struct ViewportToolbar 12 | { 13 | EditorContext eCtx; 14 | UIWindow window; 15 | UIImageWidget transformIcon; 16 | UIImageWidget rotateIcon; 17 | UIImageWidget scaleIcon; 18 | UIImageWidget playIcon; 19 | SceneOverlayGizmo* gizmoType; 20 | Impulse isRequestingPlay; 21 | Impulse isRequestingStop; 22 | bool isPlayIcon; 23 | 24 | void startup(EditorContext eCtx, UIContext uiCtx, float width, SceneOverlayGizmo* gizmoType, Hash32 layer); 25 | 26 | void display(bool isPlayIcon); 27 | 28 | static void on_draw(UIWidget widget, ScreenRenderComponent renderer); 29 | static void on_press_transform_icon(UIWidget widget, const Vec2& pos, MouseButton btn, UIEvent event); 30 | static void on_press_rotate_icon(UIWidget widget, const Vec2& pos, MouseButton btn, UIEvent event); 31 | static void on_press_scale_icon(UIWidget widget, const Vec2& pos, MouseButton btn, UIEvent event); 32 | static void on_press_play_stop_icon(UIWidget widget, const Vec2& pos, MouseButton btn, UIEvent event); 33 | }; 34 | 35 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/UI/Lib/UIAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define ANIM_NONE 0 5 | #define ANIM_SHOWING 1 6 | #define ANIM_HIDING 2 7 | 8 | namespace LD { 9 | 10 | void UIOpacityAnimation::showing(float duration) 11 | { 12 | mState = ANIM_SHOWING; 13 | mOpacity.set(duration); 14 | } 15 | 16 | void UIOpacityAnimation::hiding(float duration) 17 | { 18 | mState = ANIM_HIDING; 19 | mOpacity.set(duration); 20 | } 21 | 22 | bool UIOpacityAnimation::is_hiding() 23 | { 24 | return mState == ANIM_HIDING; 25 | } 26 | 27 | bool UIOpacityAnimation::update(float delta) 28 | { 29 | mOpacity.update(delta); 30 | 31 | if (mState != ANIM_NONE && !mOpacity.is_animated()) 32 | { 33 | mState = ANIM_NONE; 34 | return true; // animation ended 35 | } 36 | 37 | return false; 38 | } 39 | 40 | float UIOpacityAnimation::get_opacity() 41 | { 42 | float alpha = mOpacity.get(); 43 | 44 | switch (mState) 45 | { 46 | case ANIM_SHOWING: 47 | return alpha; 48 | case ANIM_HIDING: 49 | return 1.0f - alpha; 50 | } 51 | 52 | return 1.0f; 53 | } 54 | 55 | uint32_t UIOpacityAnimation::get_color_mask() 56 | { 57 | Color mask(0xFFFFFFFF); 58 | 59 | if (mState != ANIM_NONE) 60 | mask.set_alpha(get_opacity()); 61 | 62 | return mask; 63 | } 64 | 65 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/Header/GLSL/Common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define LD_GLSL_ROTATE R"( 4 | mat3 ld_rotate(float radians, vec3 axis) { 5 | float c = cos(radians); 6 | float s = sin(radians); 7 | vec3 t = axis * (1.0 - c); 8 | return mat3( 9 | t.x * axis.x + c, t.x * axis.y + s * axis.z, t.x * axis.z - s * axis.y, 10 | t.x * axis.y - s * axis.z, t.y * axis.y + c, t.y * axis.z + s * axis.x, 11 | t.x * axis.z + s * axis.y, t.y * axis.z - s * axis.x, t.z * axis.z + c 12 | ); 13 | })" 14 | 15 | // Normal mapping from tangent space to world space in the fragment shader. 16 | // Without tangent vertex attributes: http://www.thetenthplanet.de/archives/1180 17 | #define LD_GLSL_GET_NORMAL R"( 18 | vec3 get_normal(vec3 worldP, vec3 worldN, vec2 uv, vec3 sampleN) { 19 | vec3 tangentN = sampleN * 2.0 - 1.0; 20 | vec3 dp1 = dFdx(worldP); 21 | vec3 dp2 = dFdy(worldP); 22 | vec2 duv1 = dFdx(uv); 23 | vec2 duv2 = dFdy(uv); 24 | vec3 dp2perp = cross( dp2, worldN ); 25 | vec3 dp1perp = cross( worldN, dp1 ); 26 | vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; 27 | vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; 28 | float invmax = inversesqrt(max(dot(T,T), dot(B,B))); 29 | return normalize(mat3(T * invmax, B * invmax, worldN) * tangentN); 30 | })" 31 | 32 | #define LD_GLSL_TONE_MAP R"( 33 | vec3 tone_map_reinhard(vec3 hdr) { 34 | return hdr / (hdr + vec3(1.0)); 35 | })" -------------------------------------------------------------------------------- /LDCore/Asset/Lib/AssetType/UITemplateAsset.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../AssetObj.h" 6 | 7 | namespace LD { 8 | 9 | void UITemplateAssetObj::load(void* user) 10 | { 11 | LD_PROFILE_SCOPE; 12 | 13 | auto& job = *(AssetLoadJob*)user; 14 | auto* obj = (UITemplateAssetObj*)job.assetHandle.unwrap(); 15 | 16 | obj->tmpl = UITemplate::create(); 17 | 18 | uint64_t fileSize = FS::get_file_size(job.loadPath); 19 | if (fileSize == 0) 20 | { 21 | UITemplate::destroy(obj->tmpl); 22 | obj->tmpl = {}; 23 | return; 24 | } 25 | 26 | Serializer serializer(fileSize); 27 | FS::read_file(job.loadPath, fileSize, serializer.data()); 28 | UITemplateSchema::load_ui_template_from_source(obj->tmpl, serializer.data(), serializer.size()); 29 | } 30 | 31 | void UITemplateAssetObj::unload(AssetObj* base) 32 | { 33 | auto* obj = (UITemplateAssetObj*)base; 34 | 35 | UITemplate::destroy(obj->tmpl); 36 | obj->tmpl = {}; 37 | } 38 | 39 | // 40 | // Public API 41 | // 42 | 43 | UIWidget UITemplateAsset::load_ui_subtree(UIWidget parent, UITemplateOnLoadCallback callback, void* user) 44 | { 45 | auto* obj = (UITemplateAssetObj*)mObj; 46 | 47 | return obj->tmpl.load(parent, callback, user); 48 | } 49 | 50 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensEditor/EditorContext/EditorAction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | enum EditorActionType 9 | { 10 | EDITOR_ACTION_UNDO = 0, 11 | EDITOR_ACTION_REDO, 12 | EDITOR_ACTION_NEW_SCENE, 13 | EDITOR_ACTION_OPEN_SCENE, 14 | EDITOR_ACTION_SAVE_SCENE, 15 | EDITOR_ACTION_ADD_COMPONENT_SCRIPT, 16 | EDITOR_ACTION_ENUM_COUNT, 17 | }; 18 | 19 | struct EditorActionInfo 20 | { 21 | EditorActionType type; 22 | void (*action)(EditStack stack, void* user); 23 | const char* name; 24 | }; 25 | 26 | /// @brief An editor action maps to one or more editor commands. 27 | struct EditorAction 28 | { 29 | static void register_action(const EditorActionInfo& info); 30 | }; 31 | 32 | /// @brief A queue of editor actions to execute sequentially. 33 | struct EditorActionQueue : Handle 34 | { 35 | /// @brief Create the action queue. 36 | static EditorActionQueue create(EditStack stack, void* user); 37 | 38 | /// @brief Destroy the action queue. 39 | static void destroy(EditorActionQueue queue); 40 | 41 | /// @brief Add an action to queue for later execution. 42 | void enqueue(EditorActionType type); 43 | 44 | /// @brief Execute all actions sequentially until queue is empty. 45 | void poll_actions(); 46 | }; 47 | 48 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** State and stack handling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STATE_H 7 | #define _LJ_STATE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #define incr_top(L) \ 12 | (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) 13 | 14 | #define savestack(L, p) ((char *)(p) - mref(L->stack, char)) 15 | #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) 16 | 17 | LJ_FUNC void lj_state_relimitstack(lua_State *L); 18 | LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); 19 | LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); 20 | LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); 21 | LJ_FUNC int LJ_FASTCALL lj_state_cpgrowstack(lua_State *L, MSize need); 22 | 23 | static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) 24 | { 25 | if ((mref(L->maxstack, char) - (char *)L->top) <= 26 | (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) 27 | lj_state_growstack(L, need); 28 | } 29 | 30 | LJ_FUNC lua_State *lj_state_new(lua_State *L); 31 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); 32 | #if LJ_64 && !LJ_GC64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC)) 33 | LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); 34 | #endif 35 | 36 | #define LJ_ALLOCF_INTERNAL ((lua_Alloc)(void *)(uintptr_t)(1237<<4)) 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/FontAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief Font asset handle. 11 | struct FontAsset : AssetHandle 12 | { 13 | /// @brief Get font handle. 14 | Font get_font(); 15 | 16 | /// @brief Get font atlas handle. 17 | FontAtlas get_font_atlas(); 18 | }; 19 | 20 | struct FontAssetImportInfo 21 | { 22 | const void* sourceData = nullptr; /// if not null, the address of some font data in memory. 23 | size_t sourceDataSize; /// byte size of source data 24 | FS::Path sourcePath; /// path to load the source format, used if source data is null. 25 | FS::Path savePath; /// path to save the imported asset 26 | float fontSize; /// desired font size for generating font atlas 27 | }; 28 | 29 | class FontAssetImportJob 30 | { 31 | public: 32 | FontAsset asset; /// subject asset handle 33 | FontAssetImportInfo info; /// Font import configuration 34 | 35 | /// @brief Submit to job system. Address of this job instance must not 36 | /// change until the worker thread completes execution. 37 | void submit(); 38 | 39 | private: 40 | static void execute(void*); 41 | 42 | JobHeader mHeader; 43 | }; 44 | 45 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/DSP/DSP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace LD { 6 | 7 | /// the sample format of a signal 8 | enum SampleFormat 9 | { 10 | SAMPLE_FORMAT_UNKNOWN = 0, /// unknown, unsupported format 11 | SAMPLE_FORMAT_F32, /// 32-bit float in the range [-1.0f, 1.0f] 12 | SAMPLE_FORMAT_S16, /// 16-bit signed integer in the range [-32768, 32767] 13 | SAMPLE_FORMAT_S24, /// 24-bit signed integer in the range [-8388608, 8388607] 14 | SAMPLE_FORMAT_S32, /// 32-bit signed integer in the range [-2147483648, 2147483647] 15 | SAMPLE_FORMAT_U8, /// 8-bit unsigned integer in the range [0, 255] 16 | }; 17 | 18 | /// @brief perform sample format conversion 19 | /// @param srcFormat input sample format 20 | /// @param srcSamples input samples 21 | /// @param dstFormat output sample format 22 | /// @param dstSamples output samples 23 | /// @param sampleCount number of samples in srcSamples and dstSamples array 24 | /// @return true on success 25 | bool sample_format_conversion(SampleFormat srcFormat, const void* srcSamples, SampleFormat dstFormat, void* dstSamples, size_t sampleCount); 26 | 27 | /// @brief get byte size give sample count and sample format 28 | size_t sample_format_byte_size(SampleFormat format, size_t count); 29 | 30 | /// @brief get static and null-terminated string of format 31 | const char* sample_format_cstr(SampleFormat format); 32 | 33 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Serial/Lib/Compress.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include // hide 5 | #include // hide 6 | 7 | namespace LD { 8 | 9 | size_t zstd_compress_bound(size_t srcSize) 10 | { 11 | return ::ZSTD_compressBound(srcSize); 12 | } 13 | 14 | size_t zstd_compress(void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel) 15 | { 16 | LD_PROFILE_SCOPE; 17 | 18 | return ::ZSTD_compress(dst, dstCapacity, src, srcSize, compressionLevel); 19 | } 20 | 21 | void zstd_decompress(void* dst, size_t dstCapacity, const void* src, size_t compressedSize) 22 | { 23 | LD_PROFILE_SCOPE; 24 | 25 | ::ZSTD_decompress(dst, dstCapacity, src, compressedSize); 26 | } 27 | 28 | size_t lz4_compress_bound(size_t srcSize) 29 | { 30 | return (size_t)::LZ4_compressBound((int)srcSize); 31 | } 32 | 33 | size_t lz4_compress(void* dst, size_t dstCapacity, const void* src, size_t srcSize) 34 | { 35 | LD_PROFILE_SCOPE; 36 | 37 | return (size_t)::LZ4_compress_default((const char*)src, (char*)dst, (int)srcSize, (int)dstCapacity); 38 | } 39 | 40 | void lz4_decompress(void* dst, size_t dstCapacity, const void* src, size_t compressedSize) 41 | { 42 | LD_PROFILE_SCOPE; 43 | 44 | int result = ::LZ4_decompress_safe((const char*)src, (char*)dst, (int)compressedSize, (int)dstCapacity); 45 | // TODO: validate 46 | } 47 | 48 | } // namespace LD -------------------------------------------------------------------------------- /Include/LudensEditor/EInspectorWindow/EInspectorWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | struct EInspectorWindowInfo 12 | { 13 | EditorContext ctx; /// editor context handle 14 | UIWindowManager wm; /// window manager handle 15 | UIWMAreaID areaID; /// designated window area 16 | ECBSelectAssetFn selectAssetFn; /// dependency injection to select an asset 17 | void* user; /// used in callbacks 18 | }; 19 | 20 | /// @brief Editor inspector window. 21 | /// Displays the properties of the selected object. 22 | struct EInspectorWindow : Handle 23 | { 24 | /// @brief Create editor inspector window. 25 | /// @param windowInfo Inspector window creation window. 26 | /// @return Editor inspector window handle. 27 | static EInspectorWindow create(const EInspectorWindowInfo& windowInfo); 28 | 29 | /// @brief Destroy editor inspector window. 30 | static void destroy(EInspectorWindow window); 31 | 32 | /// @brief If an UIAssetSlotWidget is requesting a new asset, 33 | /// this propagates the new asset ID to the widget. 34 | void select_asset(AUID assetID); 35 | }; 36 | 37 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/AudioMixer/Lib/AudioCommand.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // Instead of trying to come up with a (hopefully correct) lock free queue ourselves, 6 | // maybe it's better to just use existing battle tested solutions. 7 | // https://moodycamel.com/blog/2013/a-fast-lock-free-queue-for-c++ 8 | #include 9 | 10 | namespace LD { 11 | 12 | /// @brief Use a lock-free queue that the audio thread can dequeue (or fail to dequeue) 13 | /// in a bounded amount of time. 14 | struct AudioCommandQueueObj 15 | { 16 | AudioCommandQueueObj(size_t capacity) 17 | : lockFreeQueue(capacity) {} 18 | 19 | moodycamel::ReaderWriterQueue lockFreeQueue; 20 | }; 21 | 22 | AudioCommandQueue AudioCommandQueue::create(const AudioCommandQueueInfo& info) 23 | { 24 | auto* obj = heap_new(MEMORY_USAGE_AUDIO, info.capacity); 25 | 26 | return AudioCommandQueue(obj); 27 | } 28 | 29 | void AudioCommandQueue::destroy(AudioCommandQueue queue) 30 | { 31 | auto* obj = (AudioCommandQueueObj*)queue.unwrap(); 32 | 33 | heap_delete(obj); 34 | } 35 | 36 | bool AudioCommandQueue::enqueue(const AudioCommand& cmd) 37 | { 38 | return mObj->lockFreeQueue.try_enqueue(cmd); 39 | } 40 | 41 | bool AudioCommandQueue::dequeue(AudioCommand& cmd) 42 | { 43 | return mObj->lockFreeQueue.try_dequeue(cmd); 44 | } 45 | 46 | } // namespace LD -------------------------------------------------------------------------------- /Include/Ludens/System/FileWatcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace LD { 7 | 8 | struct FileWatcher : Handle 9 | { 10 | typedef void (*on_modify_callback)(const FS::Path& path, void* user); 11 | 12 | /// @brief create a file watcher 13 | /// @return a new file watcher handle 14 | static FileWatcher create(); 15 | 16 | /// @brief destroy a file watcher 17 | /// @param watcher a file watcher handle 18 | static void destroy(FileWatcher watcher); 19 | 20 | /// @brief add a file to watch, multiple callbacks can be added to the same file. 21 | /// @param path file path to watch 22 | /// @param callback user callback when the file is modified 23 | /// @param user arbitrary user data 24 | void add_file(const FS::Path& path, on_modify_callback callback, void* user); 25 | 26 | /// @brief remove all watcher callbacks associated with file 27 | /// @param path file path currently being watched 28 | void remove_file(const FS::Path& path); 29 | 30 | /// @brief checks if a file is already being watched 31 | /// @param path file path to query 32 | /// @return number of callbacks associated with file path 33 | int has_file(const FS::Path& path); 34 | 35 | /// @brief asynchronous poll to check if files are modified, 36 | /// blocks until all user callbacks are completed. 37 | void poll(); 38 | }; 39 | 40 | } // namespace LD -------------------------------------------------------------------------------- /LDEditor/EditorContext/Lib/EditorAction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace LD { 5 | 6 | /// @brief Editor action queue implementation. 7 | struct EditorActionQueueObj 8 | { 9 | std::queue actionQueue; 10 | EditStack editStack; 11 | void* user; 12 | }; 13 | 14 | static EditorActionInfo sActions[EDITOR_ACTION_ENUM_COUNT]; 15 | 16 | void EditorAction::register_action(const EditorActionInfo& info) 17 | { 18 | sActions[(int)info.type] = info; 19 | } 20 | 21 | EditorActionQueue EditorActionQueue::create(EditStack stack, void* user) 22 | { 23 | auto* obj = heap_new(MEMORY_USAGE_MISC); 24 | obj->editStack = stack; 25 | obj->user = user; 26 | 27 | return EditorActionQueue(obj); 28 | } 29 | 30 | void EditorActionQueue::destroy(EditorActionQueue queue) 31 | { 32 | auto* obj = queue.unwrap(); 33 | 34 | heap_delete(obj); 35 | } 36 | 37 | void EditorActionQueue::enqueue(EditorActionType type) 38 | { 39 | mObj->actionQueue.push(type); 40 | } 41 | 42 | void EditorActionQueue::poll_actions() 43 | { 44 | while (!mObj->actionQueue.empty()) 45 | { 46 | EditorActionType type = mObj->actionQueue.front(); 47 | mObj->actionQueue.pop(); 48 | 49 | if (sActions[(int)type].action) 50 | { 51 | sActions[(int)type].action(mObj->editStack, mObj->user); 52 | } 53 | } 54 | } 55 | 56 | } // namespace LD 57 | -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Layout/RMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace LD { 11 | 12 | struct RMeshPrimitive 13 | { 14 | uint32_t indexStart; 15 | uint32_t indexCount; 16 | uint32_t matIndex; 17 | }; 18 | 19 | /// @brief renderer friendly layout of a rigid mesh. 20 | class RMesh 21 | { 22 | public: 23 | RDevice device; 24 | RSetPool setPool; 25 | RBuffer vbo; 26 | RBuffer ibo; 27 | RImage* textures; 28 | RImage dummyTexture; 29 | RMaterial* mats; 30 | RMeshPrimitive* prims; 31 | uint32_t vertexCount; 32 | uint32_t indexCount; 33 | uint32_t textureCount; 34 | uint32_t matCount; 35 | uint32_t primCount; 36 | 37 | inline operator bool() const { return (bool)device; } 38 | 39 | void create_from_media(RDevice device, RStager& stager, Model& model); 40 | void create_from_binary(RDevice device, RStager& stager, ModelBinary& bin); 41 | void destroy(); 42 | 43 | private: 44 | void upload(RStager& stager, uint32_t textureCount, const Bitmap* textureData, 45 | uint32_t matCount, const MeshMaterial* matData, 46 | uint32_t vertexCount, const MeshVertex* vertexData, 47 | uint32_t indexCount, const uint32_t* indexData); 48 | }; 49 | 50 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/Camera/Test/TestPerspective.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace LD; 8 | 9 | TEST_CASE("Perspective screen_to_world_size") 10 | { 11 | const float screenW = 1600.0f; 12 | const float screenH = 900.0f; 13 | CameraPerspectiveInfo camI{}; 14 | camI.aspectRatio = screenW / screenH; 15 | camI.fov = LD_PI_2; // 90 degrees 16 | camI.nearClip = 0.01f; 17 | camI.farClip = 100.0f; 18 | Camera cam = Camera::create(camI, Vec3(0.0f)); 19 | cam.set_pos(Vec3(0.0f, 0.0f, 10.0f)); 20 | 21 | // view depth 10, desire half screen height 22 | float worldSize = cam.screen_to_world_size(Vec3(0.0f), screenH, 450.0f); 23 | CHECK(is_equal_epsilon(worldSize, 10.0f)); 24 | 25 | // view depth 10, desire full screen height 26 | worldSize = cam.screen_to_world_size(Vec3(0.0f), screenH, 900.0f); 27 | CHECK(is_equal_epsilon(worldSize, 20.0f)); 28 | 29 | // view depth 100, desire half screen height 30 | worldSize = cam.screen_to_world_size(Vec3(0.0f, 0.0f, -90.0f), screenH, 450.0f); 31 | CHECK(is_equal_epsilon(worldSize, 100.0f)); 32 | 33 | // view depth 100, camera not aligned, desire half screen height 34 | worldSize = cam.screen_to_world_size(Vec3(123.0f, 456.0f, -90.0f), screenH, 450.0f); 35 | CHECK(is_equal_epsilon(worldSize, 100.0f)); 36 | 37 | // TODO: worldSize can be negative due to dot product 38 | 39 | Camera::destroy(cam); 40 | } 41 | -------------------------------------------------------------------------------- /LDCore/DSA/Test/DSATest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace { 4 | 5 | /// @brief A copyable, movable type for testing 6 | struct Foo 7 | { 8 | int value; 9 | 10 | static int sCtor; 11 | static int sDtor; 12 | static int sCopyCtor; 13 | static int sCopyAssign; 14 | static int sMoveCtor; 15 | static int sMoveAssign; 16 | 17 | Foo() : value(0) 18 | { 19 | sCtor++; 20 | } 21 | 22 | explicit Foo(int value) : value(value) 23 | { 24 | sCtor++; 25 | } 26 | 27 | Foo(const Foo& other) : value(other.value) 28 | { 29 | sCopyCtor++; 30 | } 31 | 32 | Foo(Foo&& other) : value(other.value) 33 | { 34 | sMoveCtor++; 35 | } 36 | 37 | ~Foo() 38 | { 39 | sDtor++; 40 | } 41 | 42 | Foo& operator=(const Foo& other) 43 | { 44 | value = other.value; 45 | sCopyAssign++; 46 | return *this; 47 | } 48 | 49 | Foo& operator=(Foo&& other) 50 | { 51 | value = other.value; 52 | sMoveAssign++; 53 | return *this; 54 | } 55 | 56 | Foo& operator=(int v) 57 | { 58 | value = v; 59 | return *this; 60 | } 61 | 62 | bool operator==(int v) const 63 | { 64 | return value == v; 65 | } 66 | 67 | static void reset() 68 | { 69 | sCtor = 0; 70 | sDtor = 0; 71 | sCopyCtor = 0; 72 | sCopyAssign = 0; 73 | sMoveCtor = 0; 74 | sMoveAssign = 0; 75 | } 76 | }; 77 | 78 | } // namespace -------------------------------------------------------------------------------- /LDCore/Serial/Test/CompressionTest.cpp: -------------------------------------------------------------------------------- 1 | #include "Extra/doctest/doctest.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace LD; 8 | 9 | namespace { 10 | 11 | const char sTinyPayload[] = "tiny payload"; 12 | 13 | } // namespace 14 | 15 | TEST_CASE("zstd") 16 | { 17 | size_t size = strlen(sTinyPayload); 18 | size_t bound = LD::zstd_compress_bound(size); 19 | 20 | constexpr int compressionLevel = 3; 21 | std::vector compressed(bound); 22 | size_t compressedSize = LD::zstd_compress(compressed.data(), compressed.size(), (const void*)sTinyPayload, size, compressionLevel); 23 | compressed.resize(compressedSize); 24 | 25 | std::string restore; 26 | restore.resize(size); 27 | 28 | LD::zstd_decompress(restore.data(), restore.size(), compressed.data(), compressed.size()); 29 | 30 | CHECK(restore == std::string(sTinyPayload)); 31 | } 32 | 33 | TEST_CASE("lz4") 34 | { 35 | size_t size = strlen(sTinyPayload); 36 | size_t bound = LD::lz4_compress_bound(size); 37 | 38 | std::vector compressed(bound); 39 | size_t compressedSize = LD::lz4_compress(compressed.data(), compressed.size(), (const void*)sTinyPayload, size); 40 | compressed.resize(compressedSize); 41 | 42 | std::string restore; 43 | restore.resize(size); 44 | 45 | LD::lz4_decompress(restore.data(), restore.size(), compressed.data(), compressed.size()); 46 | 47 | CHECK(restore == std::string(sTinyPayload)); 48 | } 49 | -------------------------------------------------------------------------------- /Include/Ludens/RenderComponent/Pipeline/RMeshPipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace LD { 9 | 10 | /// @brief pipeline for rendering MeshVertex with Blinn-Phong lighting 11 | struct RMeshBlinnPhongPipeline : Handle 12 | { 13 | struct PushConstant 14 | { 15 | Mat4 model; /// model matrix transformation 16 | uint32_t id; /// lower 16-bit written to the id-flag attachment 17 | uint32_t flags; /// lower 16-bit written to the id-flag attachment 18 | }; 19 | 20 | static RMeshBlinnPhongPipeline create(RDevice device); 21 | static void destroy(RMeshBlinnPhongPipeline pipeline); 22 | 23 | RPipeline handle(); 24 | }; 25 | 26 | /// @brief pipeline for rendering MeshVertex with flat ambient lighting 27 | struct RMeshAmbientPipeline : Handle 28 | { 29 | struct PushConstant 30 | { 31 | Mat4 model; /// model matrix transformation 32 | uint32_t id; /// lower 16-bit written to the id-flag attachment 33 | uint32_t flags; /// lower 16-bit written to the id-flag attachment 34 | Vec4 ambient; /// flat ambient color of the mesh 35 | }; 36 | 37 | static RMeshAmbientPipeline create(RDevice device); 38 | static void destroy(RMeshAmbientPipeline pipeline); 39 | 40 | RPipeline handle(); 41 | }; 42 | 43 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lj_obj.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Miscellaneous object handling. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_obj_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Object type names. */ 12 | LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ 13 | "no value", "nil", "boolean", "userdata", "number", "string", 14 | "table", "function", "userdata", "thread", "proto", "cdata" 15 | }; 16 | 17 | LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ 18 | "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", 19 | "proto", "function", "trace", "cdata", "table", "userdata", "number" 20 | }; 21 | 22 | /* Compare two objects without calling metamethods. */ 23 | int LJ_FASTCALL lj_obj_equal(cTValue *o1, cTValue *o2) 24 | { 25 | if (itype(o1) == itype(o2)) { 26 | if (tvispri(o1)) 27 | return 1; 28 | if (!tvisnum(o1)) 29 | return gcrefeq(o1->gcr, o2->gcr); 30 | } else if (!tvisnumber(o1) || !tvisnumber(o2)) { 31 | return 0; 32 | } 33 | return numberVnum(o1) == numberVnum(o2); 34 | } 35 | 36 | /* Return pointer to object or its object data. */ 37 | const void * LJ_FASTCALL lj_obj_ptr(global_State *g, cTValue *o) 38 | { 39 | UNUSED(g); 40 | if (tvisudata(o)) 41 | return uddata(udataV(o)); 42 | else if (tvislightud(o)) 43 | return lightudV(g, o); 44 | else if (LJ_HASFFI && tviscdata(o)) 45 | return cdataptr(cdataV(o)); 46 | else if (tvisgcv(o)) 47 | return gcV(o); 48 | else 49 | return NULL; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /LDEditor/EditorContext/Lib/EditorIconAtlas.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define ICON_SIZE 48 4 | #define ATLAS_WIDTH 512.0f 5 | #define ATLAS_HEIGHT 512.0f 6 | 7 | namespace LD { 8 | 9 | // clang-format off 10 | struct 11 | { 12 | EditorIcon icon; 13 | Vec2 pos; 14 | } sIconTable[] = { 15 | { EditorIcon::Folder, Vec2(288, 96) }, 16 | { EditorIcon::Description, Vec2(240, 96) }, 17 | { EditorIcon::Close, Vec2(240, 144) }, 18 | { EditorIcon::Remove, Vec2(288, 0) }, 19 | { EditorIcon::Transform, Vec2(192, 192) }, 20 | { EditorIcon::Refresh, Vec2(384, 144) }, 21 | { EditorIcon::LinearScale, Vec2(0, 240) }, 22 | { EditorIcon::PlayArrow, Vec2(48, 0) }, 23 | { EditorIcon::Code, Vec2(48, 48) }, 24 | { EditorIcon::ArrowBack, Vec2(0, 144) }, 25 | { EditorIcon::ArrowDownward, Vec2(48, 144) }, 26 | { EditorIcon::ArrowForward, Vec2(96, 144) }, 27 | { EditorIcon::ArrowUpward, Vec2(144, 144) }, 28 | }; 29 | // clang-format on 30 | 31 | static_assert(sizeof(sIconTable) / sizeof(*sIconTable) == (int)EditorIcon::ENUM_COUNT); 32 | 33 | Rect EditorIconAtlas::get_icon_rect(EditorIcon icon) 34 | { 35 | Vec2 pos = sIconTable[(int)icon].pos; 36 | 37 | return Rect(pos.x, pos.y, ICON_SIZE, ICON_SIZE); 38 | } 39 | 40 | Rect EditorIconAtlas::get_icon_rect_uv(EditorIcon icon) 41 | { 42 | Rect rect = get_icon_rect(icon); 43 | 44 | return Rect(rect.x / ATLAS_WIDTH, rect.y / ATLAS_HEIGHT, rect.w / ATLAS_WIDTH, rect.h / ATLAS_HEIGHT); 45 | } 46 | 47 | } // namespace LD -------------------------------------------------------------------------------- /LDCore/RenderComponent/Lib/Layout/VertexLayouts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace LD { 5 | 6 | // clang-format off 7 | const Vec3 sCubePos[36] = { 8 | {-1.0f, +1.0f, -1.0f}, 9 | {-1.0f, -1.0f, -1.0f}, 10 | {+1.0f, -1.0f, -1.0f}, 11 | {+1.0f, -1.0f, -1.0f}, 12 | {+1.0f, +1.0f, -1.0f}, 13 | {-1.0f, +1.0f, -1.0f}, 14 | 15 | {-1.0f, -1.0f, +1.0f}, 16 | {-1.0f, -1.0f, -1.0f}, 17 | {-1.0f, +1.0f, -1.0f}, 18 | {-1.0f, +1.0f, -1.0f}, 19 | {-1.0f, +1.0f, +1.0f}, 20 | {-1.0f, -1.0f, +1.0f}, 21 | 22 | {+1.0f, -1.0f, -1.0f}, 23 | {+1.0f, -1.0f, +1.0f}, 24 | {+1.0f, +1.0f, +1.0f}, 25 | {+1.0f, +1.0f, +1.0f}, 26 | {+1.0f, +1.0f, -1.0f}, 27 | {+1.0f, -1.0f, -1.0f}, 28 | 29 | {-1.0f, -1.0f, +1.0f}, 30 | {-1.0f, +1.0f, +1.0f}, 31 | {+1.0f, +1.0f, +1.0f}, 32 | {+1.0f, +1.0f, +1.0f}, 33 | {+1.0f, -1.0f, +1.0f}, 34 | {-1.0f, -1.0f, +1.0f}, 35 | 36 | {-1.0f, +1.0f, -1.0f}, 37 | {+1.0f, +1.0f, -1.0f}, 38 | {+1.0f, +1.0f, +1.0f}, 39 | {+1.0f, +1.0f, +1.0f}, 40 | {-1.0f, +1.0f, +1.0f}, 41 | {-1.0f, +1.0f, -1.0f}, 42 | 43 | {-1.0f, -1.0f, -1.0f}, 44 | {-1.0f, -1.0f, +1.0f}, 45 | {+1.0f, -1.0f, -1.0f}, 46 | {+1.0f, -1.0f, -1.0f}, 47 | {-1.0f, -1.0f, +1.0f}, 48 | {+1.0f, -1.0f, +1.0f}, 49 | }; 50 | // clang-format on 51 | 52 | void get_cube_mesh_vertex_attributes(Vec3* pos) 53 | { 54 | if (pos) 55 | { 56 | std::copy(sCubePos, sCubePos + 36, pos); 57 | } 58 | } 59 | 60 | } // namespace LD -------------------------------------------------------------------------------- /Extra/luajit/src/lib_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Library initialization. 3 | ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h 4 | ** 5 | ** Major parts taken verbatim from the Lua interpreter. 6 | ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h 7 | */ 8 | 9 | #define lib_init_c 10 | #define LUA_LIB 11 | 12 | #include "lua.h" 13 | #include "lauxlib.h" 14 | #include "lualib.h" 15 | 16 | #include "lj_arch.h" 17 | 18 | static const luaL_Reg lj_lib_load[] = { 19 | { "", luaopen_base }, 20 | { LUA_LOADLIBNAME, luaopen_package }, 21 | { LUA_TABLIBNAME, luaopen_table }, 22 | { LUA_IOLIBNAME, luaopen_io }, 23 | { LUA_OSLIBNAME, luaopen_os }, 24 | { LUA_STRLIBNAME, luaopen_string }, 25 | { LUA_MATHLIBNAME, luaopen_math }, 26 | { LUA_DBLIBNAME, luaopen_debug }, 27 | { LUA_BITLIBNAME, luaopen_bit }, 28 | { LUA_JITLIBNAME, luaopen_jit }, 29 | { NULL, NULL } 30 | }; 31 | 32 | static const luaL_Reg lj_lib_preload[] = { 33 | #if LJ_HASFFI 34 | { LUA_FFILIBNAME, luaopen_ffi }, 35 | #endif 36 | { NULL, NULL } 37 | }; 38 | 39 | LUALIB_API void luaL_openlibs(lua_State *L) 40 | { 41 | const luaL_Reg *lib; 42 | for (lib = lj_lib_load; lib->func; lib++) { 43 | lua_pushcfunction(L, lib->func); 44 | lua_pushstring(L, lib->name); 45 | lua_call(L, 1, 0); 46 | } 47 | luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 48 | sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); 49 | for (lib = lj_lib_preload; lib->func; lib++) { 50 | lua_pushcfunction(L, lib->func); 51 | lua_setfield(L, -2, lib->name); 52 | } 53 | lua_pop(L, 1); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Include/Ludens/Asset/AssetType/Texture2DAsset.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LD { 10 | 11 | enum TextureCompression 12 | { 13 | /// @brief LZ4 compressed bitmap 14 | TEXTURE_COMPRESSION_LZ4 = 0, 15 | }; 16 | 17 | /// @brief Texture2D asset handle. 18 | struct Texture2DAsset : AssetHandle 19 | { 20 | /// @brief Unload asset from RAM. 21 | void unload(); 22 | 23 | /// @brief Get desired texture sampling mode. 24 | RSamplerInfo get_sampler_hint() const; 25 | }; 26 | 27 | struct Texture2DAssetImportInfo 28 | { 29 | RSamplerInfo samplerHint; /// desired texture sampler mode 30 | TextureCompression compression; /// desired asset compression 31 | std::filesystem::path sourcePath; /// path to load the source format 32 | std::filesystem::path savePath; /// path to save the imported format 33 | }; 34 | 35 | /// @brief Creates Texture2DAsset from source file, 36 | /// and saves the imported asset to disk. 37 | class Texture2DAssetImportJob 38 | { 39 | public: 40 | Texture2DAsset asset; /// subject asset handle 41 | Texture2DAssetImportInfo info; /// import configuration 42 | 43 | /// @brief Submit to job system. Address of this job instance must not 44 | /// change until the worker thread completes execution. 45 | void submit(); 46 | 47 | private: 48 | static void execute(void*); 49 | 50 | JobHeader mHeader; 51 | }; 52 | 53 | } // namespace LD --------------------------------------------------------------------------------