Mercurial > fife-parpg
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:70f41ea8e7db | 27:788cb9525b2f |
---|---|
33 #include "view/rendererbase.h" | 33 #include "view/rendererbase.h" |
34 | 34 |
35 namespace FIFE { | 35 namespace FIFE { |
36 class RenderBackend; | 36 class RenderBackend; |
37 class AbstractFont; | 37 class AbstractFont; |
38 class ImagePool; | |
39 class AnimationPool; | |
38 | 40 |
39 class GenericRendererNode { | 41 class GenericRendererNode { |
40 public: | 42 public: |
41 GenericRendererNode(Instance* attached_instance, Location* relative_location, const Point &relative_point = Point(0,0)); | 43 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)); | 44 GenericRendererNode(Instance* attached_instance, const Point &relative_point = Point(0,0)); |
73 Location* m_location; | 75 Location* m_location; |
74 Point m_point; | 76 Point m_point; |
75 }; | 77 }; |
76 class GenericRendererElementInfo { | 78 class GenericRendererElementInfo { |
77 public: | 79 public: |
78 virtual void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) { }; | 80 virtual void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { }; |
79 virtual ~GenericRendererElementInfo() {}; | 81 virtual ~GenericRendererElementInfo() {}; |
80 }; | 82 }; |
81 | 83 |
82 class GenericRendererLineInfo : public GenericRendererElementInfo { | 84 class GenericRendererLineInfo : public GenericRendererElementInfo { |
83 public: | 85 public: |
84 GenericRendererNode n1; | 86 GenericRendererNode n1; |
85 GenericRendererNode n2; | 87 GenericRendererNode n2; |
86 uint8_t r; | 88 uint8_t r; |
87 uint8_t g; | 89 uint8_t g; |
88 uint8_t b; | 90 uint8_t b; |
89 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend); | 91 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
90 GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); | 92 GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); |
91 virtual ~GenericRendererLineInfo() {}; | 93 virtual ~GenericRendererLineInfo() {}; |
92 }; | 94 }; |
93 class GenericRendererPointInfo : public GenericRendererElementInfo { | 95 class GenericRendererPointInfo : public GenericRendererElementInfo { |
94 public: | 96 public: |
95 GenericRendererNode n; | 97 GenericRendererNode n; |
96 uint8_t r; | 98 uint8_t r; |
97 uint8_t g; | 99 uint8_t g; |
98 uint8_t b; | 100 uint8_t b; |
99 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend); | 101 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
100 GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); | 102 GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); |
101 virtual ~GenericRendererPointInfo() {}; | 103 virtual ~GenericRendererPointInfo() {}; |
102 }; | 104 }; |
103 class GenericRendererQuadInfo : public GenericRendererElementInfo { | 105 class GenericRendererQuadInfo : public GenericRendererElementInfo { |
104 public: | 106 public: |
107 GenericRendererNode n3; | 109 GenericRendererNode n3; |
108 GenericRendererNode n4; | 110 GenericRendererNode n4; |
109 uint8_t r; | 111 uint8_t r; |
110 uint8_t g; | 112 uint8_t g; |
111 uint8_t b; | 113 uint8_t b; |
112 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend); | 114 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
113 GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); | 115 GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); |
114 virtual ~GenericRendererQuadInfo() {}; | 116 virtual ~GenericRendererQuadInfo() {}; |
115 }; | 117 }; |
116 class GenericRendererImageInfo : public GenericRendererElementInfo { | 118 class GenericRendererImageInfo : public GenericRendererElementInfo { |
117 public: | 119 public: |
118 GenericRendererNode n; | 120 GenericRendererNode n; |
119 int image; | 121 int image; |
120 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend); | 122 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
121 GenericRendererImageInfo(GenericRendererNode n, int image); | 123 GenericRendererImageInfo(GenericRendererNode n, int image); |
122 virtual ~GenericRendererImageInfo() {}; | 124 virtual ~GenericRendererImageInfo() {}; |
123 }; | 125 }; |
124 class GenericRendererAnimationInfo : public GenericRendererElementInfo { | 126 class GenericRendererAnimationInfo : public GenericRendererElementInfo { |
125 public: | 127 public: |
126 GenericRendererNode n; | 128 GenericRendererNode n; |
127 int animation; | 129 int animation; |
128 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend); | 130 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
129 GenericRendererAnimationInfo(GenericRendererNode n, int animation); | 131 GenericRendererAnimationInfo(GenericRendererNode n, int animation); |
130 virtual ~GenericRendererAnimationInfo() {}; | 132 virtual ~GenericRendererAnimationInfo() {}; |
131 }; | 133 }; |
132 class GenericRendererTextInfo : public GenericRendererElementInfo { | 134 class GenericRendererTextInfo : public GenericRendererElementInfo { |
133 public: | 135 public: |
134 GenericRendererNode n; | 136 GenericRendererNode n; |
135 AbstractFont* font; | 137 AbstractFont* font; |
136 std::string text; | 138 std::string text; |
137 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend); | 139 void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool); |
138 GenericRendererTextInfo(GenericRendererNode n, AbstractFont* font, std::string text); | 140 GenericRendererTextInfo(GenericRendererNode n, AbstractFont* font, std::string text); |
139 virtual ~GenericRendererTextInfo() {}; | 141 virtual ~GenericRendererTextInfo() {}; |
140 }; | 142 }; |
141 class GenericRenderer: public RendererBase { | 143 class GenericRenderer: public RendererBase { |
142 public: | 144 public: |
143 /** constructor. | 145 /** constructor. |
144 * @param renderbackend to use | 146 * @param renderbackend to use |
145 * @param position position for this renderer in rendering pipeline | 147 * @param position position for this renderer in rendering pipeline |
146 */ | 148 */ |
147 GenericRenderer(RenderBackend* renderbackend, int position); | 149 GenericRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool); |
148 | 150 |
149 GenericRenderer(const GenericRenderer& old); | 151 GenericRenderer(const GenericRenderer& old); |
150 | 152 |
151 RendererBase* clone(); | 153 RendererBase* clone(); |
152 | 154 |
168 void addAnimation(GenericRendererNode n, int animation); | 170 void addAnimation(GenericRendererNode n, int animation); |
169 void removeAll(); | 171 void removeAll(); |
170 | 172 |
171 private: | 173 private: |
172 std::vector<GenericRendererElementInfo*> m_infos; | 174 std::vector<GenericRendererElementInfo*> m_infos; |
175 ImagePool* m_imagepool; | |
176 AnimationPool* m_animationpool; | |
173 }; | 177 }; |
174 | 178 |
175 } | 179 } |
176 | 180 |
177 #endif | 181 #endif |