FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
rendererbase.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 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 // Standard C++ library includes
23 
24 // 3rd party library includes
25 
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
30 #include "model/structures/layer.h"
31 #include "model/structures/map.h"
32 #include "util/log/logger.h"
33 #include "rendererbase.h"
34 
35 namespace FIFE {
36  static Logger _log(LM_VIEW);
37 
38  // use some big value, so that non-positioned renderers show on top
39  const int32_t DEFAULT_RENDERER_POSITION = 1000;
40 
41  RendererBase::RendererBase(RenderBackend* renderbackend, int32_t position):
42  m_renderbackend(renderbackend),
43  m_enabled(false),
44  m_pipeline_position(DEFAULT_RENDERER_POSITION),
45  m_listener(NULL) {
46  setPipelinePosition(position);
47  }
48 
51  m_enabled(old.m_enabled),
53  m_listener(NULL) {
55  }
56 
58  m_renderbackend(NULL),
59  m_enabled(false),
60  m_pipeline_position(DEFAULT_RENDERER_POSITION),
61  m_listener(NULL) {
62  }
63 
64  void RendererBase::setPipelinePosition(int32_t position) {
65  if (position !=m_pipeline_position) {
66  m_pipeline_position = position;
67  if (m_listener) {
69  }
70  }
71  }
72 
73  void RendererBase::setEnabled(bool enabled) {
74  if (m_enabled != enabled) {
75  m_enabled = enabled;
76  if (m_listener) {
78  }
79  }
80  }
81 
83  if (std::find(m_active_layers.begin(), m_active_layers.end(), layer) == m_active_layers.end()) {
84  m_active_layers.push_back(layer);
85  }
86  }
87 
89  m_active_layers.remove(layer);
90  }
91 
93  m_active_layers.clear();
94  }
95 
97  return std::find(m_active_layers.begin(), m_active_layers.end(), layer) != m_active_layers.end();
98  }
99 
102 
103  const std::list<Layer*>& tmp = map->getLayers();
104  std::list<Layer*>::const_iterator it = tmp.begin();
105  for (; it != tmp.end(); ++it) {
106  addActiveLayer(*it);
107  }
108  }
109 
110 }
Abstract interface for all the renderbackends.
IRendererListener * m_listener
Definition: rendererbase.h:176
void removeActiveLayer(Layer *layer)
Removes active layer from renderer.
void activateAllLayers(Map *elevation)
Activates all layers from given elevation.
const std::list< Layer * > & getLayers() const
Get the layers on this map.
Definition: map.h:120
static Logger _log(LM_AUDIO)
void addActiveLayer(Layer *layer)
Adds active layer to renderer.
virtual void onRendererEnabledChanged(RendererBase *renderer)=0
Renderer is enabled / disabled.
void setPipelinePosition(int32_t position)
Sets renderer position in the rendering pipeline Pipeline position defines in which order view calls ...
RenderBackend * m_renderbackend
Definition: rendererbase.h:171
Base class for all view renderers View renderer renders one aspect of the view shown on screen...
Definition: rendererbase.h:78
bool isActivedLayer(Layer *layer)
Returns if given layer is currently activated.
A basic layer on a map.
Definition: layer.h:99
const int32_t DEFAULT_RENDERER_POSITION
virtual void setEnabled(bool enabled)
Enables renderer.
void clearActiveLayers()
Clears all active layers from renderer.
std::list< Layer * > m_active_layers
Definition: rendererbase.h:170
A container of Layer(s).
Definition: map.h:88
int32_t m_pipeline_position
Definition: rendererbase.h:175
virtual void onRendererPipelinePositionChanged(RendererBase *renderer)=0
Renderer&#39;s pipeline position has been changed.