Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4331 in orxonox.OLD


Ignore:
Timestamp:
May 27, 2005, 5:11:36 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/physics: no more threading

Location:
orxonox/branches/physics/src/subprojects/particles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/subprojects/particles/framework.cc

    r4330 r4331  
    2929#include "camera.h"
    3030
    31 #include <pthread.h>
    3231
    3332int verbose;
    3433
    35 pthread_mutex_t mutex;
    36 
     34int quitGui(GtkWidget* widget, void* data);
    3735
    3836
     
    4139  // Creating a Test Particle System
    4240  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);
    4741
    4842  // 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));
    5444  // Add the Flow from the Emitter into the System
    5545  ParticleEngine::getInstance()->addConnection(emitter, system);
     
    5949{
    6050  Framework* framework = Framework::getInstance();
    61   while(true)
     51  while(!framework->isFinished)
    6252    {
     53      while(gtk_events_pending())
     54        gtk_main_iteration();
     55
    6356      // keyhandler returns false if sdl gets quit by some event
    64       if (!framework->keyHandler())
    65         pthread_exit(NULL);
     57      framework->keyHandler();
    6658
    6759      // tick the scene
     
    6961
    7062      // Draw the scene
    71       pthread_mutex_lock (&mutex);
    7263      framework->draw(dt);
    73       pthread_mutex_unlock (&mutex);
     64
    7465    }
    7566}
    76 
    7767
    7868bool Framework::draw(float dt)
     
    163153        switch (event.key.keysym.sym)
    164154          {
    165           case SDLK_x:
    166            
     155          case SDLK_q:
     156          case SDLK_ESCAPE:
     157            quitGui(NULL, NULL);
    167158            break;
    168159          case SDLK_c:
     
    187178      case SDL_QUIT:
    188179        // then we're done and we'll end this program
    189         return false;
     180        quitGui(NULL, NULL);
    190181        break;
    191182      default:
     
    204195}
    205196
     197void Framework::quit(void)
     198{
     199  this->isFinished = true;
     200}
     201
    206202Framework* Framework::singletonRef = NULL;
    207203
     
    215211Framework::Framework()
    216212{
     213  this->isFinished = false;
     214
    217215  this->lastFrame = 0;
    218216  // Create a new OpenGL window with the title "Cone3D Basecode" at
     
    368366  gtk_main_quit();
    369367  while(gtk_events_pending()) gtk_main_iteration();
     368  Framework::getInstance()->quit();
    370369#endif /* HAVE_GTK2 */
    371370}
     
    492491{
    493492  verbose = 3;
    494   pthread_t guiThread;
    495   pthread_t openglThread;
    496   pthread_attr_t attr;
    497   int status;
    498493 
    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 
    508494  Framework* framework = Framework::getInstance();
    509495
    510496  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
    520501
    521502  delete framework;
  • orxonox/branches/physics/src/subprojects/particles/framework.h

    r4330 r4331  
    1515  Framework();
    1616  static Framework* singletonRef;
    17 
     17 
    1818  Camera* camera;
    1919 
     20  bool isFinished;
    2021
    2122  int movement [4];
     
    3233  static Framework* getInstance(void);
    3334
     35
    3436  void initModule();
    3537  static void* mainLoop(void* tmp);
     
    3739  float tick();
    3840  bool keyHandler();
     41  void quit();
    3942
    4043  void* initGui(void* argv);
Note: See TracChangeset for help on using the changeset viewer.