- Move old test files to new unit/integration structure - Add OpenGL Test Fixture - Update CMakeLists.txt for new layout - Add OpenGL_Test_Restructuring_Plan.md
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <glad/glad.h>
|
|
#include <GLFW/glfw3.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;
|
|
|
|
GLFWwindow* GetWindow() { return m_window; }
|
|
void MakeContextCurrent();
|
|
void DoneContextCurrent();
|
|
|
|
void ClearGLErrors();
|
|
bool CheckGLError(const char* file, int line);
|
|
const char* GetGLErrorString(GLenum error);
|
|
void ResetGLState();
|
|
|
|
private:
|
|
GLFWwindow* m_window = nullptr;
|
|
OpenGLDevice* m_device = nullptr;
|
|
};
|
|
|
|
} // 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; \
|
|
} while(0) |