Files
XCEngine/tests/RHI/OpenGL/test_pipeline_state.cpp
ssdfasd 0a2f8050e5 fix(RHI): 修复 OpenGL 测试接口不匹配问题
- 修复 RHIDeviceInfo 缺少 majorVersion/minorVersion
- 修复 OpenGLTexture 使用 GetTextureType 替代 GetType
- 修复 OpenGLSampler 使用 OpenGLSamplerDesc
- 修复 BlendFactor::OneMinusSrcAlpha -> InvSrcAlpha
- 修复 OpenGLRenderTargetViewDesc/OpenGLDepthStencilViewDesc 重定义问题
- 恢复 OpenGL 测试文件到 CMakeLists
2026-03-17 19:43:20 +08:00

69 lines
1.7 KiB
C++

#include "fixtures/OpenGLTestFixture.h"
#include "XCEngine/RHI/OpenGL/OpenGLPipelineState.h"
using namespace XCEngine::RHI;
TEST_F(OpenGLTestFixture, PipelineState_SetDepthStencilState) {
OpenGLPipelineState pipeline;
DepthStencilState state;
state.depthTestEnable = true;
state.depthWriteEnable = true;
state.depthFunc = ComparisonFunc::Less;
pipeline.SetDepthStencilState(state);
pipeline.ApplyDepthStencil();
GLint depthTest = 0;
glGetIntegerv(GL_DEPTH_TEST, &depthTest);
EXPECT_EQ(depthTest, 1);
GLint depthMask = 0;
glGetIntegerv(GL_DEPTH_WRITEMASK, &depthMask);
EXPECT_EQ(depthMask, 1);
}
TEST_F(OpenGLTestFixture, PipelineState_SetBlendState) {
OpenGLPipelineState pipeline;
BlendState state;
state.blendEnable = true;
state.srcBlend = BlendFactor::SrcAlpha;
state.dstBlend = BlendFactor::InvSrcAlpha;
pipeline.SetBlendState(state);
pipeline.ApplyBlend();
GLint blend = 0;
glGetIntegerv(GL_BLEND, &blend);
EXPECT_EQ(blend, 1);
}
TEST_F(OpenGLTestFixture, PipelineState_SetViewport_SetScissor) {
OpenGLPipelineState pipeline;
ViewportState viewport;
viewport.x = 0;
viewport.y = 0;
viewport.width = 800;
viewport.height = 600;
ScissorState scissor;
scissor.enable = true;
scissor.x = 0;
scissor.y = 0;
scissor.width = 800;
scissor.height = 600;
pipeline.SetViewport(viewport);
pipeline.SetScissor(scissor);
pipeline.ApplyViewport();
GLint viewportArr[4] = {};
glGetIntegerv(GL_VIEWPORT, viewportArr);
EXPECT_EQ(viewportArr[0], 0);
EXPECT_EQ(viewportArr[1], 0);
EXPECT_EQ(viewportArr[2], 800);
EXPECT_EQ(viewportArr[3], 600);
}