Index: /branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- /branches/water/src/world_entities/environments/mapped_water.cc	(revision 7985)
+++ /branches/water/src/world_entities/environments/mapped_water.cc	(revision 7986)
@@ -34,23 +34,25 @@
     this->loadParams(root);
 
-  //! todo: rename texture to reflection texture
+  PRINTF(0)("MaxTextureUnits: %i\n", Material::getMaxTextureUnits());
+
+  // TODO rename texture to reflection texture
+  /// loads the textures
   // set up refleciton texture
   // FIXME mat.setDiffuseMap(this->texture, 0); doesnt work,
   mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
   // load refraction texture
- // mat.setDiffuseMap("pictures/sky-replace.jpg", 1);
+  mat.setDiffuseMap("pictures/error_texture.png", GL_TEXTURE_2D, 1);
   // load normal map
   mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
   // load dudv map
-   mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3);
+  mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3);
   // set up depth texture
-//  mat.setDiffuseMap("pictures/sky-replace.jpg", 4);
-
+  //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 2);
+
+
+
+  /// MAKE THE MAPPING TEXTURE.
+  // THIS IS A HACK AND SHOULD BE IN TEXTURE SOMEWHERE
   // set the size of the refraction and reflection textures
-
-
-
-  /// MAKE THE MAPPING TEXTURE.
-  // THIS IS A HACK AND SHOULD BE IN TEXTURE SOMEWHERE.
   this->textureSize = 512;
   unsigned int channels = 32;
@@ -58,6 +60,6 @@
   unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels];
   memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
-//  unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels];
-//  memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
+  unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels];
+  memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
   // Register the texture with OpenGL and bind it to the texture ID
   mat.select();
@@ -70,6 +72,6 @@
 
   //the same for the refraction
-//  glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));
-//  glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction);
+  glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));
+  glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction);
 
   // Set the texture quality
@@ -81,10 +83,8 @@
   // Since we stored the texture space with OpenGL, we can delete the image data
   delete [] pTextureReflection;
-//  delete [] pTextureRefraction;
-
-
-  //shader = new Shader( "/home/stefalie/svn/orxonox/data/trunk/shaders/water.vert", "/home/stefalie/svn/orxonox/data/trunk/shaders/mapped_water.frag");
-  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
-
+  delete [] pTextureRefraction;
+
+
+  /// initialization of the texture coords, speeds etc...
   this->move = 0.0f;
   this->g_WaterUV = 35.0f;
@@ -92,28 +92,33 @@
   this->g_WaterFlow = 0.0015f;
 
-  /// Initialization of the shaders
+  /// initialization of the shaders
+  // load shader files
+  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
+
   this->shader->activateShader();
   // Set the variable "reflection" to correspond to the first texture unit
   Shader::Uniform(shader, "reflection").set(0);
-
   // Set the variable "refraction" to correspond to the second texture unit
-  //this->uni = new Shader::Uniform (shader, "refraction");
-  //this->uni->set(1);
-
+  Shader::Uniform(shader, "refraction").set(1);
   // Set the variable "normalMap" to correspond to the third texture unit
   Shader::Uniform(shader, "normalMap").set(2);
-
   // Set the variable "dudvMap" to correspond to the fourth texture unit
   Shader::Uniform(shader, "dudvMap").set(3);
-
   // Set the variable "depthMap" to correspond to the fifth texture unit
-  //this->uni = new Shader::Uniform (shader, "depthMap");
-  //this->uni->set(4);
-  this->shader->activateShader();
+  //Shader::Uniform(shader, "depthMap").set(4);
+  // Give the variable "waterColor" a blue color
+  Shader::Uniform(shader, "waterColor").set(0.1f, 0.2f, 0.4f, 1.0f);
+  // Give the variable "lightPos" our hard coded light position
+  Shader::Uniform(shader, "lightPos").set(lightPos.x, lightPos.y, lightPos.z, 1.0f);
+  // uniform for the camera position
+  cam_uni = new Shader::Uniform(shader, "cameraPos");
+
+  this->shader->deactivateShader();
 }
 
 MappedWater::~MappedWater()
 {
-  //delete shader;
+  delete shader;
+  delete cam_uni;
 }
 
@@ -123,4 +128,5 @@
 
   LoadParam(root, "waterHeight", this, MappedWater, setHeight);
+  LoadParam(root, "lightPos", this, MappedWater, setLightPosition);
 }
 
@@ -134,37 +140,9 @@
   mat.select();
 
-
-
-  // Shader init
   this->shader->activateShader();
-  GLint uniform;
-
-
-
-
-
-  // Give the variable "waterColor" a blue color
-  uniform = glGetUniformLocationARB(shader->getProgram(), "waterColor");
-  glUniform4fARB(uniform, 0.1f, 0.2f, 0.4f, 1.0f);
-
-  // FIXME set camera and light information
-  Vector lightPos(100.0f, 600.0f, 100.0f);
-  Vector vPosition = State::getCameraNode()->getAbsCoor();
-  // Store the camera position in a variable
-  //CVector3 vPosition = g_Camera.Position();
-  //Vector vPosition(50.0f, 50.0f, 50.0f);
-
-  // Give the variable "lightPos" our hard coded light position
-  uniform = glGetUniformLocationARB(shader->getProgram(), "lightPos");
-  glUniform4fARB(uniform, lightPos.x, lightPos.y, lightPos.z, 1.0f);
-
-  // Give the variable "cameraPos" our camera position
-  uniform = glGetUniformLocationARB(shader->getProgram(), "cameraPos");
-  glUniform4fARB(uniform, vPosition.x, vPosition.y, vPosition.z, 1.0f);
-
-
-
-
-
+
+  // reset the camera uniform to the current cam position
+  Vector pos = State::getCameraNode()->getAbsCoor();
+  cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
 
   glBegin(GL_QUADS);
Index: /branches/water/src/world_entities/environments/mapped_water.h
===================================================================
--- /branches/water/src/world_entities/environments/mapped_water.h	(revision 7985)
+++ /branches/water/src/world_entities/environments/mapped_water.h	(revision 7986)
@@ -20,4 +20,5 @@
     void loadParams(const TiXmlElement* root);
 
+
     void activateReflection();
     void deactivateReflection();
@@ -30,4 +31,5 @@
 
   private:
+    void setLightPosition(float x, float y, float z) { this->lightPos = Vector(x,y,z); };
     void setHeight(float height);
 
@@ -44,7 +46,8 @@
 
     int                 textureSize;                //!< size of the texture
+    Vector              lightPos;
     Material            mat;
     Shader*             shader;
-    Shader::Uniform*    uni;
+    Shader::Uniform*    cam_uni;                        //!< uniform that is used for the camera position
 
 };
