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 13 of file SGBuffer.h.

Constructor & Destructor Documentation

◆ SGBuffer()

SGBuffer::SGBuffer ( )

Definition at line 12 of file SGBuffer.cpp.

12 {
13 m_resMgr = CORE->GetCore(ResMgr);
14}

Member Function Documentation

◆ AttachGeometryFrameBuffer() [1/2]

void SGBuffer::AttachGeometryFrameBuffer ( ) const

Definition at line 37 of file SGBuffer.cpp.

37 {
38 if(m_geometryFrameBuffer == nullptr) return;
39 m_geometryFrameBuffer->AttachFrameBuffer();
40}

◆ AttachGeometryFrameBuffer() [2/2]

void SGBuffer::AttachGeometryFrameBuffer ( int target) const

Definition at line 42 of file SGBuffer.cpp.

42 {
43 if(m_geometryFrameBuffer == nullptr) return;
44
45 m_geometryFrameBuffer->AttachFrameBuffer(target);
46}

◆ AttachLightPass()

void SGBuffer::AttachLightPass ( ) const

Definition at line 69 of file SGBuffer.cpp.

69 {
70 glUseProgram(m_lightPassHandle->Program);
71}

◆ AttachLightPassTexture()

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

Definition at line 73 of file SGBuffer.cpp.

73 {
74 m_firstTexture->Bind(m_firstTextureId, textureLayout);
75 m_secondTexture->Bind(m_secondTextureId, textureLayout + 1);
76 m_depthTexture->Bind(m_depthTextureId, textureLayout + 2);
77}

◆ BindLightPass()

void SGBuffer::BindLightPass ( GLProgramHandle * lightPassHandle)

Definition at line 60 of file SGBuffer.cpp.

60 {
61 if(lightPassHandle == nullptr || m_lightPassHandle != nullptr) return;
62
63 m_lightPassHandle = lightPassHandle;
64 m_firstTextureId = m_lightPassHandle->UniformLocation("geo.normal.mr")->id;
65 m_secondTextureId = m_lightPassHandle->UniformLocation("geo.albedo.a")->id;
66 m_depthTextureId = m_lightPassHandle->UniformLocation("geo.depth")->id;
67}

◆ GenerateGBuffer()

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

Definition at line 18 of file SGBuffer.cpp.

18 {
19 if(m_geometryFrameBuffer != nullptr) return;
20
21 m_width = width;
22 m_height = height;
23
24 m_geometryFrameBuffer = new SFrameBuffer();
25 m_geometryFrameBuffer->SetName(m_geometryFrameBuffer->GetName() + " - GBuffer");
26 m_geometryFrameBuffer->GenerateFramebuffer(SFrameBuffer::PLANE, width, height);
27
28 m_firstTexture = m_geometryFrameBuffer->GenerateTexturebuffer(SFrameBuffer::RENDER, GL_RGBA);
29 m_secondTexture = m_geometryFrameBuffer->GenerateTexturebuffer(SFrameBuffer::RENDER, GL_RGBA);
30 m_depthTexture = m_geometryFrameBuffer->GenerateTexturebuffer(SFrameBuffer::DEPTH, GL_DEPTH_COMPONENT);
31 m_geometryFrameBuffer->RasterizeFramebuffer();
32
33// if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
34// SafeLog::Log("Framebuffer not complete!");
35}
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 99 of file SGBuffer.cpp.

99 {
100 return m_height;
101}

◆ GetLightPassHandle()

GLProgramHandle * SGBuffer::GetLightPassHandle ( ) const

Definition at line 103 of file SGBuffer.cpp.

103 {
104 return m_lightPassHandle;
105}

◆ GetRendersLayer()

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

Definition at line 83 of file SGBuffer.cpp.

83 {
84 return m_rendersLayer;
85}

◆ GetWidth()

int SGBuffer::GetWidth ( ) const

Definition at line 95 of file SGBuffer.cpp.

95 {
96 return m_width;
97}

◆ PushBackToLayer()

void SGBuffer::PushBackToLayer ( SIRender * render)

Definition at line 87 of file SGBuffer.cpp.

87 {
88 m_rendersLayer.push_back(render);
89}

◆ ReleaseGBuffer()

void SGBuffer::ReleaseGBuffer ( )

Definition at line 53 of file SGBuffer.cpp.

53 {
54 if(m_geometryFrameBuffer != nullptr) {
55 m_resMgr->Remove(m_geometryFrameBuffer);
56 m_geometryFrameBuffer = nullptr;
57 }
58}

◆ RemoveToLayer()

void SGBuffer::RemoveToLayer ( SIRender * render)

Definition at line 91 of file SGBuffer.cpp.

91 {
92 m_rendersLayer.erase(std::remove(m_rendersLayer.begin(), m_rendersLayer.end(), render), m_rendersLayer.end());
93}

◆ RenderLightPass()

void SGBuffer::RenderLightPass ( ) const

Definition at line 79 of file SGBuffer.cpp.

79 {
80 ShaderUtil::BindAttributeToPlane();
81}

◆ ResizeGBuffer()

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

Definition at line 48 of file SGBuffer.cpp.

48 {
49 ReleaseGBuffer();
50 GenerateGBuffer(width, height);
51}

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