Changeset 5398 in orxonox.OLD for trunk/src/lib/graphics/render2D
- Timestamp:
- Oct 18, 2005, 6:28:54 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r5397 r5398 113 113 this->setActiveness(true); 114 114 this->setAlignment(E2D_ALIGN_NONE); 115 this->layer = E2D_ TOP;115 this->layer = E2D_DEFAULT_LAYER; 116 116 this->bindNode = NULL; 117 117 … … 214 214 { 215 215 if (!strcmp(layer, "top")) 216 this->setLayer(E2D_ TOP);216 this->setLayer(E2D_LAYER_TOP); 217 217 else if (!strcmp(layer, "medium")) 218 this->setLayer(E2D_ MEDIUM);218 this->setLayer(E2D_LAYER_MEDIUM); 219 219 else if (!strcmp(layer, "bottom")) 220 this->setLayer(E2D_ BOTTOM);220 this->setLayer(E2D_LAYER_BOTTOM); 221 221 else if (!strcmp(layer, "below-all")) 222 this->setLayer(E2D_ BELOW_ALL);222 this->setLayer(E2D_LAYER_BELOW_ALL); 223 223 } 224 224 -
trunk/src/lib/graphics/render2D/element_2d.h
r5397 r5398 21 21 typedef enum 22 22 { 23 E2D_ BELOW_ALL,//!< Will be rendered below the 3D-scene. @todo make this work.24 E2D_ BOTTOM,//!< Will be rendered on the bottom Layer25 E2D_ MEDIUM,//!< Will be rendered on the medium Layer.26 E2D_ TOP,//!< Will be rendered on top of everything else27 28 E2D_LAYER_COUNT ,//!< The count of Layers.29 30 E2D_LAYER_ALL ,23 E2D_LAYER_BELOW_ALL = 0, //!< Will be rendered below the 3D-scene. @todo make this work. 24 E2D_LAYER_BOTTOM = 1, //!< Will be rendered on the bottom Layer 25 E2D_LAYER_MEDIUM = 2, //!< Will be rendered on the medium Layer. 26 E2D_LAYER_TOP = 3, //!< Will be rendered on top of everything else 27 28 E2D_LAYER_COUNT = 4, //!< The count of Layers. 29 30 E2D_LAYER_ALL = 5, 31 31 } E2D_LAYER; 32 #define E2D_DEFAULT_LAYER E2D_ TOP32 #define E2D_DEFAULT_LAYER E2D_LAYER_MEDIUM 33 33 34 34 typedef enum … … 81 81 void setLayer(const char* layer); 82 82 /** @returns the Layer this Element is drawn to */ 83 inline E2D_LAYER getLayer() { return this->layer; };83 inline E2D_LAYER getLayer() const { return this->layer; }; 84 84 85 85 /** @param visible true if the Element should be visible false otherwise (will not be rendered) */ -
trunk/src/lib/graphics/render2D/render_2d.cc
r5397 r5398 14 14 */ 15 15 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS 17 17 18 18 #include "render_2d.h" … … 66 66 void Render2D::registerElement2D(Element2D* element2D) 67 67 { 68 if (likely(element2D != NULL)) 69 this->element2DList[E2D_DEFAULT_LAYER]->add(element2D); 68 if (likely(element2D != NULL) && element2D->getLayer() < E2D_LAYER_COUNT) 69 this->element2DList[element2D->getLayer()]->add(element2D); 70 // DEBUG printf("::::%p, %d %d \n", element2D, element2D->getLayer(), this->element2DList[element2D->getLayer()]->getSize()); 70 71 } 71 72 … … 79 80 void Render2D::unregisterElement2D(Element2D* element2D) 80 81 { 81 this->element2DList[element2D->getLayer()]->remove(element2D); 82 if (likely(element2D != NULL) && element2D->getLayer() < E2D_LAYER_COUNT) 83 this->element2DList[element2D->getLayer()]->remove(element2D); 84 // DEBUG printf(":::%s layer: %d, %d\n", element2D->getClassName(), element2D->getLayer(), this->element2DList[element2D->getLayer()]->getSize()); 82 85 } 83 86 … … 93 96 return; 94 97 95 if (E2D_LAYER_COUNT >to)98 if (E2D_LAYER_COUNT < to) 96 99 to = E2D_DEFAULT_LAYER; 97 if ( element2D->getLayer() != to)100 if (likely(element2D->getLayer() != to)) 98 101 { 99 102 this->element2DList[element2D->getLayer()]->remove(element2D); … … 127 130 * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn) 128 131 */ 129 void Render2D::draw( unsigned intlayer) const132 void Render2D::draw(E2D_LAYER layer) const 130 133 { 131 134 GraphicsEngine::enter2DMode(); … … 133 136 if (layer != E2D_LAYER_ALL) 134 137 { 135 if ( this->element2DList[layer]->getSize() > 0)138 if (likely(this->element2DList[layer]->getSize() > 0)) 136 139 { 137 140 tIterator<Element2D>* iterator = this->element2DList[layer]->getIterator(); -
trunk/src/lib/graphics/render2D/render_2d.h
r5397 r5398 23 23 24 24 void tick(float dt); 25 void draw( unsigned intlayer) const;25 void draw(E2D_LAYER layer) const; 26 26 27 27
Note: See TracChangeset
for help on using the changeset viewer.