Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/render2D/render_2d.cc @ 4848

Last change on this file since 4848 was 4848, checked in by bensch, 19 years ago

orxonox/trunk: more 2D-definitions, better draw function

File size: 1.9 KB
RevLine 
[4744]1/*
[3655]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program 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, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: ...
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
[4839]18#include "render_2d.h"
[3655]19
[4840]20#include "graphics_engine.h"
21#include "class_list.h"
22#include "list.h"
23#include "element_2d.h"
24
[3655]25using namespace std;
26
27
[4839]28
[3655]29/**
[4838]30 * standard constructor
31 */
[4839]32Render2D::Render2D ()
[3655]33{
[4839]34   this->setClassID(CL_RENDER_2D, "Render2D");
35   this->setName("Render2D");
[3655]36
[4848]37   this->element2DList = new tList<Element2D>;
[3655]38}
39
40/**
[4838]41 *  the singleton reference to this class
42 */
[4839]43Render2D* Render2D::singletonRef = NULL;
[3655]44
45/**
[4840]46 * standard deconstructor
[4838]47 */
[4839]48Render2D::~Render2D ()
[3655]49{
[4840]50  delete this->element2DList;
51
[4839]52  Render2D::singletonRef = NULL;
[3655]53}
[4840]54
55
56/**
57 * registers a 2D-element to the 2D-Renderer
58 * @param element2D the element to registers
[4848]59 *
60 * do not use this function by yourself, because this is used by Element2D's constructor
[4840]61 */
62void Render2D::registerElement2D(Element2D* element2D)
63{
64  this->element2DList->add(element2D);
65}
66
67/**
68 * unregisters a 2D-element from the 2D-Renderer
69 * @param element2D The element to unregister
[4848]70 *
71 * do not use this function by yourself, because this is used by Element2D's destructor
[4840]72 */
73void Render2D::unregisterElement2D(Element2D* element2D)
74{
75  this->element2DList->remove(element2D);
76}
[4847]77
78
79void Render2D::draw() const
80{
[4848]81  GraphicsEngine::enter2DMode();
82
[4847]83  tIterator<Element2D>* iterator = this->element2DList->getIterator();
84  Element2D* elem = iterator->nextElement();
85  while (elem != NULL)
86  {
87    if (elem->isVisible())
88      elem->draw();
89    elem = iterator->nextElement();
90  }
91  delete iterator;
[4848]92
93  GraphicsEngine::leave2DMode();
[4847]94}
Note: See TracBrowser for help on using the repository browser.