Mercurial > fife-parpg
annotate engine/core/view/renderers/genericrenderer.h @ 27:788cb9525b2f
add image and text renderer to generic renderer
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 11 Jul 2008 11:57:48 +0000 |
parents | 70f41ea8e7db |
children | 0cb049f291e1 |
rev | line source |
---|---|
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; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
38 class ImagePool; |
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
39 class AnimationPool; |
23 | 40 |
41 class GenericRendererNode { | |
42 public: | |
43 GenericRendererNode(Instance* attached_instance, Location* relative_location, const Point &relative_point = Point(0,0)); | |
44 GenericRendererNode(Instance* attached_instance, const Point &relative_point = Point(0,0)); | |
45 GenericRendererNode(Location* attached_location, const Point &relative_point = Point(0,0)); | |
46 GenericRendererNode(const Point &attached_point); | |
47 ~GenericRendererNode(); | |
48 | |
26
70f41ea8e7db
fix compile errors in node setters...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
23
diff
changeset
|
49 void setAttached(Instance* attached_instance, Location* relative_location, const Point &relative_point); |
70f41ea8e7db
fix compile errors in node setters...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
23
diff
changeset
|
50 void setAttached(Instance* attached_instance, Location* relative_location); |
23 | 51 void setAttached(Instance* attached_instance, const Point &relative_point); |
52 void setAttached(Instance* attached_instance); | |
26
70f41ea8e7db
fix compile errors in node setters...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
23
diff
changeset
|
53 void setAttached(Location* attached_location, const Point &relative_point); |
70f41ea8e7db
fix compile errors in node setters...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
23
diff
changeset
|
54 void setAttached(Location* attached_location); |
23 | 55 void setAttached(const Point &attached_point); |
56 | |
26
70f41ea8e7db
fix compile errors in node setters...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
23
diff
changeset
|
57 void setRelative(Location* relative_location); |
70f41ea8e7db
fix compile errors in node setters...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
23
diff
changeset
|
58 void setRelative(Location* relative_location, Point relative_point); |
23 | 59 void setRelative(const Point &relative_point); |
60 | |
61 Instance* getAttachedInstance(); | |
62 Location* getAttachedLocation(); | |
63 Point getAttachedPoint(); | |
64 | |
65 Location* getOffsetLocation(); | |
66 Point getOffsetPoint(); | |
67 | |
68 Instance* getInstance(); | |
69 Location* getLocation(); | |
70 Point getPoint(); | |
71 | |
72 Point getCalculatedPoint(Camera* cam, Layer* layer, std::vector<Instance*>& instances); | |
73 private: | |
74 Instance* m_instance; | |
75 Location* m_location; | |
76 Point m_point; | |
77 }; | |
78 class GenericRendererElementInfo { | |
79 public: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
80 virtual void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { }; |
23 | 81 virtual ~GenericRendererElementInfo() {}; |
82 }; | |
83 | |
84 class GenericRendererLineInfo : public GenericRendererElementInfo { | |
85 public: | |
86 GenericRendererNode n1; | |
87 GenericRendererNode n2; | |
88 uint8_t r; | |
89 uint8_t g; | |
90 uint8_t b; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
91 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 92 GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); |
93 virtual ~GenericRendererLineInfo() {}; | |
94 }; | |
95 class GenericRendererPointInfo : public GenericRendererElementInfo { | |
96 public: | |
97 GenericRendererNode n; | |
98 uint8_t r; | |
99 uint8_t g; | |
100 uint8_t b; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
101 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 102 GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); |
103 virtual ~GenericRendererPointInfo() {}; | |
104 }; | |
105 class GenericRendererQuadInfo : public GenericRendererElementInfo { | |
106 public: | |
107 GenericRendererNode n1; | |
108 GenericRendererNode n2; | |
109 GenericRendererNode n3; | |
110 GenericRendererNode n4; | |
111 uint8_t r; | |
112 uint8_t g; | |
113 uint8_t b; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
114 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 115 GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); |
116 virtual ~GenericRendererQuadInfo() {}; | |
117 }; | |
118 class GenericRendererImageInfo : public GenericRendererElementInfo { | |
119 public: | |
120 GenericRendererNode n; | |
121 int image; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
122 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 123 GenericRendererImageInfo(GenericRendererNode n, int image); |
124 virtual ~GenericRendererImageInfo() {}; | |
125 }; | |
126 class GenericRendererAnimationInfo : public GenericRendererElementInfo { | |
127 public: | |
128 GenericRendererNode n; | |
129 int animation; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
130 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 131 GenericRendererAnimationInfo(GenericRendererNode n, int animation); |
132 virtual ~GenericRendererAnimationInfo() {}; | |
133 }; | |
134 class GenericRendererTextInfo : public GenericRendererElementInfo { | |
135 public: | |
136 GenericRendererNode n; | |
137 AbstractFont* font; | |
138 std::string text; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
139 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 140 GenericRendererTextInfo(GenericRendererNode n, AbstractFont* font, std::string text); |
141 virtual ~GenericRendererTextInfo() {}; | |
142 }; | |
143 class GenericRenderer: public RendererBase { | |
144 public: | |
145 /** constructor. | |
146 * @param renderbackend to use | |
147 * @param position position for this renderer in rendering pipeline | |
148 */ | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
149 GenericRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool); |
23 | 150 |
151 GenericRenderer(const GenericRenderer& old); | |
152 | |
153 RendererBase* clone(); | |
154 | |
155 /** Destructor. | |
156 */ | |
157 virtual ~GenericRenderer(); | |
158 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances); | |
159 std::string getName() { return "GenericRenderer"; } | |
160 | |
161 /** Gets instance for interface access | |
162 */ | |
163 static GenericRenderer* getInstance(IRendererContainer* cnt); | |
164 | |
165 void addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); | |
166 void addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); | |
167 void addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); | |
168 void addText(GenericRendererNode n, AbstractFont* font, std::string text); | |
169 void addImage(GenericRendererNode n, int image); | |
170 void addAnimation(GenericRendererNode n, int animation); | |
171 void removeAll(); | |
172 | |
173 private: | |
174 std::vector<GenericRendererElementInfo*> m_infos; | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
175 ImagePool* m_imagepool; |
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
176 AnimationPool* m_animationpool; |
23 | 177 }; |
178 | |
179 } | |
180 | |
181 #endif |