Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
DeferredRenderTechnique.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Graphics module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_DEFERREDRENDERTECHNIQUE_HPP
8 #define NAZARA_DEFERREDRENDERTECHNIQUE_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Graphics/AbstractRenderTechnique.hpp>
12 #include <Nazara/Graphics/DeferredRenderQueue.hpp>
13 #include <Nazara/Graphics/ForwardRenderTechnique.hpp>
14 #include <Nazara/Math/Vector2.hpp>
15 #include <Nazara/Renderer/RenderTexture.hpp>
16 #include <Nazara/Renderer/Texture.hpp>
17 #include <map>
18 #include <memory>
19 
20 namespace Nz
21 {
22  class DeferredRenderPass;
23 
24  class NAZARA_GRAPHICS_API DeferredRenderTechnique : public AbstractRenderTechnique
25  {
26  friend class Graphics;
27 
28  public:
31 
32  void Clear(const SceneData& sceneData) const override;
33  bool Draw(const SceneData& sceneData) const override;
34 
35  void EnablePass(RenderPassType renderPass, int position, bool enable);
36 
37  Texture* GetDepthStencilTexture() const;
38  Texture* GetGBuffer(unsigned int i) const;
39  RenderTexture* GetGBufferRTT() const;
40  const ForwardRenderTechnique* GetForwardTechnique() const;
41  DeferredRenderPass* GetPass(RenderPassType renderPass, int position = 0);
42  AbstractRenderQueue* GetRenderQueue() override;
43  RenderTechniqueType GetType() const override;
44  RenderTexture* GetWorkRTT() const;
45  Texture* GetWorkTexture(unsigned int i) const;
46 
47  bool IsPassEnabled(RenderPassType renderPass, int position);
48 
49  DeferredRenderPass* ResetPass(RenderPassType renderPass, int position);
50 
51  void SetPass(RenderPassType relativeTo, int position, DeferredRenderPass* pass);
52 
53  static bool IsSupported();
54 
55  private:
56  bool Resize(const Vector2ui& dimensions) const;
57 
58  static bool Initialize();
59  static void Uninitialize();
60 
61  struct RenderPassComparator
62  {
63  bool operator()(RenderPassType pass1, RenderPassType pass2) const;
64  };
65 
66  std::map<RenderPassType, std::map<int, std::unique_ptr<DeferredRenderPass>>, RenderPassComparator> m_passes;
67  ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue
68  DeferredRenderQueue m_renderQueue;
69  mutable TextureRef m_depthStencilTexture;
70  mutable RenderTexture m_GBufferRTT;
71  mutable RenderTexture m_workRTT;
72  mutable TextureRef m_GBuffer[4];
73  mutable TextureRef m_workTextures[2];
74  mutable Vector2ui m_GBufferSize;
75  const RenderTarget* m_viewerTarget;
76  };
77 }
78 
79 #endif // NAZARA_FORWARDRENDERTECHNIQUE_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Graphics class that represents the module initializer of Graphics.
Definition: Graphics.hpp:15
Graphics class that represents the pass for rendering in deferred rendering.
Definition: DeferredRenderPass.hpp:22
Graphics class that represents the rendering queue for our scene.
Definition: AbstractRenderQueue.hpp:26
Graphics class that represents the rendering technique for our scene.
Definition: AbstractRenderTechnique.hpp:20
Graphics class that represents the technique used in deferred rendering.
Definition: DeferredRenderTechnique.hpp:24
Graphics class that represents the technique used in forward rendering.
Definition: ForwardRenderTechnique.hpp:21
Graphics class that represents the rendering queue for deferred rendering.
Definition: DeferredRenderQueue.hpp:22