diff --git a/Fostbite2D/include/fostbite2D/core/color.h b/Fostbite2D/include/fostbite2D/core/color.h index cc96804..584caea 100644 --- a/Fostbite2D/include/fostbite2D/core/color.h +++ b/Fostbite2D/include/fostbite2D/core/color.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/Fostbite2D/src/main.cpp b/Fostbite2D/src/main.cpp index 985952b..1bc4086 100644 --- a/Fostbite2D/src/main.cpp +++ b/Fostbite2D/src/main.cpp @@ -49,7 +49,11 @@ int main(int argc, char **argv) { } // 加载字体(使用系统默认字体或项目字体) +#ifdef _WIN32 std::string fontPath = "C:/Windows/Fonts/arial.ttf"; // Windows 系统字体 +#else + std::string fontPath = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"; // Linux 系统字体 +#endif FontAtlas *font = nullptr; // 尝试加载字体 diff --git a/platform/linux.lua b/platform/linux.lua index 11fa0eb..f187952 100644 --- a/platform/linux.lua +++ b/platform/linux.lua @@ -10,4 +10,59 @@ target("Frostbite2D") add_packages("libsdl2") add_packages("glm") + + -- 复制着色器文件到输出目录 + after_build(function (target) + -- 复制 shaders 目录 + local shaders_dir = path.join(os.projectdir(), "shaders") + local output_dir = target:targetdir() + local target_shaders_dir = path.join(output_dir, "shaders") + + if os.isdir(shaders_dir) then + -- 确保目标目录存在 + if not os.isdir(target_shaders_dir) then + os.mkdir(target_shaders_dir) + end + + -- 复制所有着色器文件 + for _, file in ipairs(os.files(path.join(shaders_dir, "*.*"))) do + local filename = path.filename(file) + local target_file = path.join(target_shaders_dir, filename) + os.cp(file, target_file) + end + end + + -- 复制 SDL2 DLL + local sdl2_lib = target:pkg("libsdl2") + if sdl2_lib then + local libfiles = sdl2_lib:get("libfiles") + if libfiles then + for _, libfile in ipairs(libfiles) do + -- 查找 DLL 文件 + if libfile:endswith(".dll") then + local target_dll = path.join(output_dir, path.filename(libfile)) + os.cp(libfile, target_dll) + print("Copy DLL: " .. path.filename(libfile)) + end + end + end + end + + -- 尝试从 xmake 包目录复制 SDL2.dll + local sdl2_dll_paths = { + path.join(os.getenv("USERPROFILE") or "", ".xmake/packages/l/libsdl2/**/bin/SDL2.dll"), + path.join(os.getenv("USERPROFILE") or "", ".xmake/packages/l/libsdl2/**/lib/SDL2.dll"), + } + + for _, dll_pattern in ipairs(sdl2_dll_paths) do + local dll_files = os.files(dll_pattern) + for _, dll_file in ipairs(dll_files) do + local target_dll = path.join(output_dir, "SDL2.dll") + if not os.isfile(target_dll) then + os.cp(dll_file, target_dll) + print("Copy SDL2.dll from: " .. dll_file) + end + end + end + end) target_end()