diff --git a/CMakeLists.txt b/CMakeLists.txt index 105a7c68..3824f922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ else() set(DL_DISABLE_AUDIO false) set(DL_DISABLE_OPENSSL false) set(DL_DISABLE_CURL false) - set(DL_DISABLE_CONSOLE false) + set(DL_DISABLE_CONSOLE false) # 仅控制是否有控制台 set(DL_USE_MT false) endif() @@ -144,23 +144,30 @@ add_subdirectory ("dl") if(NOT DL_DISABLE_RENDER) message("------------------解析dl_test-----------------------") add_subdirectory ("project/dl_test") + + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_editor/CMakeLists.txt) + message("------------------解析dl_editor-----------------------") + add_subdirectory ("project/dl_editor") + endif() + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_midi/CMakeLists.txt) + message("------------------解析dl_midi-----------------------") + add_subdirectory ("project/dl_midi") + endif() + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_chess/CMakeLists.txt) + message("------------------解析dl_chess-----------------------") + add_subdirectory ("project/dl_chess") + endif() + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_snake/CMakeLists.txt) + message("------------------解析dl_snake-----------------------") + add_subdirectory ("project/dl_snake") + endif() endif() + message("------------------解析dl_console-----------------------") add_subdirectory ("project/dl_console") - -if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_editor/CMakeLists.txt) - message("------------------解析dl_editor-----------------------") - add_subdirectory ("project/dl_editor") -endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_midi/CMakeLists.txt) - message("------------------解析dl_midi-----------------------") - add_subdirectory ("project/dl_midi") -endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_chess/CMakeLists.txt) - message("------------------解析dl_chess-----------------------") - add_subdirectory ("project/dl_chess") -endif() if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_config/CMakeLists.txt) message("------------------解析dl_config-----------------------") add_subdirectory ("project/dl_config") endif() + + diff --git a/dl/math/dl_random.h b/dl/math/dl_random.h index 7b7816f4..bb287518 100644 --- a/dl/math/dl_random.h +++ b/dl/math/dl_random.h @@ -84,6 +84,11 @@ public: return Integer(min, max); } + static unsigned Uint(unsigned min, unsigned max) + { + return Integer(min, max); + } + /** * @brief 从容器随机选择一个 * @param[in] container 容器(不能为空) diff --git a/dl/render/dl_factory.h b/dl/render/dl_factory.h index 50e69709..cda07134 100644 --- a/dl/render/dl_factory.h +++ b/dl/render/dl_factory.h @@ -151,6 +151,7 @@ public: /** * @brief 创建默认精灵 */ + [[nodiscard]] gcSprite CreateSpriteDefault(const Color& col = ColorDef::WHITE); /** diff --git a/dl/system/dl_midi.cpp b/dl/system/dl_midi.cpp index 0ea7f058..3a1de5bc 100644 --- a/dl/system/dl_midi.cpp +++ b/dl/system/dl_midi.cpp @@ -54,7 +54,7 @@ namespace dl // message[1] = 64; // message[2] = 91; // _out->sendMessage(&message); - // std::this_thread::sleep_for(std::chrono::milliseconds(500)); + // std::this_thread::sleep_for(std::chrono::milliseconds(500)); // message[0] = 128; // message[1] = 70; // message[2] = 40; @@ -98,4 +98,10 @@ namespace dl _imp->_out->sendMessage((unsigned char*)buf.data(), buf.size()); } + void Midi::PlayC() + { + /*unsigned char + _imp->_out->sendMessage(,);*/ + } + } diff --git a/dl/system/dl_midi.h b/dl/system/dl_midi.h index 42e27936..5dce25a5 100644 --- a/dl/system/dl_midi.h +++ b/dl/system/dl_midi.h @@ -24,6 +24,7 @@ public: ~Midi(); void Play(BufferView buf); + void PlayC(); private: MidiImp* _imp; }; diff --git a/dl/vk/dl_vertex.h b/dl/vk/dl_vertex.h index 25ed16cb..71f0c6a0 100644 --- a/dl/vk/dl_vertex.h +++ b/dl/vk/dl_vertex.h @@ -22,8 +22,8 @@ namespace dl struct Vertex { Position3 _pos; - Position3 _normal; Position2 _uv; + Position3 _normal; Position3 _tangent; static VkVertexInputBindingDescription getBindingDescription() { @@ -36,22 +36,26 @@ struct Vertex static std::array getAttributeDescriptions() { std::array attributeDescriptions{}; - attributeDescriptions[0].binding = 0; - attributeDescriptions[0].location = 0; - attributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[0].offset = offsetof(Vertex, _pos); - attributeDescriptions[1].binding = 0; - attributeDescriptions[1].location = 2; - attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[1].offset = offsetof(Vertex, _normal); - attributeDescriptions[2].binding = 0; - attributeDescriptions[2].location = 1; - attributeDescriptions[2].format = VK_FORMAT_R32G32_SFLOAT; - attributeDescriptions[2].offset = offsetof(Vertex, _uv); - attributeDescriptions[3].binding = 0; - attributeDescriptions[3].location = 3; - attributeDescriptions[3].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[3].offset = offsetof(Vertex, _tangent); + uint32_t i = 0; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _pos); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _uv); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _normal); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _tangent); return attributeDescriptions; } }; @@ -61,11 +65,12 @@ constexpr size_t NUM_BONE = 4; struct VertexBone { Position3 _pos; - Position3 _normal; Position2 _uv0; Position2 _uv1; - std::array _joint0; + Position3 _normal; + Position3 _tangent; Position4 _weight0; + std::array _joint0; Position4 _color; static VkVertexInputBindingDescription getBindingDescription() { @@ -75,19 +80,14 @@ struct VertexBone bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; return bindingDescription; } - static std::array getAttributeDescriptions() + static std::array getAttributeDescriptions() { - std::array attributeDescriptions{}; + std::array attributeDescriptions{}; uint32_t i = 0; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; attributeDescriptions[i].offset = offsetof(VertexBone, _pos); - ++i; - attributeDescriptions[i].binding = 0; - attributeDescriptions[i].location = i; - attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[i].offset = offsetof(VertexBone, _normal); ++i; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; @@ -98,6 +98,21 @@ struct VertexBone attributeDescriptions[i].location = i; attributeDescriptions[i].format = VK_FORMAT_R32G32_SFLOAT; attributeDescriptions[i].offset = offsetof(VertexBone, _uv1); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(VertexBone, _normal); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(VertexBone, _tangent); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; + attributeDescriptions[i].offset = offsetof(VertexBone, _weight0); ++i; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; @@ -106,12 +121,7 @@ struct VertexBone ++i; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; - attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_UINT; - attributeDescriptions[i].offset = offsetof(VertexBone, _weight0); - ++i; - attributeDescriptions[i].binding = 0; - attributeDescriptions[i].location = i; - attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_UINT; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; attributeDescriptions[i].offset = offsetof(VertexBone, _color); return attributeDescriptions; diff --git a/dl/vk/dl_vk.h b/dl/vk/dl_vk.h index cc7a3f26..fb2928b4 100644 --- a/dl/vk/dl_vk.h +++ b/dl/vk/dl_vk.h @@ -352,9 +352,9 @@ public: void* pUserData) { if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) - ;// log_test0(pCallbackData->pMessage); + log_test0(pCallbackData->pMessage); else if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) - log_info0(pCallbackData->pMessage);//提高了一个等级,方便断点 + log_info0(pCallbackData->pMessage); return VK_FALSE; } diff --git a/project/dl_midi b/project/dl_midi index ae96c815..7c18afc8 160000 --- a/project/dl_midi +++ b/project/dl_midi @@ -1 +1 @@ -Subproject commit ae96c81546a6b83c2e1e7a6c2309015602cb813f +Subproject commit 7c18afc83138da7df33f3f1f62ebd43da294a0b4 diff --git a/project/dl_test/CMakeLists.txt b/project/dl_test/CMakeLists.txt index 19586ae2..14884384 100644 --- a/project/dl_test/CMakeLists.txt +++ b/project/dl_test/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # 设置处理 if (DL_DISABLE_RENDER) - message(SEND_ERROR "dl_test必须启动绘图系统,将会编译失败(DL_DISABLE_RENDER)!") + message(SEND_ERROR ${PROJECT_NAME}"必须启动绘图系统,将会编译失败(DL_DISABLE_RENDER)!") endif() # dl目录 @@ -49,6 +49,10 @@ include_directories(${CMAKE_SOURCE_DIR}/third/tinyxml2) include_directories(${CMAKE_SOURCE_DIR}/third/asio/include) # angelscript include_directories(${CMAKE_SOURCE_DIR}/third/angelscript/angelscript/include) +# lua +include_directories(${CMAKE_SOURCE_DIR}/third/lua) +# lua bridge +include_directories(${CMAKE_SOURCE_DIR}/third/LuaBridge3/Source) # dl资源文件夹 set(DL_PATH_RES ${CMAKE_SOURCE_DIR}/res) diff --git a/project/dl_test/main.cpp b/project/dl_test/main.cpp index e4384ef0..8559158e 100644 --- a/project/dl_test/main.cpp +++ b/project/dl_test/main.cpp @@ -154,24 +154,24 @@ void Init() //g_factory->LoadModel("axis.glb", "axis"); // 脚本加载 - { - g_as->SetPathRoot("as/"); - std::vector vec; - File::GetPathFileAll("as/", vec, {}, false); - for (auto& iter : vec) - { - g_as->LoadModule(iter); - } - } - // mod加载 - { - std::vector vec; - File::GetPathFileAll("mod/", vec, {}, false); - for (auto& iter : vec) - { - g_mod->LoadMod(iter); - } - } + //{ + // g_as->SetPathRoot("as/"); + // std::vector vec; + // File::GetPathFileAll("as/", vec, {}, false); + // for (auto& iter : vec) + // { + // g_as->LoadModule(iter); + // } + //} + //// mod加载 + //{ + // std::vector vec; + // File::GetPathFileAll("mod/", vec, {}, false); + // for (auto& iter : vec) + // { + // g_mod->LoadMod(iter); + // } + //} g_ui->SetStandardSize({ 800, 600 }); g_ui->RegisterAll("ui/"); diff --git a/project/dl_test/ui_main.cpp b/project/dl_test/ui_main.cpp index 2b9c404f..02d84e7d 100644 --- a/project/dl_test/ui_main.cpp +++ b/project/dl_test/ui_main.cpp @@ -49,8 +49,8 @@ UIMain::UIMain() _ruler = Tool::Ruler::Create(); - g_as->ExcuteFunction("mod管理器", "UI::Panel@ initUI(string)", - _panelMod, std::string{ "dddddddddd" }); + /*g_as->ExcuteFunction("mod管理器", "UI::Panel@ initUI(string)", + _panelMod, std::string{ "dddddddddd" });*/ int x = 3; } diff --git a/res/dl/shader/vert_bone.spv b/res/dl/shader/vert_bone.spv index c30d0463..a5d307a9 100644 Binary files a/res/dl/shader/vert_bone.spv and b/res/dl/shader/vert_bone.spv differ diff --git a/shader/compile_copy.bat b/shader/compile_copy.bat index 075233f0..68c2dd1c 100644 --- a/shader/compile_copy.bat +++ b/shader/compile_copy.bat @@ -1,30 +1,30 @@ ::3d普通 -glslc.exe shader.vert -o vert.spv -glslc.exe shader.frag -o frag.spv -copy vert.spv ..\res\shader\ -copy frag.spv ..\res\shader\ +glslc.exe shader_pbr.vert -o vert.spv +glslc.exe shader_pbr.frag -o frag.spv +copy vert.spv ..\res\dl\shader\ +copy frag.spv ..\res\dl\shader\ del vert.spv del frag.spv ::3d骨骼 -glslc.exe shader.vert -D=BONE -o vert_bone.spv -glslc.exe shader.frag -D=BONE -o frag_bone.spv -copy vert_bone.spv ..\res\shader\ -copy frag_bone.spv ..\res\shader\ +glslc.exe shader_pbr.vert -D=BONE -o vert_bone.spv +glslc.exe shader_pbr.frag -D=BONE -o frag_bone.spv +copy vert_bone.spv ..\res\dl\shader\ +copy frag_bone.spv ..\res\dl\shader\ del vert_bone.spv del frag_bone.spv glslc.exe shader_2d.vert -o vert_2d.spv glslc.exe shader_2d.frag -o frag_2d.spv -copy vert_2d.spv ..\res\shader\ -copy frag_2d.spv ..\res\shader\ +copy vert_2d.spv ..\res\dl\shader\ +copy frag_2d.spv ..\res\dl\shader\ del vert_2d.spv del frag_2d.spv glslc.exe shader_gfx.vert -o vert_gfx.spv glslc.exe shader_gfx.frag -o frag_gfx.spv -copy vert_gfx.spv ..\res\shader\ -copy frag_gfx.spv ..\res\shader\ +copy vert_gfx.spv ..\res\dl\shader\ +copy frag_gfx.spv ..\res\dl\shader\ del vert_gfx.spv del frag_gfx.spv diff --git a/shader/shader.vert b/shader/shader.vert index e4b37822..a49fafe1 100644 --- a/shader/shader.vert +++ b/shader/shader.vert @@ -20,12 +20,14 @@ layout (set = 1, binding = 0) uniform UniformBufferBone layout(location = 0) in vec3 inPosition; -layout(location = 1) in vec2 inTexCoord; -layout(location = 2) in vec3 inNormal; +layout(location = 1) in vec3 inNormal; +layout(location = 2) in vec2 inTexCoord; layout(location = 3) in vec3 inTangent; #ifdef BONE layout(location = 4) in vec4 boneWeight; layout(location = 5) in uvec4 boneIndex; +layout(location = 6) in vec2 inTexCoord1; +layout(location = 7) in vec4 inColor; #endif layout(location = 0) out vec3 fragColor; diff --git a/shader/shader_pbr.vert b/shader/shader_pbr.vert index 1dd9cac7..c53b525c 100644 --- a/shader/shader_pbr.vert +++ b/shader/shader_pbr.vert @@ -19,13 +19,20 @@ layout (set = 1, binding = 0) uniform UniformBufferBone #endif +#ifdef BONE +layout(location = 0) in vec3 inPosition; +layout(location = 1) in vec2 inTexCoord; +layout(location = 2) in vec2 inTexCoord1; +layout(location = 3) in vec3 inNormal; +layout(location = 4) in vec3 inTangent; +layout(location = 5) in vec3 boneWeight; +layout(location = 6) in uvec4 boneIndex; +layout(location = 7) in vec4 inColor; +#else layout(location = 0) in vec3 inPosition; layout(location = 1) in vec2 inTexCoord; layout(location = 2) in vec3 inNormal; layout(location = 3) in vec3 inTangent; -#ifdef BONE -layout(location = 4) in vec3 boneWeight; -layout(location = 5) in uvec4 boneIndex; #endif layout(location = 0) out vec3 fragColor;