comparison engine/core/view/renderers/genericrenderer.cpp @ 583:47b49b9b0c0a

* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands. * Added a triangle function to backends and genericrenderer, also added the functions to set an alpha value for geometric figures.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 07 Aug 2010 16:36:35 +0000
parents b2feacaed53c
children a2dde16ddc62
comparison
equal deleted inserted replaced
582:5e04f6349894 583:47b49b9b0c0a
227 setAttached(*layer_it); 227 setAttached(*layer_it);
228 } 228 }
229 return Point(m_point.x + p.x, m_point.y + p.y); 229 return Point(m_point.x + p.x, m_point.y + p.y);
230 } 230 }
231 231
232 GenericRendererLineInfo::GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b): 232 GenericRendererLineInfo::GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a):
233 GenericRendererElementInfo(), 233 GenericRendererElementInfo(),
234 m_edge1(n1), 234 m_edge1(n1),
235 m_edge2(n2), 235 m_edge2(n2),
236 m_red(r), 236 m_red(r),
237 m_green(g), 237 m_green(g),
238 m_blue(b) { 238 m_blue(b),
239 m_alpha(a) {
239 } 240 }
240 void GenericRendererLineInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 241 void GenericRendererLineInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
241 Point p1 = m_edge1.getCalculatedPoint(cam, layer); 242 Point p1 = m_edge1.getCalculatedPoint(cam, layer);
242 Point p2 = m_edge2.getCalculatedPoint(cam, layer); 243 Point p2 = m_edge2.getCalculatedPoint(cam, layer);
243 if(m_edge1.getLayer() == layer) { 244 if(m_edge1.getLayer() == layer) {
244 renderbackend->drawLine(p1, p2, m_red, m_green, m_blue); 245 renderbackend->drawLine(p1, p2, m_red, m_green, m_blue, m_alpha);
245 } 246 }
246 } 247 }
247 248
248 GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode anchor, uint8_t r, uint8_t g, uint8_t b): 249 GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode anchor, uint8_t r, uint8_t g, uint8_t b, uint8_t a):
249 GenericRendererElementInfo(), 250 GenericRendererElementInfo(),
250 m_anchor(anchor), 251 m_anchor(anchor),
251 m_red(r), 252 m_red(r),
252 m_green(g), 253 m_green(g),
253 m_blue(b) { 254 m_blue(b),
255 m_alpha(a) {
254 } 256 }
255 void GenericRendererPointInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 257 void GenericRendererPointInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
256 Point p = m_anchor.getCalculatedPoint(cam, layer); 258 Point p = m_anchor.getCalculatedPoint(cam, layer);
257 if(m_anchor.getLayer() == layer) { 259 if(m_anchor.getLayer() == layer) {
258 renderbackend->putPixel(p.x, p.y, m_red, m_green, m_blue); 260 renderbackend->putPixel(p.x, p.y, m_red, m_green, m_blue, m_alpha);
259 } 261 }
260 } 262 }
261 263
262 GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b): 264 GenericRendererTriangleInfo::GenericRendererTriangleInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a):
265 GenericRendererElementInfo(),
266 m_edge1(n1),
267 m_edge2(n2),
268 m_edge3(n3),
269 m_red(r),
270 m_green(g),
271 m_blue(b),
272 m_alpha(a) {
273 }
274 void GenericRendererTriangleInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
275 Point p1 = m_edge1.getCalculatedPoint(cam, layer);
276 Point p2 = m_edge2.getCalculatedPoint(cam, layer);
277 Point p3 = m_edge3.getCalculatedPoint(cam, layer);
278 if(m_edge1.getLayer() == layer) {
279 renderbackend->drawTriangle(p1, p2, p3, m_red, m_green, m_blue, m_alpha);
280 }
281 }
282
283 GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a):
263 GenericRendererElementInfo(), 284 GenericRendererElementInfo(),
264 m_edge1(n1), 285 m_edge1(n1),
265 m_edge2(n2), 286 m_edge2(n2),
266 m_edge3(n3), 287 m_edge3(n3),
267 m_edge4(n4), 288 m_edge4(n4),
268 m_red(r), 289 m_red(r),
269 m_green(g), 290 m_green(g),
270 m_blue(b) { 291 m_blue(b),
292 m_alpha(a) {
271 } 293 }
272 void GenericRendererQuadInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 294 void GenericRendererQuadInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
273 Point p1 = m_edge1.getCalculatedPoint(cam, layer); 295 Point p1 = m_edge1.getCalculatedPoint(cam, layer);
274 Point p2 = m_edge2.getCalculatedPoint(cam, layer); 296 Point p2 = m_edge2.getCalculatedPoint(cam, layer);
275 Point p3 = m_edge3.getCalculatedPoint(cam, layer); 297 Point p3 = m_edge3.getCalculatedPoint(cam, layer);
276 Point p4 = m_edge4.getCalculatedPoint(cam, layer); 298 Point p4 = m_edge4.getCalculatedPoint(cam, layer);
277 if(m_edge1.getLayer() == layer) { 299 if(m_edge1.getLayer() == layer) {
278 renderbackend->drawQuad(p1, p2, p3, p4, m_red, m_green, m_blue); 300 renderbackend->drawQuad(p1, p2, p3, p4, m_red, m_green, m_blue, m_alpha);
279 } 301 }
280 } 302 }
281 303
282 GenericRendererVertexInfo::GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b): 304 GenericRendererVertexInfo::GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a):
283 GenericRendererElementInfo(), 305 GenericRendererElementInfo(),
284 m_center(center), 306 m_center(center),
285 m_size(size), 307 m_size(size),
286 m_red(r), 308 m_red(r),
287 m_green(g), 309 m_green(g),
288 m_blue(b) { 310 m_blue(b),
311 m_alpha(a) {
289 } 312 }
290 void GenericRendererVertexInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 313 void GenericRendererVertexInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
291 Point p = m_center.getCalculatedPoint(cam, layer); 314 Point p = m_center.getCalculatedPoint(cam, layer);
292 if(m_center.getLayer() == layer) { 315 if(m_center.getLayer() == layer) {
293 renderbackend->drawVertex(p, m_size, m_red, m_green, m_blue); 316 renderbackend->drawVertex(p, m_size, m_red, m_green, m_blue, m_alpha);
294 } 317 }
295 } 318 }
296 319
297 GenericRendererImageInfo::GenericRendererImageInfo(GenericRendererNode anchor, int image): 320 GenericRendererImageInfo::GenericRendererImageInfo(GenericRendererNode anchor, int image):
298 GenericRendererElementInfo(), 321 GenericRendererElementInfo(),
383 return new GenericRenderer(*this); 406 return new GenericRenderer(*this);
384 } 407 }
385 408
386 GenericRenderer::~GenericRenderer() { 409 GenericRenderer::~GenericRenderer() {
387 } 410 }
388 void GenericRenderer::addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) { 411 void GenericRenderer::addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
389 GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b); 412 GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b, a);
390 m_groups[group].push_back(info); 413 m_groups[group].push_back(info);
391 } 414 }
392 void GenericRenderer::addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) { 415 void GenericRenderer::addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
393 GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b); 416 GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b, a);
394 m_groups[group].push_back(info); 417 m_groups[group].push_back(info);
395 } 418 }
396 void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { 419 void GenericRenderer::addTriangle(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
397 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b); 420 GenericRendererElementInfo* info = new GenericRendererTriangleInfo(n1, n2, n3, r, g, b, a);
398 m_groups[group].push_back(info); 421 m_groups[group].push_back(info);
399 } 422 }
400 void GenericRenderer::addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b) { 423 void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
401 GenericRendererElementInfo* info = new GenericRendererVertexInfo(n, size, r, g, b); 424 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b, a);
425 m_groups[group].push_back(info);
426 }
427 void GenericRenderer::addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
428 GenericRendererElementInfo* info = new GenericRendererVertexInfo(n, size, r, g, b, a);
402 m_groups[group].push_back(info); 429 m_groups[group].push_back(info);
403 } 430 }
404 void GenericRenderer::addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text) { 431 void GenericRenderer::addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text) {
405 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text); 432 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text);
406 m_groups[group].push_back(info); 433 m_groups[group].push_back(info);