FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
lightrenderer.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_LIGHTRENDERER_H
23 #define FIFE_LIGHTRENDERER_H
24 
25 // Standard C++ library includes
26 #include <vector>
27 
28 // 3rd party library includes
29 
30 // FIFE includes
31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src directory
33 // Second block: files included from the same folder
35 #include "view/rendererbase.h"
36 #include "video/animation.h"
37 
38 namespace FIFE {
39  class RenderBackend;
40  class IFont;
41 
43  public:
44  LightRendererElementInfo(RendererNode n, int32_t src, int32_t dst);
46 
47  virtual void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend) = 0;
48  virtual std::string getName() = 0;
49 
50  RendererNode* getNode() { return &m_anchor; };
51  int32_t getSrcBlend() { return m_src; };
52  int32_t getDstBlend() { return m_dst; };
53 
54  void setStencil(uint8_t stencil_ref);
55  int32_t getStencil();
56  void removeStencil();
57 
58  virtual std::vector<uint8_t> getColor() { return std::vector<uint8_t>(); };
59  virtual float getRadius() { return 0; };
60  virtual int32_t getSubdivisions() { return 0; };
61  virtual float getXStretch() { return 0; };
62  virtual float getYStretch() { return 0; };
63 
64  protected:
66  int32_t m_src;
67  int32_t m_dst;
68  bool m_stencil;
70  };
71 
73  public:
74  LightRendererImageInfo(RendererNode n, ImagePtr image, int32_t src, int32_t dst);
76 
77  virtual void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend);
78  virtual std::string getName() { return "image"; };
79  ImagePtr getImage() { return m_image; };
80 
81  private:
83  };
84 
86  public:
87  LightRendererAnimationInfo(RendererNode n, AnimationPtr animation, int32_t src, int32_t dst);
89 
90  virtual void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend);
91  virtual std::string getName() { return "animation"; };
92  AnimationPtr getAnimation() { return m_animation; };
93 
94  private:
97  float m_time_scale;
98  };
99 
101  public:
102  LightRendererSimpleLightInfo(RendererNode n, uint8_t intensity, float radius, int32_t subdivisions, float xstretch, float ystretch, uint8_t r, uint8_t g, uint8_t b, int32_t src, int32_t dst);
104 
105  virtual void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend);
106  virtual std::string getName() { return "simple"; };
107 
108  std::vector<uint8_t> getColor();
109  float getRadius() { return m_radius; };
110  int32_t getSubdivisions() { return m_subdivisions; };
111  float getXStretch() { return m_xstretch; };
112  float getYStretch() { return m_ystretch; };
113 
114  private:
116  float m_radius;
117  int32_t m_subdivisions;
118  float m_xstretch;
119  float m_ystretch;
123  };
124 
126  public:
127  LightRendererResizeInfo(RendererNode n, ImagePtr image, int32_t width, int32_t height, int32_t src, int32_t dst);
129 
130  virtual void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend);
131  virtual std::string getName() { return "resize"; };
132 
133  ImagePtr getImage() { return m_image; };
134 
135  private:
137  int32_t m_width;
138  int32_t m_height;
139  };
140 
141  class LightRenderer: public RendererBase {
142  public:
147  LightRenderer(RenderBackend* renderbackend, int32_t position);
148 
149  LightRenderer(const LightRenderer& old);
150 
151  RendererBase* clone();
152 
155  virtual ~LightRenderer();
156  void render(Camera* cam, Layer* layer, RenderList& instances);
157  std::string getName() { return "LightRenderer"; }
158 
161  static LightRenderer* getInstance(IRendererContainer* cnt);
162 
163  void addImage(const std::string &group, RendererNode n, ImagePtr image, int32_t src=-1, int32_t dst=-1);
164  void addAnimation(const std::string &group, RendererNode n, AnimationPtr animation, int32_t src=-1, int32_t dst=-1);
165  void addSimpleLight(const std::string &group, RendererNode n, uint8_t intensity, float radius, int32_t subdivisions, float xstretch, float ystretch, uint8_t r, uint8_t g, uint8_t b, int32_t src=-1, int32_t dst=-1);
166  void resizeImage(const std::string &group, RendererNode n, ImagePtr image, int32_t width, int32_t height, int32_t src=-1, int32_t dst=-1);
167  void addStencilTest(const std::string &group, uint8_t stencil_ref=0);
168  void removeStencilTest(const std::string &group);
169  std::list<std::string> getGroups();
170  std::vector<LightRendererElementInfo*> getLightInfo(const std::string &group);
171  void removeAll(const std::string &group);
172  void removeAll();
173  void reset();
174 
175  private:
176  std::map<std::string, std::vector<LightRendererElementInfo*> > m_groups;
177  };
178 
179 }
180 
181 #endif
virtual int32_t getSubdivisions()
Definition: lightrenderer.h:60
Abstract interface for all the renderbackends.
virtual std::string getName()
Definition: lightrenderer.h:78
std::vector< RenderItem * > RenderList
Definition: renderitem.h:130
void setStencil(uint8_t stencil_ref)
LightRendererElementInfo(RendererNode n, int32_t src, int32_t dst)
virtual std::vector< uint8_t > getColor()
Definition: lightrenderer.h:58
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 std::string getName()=0
unsigned char uint8_t
Definition: core.h:38
Base class for all view renderers View renderer renders one aspect of the view shown on screen...
Definition: rendererbase.h:78
virtual std::string getName()
Definition: lightrenderer.h:91
A basic layer on a map.
Definition: layer.h:99
std::map< std::string, std::vector< LightRendererElementInfo * > > m_groups
virtual void render(Camera *cam, Layer *layer, RenderList &instances, RenderBackend *renderbackend)=0
unsigned int uint32_t
Definition: core.h:40
virtual std::string getName()
std::string getName()
Name of the renderer.