FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
rendererbase.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_RENDERERBASE_H
23 #define FIFE_RENDERERBASE_H
24 
25 // Standard C++ library includes
26 #include <list>
27 #include <vector>
28 
29 // 3rd party library includes
30 
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
35 
36 #include "renderitem.h"
37 
38 namespace FIFE {
39  class Camera;
40  class Layer;
41  class Map;
42  class Instance;
43  class RenderBackend;
44 
45  class RendererBase;
51  public:
52  virtual ~IRendererListener() {}
53 
56  virtual void onRendererPipelinePositionChanged(RendererBase* renderer) = 0;
57 
60  virtual void onRendererEnabledChanged(RendererBase* renderer) = 0;
61  };
62 
67  public:
68  virtual ~IRendererContainer() {}
69 
72  virtual RendererBase* getRenderer(const std::string& renderername) = 0;
73  };
74 
78  class RendererBase {
79  public:
84  RendererBase(RenderBackend* renderbackend, int32_t position);
85 
88  RendererBase(const RendererBase& old);
89 
92  virtual RendererBase* clone() = 0;
93 
96  virtual ~RendererBase() {};
97 
109  virtual void render(Camera* cam, Layer* layer, RenderList& instances) = 0;
110 
113  virtual std::string getName() = 0;
114 
117  int32_t getPipelinePosition() const { return m_pipeline_position; }
118 
124  void setPipelinePosition(int32_t position);
125 
128  virtual void setEnabled(bool enabled);
129 
132  virtual void reset() {}
133 
136  bool isEnabled() const { return m_enabled; }
137 
140  void setRendererListener(IRendererListener* listener) { m_listener = listener; }
141 
144  void addActiveLayer(Layer* layer);
145 
148  void removeActiveLayer(Layer* layer);
149 
152  void clearActiveLayers();
153 
156  void activateAllLayers(Map* elevation);
157 
160  bool isActivedLayer(Layer* layer);
161 
164  std::list<Layer*> getActiveLayers() const {return m_active_layers;}
165 
166 
167  protected:
168  RendererBase();
169 
170  std::list<Layer*> m_active_layers;
172 
173  private:
174  bool m_enabled;
177  };
178 }
179 
180 #endif
virtual ~RendererBase()
Destructor.
Definition: rendererbase.h:96
Abstract interface for all the renderbackends.
IRendererListener * m_listener
Definition: rendererbase.h:176
std::vector< RenderItem * > RenderList
Definition: renderitem.h:130
bool isEnabled() const
Is renderer enabled.
Definition: rendererbase.h:136
Interface to class owning the renderers Used to get correct subclass of renderer in scripting side (v...
Definition: rendererbase.h:66
Camera describes properties of a view port shown in the main screen Main screen can have multiple cam...
Definition: camera.h:59
virtual void onRendererEnabledChanged(RendererBase *renderer)=0
Renderer is enabled / disabled.
virtual ~IRendererListener()
Definition: rendererbase.h:52
RenderBackend * m_renderbackend
Definition: rendererbase.h:171
virtual void reset()
Resets information in the renderer.
Definition: rendererbase.h:132
Base class for all view renderers View renderer renders one aspect of the view shown on screen...
Definition: rendererbase.h:78
A basic layer on a map.
Definition: layer.h:99
std::list< Layer * > getActiveLayers() const
Returns list of activated layer.
Definition: rendererbase.h:164
RendererListener allows reaction to changes in renderer Having this implemented via callback mechanis...
Definition: rendererbase.h:50
void setRendererListener(IRendererListener *listener)
Sets listener for renderer.
Definition: rendererbase.h:140
std::list< Layer * > m_active_layers
Definition: rendererbase.h:170
A container of Layer(s).
Definition: map.h:88
int32_t getPipelinePosition() const
Gets renderer position in the rendering pipeline.
Definition: rendererbase.h:117
int32_t m_pipeline_position
Definition: rendererbase.h:175
virtual void onRendererPipelinePositionChanged(RendererBase *renderer)=0
Renderer&#39;s pipeline position has been changed.