4#include "SFrameBuffer.h"
6#include "../GLProgramHandle.h"
7#include "../../Manager/EngineCore.h"
8#include "RenderInterfaces.h"
16 resMgr = CORE->GetCore(
ResMgr);
19SGBuffer::~SGBuffer() =
default;
21void SGBuffer::GenerateGBuffer(
int width,
int height) {
22 if(m_geometryFrameBuffer !=
nullptr)
return;
28 m_geometryFrameBuffer->SetName(m_geometryFrameBuffer->GetName() +
" - GBuffer");
33 m_depthTexture = m_geometryFrameBuffer->
GenerateTexturebuffer(SFrameBuffer::DEPTH, GL_DEPTH_COMPONENT);
40void SGBuffer::AttachGeometryFrameBuffer()
const {
41 if(m_geometryFrameBuffer ==
nullptr)
return;
42 m_geometryFrameBuffer->AttachFrameBuffer();
45void SGBuffer::AttachGeometryFrameBuffer(
int target)
const {
46 if(m_geometryFrameBuffer ==
nullptr)
return;
48 m_geometryFrameBuffer->AttachFrameBuffer(target);
51void SGBuffer::ResizeGBuffer(
int width,
int height) {
53 GenerateGBuffer(width, height);
56void SGBuffer::ReleaseGBuffer() {
57 if(m_geometryFrameBuffer !=
nullptr) {
58 resMgr->Remove(m_geometryFrameBuffer);
59 SAFE_DELETE(m_geometryFrameBuffer);
64 if(lightPassHandle ==
nullptr || m_lightPassHandle !=
nullptr)
return;
66 m_lightPassHandle = lightPassHandle;
67 m_firstTextureId = m_lightPassHandle->UniformLocation(
"geo.normal.mr")->id;
68 m_secondTextureId = m_lightPassHandle->UniformLocation(
"geo.albedo.a")->id;
69 m_depthTextureId = m_lightPassHandle->UniformLocation(
"geo.depth")->id;
72void SGBuffer::AttachLightPass()
const {
73 glUseProgram(m_lightPassHandle->Program);
76void SGBuffer::AttachLightPassTexture(
int textureLayout)
const {
77 m_firstTexture->Bind(m_firstTextureId, textureLayout);
78 m_secondTexture->Bind(m_secondTextureId, textureLayout + 1);
79 m_depthTexture->Bind(m_depthTextureId, textureLayout + 2);
82void SGBuffer::RenderLightPass()
const {
83 ShaderUtil::BindAttributeToPlane();
86const std::vector<SIRender*>& SGBuffer::GetRendersLayer()
const {
87 return m_rendersLayer;
90void SGBuffer::PushBackToLayer(
SIRender* render) {
91 m_rendersLayer.push_back(render);
94void SGBuffer::RemoveToLayer(
SIRender* render) {
95 m_rendersLayer.erase(std::remove(m_rendersLayer.begin(), m_rendersLayer.end(), render), m_rendersLayer.end());
98int SGBuffer::GetWidth()
const {
102int SGBuffer::GetHeight()
const {
107 return m_lightPassHandle;
STexture * GenerateTexturebuffer(BufferType type, int channel, int level=0)
void RasterizeFramebuffer()
void GenerateFramebuffer(BufferDimension dimension, int width, int height)