Changeset 5397 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Oct 18, 2005, 5:33:11 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r5394 r5397 415 415 } 416 416 child->parent = this; 417 this->children->add(child); 417 if (unlikely(this != NULL)) 418 this->children->add(child); 418 419 child->parentCoorChanged(); 419 420 } -
trunk/src/lib/graphics/graphics_engine.cc
r5347 r5397 546 546 GraphicsEngine::storeMatrices(); 547 547 Shader::suspendShader(); 548 Render2D::getInstance()->draw(E2D_ ALL_LAYERS);548 Render2D::getInstance()->draw(E2D_LAYER_ALL); 549 549 Shader::restoreShader(); 550 550 LightManager::getInstance()->draw(); -
trunk/src/lib/graphics/render2D/element_2d.cc
r5396 r5397 35 35 { 36 36 this->init(); 37 Render2D::getInstance()->registerElement2D(this); 37 38 this->setParent2D(NullElement2D::getInstance()); 38 39 } … … 48 49 { 49 50 this->init(); 51 Render2D::getInstance()->registerElement2D(this); 50 52 51 53 // check Parenting, and if ok parent the stuff … … 124 126 this->toDirection = NULL; 125 127 this->setSize2D(1,1); 126 127 Render2D::getInstance()->registerElement2D(this);128 128 } 129 129 … … 471 471 child->parentMode = parentingMode; 472 472 child->parent = this; 473 this->children->add(child); 473 if (likely(this != NULL)) 474 this->children->add(child); 474 475 child->parentCoorChanged(); 475 476 } … … 667 668 668 669 669 if ( this->alignment == E2D_ALIGN_SCREEN_CENTER && this->bRelCoorChanged)670 if (unlikely(this->alignment & E2D_ALIGN_SCREEN_CENTER && this->bRelCoorChanged)) 670 671 { 671 672 this->prevRelCoordinate = this->relCoordinate; … … 674 675 this->absCoordinate.z = 0.0; 675 676 } 676 else if ( this->bindNode)677 else if (unlikely(this->bindNode != NULL)) 677 678 { 678 679 GLdouble projectPos[3]; -
trunk/src/lib/graphics/render2D/element_2d.h
r5387 r5397 21 21 typedef enum 22 22 { 23 E2D_BELOW_ALL = 1, //!< Will be rendered below the 3D-scene. @todo make this work. 24 E2D_BOTTOM = 2, //!< Will be rendered on the bottom Layer 25 E2D_MEDIUM = 4, //!< Will be rendered on the medium Layer. 26 E2D_TOP = 8, //!< Will be rendered on top of everything else 27 28 E2D_LAYER_COUNT = 4 //!< The count of Layers. 23 E2D_BELOW_ALL, //!< Will be rendered below the 3D-scene. @todo make this work. 24 E2D_BOTTOM, //!< Will be rendered on the bottom Layer 25 E2D_MEDIUM, //!< Will be rendered on the medium Layer. 26 E2D_TOP, //!< Will be rendered on top of everything else 27 28 E2D_LAYER_COUNT, //!< The count of Layers. 29 30 E2D_LAYER_ALL, 29 31 } E2D_LAYER; 30 32 #define E2D_DEFAULT_LAYER E2D_TOP 31 #define E2D_ALL_LAYERS E2D_TOP | E2D_MEDIUM | E2D_BOTTOM | E2D_BELOW_ALL32 33 33 34 typedef enum … … 153 154 void setParent2D (const char* parentName); 154 155 /** @returns the parent of this Element2D */ 155 inline Element2D* getParent () const { return this->parent; };156 inline Element2D* getParent2D () const { return this->parent; }; 156 157 /** @returns the List of Children of this Element2D */ 157 158 inline const tList<Element2D>* getChildren2D() const { return this->children; }; -
trunk/src/lib/graphics/render2D/render_2d.cc
r5382 r5397 67 67 { 68 68 if (likely(element2D != NULL)) 69 this->element2DList[ (int)log2(E2D_DEFAULT_LAYER)]->add(element2D);69 this->element2DList[E2D_DEFAULT_LAYER]->add(element2D); 70 70 } 71 71 … … 79 79 void Render2D::unregisterElement2D(Element2D* element2D) 80 80 { 81 this->element2DList[ (int)log2(element2D->getLayer())]->remove(element2D);81 this->element2DList[element2D->getLayer()]->remove(element2D); 82 82 } 83 83 … … 93 93 return; 94 94 95 if ( unlikely(pow(2, E2D_LAYER_COUNT ) > to))95 if (E2D_LAYER_COUNT > to) 96 96 to = E2D_DEFAULT_LAYER; 97 97 if (element2D->getLayer() != to) 98 98 { 99 this->element2DList[ (int)log2(element2D->getLayer())]->remove(element2D);100 this->element2DList[ (int)log2(to)]->add(element2D);99 this->element2DList[element2D->getLayer()]->remove(element2D); 100 this->element2DList[to]->add(element2D); 101 101 } 102 102 } … … 124 124 125 125 /** 126 * renders all the Elements of the Render2D-engine 127 * @param layer the Layer to draw 126 * renders all the Elements of the Render2D-engine's layer 127 * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn) 128 128 */ 129 129 void Render2D::draw(unsigned int layer) const … … 131 131 GraphicsEngine::enter2DMode(); 132 132 133 int drawLayer = 1; 134 135 for (int i = 0; i < E2D_LAYER_COUNT; i++) 133 if (layer != E2D_LAYER_ALL) 136 134 { 137 if ( layer & drawLayer && this->element2DList[i]->getSize() > 0)135 if ( this->element2DList[layer]->getSize() > 0) 138 136 { 139 tIterator<Element2D>* iterator = this->element2DList[ i]->getIterator();137 tIterator<Element2D>* iterator = this->element2DList[layer]->getIterator(); 140 138 Element2D* elem = iterator->firstElement(); 141 139 while (elem != NULL) … … 147 145 delete iterator; 148 146 } 149 drawLayer << 1; 147 } 148 else // if (layer != E2D_LAYER_ALL) 149 { 150 for (int i = 0; i < E2D_LAYER_COUNT; i++) 151 { 152 if (this->element2DList[i]->getSize() > 0) 153 { 154 tIterator<Element2D>* iterator = this->element2DList[i]->getIterator(); 155 Element2D* elem = iterator->firstElement(); 156 while (elem != NULL) 157 { 158 if (elem->isVisible()) 159 elem->draw(); 160 elem = iterator->nextElement(); 161 } 162 delete iterator; 163 } 164 } 150 165 } 151 166 GraphicsEngine::leave2DMode(); -
trunk/src/lib/graphics/render2D/render_2d.h
r4862 r5397 15 15 //! A default singleton class. 16 16 class Render2D : public BaseObject { 17 friend class Element2D; 17 18 18 public:19 virtual ~Render2D();20 /** @returns a Pointer to the only object of this Class */21 inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D(); return singletonRef; };19 public: 20 virtual ~Render2D(); 21 /** @returns a Pointer to the only object of this Class */ 22 inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D(); return singletonRef; }; 22 23 23 void tick(float dt);24 void draw(unsigned int layer) const;24 void tick(float dt); 25 void draw(unsigned int layer) const; 25 26 26 void registerElement2D(Element2D* element2D);27 void unregisterElement2D(Element2D* element2D);28 void moveToLayer(Element2D* element2D, E2D_LAYER to);29 27 30 private: 31 Render2D(); 32 static Render2D* singletonRef; //!< Reference to this class. 28 private: 29 void registerElement2D(Element2D* element2D); 30 void unregisterElement2D(Element2D* element2D); 31 void moveToLayer(Element2D* element2D, E2D_LAYER to); 32 33 34 Render2D(); 35 static Render2D* singletonRef; //!< Reference to this class. 33 36 34 37 // tList<Element2D>* element2DList; //!< List of all valid 2D-elements. 35 tList<Element2D>* element2DList[E2D_LAYER_COUNT]; //!< List of all valid 2D-elements in the different Layers.38 tList<Element2D>* element2DList[E2D_LAYER_COUNT]; //!< List of all valid 2D-elements in the different Layers. 36 39 }; 37 40 -
trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc
r5396 r5397 28 28 { 29 29 this->init(); 30 31 30 } 32 31 -
trunk/src/lib/gui/gl_gui/glgui_widget.cc
r5395 r5397 28 28 { 29 29 this->init(); 30 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);31 30 } 32 31 … … 50 49 this->focusable = true; 51 50 this->clickable = true; 51 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 52 this->setParent2D((Element2D*)NULL); 52 53 53 54 this->backMat = NULL; -
trunk/src/lib/shell/shell.cc
r5388 r5397 285 285 this->shellInput->setFont(this->fontFile, this->textSize); 286 286 this->shellInput->setAlignment(TEXT_ALIGN_LEFT); 287 if (shellInput->getParent () != this)287 if (shellInput->getParent2D() != this) 288 288 this->shellInput->setParent2D(this); 289 289
Note: See TracChangeset
for help on using the changeset viewer.