Files
XCEngine/tests/OpenGL/OpenGLDevice.h
ssdfasd 6aaf89e603 Add OpenGL backend: OpenGLDevice class
- Created OpenGLDevice class for window and OpenGL context management
- Added CreateWindow() and InitializeWithExistingWindow() methods
- Integrated with GLFW and GLAD
- Added to tests/OpenGL as test target

This is the first step in building the OpenGL RHI backend parallel to D3D12.
2026-03-16 16:07:12 +08:00

43 lines
903 B
C++

#pragma once
#include <string>
#include <GLFW/glfw3.h>
namespace XCEngine {
namespace RHI {
struct OpenGLDeviceInfo {
std::string vendor;
std::string renderer;
std::string version;
int majorVersion;
int minorVersion;
};
class OpenGLDevice {
public:
OpenGLDevice();
~OpenGLDevice();
bool CreateWindow(int width, int height, const char* title, bool enableDebug = false);
bool InitializeWithExistingWindow(GLFWwindow* window);
void Shutdown();
GLFWwindow* GetWindow() const { return m_window; }
const OpenGLDeviceInfo& GetDeviceInfo() const { return m_deviceInfo; }
void SwapBuffers();
bool PollEvents();
void SetShouldClose(bool shouldClose);
bool ShouldClose() const;
private:
GLFWwindow* m_window;
OpenGLDeviceInfo m_deviceInfo;
bool m_initialized;
bool m_ownsWindow;
};
} // namespace RHI
} // namespace XCEngine