Add OpenGL test infrastructure - Phase 1: Device, Buffer, Fence tests (17 tests)
- Create test directory structure at tests/RHI/OpenGL/
- Implement OpenGLTestFixture with GLFW/GLAD initialization
- Add Device tests: CreateRenderWindow, InitializeWithExistingWindow, GetDeviceInfo, SwapBuffers, PollEvents
- Add Buffer tests: VertexBuffer, IndexBuffer, UniformBuffer, Dynamic, Bind/Unbind, Map/Unmap
- Add Fence tests: Initialize (signaled/unsignaled), Signal, Wait, IsSignaled, GetStatus
- Add CMakeLists.txt with proper GLFW/GLAD/GTest linking
- Create implementation plan document at docs/OpenGL测试实施计划.md
2026-03-17 12:26:21 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-03-20 19:05:50 +08:00
|
|
|
#include <windows.h>
|
Add OpenGL test infrastructure - Phase 1: Device, Buffer, Fence tests (17 tests)
- Create test directory structure at tests/RHI/OpenGL/
- Implement OpenGLTestFixture with GLFW/GLAD initialization
- Add Device tests: CreateRenderWindow, InitializeWithExistingWindow, GetDeviceInfo, SwapBuffers, PollEvents
- Add Buffer tests: VertexBuffer, IndexBuffer, UniformBuffer, Dynamic, Bind/Unbind, Map/Unmap
- Add Fence tests: Initialize (signaled/unsignaled), Signal, Wait, IsSignaled, GetStatus
- Add CMakeLists.txt with proper GLFW/GLAD/GTest linking
- Create implementation plan document at docs/OpenGL测试实施计划.md
2026-03-17 12:26:21 +08:00
|
|
|
#include <glad/glad.h>
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace RHI {
|
|
|
|
|
|
|
|
|
|
class OpenGLTestFixture : public ::testing::Test {
|
|
|
|
|
protected:
|
|
|
|
|
void SetUp() override;
|
|
|
|
|
void TearDown() override;
|
|
|
|
|
|
2026-03-20 19:05:50 +08:00
|
|
|
HWND GetWindow() { return m_hwnd; }
|
|
|
|
|
HDC GetDC() { return m_hdc; }
|
|
|
|
|
HGLRC GetContext() { return m_hglrc; }
|
2026-03-23 21:48:46 +08:00
|
|
|
OpenGLDevice* GetDevice() { return m_device; }
|
Add OpenGL test infrastructure - Phase 1: Device, Buffer, Fence tests (17 tests)
- Create test directory structure at tests/RHI/OpenGL/
- Implement OpenGLTestFixture with GLFW/GLAD initialization
- Add Device tests: CreateRenderWindow, InitializeWithExistingWindow, GetDeviceInfo, SwapBuffers, PollEvents
- Add Buffer tests: VertexBuffer, IndexBuffer, UniformBuffer, Dynamic, Bind/Unbind, Map/Unmap
- Add Fence tests: Initialize (signaled/unsignaled), Signal, Wait, IsSignaled, GetStatus
- Add CMakeLists.txt with proper GLFW/GLAD/GTest linking
- Create implementation plan document at docs/OpenGL测试实施计划.md
2026-03-17 12:26:21 +08:00
|
|
|
void MakeContextCurrent();
|
|
|
|
|
void DoneContextCurrent();
|
|
|
|
|
|
|
|
|
|
void ClearGLErrors();
|
|
|
|
|
bool CheckGLError(const char* file, int line);
|
|
|
|
|
const char* GetGLErrorString(GLenum error);
|
|
|
|
|
void ResetGLState();
|
|
|
|
|
|
|
|
|
|
private:
|
2026-03-20 19:05:50 +08:00
|
|
|
HWND m_hwnd = nullptr;
|
|
|
|
|
HDC m_hdc = nullptr;
|
|
|
|
|
HGLRC m_hglrc = nullptr;
|
2026-03-20 17:37:09 +08:00
|
|
|
OpenGLDevice* m_device = nullptr;
|
2026-03-20 19:05:50 +08:00
|
|
|
bool m_ownsWindow = false;
|
Add OpenGL test infrastructure - Phase 1: Device, Buffer, Fence tests (17 tests)
- Create test directory structure at tests/RHI/OpenGL/
- Implement OpenGLTestFixture with GLFW/GLAD initialization
- Add Device tests: CreateRenderWindow, InitializeWithExistingWindow, GetDeviceInfo, SwapBuffers, PollEvents
- Add Buffer tests: VertexBuffer, IndexBuffer, UniformBuffer, Dynamic, Bind/Unbind, Map/Unmap
- Add Fence tests: Initialize (signaled/unsignaled), Signal, Wait, IsSignaled, GetStatus
- Add CMakeLists.txt with proper GLFW/GLAD/GTest linking
- Create implementation plan document at docs/OpenGL测试实施计划.md
2026-03-17 12:26:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace RHI
|
|
|
|
|
} // namespace XCEngine
|
|
|
|
|
|
|
|
|
|
#define GL_CLEAR_ERRORS() \
|
|
|
|
|
do { while (glGetError() != GL_NO_ERROR); } while(0)
|
|
|
|
|
|
|
|
|
|
#define GL_CHECK(call) \
|
|
|
|
|
do { \
|
|
|
|
|
call; \
|
|
|
|
|
ASSERT_TRUE(XCEngine::RHI::OpenGLTestFixture::CheckGLError(__FILE__, __LINE__)) \
|
|
|
|
|
<< "GL error after " << #call; \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define GL_EXPECT_SUCCESS(call) \
|
|
|
|
|
do { \
|
|
|
|
|
call; \
|
|
|
|
|
EXPECT_EQ(glGetError(), GL_NO_ERROR) \
|
|
|
|
|
<< "GL error after " << #call; \
|
2026-03-20 17:37:09 +08:00
|
|
|
} while(0)
|