fix(RHI): 添加 OpenGL 源文件到 CMakeLists 并修复编译错误

- 添加 OpenGL RHI 所有源文件到 engine/CMakeLists.txt
- 修复 OpenGLPipelineState 结构体重定义问题
- 修复 BufferDesc/TextureDesc/ShaderCompileDesc API 不匹配
- 添加 OpenGLShader 缺少的基类纯虚函数实现
- 修复 HashMap 迭代器支持和 ResourceManager API 调用
This commit is contained in:
2026-03-18 03:37:34 +08:00
parent 8344057886
commit 3196261e9b
8 changed files with 90 additions and 31 deletions

View File

@@ -42,6 +42,24 @@ public:
size_t Size() const { return m_size; }
bool Empty() const { return m_size == 0; }
using Iterator = typename Array<Pair>::Iterator;
using ConstIterator = typename Array<Pair>::ConstIterator;
Iterator begin() { return m_buckets[0].pairs.begin(); }
Iterator end() {
if (m_bucketCount > 0) {
return m_buckets[m_bucketCount - 1].pairs.end();
}
return Iterator(nullptr);
}
ConstIterator begin() const { return m_buckets[0].pairs.begin(); }
ConstIterator end() const {
if (m_bucketCount > 0) {
return m_buckets[m_bucketCount - 1].pairs.end();
}
return ConstIterator(nullptr);
}
void SetAllocator(Memory::IAllocator* allocator) { m_allocator = allocator; }
private:

View File

@@ -43,7 +43,7 @@ enum class PolygonMode {
Fill
};
struct DepthStencilState {
struct OpenGLDepthStencilState {
bool depthTestEnable = true;
bool depthWriteEnable = true;
ComparisonFunc depthFunc = ComparisonFunc::Less;
@@ -57,7 +57,7 @@ struct DepthStencilState {
StencilOp stencilDepthPassOp = StencilOp::Keep;
};
struct BlendState {
struct OpenGLBlendState {
bool blendEnable = false;
BlendFactor srcBlend = BlendFactor::SrcAlpha;
BlendFactor dstBlend = BlendFactor::InvSrcAlpha;
@@ -69,7 +69,7 @@ struct BlendState {
float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
};
struct RasterizerState {
struct OpenGLRasterizerState {
bool cullFaceEnable = true;
CullFace cullFace = CullFace::Back;
FrontFace frontFace = FrontFace::CounterClockwise;
@@ -117,9 +117,9 @@ public:
void* GetNativeHandle() override;
PipelineType GetType() const override { return PipelineType::Graphics; }
void SetDepthStencilState(const DepthStencilState& state);
void SetBlendState(const BlendState& state);
void SetRasterizerState(const RasterizerState& state);
void SetDepthStencilState(const OpenGLDepthStencilState& state);
void SetBlendState(const OpenGLBlendState& state);
void SetRasterizerState(const OpenGLRasterizerState& state);
void SetViewport(const ViewportState& state);
void SetScissor(const ScissorState& state);
void SetLogicalOperation(const LogicalOperation& state);
@@ -137,15 +137,14 @@ public:
void AttachShader(unsigned int program);
void DetachShader();
const DepthStencilState& GetDepthStencilState() const { return m_depthStencilState; }
const BlendState& GetBlendState() const { return m_blendState; }
const RasterizerState& GetRasterizerState() const { return m_rasterizerState; }
const ViewportState& GetViewportState() const { return m_viewportState; }
const OpenGLDepthStencilState& GetDepthStencilState() const { return m_depthStencilState; }
const OpenGLBlendState& GetBlendState() const { return m_blendState; }
const OpenGLRasterizerState& GetRasterizerState() const { return m_rasterizerState; }
private:
DepthStencilState m_depthStencilState;
BlendState m_blendState;
RasterizerState m_rasterizerState;
OpenGLDepthStencilState m_depthStencilState;
OpenGLBlendState m_blendState;
OpenGLRasterizerState m_rasterizerState;
ViewportState m_viewportState;
ScissorState m_scissorState;
LogicalOperation m_logicalOperation;