Enhance OpenGLSwapChain with presentation control
- Add PresentMode enum (Immediate, VSync, Mailbox, Fifo) - Add SurfaceFormat enum for color formats - Add Initialize() overloads with vsync, width/height, PresentMode - Add Resize(), SetVSync() for runtime control - Add GetWidth/Height/FramebufferWidth/FramebufferHeight - Add ShouldClose, SetShouldClose, PollEvents for window management - Implement using GLFW for window/swap control
This commit is contained in:
@@ -1,25 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
enum class PresentMode {
|
||||
Immediate,
|
||||
VSync,
|
||||
Mailbox,
|
||||
Fifo
|
||||
};
|
||||
|
||||
enum class SurfaceFormat {
|
||||
RGBA8,
|
||||
RGBA16F,
|
||||
RGBA32F,
|
||||
BGRA8
|
||||
};
|
||||
|
||||
class OpenGLSwapChain {
|
||||
public:
|
||||
OpenGLSwapChain();
|
||||
~OpenGLSwapChain();
|
||||
|
||||
bool Initialize(GLFWwindow* window);
|
||||
bool Initialize(GLFWwindow* window, bool vsync = true);
|
||||
bool Initialize(GLFWwindow* window, int width, int height, PresentMode mode = PresentMode::VSync);
|
||||
void Shutdown();
|
||||
|
||||
void Present();
|
||||
void SwapBuffers();
|
||||
void Resize(int width, int height);
|
||||
void SetVSync(bool enabled);
|
||||
bool IsVSync() const { return m_vsync; }
|
||||
|
||||
void SetFramebufferSize(int width, int height);
|
||||
int GetWidth() const { return m_width; }
|
||||
int GetHeight() const { return m_height; }
|
||||
int GetFramebufferWidth() const { return m_framebufferWidth; }
|
||||
int GetFramebufferHeight() const { return m_framebufferHeight; }
|
||||
|
||||
GLFWwindow* GetWindow() const { return m_window; }
|
||||
|
||||
bool ShouldClose() const;
|
||||
void SetShouldClose(bool shouldClose);
|
||||
void PollEvents();
|
||||
|
||||
private:
|
||||
GLFWwindow* m_window;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_framebufferWidth;
|
||||
int m_framebufferHeight;
|
||||
bool m_vsync;
|
||||
PresentMode m_presentMode;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
|
||||
Reference in New Issue
Block a user