Changeset 5285 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Oct 6, 2005, 8:31:23 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_handler.cc
r5237 r5285 34 34 EventHandler::EventHandler () 35 35 { 36 this->setClassID(CL_EVENT_HANDLER, "EventHandler"); 37 this->setName("EventHandler"); 38 36 39 SDL_InitSubSystem(SDL_INIT_JOYSTICK); 37 40 SDL_InitSubSystem(SDL_INIT_EVENTTHREAD); 38 41 // SDL_SetEventFilter(EventHandler::eventFilter); 39 42 40 this->setClassID(CL_EVENT_HANDLER, "EventHandler");41 43 42 44 /* now initialize them all to zero */ … … 49 51 } 50 52 this->state = ES_GAME; 53 this->keyMapper = NULL; 51 54 } 52 55 … … 70 73 if( this->listeners[i][j] != NULL) 71 74 { 72 PRINTF(2)("forgot to unsubscribe an EventListener %s!\n");//, this->listeners[i][j]->getName());75 PRINTF(2)("forgot to unsubscribe an EventListener!\n");// %s!\n", this->listeners[i][j]->getName()); 73 76 } 74 77 } … … 84 87 /** 85 88 * initializes the event handler 86 87 89 * 90 * this has to be called before the use of the event handler 88 91 */ 89 92 void EventHandler::init(IniParser* iniParser) … … 142 145 143 146 /** 144 * 147 * unsubscribe all events from a specific listener 145 148 * @param el: the listener that wants to unsubscribe itself 146 149 * @param state: the state in which the events shall be unsubscribed … … 174 177 175 178 /** 176 * 179 * flush all registered events 177 180 * @param state: a specific state 178 181 */ -
trunk/src/lib/graphics/graphics_engine.cc
r5266 r5285 58 58 this->hwVersion = NULL; 59 59 this->hwExtensions = NULL; 60 61 // initialize the TextEngine 62 TextEngine::getInstance(); 60 63 } 61 64 … … 81 84 82 85 delete Render2D::getInstance(); 86 delete TextEngine::getInstance(); 83 87 84 88 SDL_QuitSubSystem(SDL_INIT_VIDEO); … … 557 561 { 558 562 this->geTextCFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 563 this->geTextCFPS->setName("curFPS"); 559 564 this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT); 560 565 this->geTextCFPS->setAbsCoor2D(5, 15); … … 563 568 { 564 569 this->geTextMaxFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 570 this->geTextMaxFPS->setName("MaxFPS"); 565 571 this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT); 566 572 this->geTextMaxFPS->setAbsCoor2D(5, 40); … … 569 575 { 570 576 this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 577 this->geTextMinFPS->setName("MinFPS"); 571 578 this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT); 572 579 this->geTextMinFPS->setAbsCoor2D(5, 65); -
trunk/src/lib/graphics/render2D/element_2d.cc
r5254 r5285 25 25 #include "class_list.h" 26 26 #include "list.h" 27 #include "color.h" 27 28 28 29 using namespace std; 29 30 31 /** 32 * standard constructor 33 */ 30 34 Element2D::Element2D() 31 35 { 32 36 this->init(); 37 33 38 this->setParent2D(NullElement2D::getInstance()); 39 NullElement2D::getInstance()->debug(0); 34 40 } 35 41 36 42 /** 37 43 * standard constructor 38 * @todo this constructor is not jet implemented - do it 39 */ 44 * @param parent the parent to set for this Element2D 45 * 46 * NullElement2D needs this constructor with parameter NULL to initialize 47 * itself. Otherwise it would result in an endless Loop. 48 */ 40 49 Element2D::Element2D (Element2D* parent) 41 50 { … … 44 53 if (this->parent != NULL) 45 54 this->setParent2D(parent); 55 else if (NullElement2D::isInstanciated()) 56 this->setParent2D(NullElement2D::getInstance()); 46 57 } 47 58 48 59 /** 49 60 * standard deconstructor 50 */ 61 * 62 * There are two general ways to delete an Element2D 63 * 1. delete instance; 64 * -> result 65 * delete this Node and all its children and children's children... 66 * (danger if you still want the instance!!) 67 * 68 * 2. instance->remove2D(); delete instance; 69 * -> result: 70 * moves its children to the NullParent 71 * then deletes the Element. 72 */ 51 73 Element2D::~Element2D () 52 74 { … … 54 76 Render2D::getInstance()->unregisterElement2D(this); 55 77 56 if (this->parent) 57 this->parent->removeChild2D(this); 58 else 59 { 60 tIterator<Element2D>* iterator = this->children->getIterator(); 61 Element2D* pn = iterator->firstElement(); 62 while( pn != NULL) 63 { 64 delete pn; 65 pn = iterator->nextElement(); 66 } 67 delete iterator; 68 /* this deletes all children in the list */ 78 // remove the Node, delete it's children. 79 tIterator<Element2D>* iterator = this->children->getIterator(); 80 Element2D* child = iterator->firstElement(); 81 82 while( child != NULL) 83 { 84 delete child; 85 child = iterator->nextElement(); 86 } 87 delete iterator; 88 89 if (this->parent != NULL) 90 { 91 this->parent->children->remove(this); 92 this->parent = NULL; 69 93 } 70 94 delete this->children; 71 95 96 // remove all other allocated memory. 72 97 if (this->toCoordinate != NULL) 73 98 delete this->toCoordinate; … … 99 124 this->toCoordinate = NULL; 100 125 this->toDirection = NULL; 101 // else102 // this->setParent2D(parent);103 126 104 127 Render2D::getInstance()->registerElement2D(this); … … 480 503 481 504 /** 482 * remove this pnode from the tree and adds all following to NullParent505 * remove this Element from the tree and adds all children to NullElement2D 483 506 * 484 * this can be the case, if an entity in the world is being destroyed.507 * afterwards this Node is free, and can be reattached, or deleted freely. 485 508 */ 486 509 void Element2D::remove2D() … … 495 518 } 496 519 delete iterator; 520 521 delete this->children; 522 this->children = new tList<Element2D>; 523 497 524 if (this->parent != NULL) 525 { 498 526 this->parent->children->remove(this); 527 this->parent = NULL; 528 } 499 529 } 500 530 … … 762 792 } 763 793 764 #include "color.h" 794 /** 795 * ticks the 2d-Element 796 * @param dt the time elapsed since the last tick 797 */ 798 void Element2D::tick(float dt) 799 { 800 801 } 765 802 766 803 /** … … 816 853 817 854 818 819 /** 820 * ticks the 2d-Element 821 * @param dt the time elapsed since the last tick 822 */ 823 void Element2D::tick(float dt) 824 { 825 826 } 827 828 829 830 831 832 833 855 /////////////////// 856 // NullElement2D // 857 /////////////////// 834 858 NullElement2D* NullElement2D::singletonRef = 0; 835 859 -
trunk/src/lib/graphics/render2D/element_2d.h
r5279 r5285 218 218 public: 219 219 /** @returns a Pointer to the only object of this Class */ 220 inline static NullElement2D* getInstance() { if (!singletonRef) singletonRef = new NullElement2D(); return singletonRef; }; 220 inline static NullElement2D* getInstance() { if (!NullElement2D::singletonRef) NullElement2D::singletonRef = new NullElement2D(); return NullElement2D::singletonRef; }; 221 inline static bool isInstanciated() { return (NullElement2D::singletonRef != NULL)?true:false; }; 221 222 virtual ~NullElement2D (); 222 223 -
trunk/src/lib/graphics/shader.cc
r5283 r5285 49 49 50 50 if (vertexShaderFile != NULL) 51 51 this->loadShaderProgramm(SHADER_VERTEX, vertexShaderFile); 52 52 if (fragmentShaderFile != NULL) 53 53 this->loadShaderProgramm(SHADER_FRAGMENT, fragmentShaderFile); 54 54 try { 55 55 glLinkProgramARB(this->shaderProgram); } 56 56 catch(GLenum errorCode) { 57 57 this->printError(this->shaderProgram); } 58 58 } 59 59 else … … 84 84 bool Shader::loadShaderProgramm(SHADER_TYPE type, const char* fileName) 85 85 { 86 GLenum shader = 0; 87 86 88 if (type != SHADER_VERTEX && type != SHADER_FRAGMENT) 87 89 return false; … … 92 94 if (program == NULL) 93 95 return false; 94 GLenum shader = 0;95 96 if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader) 96 97 { … … 113 114 glShaderSourceARB(shader, 1, (const GLcharARB**)&program, NULL); 114 115 try { 115 116 glCompileShaderARB(shader); 116 117 } 117 118 catch (...) 118 119 120 119 { 120 this->printError(shader); 121 } 121 122 glAttachObjectARB(this->shaderProgram, shader); 122 123 delete[] program; -
trunk/src/lib/graphics/text_engine.cc
r5215 r5285 848 848 /** 849 849 * creates a new Text with a certain font. 850 851 850 * @see Font::Font 851 * @see Text::Text 852 852 */ 853 853 Text* TextEngine::createText(const char* fontFile, unsigned int fontSize, int textType) -
trunk/src/lib/util/list.h
r5248 r5285 135 135 136 136 /** 137 * 137 * remove an entity from the list 138 138 * @param entity: the entity to be removed 139 139 */
Note: See TracChangeset
for help on using the changeset viewer.