MxEngine
RenderController.h
1 // Copyright(c) 2019 - 2020, #Momo
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met :
6 //
7 // 1. Redistributions of source code must retain the above copyright notice, this
8 // list of conditions and the following disclaimer.
9 //
10 // 2. Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and /or other materials provided with the distribution.
13 //
14 // 3. Neither the name of the copyright holder nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #pragma once
30 
31 #include "Utilities/Memory/Memory.h"
32 #include "Utilities/Array/ArrayView.h"
33 #include "Core/Components/Camera/CameraController.h"
34 #include "Core/Components/Lighting/DirectionalLight.h"
35 #include "Core/Components/Lighting/PointLight.h"
36 #include "Core/Components/Lighting/SpotLight.h"
37 #include "Core/Components/Rendering/Skybox.h"
38 #include "Core/Components/Rendering/MeshSource.h"
39 #include "Core/Resources/Material.h"
40 #include "Platform/OpenGL/Renderer.h"
41 #include "DebugBuffer.h"
42 #include "RenderPipeline.h"
43 
44 #include <array>
45 
46 namespace MxEngine
47 {
49  {
50  Renderer renderer;
51  RenderPipeline Pipeline;
52 
53  void PrepareShadowMaps();
54  void DrawSkybox(const CameraUnit& camera);
55  void DrawObjects(const CameraUnit& camera, const MxVector<RenderUnit>& objects);
56  void DrawDebugBuffer(const CameraUnit& camera);
57  void DrawObject(const RenderUnit& unit, Texture::TextureBindId textureBindIndex, const Shader& shader);
58  void DrawShadowMap(const RenderUnit& unit, const DirectionalLigthUnit& dirLight, const Shader& shader);
59  void DrawShadowMap(const RenderUnit& unit, const SpotLightUnit& spotLight, const Shader& shader);
60  void DrawShadowMap(const RenderUnit& unit, const PointLightUnit& pointLight, const Shader& shader);
61  void AttachDepthMap(const GResource<Texture>& texture);
62  void AttachDepthMap(const GResource<CubeMap>& cubemap);
63  void PostProcessImage(CameraUnit& camera);
64  GResource<Texture> PerformBloomIterations(const GResource<Texture>& inputBloom, uint8_t iterations);
65  public:
66  const Renderer& GetRenderEngine() const;
67  Renderer& GetRenderEngine();
68  void Render() const;
69  void Clear() const;
70  void ToggleDepthOnlyMode(bool value);
71  void ToggleReversedDepth(bool value);
72  void ToggleFaceCulling(bool value, bool counterClockWise = true, bool cullBack = true);
73  void SetAnisotropicFiltering(float value);
74  void SetViewport(int x, int y, int width, int height);
75  void AttachFrameBuffer(const GResource<FrameBuffer>& framebuffer);
76  void AttachDefaultFrameBuffer();
77  void RenderToFrameBuffer(const GResource<FrameBuffer>& framebuffer, const Shader& shader);
78  void RenderToTexture(const GResource<Texture>& texture, const Shader& shader, Attachment attachment = Attachment::COLOR_ATTACHMENT0);
79 
80  EnvironmentUnit& GetEnvironment();
81  const EnvironmentUnit& GetEnvironment() const;
82  void ResetPipeline();
83  void SubmitLightSource(const DirectionalLight& light, const Transform& parentTransform);
84  void SubmitLightSource(const PointLight& light, const Transform& parentTransform);
85  void SubmitLightSource(const SpotLight& light, const Transform& parentTransform);
86  void SubmitCamera(const CameraController& controller, const Transform& parentTransform, const Skybox& skybox);
87  void SubmitPrimitive(const SubMesh& object, const Material& material, const Transform& parentTransform, size_t instanceCount);
88  void SubmitFinalImage(const GResource<Texture>& texture);
89  void StartPipeline();
90  };
91 }
Definition: AbstractFactory.h:61
Definition: RenderPipeline.h:123
Definition: RenderController.h:48
Definition: SpotLight.h:37
Definition: RenderPipeline.h:43
Definition: Material.h:38
Definition: Transform.h:36
Definition: Skybox.h:36
Definition: SubMesh.h:35
Definition: Shader.h:38
Definition: RenderPipeline.h:157
Definition: RenderPipeline.h:111
Definition: PointLight.h:37
Definition: Renderer.h:51
Definition: RenderPipeline.h:62
Definition: RenderPipeline.h:100
Definition: DirectionalLight.h:37
Definition: CameraController.h:57
Definition: Application.cpp:49
Definition: RenderPipeline.h:144