CSEngine
Loading...
Searching...
No Matches
CSE::SGBuffer Class Reference

Public Member Functions

void GenerateGBuffer (int width, int height)
 
void AttachGeometryFrameBuffer () const
 
void AttachGeometryFrameBuffer (int target) const
 
void ResizeGBuffer (int width, int height)
 
void ReleaseGBuffer ()
 
void BindLightPass (GLProgramHandle *lightPassHandle)
 
void AttachLightPass () const
 
void AttachLightPassTexture (int textureLayout=0) const
 
void RenderLightPass () const
 
const std::vector< SIRender * > & GetRendersLayer () const
 
void PushBackToLayer (SIRender *render)
 
void RemoveToLayer (SIRender *render)
 
int GetWidth () const
 
int GetHeight () const
 
GLProgramHandleGetLightPassHandle () const
 

Detailed Description

Definition at line 12 of file SGBuffer.h.

Constructor & Destructor Documentation

◆ SGBuffer()

SGBuffer::SGBuffer ( )

Definition at line 15 of file SGBuffer.cpp.

15 {
16 resMgr = CORE->GetCore(ResMgr);
17}

Member Function Documentation

◆ AttachGeometryFrameBuffer() [1/2]

void SGBuffer::AttachGeometryFrameBuffer ( ) const

Definition at line 40 of file SGBuffer.cpp.

40 {
41 if(m_geometryFrameBuffer == nullptr) return;
42 m_geometryFrameBuffer->AttachFrameBuffer();
43}

◆ AttachGeometryFrameBuffer() [2/2]

void SGBuffer::AttachGeometryFrameBuffer ( int  target) const

Definition at line 45 of file SGBuffer.cpp.

45 {
46 if(m_geometryFrameBuffer == nullptr) return;
47
48 m_geometryFrameBuffer->AttachFrameBuffer(target);
49}

◆ AttachLightPass()

void SGBuffer::AttachLightPass ( ) const

Definition at line 72 of file SGBuffer.cpp.

72 {
73 glUseProgram(m_lightPassHandle->Program);
74}

◆ AttachLightPassTexture()

void SGBuffer::AttachLightPassTexture ( int  textureLayout = 0) const

Definition at line 76 of file SGBuffer.cpp.

76 {
77 m_firstTexture->Bind(m_firstTextureId, textureLayout);
78 m_secondTexture->Bind(m_secondTextureId, textureLayout + 1);
79 m_depthTexture->Bind(m_depthTextureId, textureLayout + 2);
80}

◆ BindLightPass()

void SGBuffer::BindLightPass ( GLProgramHandle lightPassHandle)

Definition at line 63 of file SGBuffer.cpp.

63 {
64 if(lightPassHandle == nullptr || m_lightPassHandle != nullptr) return;
65
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;
70}

◆ GenerateGBuffer()

void SGBuffer::GenerateGBuffer ( int  width,
int  height 
)

Definition at line 21 of file SGBuffer.cpp.

21 {
22 if(m_geometryFrameBuffer != nullptr) return;
23
24 m_width = width;
25 m_height = height;
26
27 m_geometryFrameBuffer = new SFrameBuffer();
28 m_geometryFrameBuffer->SetName(m_geometryFrameBuffer->GetName() + " - GBuffer");
29 m_geometryFrameBuffer->GenerateFramebuffer(SFrameBuffer::PLANE, width, height);
30
31 m_firstTexture = m_geometryFrameBuffer->GenerateTexturebuffer(SFrameBuffer::RENDER, GL_RGBA);
32 m_secondTexture = m_geometryFrameBuffer->GenerateTexturebuffer(SFrameBuffer::RENDER, GL_RGBA);
33 m_depthTexture = m_geometryFrameBuffer->GenerateTexturebuffer(SFrameBuffer::DEPTH, GL_DEPTH_COMPONENT);
34 m_geometryFrameBuffer->RasterizeFramebuffer();
35
36// if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
37// std::cout << "Framebuffer not complete!" << std::endl;
38}
STexture * GenerateTexturebuffer(BufferType type, int channel, int level=0)
void GenerateFramebuffer(BufferDimension dimension, int width, int height)

◆ GetHeight()

int SGBuffer::GetHeight ( ) const

Definition at line 102 of file SGBuffer.cpp.

102 {
103 return m_height;
104}

◆ GetLightPassHandle()

GLProgramHandle * SGBuffer::GetLightPassHandle ( ) const

Definition at line 106 of file SGBuffer.cpp.

106 {
107 return m_lightPassHandle;
108}

◆ GetRendersLayer()

const std::vector< SIRender * > & SGBuffer::GetRendersLayer ( ) const

Definition at line 86 of file SGBuffer.cpp.

86 {
87 return m_rendersLayer;
88}

◆ GetWidth()

int SGBuffer::GetWidth ( ) const

Definition at line 98 of file SGBuffer.cpp.

98 {
99 return m_width;
100}

◆ PushBackToLayer()

void SGBuffer::PushBackToLayer ( SIRender render)

Definition at line 90 of file SGBuffer.cpp.

90 {
91 m_rendersLayer.push_back(render);
92}

◆ ReleaseGBuffer()

void SGBuffer::ReleaseGBuffer ( )

Definition at line 56 of file SGBuffer.cpp.

56 {
57 if(m_geometryFrameBuffer != nullptr) {
58 resMgr->Remove(m_geometryFrameBuffer);
59 SAFE_DELETE(m_geometryFrameBuffer);
60 }
61}

◆ RemoveToLayer()

void SGBuffer::RemoveToLayer ( SIRender render)

Definition at line 94 of file SGBuffer.cpp.

94 {
95 m_rendersLayer.erase(std::remove(m_rendersLayer.begin(), m_rendersLayer.end(), render), m_rendersLayer.end());
96}

◆ RenderLightPass()

void SGBuffer::RenderLightPass ( ) const

Definition at line 82 of file SGBuffer.cpp.

82 {
83 ShaderUtil::BindAttributeToPlane();
84}

◆ ResizeGBuffer()

void SGBuffer::ResizeGBuffer ( int  width,
int  height 
)

Definition at line 51 of file SGBuffer.cpp.

51 {
52 ReleaseGBuffer();
53 GenerateGBuffer(width, height);
54}

The documentation for this class was generated from the following files: