Index: orxonox/branches/physics/src/lib/graphics/particles/particle_system.cc
===================================================================
--- orxonox/branches/physics/src/lib/graphics/particles/particle_system.cc	(revision 4328)
+++ orxonox/branches/physics/src/lib/graphics/particles/particle_system.cc	(revision 4330)
@@ -115,29 +115,22 @@
   this->particleType = particleType;
   this->dialectCount = count;
-  if (glID != NULL)
-    delete glID;
-
-  glID = new GLuint[count];
-  for (int i = 0; i< count; i++)
-    glID[i] = 0;
-
-  glID[0] = glGenLists(count);
-  
-  material = new Material("transperencyMap");
-  material->setDiffuseMap("pictures/radialTransparency.png");
-  //  material->setTransparency(.5);
-
-  glNewList(glID[0], GL_COMPILE);
-  glBegin(GL_TRIANGLE_STRIP);
-  glTexCoord2f(1, 1);
-  glVertex3f(0.0, .5, .5);
-  glTexCoord2f(1, 0);
-  glVertex3f(0.0, -.5, .5);
-  glTexCoord2f(0, 1);
-  glVertex3f(0.0, .5, -.5);
-  glTexCoord2f(0, 0);
-  glVertex3f(0.0, -.5, -.5);
-  glEnd();
-  glEndList();
+  //  if (glID != NULL)
+  //    delete glID;
+
+  //  glID = new GLuint[count];
+  //  for (int i = 0; i< count; i++)
+  //    glID[i] = 0;
+
+  //  glID[0] = glGenLists(count);
+  if (material)
+    delete material;
+  material = NULL;
+
+  if (particleType == PARTICLE_SPRITE)
+    {
+      material = new Material("transperencyMap");
+      material->setDiffuseMap("pictures/radialTransparency.png");
+      //  material->setTransparency(.5);
+    }
 }
 
Index: orxonox/branches/physics/src/subprojects/particles/Makefile.in
===================================================================
--- orxonox/branches/physics/src/subprojects/particles/Makefile.in	(revision 4328)
+++ orxonox/branches/physics/src/subprojects/particles/Makefile.in	(revision 4330)
@@ -67,5 +67,7 @@
 	particles-null_parent.$(OBJEXT) particles-gui_gtk.$(OBJEXT)
 particles_OBJECTS = $(am_particles_OBJECTS)
-particles_DEPENDENCIES = $(MAINSRCDIR)/lib/physics/libORXphysics.a
+am__DEPENDENCIES_1 =
+particles_DEPENDENCIES = $(MAINSRCDIR)/lib/physics/libORXphysics.a \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -213,8 +215,8 @@
 MAINSRCDIR = ../..
 AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/coord -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/graphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/graphics/particles -I$(MAINSRCDIR)/lib/gui -I$(MAINSRCDIR)/lib/gui/gui -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/lib/physics -I$(MAINSRCDIR)/lib/physics/fields -I$(MAINSRCDIR)/lib/tinyxml -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai -I$(MAINSRCDIR)/util -I$(MAINSRCDIR)/util/animation -I$(MAINSRCDIR)/util/common -I$(MAINSRCDIR)/util/loading -I$(MAINSRCDIR)/util/track -I$(MAINSRCDIR)/subprojects
-AM_LDFLAGS = $(MWINDOWS) \
-           $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
-
-particles_LDADD = $(MAINSRCDIR)/lib/physics/libORXphysics.a 
+particles_LDADD = $(MAINSRCDIR)/lib/physics/libORXphysics.a \
+                  $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
+		  -lpthread
+
 particles_CPPFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
 particles_SOURCES = framework.cc \
Index: orxonox/branches/physics/src/subprojects/particles/framework.cc
===================================================================
--- orxonox/branches/physics/src/subprojects/particles/framework.cc	(revision 4328)
+++ orxonox/branches/physics/src/subprojects/particles/framework.cc	(revision 4330)
@@ -33,4 +33,8 @@
 int verbose;
 
+pthread_mutex_t mutex;
+
+
+
 void Framework::initModule()
 {
@@ -52,17 +56,20 @@
 }
 
