From a1e68c878bdf5f0c50a9a23d4e215abf67a37b43 Mon Sep 17 00:00:00 2001 From: tzdwindows 7 <3076584115@qq.com> Date: Fri, 14 Nov 2025 20:39:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E9=9B=86=E6=88=90RenderSystem?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E6=9E=84=E5=BB=BA=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加VIVID_2D_MYDLL_API宏定义支持动态链接库导出- 引入RenderSystem头文件及系统模块 - 实现RenderSystem静态方法调用逻辑 - 添加渲染指令记录与回放功能演示- 配置项目属性包含路径和外部依赖 - 更新Release模式下的库目录和依赖项设置 - 移除原有注释说明改用功能模块划分方式呈现代码结构 --- Vivid2D/Vivid2D.cpp | 65 ++++++++++++++++++++++++++--------------- Vivid2D/Vivid2D.vcxproj | 6 ++++ 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/Vivid2D/Vivid2D.cpp b/Vivid2D/Vivid2D.cpp index 151a96e..95437ce 100644 --- a/Vivid2D/Vivid2D.cpp +++ b/Vivid2D/Vivid2D.cpp @@ -1,37 +1,56 @@ // Vivid2D.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // -// 包含GLM主头文件 +#ifdef VIVID_2D_MYDLL_API +#undef VIVID_2D_MYDLL_API +#endif +#define VIVID_2D_MYDLL_API __declspec(dllexport) + #include -// 包含vec2定义 #include #include +#include int main() { - // 创建一个二维浮点向量 (Vector2f) + // ---------------------------------------------------- + // GLM 向量操作 (与 RenderSystem 无关,保持原样) + // ---------------------------------------------------- glm::vec2 position(100.0f, 200.0f); - - // 创建另一个向量代表速度 glm::vec2 velocity(5.0f, -2.0f); - - // 向量加法,更新位置 position += velocity; - - // 输出新的位置 - // GLM的向量可以直接用std::cout输出,但需要包含 - // 这里为了简单,我们手动输出 std::cout << "New Position: (" << position.x << ", " << position.y << ")" << std::endl; + std::cout << "---------------------------------------" << std::endl; + + + // ---------------------------------------------------- + // RenderSystem 静态方法调用 (无需实例化) + // ---------------------------------------------------- + + // 1. 初始化日志系统 (假设已实现) + std::cout << "Initializing RenderSystem Logging..." << std::endl; + RenderSystem::InitializeLogging(); + + // 2. 开始渲染线程初始化阶段 (假设已实现) + RenderSystem::beginInitialization(); + + // 3. 记录一个渲染指令到队列中 + std::cout << "Recording a clear color command..." << std::endl; + // 这是一个 lambda 函数,捕获了要执行的 GL 命令 + RenderSystem::recordRenderCall([]() { + // 在实际的 RenderSystem 实现中,这会调用 glClearColor(1.0f, 0.5f, 0.0f, 1.0f); + std::cout << "-> (Render Thread) Executing glClearColor(Orange)" << std::endl; + }); + + // 4. 执行队列中的渲染指令 + std::cout << "Replaying render queue (" << RenderSystem::getQueueSize() << " calls)..." << std::endl; + RenderSystem::replayQueue(); // 假设这个调用会执行上面的 lambda + + // 5. 结束初始化阶段 + RenderSystem::finishInitialization(); + + // 6. 关闭日志系统 (确保日志被刷新) + std::cout << "Shutting down RenderSystem Logging." << std::endl; + RenderSystem::ShutdownLogging(); return 0; -} - -// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单 -// 调试程序: F5 或调试 >“开始调试”菜单 - -// 入门使用技巧: -// 1. 使用解决方案资源管理器窗口添加/管理文件 -// 2. 使用团队资源管理器窗口连接到源代码管理 -// 3. 使用输出窗口查看生成输出和其他消息 -// 4. 使用错误列表窗口查看错误 -// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 -// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件 +} \ No newline at end of file diff --git a/Vivid2D/Vivid2D.vcxproj b/Vivid2D/Vivid2D.vcxproj index 40e49cf..4e75e7e 100644 --- a/Vivid2D/Vivid2D.vcxproj +++ b/Vivid2D/Vivid2D.vcxproj @@ -70,6 +70,10 @@ + + $(SolutionDir)x64\Release\include;$(IncludePath) + $(SolutionDir)x64\Release\include;$(ExternalIncludePath) + Level3 @@ -124,6 +128,8 @@ true true true + $(SolutionDir)x64\Release;%(AdditionalLibraryDirectories) + Vivid2DRenderer.lib;%(AdditionalDependencies)