refactor: Refactor OpenGL backend to use OpenGLEnums
Use centralized OpenGLEnums.h for enum conversion: - Remove local ToGL* functions from OpenGLCommandList - Replace with ToOpenGL() and ToOpenGLClearBuffer() from OpenGLEnums - Simplify OpenGLTexture, OpenGLBuffer, OpenGLSampler, etc.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDepthStencilView.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLEnums.h"
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
OpenGLDepthStencilView::OpenGLDepthStencilView()
|
||||
OpenGLDepthStencilView::OpenGLDepthStencilView()
|
||||
: m_texture(0)
|
||||
, m_framebuffer(0)
|
||||
, m_mipLevel(0)
|
||||
@@ -26,18 +27,15 @@ bool OpenGLDepthStencilView::Initialize(unsigned int texture, const OpenGLDepthS
|
||||
glGenFramebuffers(1, &m_framebuffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
|
||||
|
||||
GLenum depthAttachment = GL_DEPTH_ATTACHMENT;
|
||||
GLenum stencilAttachment = GL_STENCIL_ATTACHMENT;
|
||||
|
||||
switch (desc.type) {
|
||||
case DepthStencilType::Texture2D:
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture, desc.mipLevel);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, ToOpenGLDepthAttachment(), GL_TEXTURE_2D, texture, desc.mipLevel);
|
||||
break;
|
||||
case DepthStencilType::Texture2DArray:
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, texture, desc.mipLevel, desc.baseArraySlice);
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, ToOpenGLDepthAttachment(), texture, desc.mipLevel, desc.baseArraySlice);
|
||||
break;
|
||||
case DepthStencilType::TextureCube:
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc.baseArraySlice, texture, desc.mipLevel);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, ToOpenGLDepthAttachment(), GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc.baseArraySlice, texture, desc.mipLevel);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -63,7 +61,7 @@ bool OpenGLDepthStencilView::InitializeCubemap(unsigned int cubemap, int face, i
|
||||
|
||||
glGenFramebuffers(1, &m_framebuffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, cubemap, mipLevel);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, ToOpenGLDepthAttachment(), GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, cubemap, mipLevel);
|
||||
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
Reference in New Issue
Block a user