-bool Framework::mainLoop()
-{
+void* Framework::mainLoop(void* tmp)
+{
+  Framework* framework = Framework::getInstance();
   while(true)
     {
       // keyhandler returns false if sdl gets quit by some event
-      if (!this->keyHandler())
-	return false;
+      if (!framework->keyHandler())
+	pthread_exit(NULL);
 
       // tick the scene
-      float dt = this->tick();
+      float dt = framework->tick();
 
       // Draw the scene
-      this->draw(dt);
+      pthread_mutex_lock (&mutex); 
+      framework->draw(dt);
+      pthread_mutex_unlock (&mutex);
     }
 }
@@ -174,101 +181,4 @@
 	    this->printHelp();
 	    break;
-
-	  case SDLK_1:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setEmissionRate(tmpEmit->getEmissionRate() +1.0);
-		  PRINT(3)("emissionRate set to %f\n", tmpEmit->getEmissionRate());
-		}
-	    }
-	    break;
-	  case SDLK_2:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setEmissionRate(tmpEmit->getEmissionRate() -1.0);
-		  PRINT(3)("emissionRate set to %f\n", tmpEmit->getEmissionRate());
-		}
-	    }
-	    break;
-	  case SDLK_3:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setEmissionVelocity(tmpEmit->getEmissionVelocity() -.01);
-		  PRINT(3)("emissionVelocity set to %f\n", tmpEmit->getEmissionVelocity());
-		}
-	    }
-	    break;
-	  case SDLK_4:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setEmissionVelocity(tmpEmit->getEmissionVelocity() + .01);
-		  PRINT(3)("emissionVelocity set to %f\n", tmpEmit->getEmissionVelocity());
-		}
-	    }
-	    break;
-	  case SDLK_5:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setSpread(tmpEmit->getSpread() +.1);
-		  PRINT(3)("emissionSpreadAngle set to %f\n", tmpEmit->getSpread());
-		}
-	    }
-	    break;
-	  case SDLK_6:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setSpread(tmpEmit->getSpread() -.1);
-		  PRINT(3)("emissionSpreadAngle set to %f\n", tmpEmit->getSpread());
-		}
-	    }
-	    break;
-	  case SDLK_7:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setSize(tmpEmit->getSize() - 1.0);
-		  PRINT(3)("EmitterSize set to %f\n", tmpEmit->getSize());
-		}
-	    }
-	    break;
-	  case SDLK_8:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  tmpEmit->setSize(tmpEmit->getSize() +1.0);
-		  PRINT(3)("EmitterSize set to %f\n", tmpEmit->getSize());
-		}
-	    }
-	    break;
-	  case SDLK_9:
-	    {
-	      ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);
-	      if (tmpEmit)
-		{
-		  if (tmpEmit->getType() == EMITTER_DOT)
-		    tmpEmit->setType(EMITTER_PLANE);
-		  else if (tmpEmit->getType() == EMITTER_PLANE)
-		    tmpEmit->setType(EMITTER_CUBE);
-		  else if (tmpEmit->getType() == EMITTER_CUBE)
-		    tmpEmit->setType(EMITTER_DOT);
-		  PRINT(3)("EmitterType set to %d\n", tmpEmit->getType());
-		}
-	    }
-	    break;
-
 	  }
 	break;
@@ -347,10 +257,4 @@
   PRINT(0)("h - print thisHelp\n");
   PRINT(0)("i - state Information\n\n");
-  PRINT(0)("Emitter Properties\n");
-  PRINT(0)("1,2 - increase/decrease emissionRate\n");
-  PRINT(0)("3,4 - increase/decrease emission velocity\n");
-  PRINT(0)("5,6 - increase/decrease spread angle\n");
-  PRINT(0)("7,8 - increase-decrease emitter-size\n");
-  PRINT(0)("9 - swap emitterType\n");
   PRINT(0)("\n");
 
@@ -358,5 +262,5 @@
 }
 
-int changeOption(GtkWidget* nonInterest, void* widget)
+int emitterChange(GtkWidget* nonInterest, void* widget)
 {
   Option* option = (Option*) widget;
@@ -399,4 +303,14 @@
 	}
     }
+  delete valueC;
+}
+
+
+int systemChange(GtkWidget* nonInterest, void* widget)
+{
+  Option* option = (Option*) widget;
+  const char* name = option->getTitle();
+  char* valueC = option->save();
+  float value = atof(valueC);
 
   ParticleSystem* tmpSys = ParticleEngine::getInstance()->getSystemByNumber(1);
@@ -435,5 +349,5 @@
 	    tmpSys->setType(PARTICLE_SPRITE);
 
-	  PRINT(3)("ParticleType set to %f\n", valueC);
+	  PRINT(3)("ParticleType set to %s\n", valueC);
 	}
 
@@ -445,8 +359,15 @@
 
     }
-
   delete valueC;
 }
 
+
+int quitGui(GtkWidget* widget, void* data)
+{
+#ifdef HAVE_GTK2
+  gtk_main_quit();
+  while(gtk_events_pending()) gtk_main_iteration();
+#endif /* HAVE_GTK2 */
+}
 
 void* Framework::initGui(void* argv)
@@ -466,5 +387,5 @@
 	  emitterBox->fill(new Label("EmissionRate"));
 	  Slider* EmissionRate = new Slider("EmissionRate", 0, 1000);
-	  EmissionRate->connectSignal("value_changed", (void*)EmissionRate, changeOption );
+	  EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange );
 	  emitterBox->fill(EmissionRate);
 	  
@@ -472,5 +393,5 @@
 	  Slider* velocity = new Slider("Velocity", 0, 2);
 	  velocity->setExactness(3);
-	  velocity->connectSignal("value_changed", (void*)velocity, changeOption );
+	  velocity->connectSignal("value_changed", (void*)velocity, emitterChange );
 	  emitterBox->fill(velocity);
 	  
