23
|
1 /***************************************************************************
|
|
2 * Copyright (C) 2005-2008 by the FIFE Team *
|
|
3 * http://www.fifengine.de *
|
|
4 * This file is part of FIFE. *
|
|
5 * *
|
|
6 * FIFE is free software; you can redistribute it and/or modify *
|
|
7 * it under the terms of the GNU General Public License as published by *
|
|
8 * the Free Software Foundation; either version 2 of the License, or *
|
|
9 * (at your option) any later version. *
|
|
10 * *
|
|
11 * This program 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 *
|
|
14 * GNU General Public License for more details. *
|
|
15 * *
|
|
16 * You should have received a copy of the GNU General Public License *
|
|
17 * along with this program; if not, write to the *
|
|
18 * Free Software Foundation, Inc., *
|
|
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
20 ***************************************************************************/
|
|
21
|
|
22 #ifndef FIFE_GENERICRENDERER_H
|
|
23 #define FIFE_GENERICRENDERER_H
|
|
24
|
|
25 // Standard C++ library includes
|
|
26
|
|
27 // 3rd party library includes
|
|
28
|
|
29 // FIFE includes
|
|
30 // These includes are split up in two parts, separated by one empty line
|
|
31 // First block: files included from the FIFE root src directory
|
|
32 // Second block: files included from the same folder
|
|
33 #include "view/rendererbase.h"
|
|
34
|
|
35 namespace FIFE {
|
|
36 class RenderBackend;
|
|
37 class AbstractFont;
|
|
38
|
|
39 class GenericRendererNode {
|
|
40 public:
|
|
41 GenericRendererNode(Instance* attached_instance, Location* relative_location, const Point &relative_point = Point(0,0));
|
|
42 GenericRendererNode(Instance* attached_instance, const Point &relative_point = Point(0,0));
|
|
43 GenericRendererNode(Location* attached_location, const Point &relative_point = Point(0,0));
|
|
44 GenericRendererNode(const Point &attached_point);
|
|
45 ~GenericRendererNode();
|
|
46
|
|
47 void setAttached(Instance* attached_instance, const Location &relative_location, const Point &relative_point);
|
|
48 void setAttached(Instance* attached_instance, const Location &relative_location);
|
|
49 void setAttached(Instance* attached_instance, const Point &relative_point);
|
|
50 void setAttached(Instance* attached_instance);
|
|
51 void setAttached(const Location &attached_location, const Point &relative_point);
|
|
52 void setAttached(const Location &attached_location);
|
|
53 void setAttached(const Point &attached_point);
|
|
54
|
|
55 void setRelative(const Location &relative_location);
|
|
56 void setRelative(const Location &relative_location, Point relative_point);
|
|
57 void setRelative(const Point &relative_point);
|
|
58
|
|
59 Instance* getAttachedInstance();
|
|
60 Location* getAttachedLocation();
|
|
61 Point getAttachedPoint();
|
|
62
|
|
63 Location* getOffsetLocation();
|
|
64 Point getOffsetPoint();
|
|
65
|
|
66 Instance* getInstance();
|
|
67 Location* getLocation();
|
|
68 Point getPoint();
|
|
69
|
|
70 Point getCalculatedPoint(Camera* cam, Layer* layer, std::vector<Instance*>& instances);
|
|
71 private:
|
|
72 Instance* m_instance;
|
|
73 Location* m_location;
|
|
74 Point m_point;
|
|
75 };
|
|
76 class GenericRendererElementInfo {
|
|
77 public:
|
|
78 virtual void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) { };
|
|
79 virtual ~GenericRendererElementInfo() {};
|
|
80 };
|
|
81
|
|
82 class GenericRendererLineInfo : public GenericRendererElementInfo {
|
|
83 public:
|
|
84 GenericRendererNode n1;
|
|
85 GenericRendererNode n2;
|
|
86 uint8_t r;
|
|
87 uint8_t g;
|
|
88 uint8_t b;
|
|
89 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend);
|
|
90 GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b);
|
|
91 virtual ~GenericRendererLineInfo() {};
|
|
92 };
|
|
93 class GenericRendererPointInfo : public GenericRendererElementInfo {
|
|
94 public:
|
|
95 GenericRendererNode n;
|
|
96 uint8_t r;
|
|
97 uint8_t g;
|
|
98 uint8_t b;
|
|
99 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend);
|
|
100 GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b);
|
|
101 virtual ~GenericRendererPointInfo() {};
|
|
102 };
|
|
103 class GenericRendererQuadInfo : public GenericRendererElementInfo {
|
|
104 public:
|
|
105 GenericRendererNode n1;
|
|
106 GenericRendererNode n2;
|
|
107 GenericRendererNode n3;
|
|
108 GenericRendererNode n4;
|
|
109 uint8_t r;
|
|
110 uint8_t g;
|
|
111 uint8_t b;
|
|
112 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend);
|
|
113 GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b);
|
|
114 virtual ~GenericRendererQuadInfo() {};
|
|
115 };
|
|
116 class GenericRendererImageInfo : public GenericRendererElementInfo {
|
|
117 public:
|
|
118 GenericRendererNode n;
|
|
119 int image;
|
|
120 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend);
|
|
121 GenericRendererImageInfo(GenericRendererNode n, int image);
|
|
122 virtual ~GenericRendererImageInfo() {};
|
|
123 };
|
|
124 class GenericRendererAnimationInfo : public GenericRendererElementInfo {
|
|
125 public:
|
|
126 GenericRendererNode n;
|
|
127 int animation;
|
|
128 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend);
|
|
129 GenericRendererAnimationInfo(GenericRendererNode n, int animation);
|
|
130 virtual ~GenericRendererAnimationInfo() {};
|
|
131 };
|
|
132 class GenericRendererTextInfo : public GenericRendererElementInfo {
|
|
133 public:
|
|
134 GenericRendererNode n;
|
|
135 AbstractFont* font;
|
|
136 std::string text;
|
|
137 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend);
|
|
138 GenericRendererTextInfo(GenericRendererNode n, AbstractFont* font, std::string text);
|
|
139 virtual ~GenericRendererTextInfo() {};
|
|
140 };
|
|
141 class GenericRenderer: public RendererBase {
|
|
142 public:
|
|
143 /** constructor.
|
|
144 * @param renderbackend to use
|
|
145 * @param position position for this renderer in rendering pipeline
|
|
146 */
|
|
147 GenericRenderer(RenderBackend* renderbackend, int position);
|
|
148
|
|
149 GenericRenderer(const GenericRenderer& old);
|
|
150
|
|
151 RendererBase* clone();
|
|
152
|
|
153 /** Destructor.
|
|
154 */
|
|
155 virtual ~GenericRenderer();
|
|
156 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances);
|
|
157 std::string getName() { return "GenericRenderer"; }
|
|
158
|
|
159 /** Gets instance for interface access
|
|
160 */
|
|
161 static GenericRenderer* getInstance(IRendererContainer* cnt);
|
|
162
|
|
163 void addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b);
|
|
164 void addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b);
|
|
165 void addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b);
|
|
166 void addText(GenericRendererNode n, AbstractFont* font, std::string text);
|
|
167 void addImage(GenericRendererNode n, int image);
|
|
168 void addAnimation(GenericRendererNode n, int animation);
|
|
169 void removeAll();
|
|
170
|
|
171 private:
|
|
172 std::vector<GenericRendererElementInfo*> m_infos;
|
|
173 };
|
|
174
|
|
175 }
|
|
176
|
|
177 #endif
|