[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: |
---|
[5399] | 12 | main-programmer: Benjamin Grauer |
---|
[3655] | 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[5398] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS |
---|
[3655] | 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 | |
---|
[4862] | 25 | #include <math.h> |
---|
| 26 | |
---|
[5417] | 27 | #include "shell_command.h" |
---|
| 28 | SHELL_COMMAND(toggleNodeVisibility, Render2D, toggleNodesVisibility); |
---|
| 29 | |
---|
[3655] | 30 | using namespace std; |
---|
| 31 | |
---|
| 32 | /** |
---|
[4838] | 33 | * standard constructor |
---|
| 34 | */ |
---|
[4839] | 35 | Render2D::Render2D () |
---|
[3655] | 36 | { |
---|
[4839] | 37 | this->setClassID(CL_RENDER_2D, "Render2D"); |
---|
| 38 | this->setName("Render2D"); |
---|
[5417] | 39 | |
---|
| 40 | this->showNodes = false; |
---|
[3655] | 41 | } |
---|
| 42 | |
---|
| 43 | /** |
---|
[4838] | 44 | * the singleton reference to this class |
---|
| 45 | */ |
---|
[4839] | 46 | Render2D* Render2D::singletonRef = NULL; |
---|
[3655] | 47 | |
---|
| 48 | /** |
---|
[4840] | 49 | * standard deconstructor |
---|
[4838] | 50 | */ |
---|
[4839] | 51 | Render2D::~Render2D () |
---|
[3655] | 52 | { |
---|
[5286] | 53 | delete NullElement2D::getInstance(); |
---|
| 54 | |
---|
[4839] | 55 | Render2D::singletonRef = NULL; |
---|
[3655] | 56 | } |
---|
[4840] | 57 | |
---|
| 58 | /** |
---|
[5406] | 59 | * updates all the 2d-elements |
---|
| 60 | * @param dt the timestep since last dt |
---|
| 61 | */ |
---|
| 62 | void Render2D::update(float dt) |
---|
| 63 | { |
---|
| 64 | NullElement2D::getInstance()->update2D(dt); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | /** |
---|
[4862] | 69 | * ticks all the 2d-elements |
---|
| 70 | * @param dt the timestep since last dt |
---|
| 71 | */ |
---|
[4849] | 72 | void Render2D::tick(float dt) |
---|
| 73 | { |
---|
[5401] | 74 | NullElement2D::getInstance()->tick2D(dt); |
---|
[4849] | 75 | } |
---|
| 76 | |
---|
| 77 | /** |
---|
[5397] | 78 | * renders all the Elements of the Render2D-engine's layer |
---|
| 79 | * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn) |
---|
[4849] | 80 | */ |
---|
[5404] | 81 | void Render2D::draw(short layer) const |
---|
[4847] | 82 | { |
---|
[4848] | 83 | GraphicsEngine::enter2DMode(); |
---|
[5401] | 84 | NullElement2D::getInstance()->draw2D(E2D_LAYER_ALL); |
---|
[5417] | 85 | if (this->showNodes) |
---|
| 86 | NullElement2D::getInstance()->debugDraw2D(0); |
---|
[4848] | 87 | GraphicsEngine::leave2DMode(); |
---|
[4847] | 88 | } |
---|
[5399] | 89 | |
---|
| 90 | |
---|