@@ -478,5 +399,5 @@
 	  Slider* SpreadAngle = new Slider("SpreadAngle", 0, M_PI);
 	  SpreadAngle->setExactness(3);
-	  SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, changeOption );
+	  SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange );
 	  emitterBox->fill(SpreadAngle);
 
@@ -486,5 +407,5 @@
 	  EmitterType->addItem("EMITTER_PLANE");
 	  EmitterType->addItem("EMITTER_CUBE");
-	  EmitterType->connectSignal("changed", (void*)EmitterType, changeOption );	  
+	  EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange );	  
 	  emitterBox->fill(EmitterType);
 
@@ -492,5 +413,5 @@
 	  Slider* EmitterSize = new Slider("EmitterSize", 0, 100);
 	  EmitterSize->setExactness(1);
-	  EmitterSize->connectSignal("value_changed", (void*)EmitterSize, changeOption );
+	  EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange );
 	  emitterBox->fill(EmitterSize);
 	}
@@ -506,5 +427,5 @@
 	  Slider* StartRadius = new Slider("StartRadius", 0, 10);
 	  StartRadius->setExactness(3);
-	  StartRadius->connectSignal("value_changed", (void*)StartRadius, changeOption );
+	  StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange );
 	  systemBox->fill(StartRadius);
 
@@ -512,5 +433,5 @@
 	  Slider* EndRadius = new Slider("EndRadius", 0, 10);
 	  EndRadius->setExactness(3);
-	  EndRadius->connectSignal("value_changed", (void*)EndRadius, changeOption );
+	  EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange );
 	  systemBox->fill(EndRadius);
 
@@ -518,5 +439,5 @@
 	  Slider* LifeSpan = new Slider("LifeSpan", 0, 10);
 	  LifeSpan->setExactness(3);
-	  LifeSpan->connectSignal("value_changed", (void*)LifeSpan, changeOption );
+	  LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange );
 	  systemBox->fill(LifeSpan);
 	  
@@ -524,5 +445,5 @@
 	  Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1);
 	  ConserveFactor->setExactness(3);
-	  ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, changeOption );
+	  ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange );
 	  systemBox->fill(ConserveFactor);
 
@@ -532,5 +453,5 @@
 	  ParticleType->addItem("PARTICLE_SPARK");
 	  ParticleType->addItem("PARTICLE_SPRITE");
-	  ParticleType->connectSignal("changed", (void*)ParticleType, changeOption );	  
+	  ParticleType->connectSignal("changed", (void*)ParticleType, systemChange );	  
 	  systemBox->fill(ParticleType);
 	  
@@ -538,5 +459,5 @@
 	  Slider* InheritSpeed = new Slider("InheritSpeed", 0, 1);
 	  InheritSpeed->setExactness(3);
-	  InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, changeOption );
+	  InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, systemChange );
 	  systemBox->fill(InheritSpeed);
 
@@ -549,4 +470,7 @@
       Button* quitButton = new Button("quit");
       
+      quitButton->connectSignal("clicked", NULL, quitGui);
+      //  Window::mainWindow->connectSignal("remove", this, GuiExec::quitGui);
+      Window::mainWindow->connectSignal("destroy", NULL, quitGui);
       
       windowBox->fill(quitButton);
@@ -556,4 +480,8 @@
   Window::mainWindow->showall();
   Window::mainWindow->setSize(300, 500);
+}
+
+void* Framework::mainloopGui(void* tmp)
+{
   mainloopGUI();
 }
@@ -565,11 +493,29 @@
   verbose = 3;
   pthread_t guiThread;
+  pthread_t openglThread;
+  pthread_attr_t attr;
+  int status;
+  
+  pthread_mutex_init(&mutex, NULL);
+  
+  /* Create threads to perform the dotproduct  */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+
+
 
   Framework* framework = Framework::getInstance();
 
-  pthread_create(&guiThread, NULL, Framework::initGui,(void*) argv);
+  framework->initGui((void*)argv);
+  pthread_create(&guiThread, &attr, Framework::mainloopGui ,(void*) argv);
   //  framework->initGui(argv);
 
-  framework->mainLoop();
+  pthread_create(&openglThread, &attr, Framework::mainLoop, NULL);
+
+  pthread_attr_destroy(&attr);
+
+  pthread_join( guiThread, (void **)&status);	
+  pthread_join( openglThread, (void **)&status);	
 
   delete framework;
Index: orxonox/branches/physics/src/subprojects/particles/framework.h
===================================================================
--- orxonox/branches/physics/src/subprojects/particles/framework.h	(revision 4328)
+++ orxonox/branches/physics/src/subprojects/particles/framework.h	(revision 4330)
@@ -33,12 +33,14 @@
 
   void initModule();
-  bool mainLoop();
+  static void* mainLoop(void* tmp);
   bool draw(float dt);
   float tick();
   bool keyHandler();
 
-  static void* initGui(void* argv);
+  void* initGui(void* argv);
+  static void* mainloopGui(void* tmp);
 
   void printHelp(void) const;
 };
+
 #endif /* _FRAMEWORK_H */
