refactor(RHI): 将窗口职责从RHI移到Platform层

- RHIDeviceDesc 删除 windowHandle/width/height/appName
- SwapChainDesc 添加 windowHandle 字段
- RHISwapChain 删除 PollEvents/ShouldClose/SetFullscreen 等窗口相关接口
- OpenGLDevice 删除 CreateRenderWindow,改用 InitializeWithExistingWindow
- 更新所有集成测试使用新API
- 273个单元测试 + 8个集成测试全部通过
This commit is contained in:
2026-03-24 23:00:49 +08:00
parent 9fae910854
commit 7a66913f2b
22 changed files with 66 additions and 379 deletions

View File

@@ -3,24 +3,6 @@
using namespace XCEngine::RHI;
TEST_F(OpenGLTestFixture, Device_CreateRenderWindow_ValidParams) {
OpenGLDevice device;
bool result = device.CreateRenderWindow(800, 600, "Test Window", false);
ASSERT_TRUE(result);
ASSERT_NE(device.GetWindow(), nullptr);
}
TEST_F(OpenGLTestFixture, Device_CreateRenderWindow_DebugMode) {
OpenGLDevice device;
bool result = device.CreateRenderWindow(640, 480, "Debug Window", true);
ASSERT_TRUE(result);
ASSERT_NE(device.GetWindow(), nullptr);
}
TEST_F(OpenGLTestFixture, Device_InitializeWithExistingWindow) {
OpenGLDevice device;
HWND existingWindow = GetWindow();
@@ -28,12 +10,11 @@ TEST_F(OpenGLTestFixture, Device_InitializeWithExistingWindow) {
bool result = device.InitializeWithExistingWindow(existingWindow);
ASSERT_TRUE(result);
ASSERT_EQ(device.GetWindow(), existingWindow);
}
TEST_F(OpenGLTestFixture, Device_GetDeviceInfo_ReturnsValid) {
OpenGLDevice device;
device.CreateRenderWindow(800, 600, "Test", false);
device.InitializeWithExistingWindow(GetWindow());
const auto& info = device.GetDeviceInfo();
@@ -45,19 +26,10 @@ TEST_F(OpenGLTestFixture, Device_GetDeviceInfo_ReturnsValid) {
TEST_F(OpenGLTestFixture, Device_SwapBuffers_NoErrors) {
OpenGLDevice device;
device.CreateRenderWindow(800, 600, "Test", false);
device.InitializeWithExistingWindow(GetWindow());
device.SwapBuffers();
GLenum error = glGetError();
EXPECT_EQ(error, GL_NO_ERROR);
}
TEST_F(OpenGLTestFixture, Device_PollEvents_ReturnsTrue) {
OpenGLDevice device;
device.CreateRenderWindow(800, 600, "Test", false);
bool result = device.PollEvents();
EXPECT_TRUE(result);
}
}