feat(render): 导出渲染系统核心类并优化数据类型- 为 RenderSystem、BufferBuilder 等关键类添加 VIVID_2D_MYDLL_API 导出宏
- 将多个 int 类型成员变量和返回值改为 size_t 以提升跨平台兼容性 - 在 pch.h 中统一管理 VIVID_2D_MYDLL_API 宏定义逻辑 - 更新项目配置禁用特定警告 4251 并增加头文件打包后处理脚本- 优化构建流程自动复制所需头文件至输出目录并排除无关文件
This commit is contained in:
@@ -131,7 +131,7 @@
|
|||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
<DisableSpecificWarnings>4828</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4828;4251</DisableSpecificWarnings>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -140,6 +140,26 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>REM 目标路径:$(OutDir)include
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
REM 1. 复制项目根目录下的 .h 文件
|
||||||
|
xcopy "$(ProjectDir)*.h" "$(OutDir)include" /Y /I
|
||||||
|
|
||||||
|
REM 2. 递归复制 'systems\' 文件夹下的所有 .h 文件
|
||||||
|
REM /E 确保复制子目录结构
|
||||||
|
xcopy "$(ProjectDir)systems\*.h" "$(OutDir)include\systems" /E /Y /I
|
||||||
|
|
||||||
|
REM --- 排除操作 ---
|
||||||
|
REM 3. 递归查找目标目录 "$(OutDir)include" 下的排除文件并删除
|
||||||
|
for /R "$(OutDir)include" %%f in (framework.h pch.h) do (
|
||||||
|
del /Q "%%f"
|
||||||
|
)</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Message>==== Package include ====</Message>
|
||||||
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="systems\buffer\BufferUploader.h" />
|
<ClInclude Include="systems\buffer\BufferUploader.h" />
|
||||||
|
|||||||
@@ -7,6 +7,17 @@
|
|||||||
#ifndef PCH_H
|
#ifndef PCH_H
|
||||||
#define PCH_H
|
#define PCH_H
|
||||||
|
|
||||||
|
// 检查 VIVID_2D_MYDLL_API 宏是否已经被定义
|
||||||
|
#ifdef VIVID_2D_MYDLL_API
|
||||||
|
// 如果已经定义,则先取消其定义(防止重复或冲突的定义)
|
||||||
|
#undef VIVID_2D_MYDLL_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 强制将 VIVID_2D_MYDLL_API 宏定义为 __declspec(dllexport)
|
||||||
|
// 作用:告诉编译器,使用此宏标记的类、函数或变量,必须从当前 DLL 中导出。
|
||||||
|
// 这是在编译 DLL 自身源代码时,确保其接口能够被外部应用程序使用的关键步骤。
|
||||||
|
#define VIVID_2D_MYDLL_API __declspec(dllexport)
|
||||||
|
|
||||||
// 添加要在此处预编译的标头
|
// 添加要在此处预编译的标头
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ void RenderSystem::_popState() {
|
|||||||
s_Logger->warn("popState called with empty state stack.");
|
s_Logger->warn("popState called with empty state stack.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int RenderSystem::getStateStackSize() { return s_StateStack.size(); }
|
size_t RenderSystem::getStateStackSize() { return s_StateStack.size(); }
|
||||||
|
|
||||||
void RenderSystem::clearColor(float r, float g, float b, float a) { RENDER_SYSTEM_QUEUE_CALL(_clearColor, r, g, b, a); }
|
void RenderSystem::clearColor(float r, float g, float b, float a) { RENDER_SYSTEM_QUEUE_CALL(_clearColor, r, g, b, a); }
|
||||||
void RenderSystem::_clearColor(float r, float g, float b, float a) {
|
void RenderSystem::_clearColor(float r, float g, float b, float a) {
|
||||||
@@ -468,7 +468,7 @@ std::string RenderSystem::getGLErrorString(GLenum error) {
|
|||||||
int RenderSystem::getViewportWidth() { return s_ViewportWidth; }
|
int RenderSystem::getViewportWidth() { return s_ViewportWidth; }
|
||||||
int RenderSystem::getViewportHeight() { return s_ViewportHeight; }
|
int RenderSystem::getViewportHeight() { return s_ViewportHeight; }
|
||||||
glm::vec4 RenderSystem::getClearColor() { return s_ClearColorValue; }
|
glm::vec4 RenderSystem::getClearColor() { return s_ClearColorValue; }
|
||||||
int RenderSystem::getQueueSize() {
|
size_t RenderSystem::getQueueSize() {
|
||||||
std::lock_guard<std::mutex> lock(s_RenderQueueMutex);
|
std::lock_guard<std::mutex> lock(s_RenderQueueMutex);
|
||||||
return s_RenderQueue.size();
|
return s_RenderQueue.size();
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ namespace spdlog {
|
|||||||
class logger;
|
class logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenderSystem {
|
class VIVID_2D_MYDLL_API RenderSystem {
|
||||||
public:
|
public:
|
||||||
RenderSystem() = delete;
|
RenderSystem() = delete;
|
||||||
~RenderSystem() = delete;
|
~RenderSystem() = delete;
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
static void disable(GLenum capability);
|
static void disable(GLenum capability);
|
||||||
static void pushState();
|
static void pushState();
|
||||||
static void popState();
|
static void popState();
|
||||||
static int getStateStackSize();
|
static size_t getStateStackSize();
|
||||||
static void clearColor(float r, float g, float b, float a);
|
static void clearColor(float r, float g, float b, float a);
|
||||||
static void clear(GLbitfield mask);
|
static void clear(GLbitfield mask);
|
||||||
static void viewport(int x, int y, int width, int height);
|
static void viewport(int x, int y, int width, int height);
|
||||||
@@ -159,7 +159,7 @@ public:
|
|||||||
static int getViewportWidth();
|
static int getViewportWidth();
|
||||||
static int getViewportHeight();
|
static int getViewportHeight();
|
||||||
static glm::vec4 getClearColor();
|
static glm::vec4 getClearColor();
|
||||||
static int getQueueSize();
|
static size_t getQueueSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct RenderState;
|
struct RenderState;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Buffer {
|
|||||||
/**
|
/**
|
||||||
* @brief <20><>Ⱦ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
* @brief <20><>Ⱦ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||||
*/
|
*/
|
||||||
struct RenderState {
|
struct VIVID_2D_MYDLL_API RenderState {
|
||||||
// <20><>Ⱦ״̬<D7B4><CCAC><EFBFBD><EFBFBD> (<28><>Ӧ Java <20>е<EFBFBD> RenderState)
|
// <20><>Ⱦ״̬<D7B4><CCAC><EFBFBD><EFBFBD> (<28><>Ӧ Java <20>е<EFBFBD> RenderState)
|
||||||
unsigned int textureId = 0;
|
unsigned int textureId = 0;
|
||||||
int textureUnit = 0;
|
int textureUnit = 0;
|
||||||
@@ -55,7 +55,7 @@ namespace Buffer {
|
|||||||
/**
|
/**
|
||||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵĻ<C9B5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ
|
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵĻ<C9B5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ
|
||||||
*/
|
*/
|
||||||
struct BuiltBuffer {
|
struct VIVID_2D_MYDLL_API BuiltBuffer {
|
||||||
unsigned int vao;
|
unsigned int vao;
|
||||||
unsigned int vbo;
|
unsigned int vbo;
|
||||||
int vertexCount;
|
int vertexCount;
|
||||||
@@ -71,13 +71,13 @@ namespace Buffer {
|
|||||||
* @brief <20><EFBFBD> BufferBuilder<65><72><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ի<EFBFBD><D4BB>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD>塣
|
* @brief <20><EFBFBD> BufferBuilder<65><72><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ի<EFBFBD><D4BB>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD>塣
|
||||||
* ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD> float x, float y, float u, float v <20><><EFBFBD><EFBFBD>4<EFBFBD><34> float<61><74>
|
* ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD> float x, float y, float u, float v <20><><EFBFBD><EFBFBD>4<EFBFBD><34> float<61><74>
|
||||||
*/
|
*/
|
||||||
class BufferBuilder {
|
class VIVID_2D_MYDLL_API BufferBuilder {
|
||||||
private:
|
private:
|
||||||
static constexpr int COMPONENTS_PER_VERTEX = 4; // x,y,u,v
|
static constexpr int COMPONENTS_PER_VERTEX = 4; // x,y,u,v
|
||||||
std::vector<float> array;
|
std::vector<float> array;
|
||||||
int size; // ʵ<>ʴ洢<CAB4><E6B4A2> float <20><><EFBFBD><EFBFBD> (array.size())
|
size_t size; // ʵ<>ʴ洢<CAB4><E6B4A2> float <20><><EFBFBD><EFBFBD> (array.size())
|
||||||
int vertexCount;
|
size_t vertexCount;
|
||||||
int mode; // GL mode
|
size_t mode; // GL mode
|
||||||
RenderState renderState;
|
RenderState renderState;
|
||||||
bool stateSaved = false;
|
bool stateSaved = false;
|
||||||
public:
|
public:
|
||||||
@@ -119,7 +119,7 @@ namespace Buffer {
|
|||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
int getVertexCount() const {
|
size_t getVertexCount() const {
|
||||||
return vertexCount;
|
return vertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Buffer {
|
|||||||
/**
|
/**
|
||||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ⱦ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VAO <20><>ִ<EFBFBD>л<EFBFBD><D0BB>ơ<EFBFBD>
|
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ⱦ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VAO <20><>ִ<EFBFBD>л<EFBFBD><D0BB>ơ<EFBFBD>
|
||||||
*/
|
*/
|
||||||
class BufferUploader {
|
class VIVID_2D_MYDLL_API BufferUploader {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief ʹ<><CAB9><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
|
* @brief ʹ<><CAB9><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace Buffer {
|
|||||||
* 2. <20><>װ BufferBuilder<65><72><EFBFBD>ṩһ<E1B9A9>µļ<C2B5><C4BC><EFBFBD><EFBFBD>幹<EFBFBD><E5B9B9><EFBFBD>ӿڡ<D3BF>
|
* 2. <20><>װ BufferBuilder<65><72><EFBFBD>ṩһ<E1B9A9>µļ<C2B5><C4BC><EFBFBD><EFBFBD>幹<EFBFBD><E5B9B9><EFBFBD>ӿڡ<D3BF>
|
||||||
* 3. <20><> end() <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BufferUploader <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
* 3. <20><> end() <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BufferUploader <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||||
*/
|
*/
|
||||||
class Tesselator {
|
class VIVID_2D_MYDLL_API Tesselator {
|
||||||
private:
|
private:
|
||||||
static constexpr int DEFAULT_BUFFER_SIZE = 2097152; // 2MB floats
|
static constexpr int DEFAULT_BUFFER_SIZE = 2097152; // 2MB floats
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class TextShader;
|
|||||||
/**
|
/**
|
||||||
* @brief <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ı<EFBFBD><C4B1>롢<EFBFBD><EBA1A2><EFBFBD>Ӻ<D3BA><CDB9><EFBFBD> (C++ <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>)
|
* @brief <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ı<EFBFBD><C4B1>롢<EFBFBD><EBA1A2><EFBFBD>Ӻ<D3BA><CDB9><EFBFBD> (C++ <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>)
|
||||||
*/
|
*/
|
||||||
class ShaderManagement
|
class VIVID_2D_MYDLL_API ShaderManagement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// <20><>ֹʵ<D6B9><CAB5><EFBFBD><EFBFBD>
|
// <20><>ֹʵ<D6B9><CAB5><EFBFBD><EFBFBD>
|
||||||
|
|||||||
Reference in New Issue
Block a user