feat(core): 集成RenderSystem并优化构建配置
- 添加VIVID_2D_MYDLL_API宏定义支持动态链接库导出- 引入RenderSystem头文件及系统模块 - 实现RenderSystem静态方法调用逻辑 - 添加渲染指令记录与回放功能演示- 配置项目属性包含路径和外部依赖 - 更新Release模式下的库目录和依赖项设置 - 移除原有注释说明改用功能模块划分方式呈现代码结构
This commit is contained in:
@@ -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 <glm/glm.hpp>
|
||||
// 包含vec2定义
|
||||
#include <iostream>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <systems/RenderSystem.h>
|
||||
|
||||
int main() {
|
||||
// 创建一个二维浮点向量 (Vector2f)
|
||||
// ----------------------------------------------------
|
||||
// GLM 向量操作 (与 RenderSystem 无关,保持原样)
|
||||
// ----------------------------------------------------
|
||||
glm::vec2 position(100.0f, 200.0f);
|
||||
|
||||
// 创建另一个向量代表速度
|
||||
glm::vec2 velocity(5.0f, -2.0f);
|
||||
|
||||
// 向量加法,更新位置
|
||||
position += velocity;
|
||||
|
||||
// 输出新的位置
|
||||
// GLM的向量可以直接用std::cout输出,但需要包含<glm/gtx/string_cast.hpp>
|
||||
// 这里为了简单,我们手动输出
|
||||
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 文件
|
||||
}
|
||||
@@ -70,6 +70,10 @@
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)x64\Release\include;$(IncludePath)</IncludePath>
|
||||
<ExternalIncludePath>$(SolutionDir)x64\Release\include;$(ExternalIncludePath)</ExternalIncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -124,6 +128,8 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>Vivid2DRenderer.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user