Changeset 4331 in orxonox.OLD
- Timestamp:
- May 27, 2005, 5:11:36 PM (19 years ago)
- Location:
- orxonox/branches/physics/src/subprojects/particles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/subprojects/particles/framework.cc
r4330 r4331 29 29 #include "camera.h" 30 30 31 #include <pthread.h>32 31 33 32 int verbose; 34 33 35 pthread_mutex_t mutex; 36 34 int quitGui(GtkWidget* widget, void* data); 37 35 38 36 … … 41 39 // Creating a Test Particle System 42 40 ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE); 43 system->setLifeSpan(5);44 system->setConserve(.999);45 system->setRadius(4, 3, 1, 2);46 system->setColor(.5,0,0,.5, 1,1,0,1, 0,0,0,0);47 41 48 42 // Creating a Test Particle Emitter 49 ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0), M_PI_4, 20, .1); 50 emitter->setType(EMITTER_DOT ); 51 emitter->setSize(0); 52 emitter->setRelCoor(Vector(0,0,0)); 53 43 ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0)); 54 44 // Add the Flow from the Emitter into the System 55 45 ParticleEngine::getInstance()->addConnection(emitter, system); … … 59 49 { 60 50 Framework* framework = Framework::getInstance(); 61 while( true)51 while(!framework->isFinished) 62 52 { 53 while(gtk_events_pending()) 54 gtk_main_iteration(); 55 63 56 // keyhandler returns false if sdl gets quit by some event 64 if (!framework->keyHandler()) 65 pthread_exit(NULL); 57 framework->keyHandler(); 66 58 67 59 // tick the scene … … 69 61 70 62 // Draw the scene 71 pthread_mutex_lock (&mutex);72 63 framework->draw(dt); 73 pthread_mutex_unlock (&mutex); 64 74 65 } 75 66 } 76 77 67 78 68 bool Framework::draw(float dt) … … 163 153 switch (event.key.keysym.sym) 164 154 { 165 case SDLK_x: 166 155 case SDLK_q: 156 case SDLK_ESCAPE: 157 quitGui(NULL, NULL); 167 158 break; 168 159 case SDLK_c: … … 187 178 case SDL_QUIT: 188 179 // then we're done and we'll end this program 189 return false;180 quitGui(NULL, NULL); 190 181 break; 191 182 default: … … 204 195 } 205 196 197 void Framework::quit(void) 198 { 199 this->isFinished = true; 200 } 201 206 202 Framework* Framework::singletonRef = NULL; 207 203 … … 215 211 Framework::Framework() 216 212 { 213 this->isFinished = false; 214 217 215 this->lastFrame = 0; 218 216 // Create a new OpenGL window with the title "Cone3D Basecode" at … … 368 366 gtk_main_quit(); 369 367 while(gtk_events_pending()) gtk_main_iteration(); 368 Framework::getInstance()->quit(); 370 369 #endif /* HAVE_GTK2 */ 371 370 } … … 492 491 { 493 492 verbose = 3; 494 pthread_t guiThread;495 pthread_t openglThread;496 pthread_attr_t attr;497 int status;498 493 499 pthread_mutex_init(&mutex, NULL);500 501 /* Create threads to perform the dotproduct */502 pthread_attr_init(&attr);503 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);504 505 506 507 508 494 Framework* framework = Framework::getInstance(); 509 495 510 496 framework->initGui((void*)argv); 511 pthread_create(&guiThread, &attr, Framework::mainloopGui ,(void*) argv); 512 // framework->initGui(argv); 513 514 pthread_create(&openglThread, &attr, Framework::mainLoop, NULL); 515 516 pthread_attr_destroy(&attr); 517 518 pthread_join( guiThread, (void **)&status); 519 pthread_join( openglThread, (void **)&status); 497 // framework->mainloopGui(NULL); 498 499 framework->mainLoop(NULL); 500 520 501 521 502 delete framework; -
orxonox/branches/physics/src/subprojects/particles/framework.h
r4330 r4331 15 15 Framework(); 16 16 static Framework* singletonRef; 17 17 18 18 Camera* camera; 19 19 20 bool isFinished; 20 21 21 22 int movement [4]; … … 32 33 static Framework* getInstance(void); 33 34 35 34 36 void initModule(); 35 37 static void* mainLoop(void* tmp); … … 37 39 float tick(); 38 40 bool keyHandler(); 41 void quit(); 39 42 40 43 void* initGui(void* argv);
Note: See TracChangeset
for help on using the changeset viewer.