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.
This commit is contained in:
42
tests/OpenGL/OpenGLDevice.h
Normal file
42
tests/OpenGL/OpenGLDevice.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user