Mercurial > fife-parpg
annotate engine/core/view/renderers/genericrenderer.h @ 29:0cb049f291e1
make members private and prefix with m_
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 11 Jul 2008 13:00:10 +0000 |
parents | 788cb9525b2f |
children | 9a9f4447af7c |
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: | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
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: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
86 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 87 GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); |
88 virtual ~GenericRendererLineInfo() {}; | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
89 private: |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
90 GenericRendererNode m_edge1; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
91 GenericRendererNode m_edge2; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
92 uint8_t m_red; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
93 uint8_t m_green; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
94 uint8_t m_blue; |
23 | 95 }; |
96 class GenericRendererPointInfo : public GenericRendererElementInfo { | |
97 public: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
98 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 99 GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); |
100 virtual ~GenericRendererPointInfo() {}; | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
101 private: |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
102 GenericRendererNode m_anchor; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
103 uint8_t m_red; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
104 uint8_t m_green; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
105 uint8_t m_blue; |
23 | 106 }; |
107 class GenericRendererQuadInfo : public GenericRendererElementInfo { | |
108 public: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
109 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 110 GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); |
111 virtual ~GenericRendererQuadInfo() {}; | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
112 private: |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
113 GenericRendererNode m_edge1; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
114 GenericRendererNode m_edge2; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
115 GenericRendererNode m_edge3; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
116 GenericRendererNode m_edge4; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
117 uint8_t m_red; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
118 uint8_t m_green; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
119 uint8_t m_blue; |
23 | 120 }; |
121 class GenericRendererImageInfo : public GenericRendererElementInfo { | |
122 public: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
123 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 124 GenericRendererImageInfo(GenericRendererNode n, int image); |
125 virtual ~GenericRendererImageInfo() {}; | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
126 private: |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
127 GenericRendererNode m_anchor; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
128 int m_image; |
23 | 129 }; |
130 class GenericRendererAnimationInfo : public GenericRendererElementInfo { | |
131 public: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
132 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 133 GenericRendererAnimationInfo(GenericRendererNode n, int animation); |
134 virtual ~GenericRendererAnimationInfo() {}; | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
135 private: |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
136 GenericRendererNode m_anchor; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
137 int m_animation; |
23 | 138 }; |
139 class GenericRendererTextInfo : public GenericRendererElementInfo { | |
140 public: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
141 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
23 | 142 GenericRendererTextInfo(GenericRendererNode n, AbstractFont* font, std::string text); |
143 virtual ~GenericRendererTextInfo() {}; | |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
144 private: |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
145 GenericRendererNode m_anchor; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
146 AbstractFont* m_font; |
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
147 std::string m_text; |
23 | 148 }; |
149 class GenericRenderer: public RendererBase { | |
150 public: | |
151 /** constructor. | |
152 * @param renderbackend to use | |
153 * @param position position for this renderer in rendering pipeline | |
154 */ | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
155 GenericRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool); |
23 | 156 |
157 GenericRenderer(const GenericRenderer& old); | |
158 | |
159 RendererBase* clone(); | |
160 | |
161 /** Destructor. | |
162 */ | |
163 virtual ~GenericRenderer(); | |
164 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances); | |
165 std::string getName() { return "GenericRenderer"; } | |
166 | |
167 /** Gets instance for interface access | |
168 */ | |
169 static GenericRenderer* getInstance(IRendererContainer* cnt); | |
170 | |
171 void addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); | |
172 void addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); | |
173 void addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); | |
174 void addText(GenericRendererNode n, AbstractFont* font, std::string text); | |
175 void addImage(GenericRendererNode n, int image); | |
176 void addAnimation(GenericRendererNode n, int animation); | |
177 void removeAll(); | |
178 | |
179 private: | |
27
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
180 ImagePool* m_imagepool; |
788cb9525b2f
add image and text renderer to generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
26
diff
changeset
|
181 AnimationPool* m_animationpool; |
29
0cb049f291e1
make members private and prefix with m_
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
27
diff
changeset
|
182 std::vector<GenericRendererElementInfo*> m_infos; |
23 | 183 }; |
184 | |
185 } | |
186 | |
187 #endif |