SuperTuxKart
abstract_renderer.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2015 SuperTuxKart-Team
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 #ifndef HEADER_ABSTRACT_RENDERER_HPP
19 #define HEADER_ABSTRACT_RENDERER_HPP
20 
21 #include "graphics/gl_headers.hpp"
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include <dimension2d.h>
27 #include <vector2d.h>
28 #include <vector3d.h>
29 
30 namespace irr
31 {
32  namespace scene
33  {
34  class ISceneNode; class ISkinnedMesh; class ICameraSceneNode;
35  }
36  namespace video
37  {
38  class SColorf;
39  }
40 }
41 
42 class RenderTarget;
43 
44 enum TypeRTT : unsigned int;
45 
46 struct GlowData {
47  irr::scene::ISceneNode * node;
48  float r, g, b;
49 };
50 
51 struct SHCoefficients;
52 
60 {
61 protected:
62  irr::core::vector2df m_current_screen_size;
63 
64 #ifdef DEBUG
65  void drawDebugMeshes() const;
66 
67  void drawJoint(bool drawline, bool drawname,
68  void* sjoint,
69  irr::scene::ISkinnedMesh* mesh, int id) const;
70 #endif
71 
72  void renderSkybox(const irr::scene::ICameraSceneNode *camera) const;
73 
74 public:
75  AbstractRenderer() {}
76  virtual ~AbstractRenderer(){}
77 
78  virtual void onLoadWorld() = 0;
79  virtual void onUnloadWorld() = 0;
80 
81  virtual void resetPostProcessing() {}
82  virtual void giveBoost(unsigned int cam_index) {}
83 
84  virtual void removeSkyBox() {}
85 
86  //FIXME: these three methods should not appear in the public Renderer interface
87  virtual const SHCoefficients* getSHCoefficients() const { return NULL; }
88  virtual GLuint getRenderTargetTexture(TypeRTT which) const { return 0;}
89  virtual GLuint getDepthStencilTexture( ) const { return 0;}
90 
91  virtual void setAmbientLight(const irr::video::SColorf &light,
92  bool force_SH_computation = true) {}
93 
94  virtual void addSunLight(const irr::core::vector3df &pos){}
95 
96  virtual void addGlowingNode(irr::scene::ISceneNode *n,
97  float r = 1.0f, float g = 1.0f, float b = 1.0f) {}
98 
99  virtual void clearGlowingNodes() {}
100 
101  virtual void render(float dt, bool is_loading=false) = 0;
102 
103  // ------------------------------------------------------------------------
104  const irr::core::vector2df &getCurrentScreenSize() const
105  {
106  return m_current_screen_size;
107  }
108 
109  // ----------------------------------------------------------------------------
114  virtual std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension,
115  const std::string &name) = 0;
116  virtual void createPostProcessing() {}
117 };
118 
119 #endif //HEADER_ABSTRACT_RENDERER_HPP
Virtual base class for the renderer.
Definition: abstract_renderer.hpp:60
virtual std::unique_ptr< RenderTarget > createRenderTarget(const irr::core::dimension2du &dimension, const std::string &name)=0
Create a RenderTarget (for rendering to a texture)
Definition: render_target.hpp:42
Definition: abstract_renderer.hpp:46
Definition: spherical_harmonics.hpp:33