2#include "../LightMgr.h"
3#include "../EngineCore.h"
4#include "../../Util/Render/SFrameBuffer.h"
5#include "../../Util/Render/SEnvironmentMgr.h"
6#include "../../Util/Render/SGBuffer.h"
7#include "../CameraMgr.h"
8#include "../../Component/RenderComponent.h"
9#include "../../Util/Settings.h"
10#include "../../Util/GLProgramHandle.h"
12#include "ForwardRenderGroup.h"
13#include "DeferredRenderGroup.h"
14#include "DepthOnlyRenderGroup.h"
23RenderMgr::~RenderMgr() {
31 m_width = SEnvironmentMgr::GetPointerWidth();
32 m_height = SEnvironmentMgr::GetPointerHeight();
34 InitBuffers((
int)*m_width, (
int)*m_height);
42 if(m_deferredRenderGroup !=
nullptr)
44 ResizeBuffers((
int)*m_width, (
int)*m_height);
58void RenderMgr::RenderShadows()
const {
59 const auto& lightObjects = lightMgr->GetAll();
60 for (
const auto& light : lightObjects) {
61 if(!light->IsShadow())
continue;
62 m_depthOnlyRenderGroup->RenderAll(*light);
67void RenderMgr::RenderSubCameras()
const {
68 const auto& cameraObjects = cameraMgr->GetAll();
69 const auto& mainCamera = cameraMgr->GetCurrentCamera();
71 for (
const auto& camera : cameraObjects) {
72 if(!camera->GetIsEnable() || camera == mainCamera || camera->GetFrameBuffer() ==
nullptr)
continue;
74 m_deferredRenderGroup->RenderAll(*camera);
75 m_forwardRenderGroup->RenderAll(*camera);
79void RenderMgr::RenderMainCamera()
const {
80 const auto& mainCamera = cameraMgr->GetCurrentCamera();
81 if (mainCamera ==
nullptr)
return;
83 ResetBuffer(*mainCamera);
84 m_deferredRenderGroup->RenderAll(*mainCamera);
85 m_forwardRenderGroup->RenderAll(*mainCamera);
87 GetMainBuffer()->AttachFrameBuffer(GL_READ_FRAMEBUFFER);
89 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 1);
91 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
93 glBlitFramebuffer(0, 0, *m_width, *m_height, 0, 0, *m_width, *m_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
97 RenderContainer::Exterminate();
100void RenderMgr::ResetBuffer(
const CameraBase& camera)
const {
101 auto frameBuffer = camera.GetFrameBuffer();
102 if(frameBuffer ==
nullptr) {
103 frameBuffer = GetMainBuffer();
105 frameBuffer->AttachFrameBuffer();
106 camera.RenderBackground();
void RefreshShadowCount(int shadowCount=-1) const
void Init() override
Initialization of resources required for rendering.
void SetViewport()
Modify the framebuffer to fit the modified screen size.
RenderMgr()
Constructor for RenderMgr.
void Exterminate() override
Destroy all resources used for rendering.
void Render() const override
Rendering all stuffs.