Add OpenGLSwapChain
This commit is contained in:
@@ -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
|
||||||
|
|||||||
26
engine/include/XCEngine/RHI/OpenGL/OpenGLSwapChain.h
Normal file
26
engine/include/XCEngine/RHI/OpenGL/OpenGLSwapChain.h
Normal 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
|
||||||
32
engine/src/RHI/OpenGL/OpenGLSwapChain.cpp
Normal file
32
engine/src/RHI/OpenGL/OpenGLSwapChain.cpp
Normal 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
|
||||||
Reference in New Issue
Block a user