Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/backend/gl/Framebuffer.cpp
Show All 30 Lines | |||||
namespace Backend | namespace Backend | ||||
{ | { | ||||
namespace GL | namespace GL | ||||
{ | { | ||||
// static | // static | ||||
std::unique_ptr<CFramebuffer> CFramebuffer::Create( | std::unique_ptr<CFramebuffer> CFramebuffer::Create( | ||||
CDevice* device, const char* name, | CDevice* device, const char* name, CTexture* colorAttachment, | ||||
CTexture* colorAttachment, CTexture* depthStencilAttachment, | const AttachmentLoadOp colorAttachmentLoadOp, | ||||
const CColor& clearColor) | const AttachmentStoreOp colorAttachmentStoreOp, | ||||
const CColor& clearColor, CTexture* depthStencilAttachment, | |||||
const AttachmentLoadOp depthStencilAttachmentLoadOp, | |||||
const AttachmentStoreOp depthStencilAttachmentStoreOp) | |||||
{ | { | ||||
ENSURE(colorAttachment || depthStencilAttachment); | ENSURE(colorAttachment || depthStencilAttachment); | ||||
std::unique_ptr<CFramebuffer> framebuffer(new CFramebuffer()); | std::unique_ptr<CFramebuffer> framebuffer(new CFramebuffer()); | ||||
framebuffer->m_Device = device; | framebuffer->m_Device = device; | ||||
framebuffer->m_ClearColor = clearColor; | framebuffer->m_ClearColor = clearColor; | ||||
framebuffer->m_ColorAttachmentLoadOp = colorAttachmentLoadOp; | |||||
framebuffer->m_ColorAttachmentStoreOp = colorAttachmentStoreOp; | |||||
framebuffer->m_DepthStencilAttachmentLoadOp = depthStencilAttachmentLoadOp; | |||||
framebuffer->m_DepthStencilAttachmentStoreOp = depthStencilAttachmentStoreOp; | |||||
glGenFramebuffersEXT(1, &framebuffer->m_Handle); | glGenFramebuffersEXT(1, &framebuffer->m_Handle); | ||||
if (!framebuffer->m_Handle) | if (!framebuffer->m_Handle) | ||||
{ | { | ||||
LOGERROR("Failed to create CFramebuffer object"); | LOGERROR("Failed to create CFramebuffer object"); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->m_Handle); | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->m_Handle); | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | #endif | ||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | ||||
return framebuffer; | return framebuffer; | ||||
} | } | ||||
// static | // static | ||||
std::unique_ptr<CFramebuffer> CFramebuffer::CreateBackbuffer( | std::unique_ptr<CFramebuffer> CFramebuffer::CreateBackbuffer( | ||||
CDevice* device) | CDevice* device, | ||||
const AttachmentLoadOp colorAttachmentLoadOp, | |||||
const AttachmentStoreOp colorAttachmentStoreOp, | |||||
const AttachmentLoadOp depthStencilAttachmentLoadOp, | |||||
const AttachmentStoreOp depthStencilAttachmentStoreOp) | |||||
{ | { | ||||
// Backbuffer for GL is a special case with a zero framebuffer. | // Backbuffer for GL is a special case with a zero framebuffer. | ||||
std::unique_ptr<CFramebuffer> framebuffer(new CFramebuffer()); | std::unique_ptr<CFramebuffer> framebuffer(new CFramebuffer()); | ||||
framebuffer->m_Device = device; | framebuffer->m_Device = device; | ||||
framebuffer->m_AttachmentMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; | framebuffer->m_AttachmentMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; | ||||
framebuffer->m_ClearColor = CColor(0.0f, 0.0f, 0.0f, 0.0f); | framebuffer->m_ClearColor = CColor(0.0f, 0.0f, 0.0f, 0.0f); | ||||
framebuffer->m_ColorAttachmentLoadOp = colorAttachmentLoadOp; | |||||
framebuffer->m_ColorAttachmentStoreOp = colorAttachmentStoreOp; | |||||
framebuffer->m_DepthStencilAttachmentLoadOp = depthStencilAttachmentLoadOp; | |||||
framebuffer->m_DepthStencilAttachmentStoreOp = depthStencilAttachmentStoreOp; | |||||
return framebuffer; | return framebuffer; | ||||
} | } | ||||
CFramebuffer::CFramebuffer() = default; | CFramebuffer::CFramebuffer() = default; | ||||
CFramebuffer::~CFramebuffer() | CFramebuffer::~CFramebuffer() | ||||
{ | { | ||||
if (m_Handle) | if (m_Handle) | ||||
Show All 13 Lines |
Wildfire Games · Phabricator