Add OpenGLSwapChain

This commit is contained in:
2026-03-16 18:41:05 +08:00
parent fce3d2421c
commit 377f43260b
3 changed files with 60 additions and 0 deletions

View File

@@ -133,6 +133,7 @@ add_library(XCEngine STATIC
include/XCEngine/RHI/OpenGL/OpenGLTexture.h include/XCEngine/RHI/OpenGL/OpenGLTexture.h
include/XCEngine/RHI/OpenGL/OpenGLPipelineState.h include/XCEngine/RHI/OpenGL/OpenGLPipelineState.h
include/XCEngine/RHI/OpenGL/OpenGLCommandList.h include/XCEngine/RHI/OpenGL/OpenGLCommandList.h
include/XCEngine/RHI/OpenGL/OpenGLSwapChain.h
src/RHI/OpenGL/OpenGLDevice.cpp src/RHI/OpenGL/OpenGLDevice.cpp
src/RHI/OpenGL/OpenGLShader.cpp src/RHI/OpenGL/OpenGLShader.cpp
src/RHI/OpenGL/OpenGLBuffer.cpp src/RHI/OpenGL/OpenGLBuffer.cpp
@@ -140,6 +141,7 @@ add_library(XCEngine STATIC
src/RHI/OpenGL/OpenGLTexture.cpp src/RHI/OpenGL/OpenGLTexture.cpp
src/RHI/OpenGL/OpenGLPipelineState.cpp src/RHI/OpenGL/OpenGLPipelineState.cpp
src/RHI/OpenGL/OpenGLCommandList.cpp src/RHI/OpenGL/OpenGLCommandList.cpp
src/RHI/OpenGL/OpenGLSwapChain.cpp
) )
target_include_directories(XCEngine PUBLIC target_include_directories(XCEngine PUBLIC

View File

@@ -0,0 +1,26 @@
#pragma once
#include <GLFW/glfw3.h>
namespace XCEngine {
namespace RHI {
class OpenGLSwapChain {
public:
OpenGLSwapChain();
~OpenGLSwapChain();
bool Initialize(GLFWwindow* window);
void Shutdown();
void Present();
void SwapBuffers();
GLFWwindow* GetWindow() const { return m_window; }
private:
GLFWwindow* m_window;
};
} // namespace RHI
} // namespace XCEngine

View File

@@ -0,0 +1,32 @@
#define GLFW_INCLUDE_NONE
#include "XCEngine/RHI/OpenGL/OpenGLSwapChain.h"
#include <GLFW/glfw3.h>
namespace XCEngine {
namespace RHI {
OpenGLSwapChain::OpenGLSwapChain() : m_window(nullptr) {
}
OpenGLSwapChain::~OpenGLSwapChain() {
}
bool OpenGLSwapChain::Initialize(GLFWwindow* window) {
m_window = window;
return true;
}
void OpenGLSwapChain::Shutdown() {
m_window = nullptr;
}
void OpenGLSwapChain::Present() {
glfwSwapBuffers(m_window);
}
void OpenGLSwapChain::SwapBuffers() {
glfwSwapBuffers(m_window);
}
} // namespace RHI
} // namespace XCEngine