Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
DepthRenderTechnique.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_DEPTHRENDERTECHNIQUE_HPP
8 #define NAZARA_DEPTHRENDERTECHNIQUE_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Graphics/AbstractRenderTechnique.hpp>
12 #include <Nazara/Graphics/Config.hpp>
13 #include <Nazara/Graphics/DepthRenderQueue.hpp>
14 #include <Nazara/Renderer/Shader.hpp>
15 #include <Nazara/Utility/IndexBuffer.hpp>
16 #include <Nazara/Utility/VertexBuffer.hpp>
17 
18 namespace Nz
19 {
20  class NAZARA_GRAPHICS_API DepthRenderTechnique : public AbstractRenderTechnique
21  {
22  public:
24  ~DepthRenderTechnique() = default;
25 
26  void Clear(const SceneData& sceneData) const override;
27  bool Draw(const SceneData& sceneData) const override;
28 
29  AbstractRenderQueue* GetRenderQueue() override;
30  RenderTechniqueType GetType() const override;
31 
32  static bool Initialize();
33  static void Uninitialize();
34 
35  private:
36  struct ShaderUniforms;
37 
38  void DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
39  void DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
40  void DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
41  const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
42  void OnShaderInvalidated(const Shader* shader) const;
43 
44  struct LightIndex
45  {
46  LightType type;
47  float score;
48  unsigned int index;
49  };
50 
51  struct ShaderUniforms
52  {
53  NazaraSlot(Shader, OnShaderUniformInvalidated, shaderUniformInvalidatedSlot);
54  NazaraSlot(Shader, OnShaderRelease, shaderReleaseSlot);
55 
56  // Autre uniformes
57  int sceneAmbient;
58  int textureOverlay;
59  };
60 
61  mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
62  Buffer m_vertexBuffer;
63  mutable DepthRenderQueue m_renderQueue;
64  Texture m_whiteTexture;
65  VertexBuffer m_billboardPointBuffer;
66  VertexBuffer m_spriteBuffer;
67 
68  static IndexBuffer s_quadIndexBuffer;
69  static VertexBuffer s_quadVertexBuffer;
70  static VertexDeclaration s_billboardInstanceDeclaration;
71  static VertexDeclaration s_billboardVertexDeclaration;
72  };
73 }
74 
75 
76 #include <Nazara/Graphics/DepthRenderTechnique.inl>
77 
78 #endif // NAZARA_DEPTHRENDERTECHNIQUE_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Graphics class that represents the rendering queue for depth rendering.
Definition: DepthRenderQueue.hpp:17
Graphics class that represents the technique used in depth rendering.
Definition: DepthRenderTechnique.hpp:20
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