Index: /branches/water/src/lib/graphics/importer/material.cc
===================================================================
--- /branches/water/src/lib/graphics/importer/material.cc	(revision 7699)
+++ /branches/water/src/lib/graphics/importer/material.cc	(revision 7700)
@@ -333,6 +333,21 @@
 // MAPPING //
 
-/**
- *  Sets the Materials Diffuse Map
+void Material::setDiffuseMap(Texture* texture, unsigned int textureNumber)
+{
+  assert(textureNumber < Material::getMaxTextureUnits());
+
+  if (this->textures.size() > textureNumber && this->textures[textureNumber] != NULL)
+    ResourceManager::getInstance()->unload(this->textures[textureNumber]);
+
+  if (this->textures.size() <= textureNumber)
+    this->textures.resize(textureNumber+1, NULL);
+
+  //! @todo check if RESOURCE MANAGER is availiable
+  this->textures[textureNumber] = texture;
+}
+
+
+/**
+ * @brief Sets the Materials Diffuse Map
  * @param dMap the Name of the Image to Use
 */
Index: /branches/water/src/lib/graphics/importer/material.h
===================================================================
--- /branches/water/src/lib/graphics/importer/material.h	(revision 7699)
+++ /branches/water/src/lib/graphics/importer/material.h	(revision 7700)
@@ -53,4 +53,5 @@
 
     // MAPPING //
+    void setDiffuseMap(Texture* texture, unsigned int textureNumber = 0);
     void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
Index: /branches/water/src/lib/graphics/importer/texture.cc
===================================================================
--- /branches/water/src/lib/graphics/importer/texture.cc	(revision 7699)
+++ /branches/water/src/lib/graphics/importer/texture.cc	(revision 7700)
@@ -29,4 +29,13 @@
 #endif
 
+
+
+
+Texture::Texture(GLenum target)
+{
+  this->init();
+  this->generateTexture(texture, target);
+}
+
 /**
  *  Constructor for a Texture
@@ -42,4 +51,6 @@
   }
 }
+
+
 
 Texture::Texture(SDL_Surface* surface, GLenum target)
@@ -150,5 +161,5 @@
 
 /**
- * rebuilds the texture.
+ * @brief rebuilds the texture.
  * reloads the Texture from Memory to OpenGL.
  */
@@ -171,5 +182,5 @@
 
 /**
- * set the surface this Texture handles
+ * @brief set the surface this Texture handles
  * @param newSurface the new Surface to set as the image for this Texture.
  *
@@ -191,5 +202,5 @@
 
 /**
- * enables, disables textures
+ * @brief enables, disables textures
  * @param texturesEnabled true if the textures should be enabled
  */
@@ -204,5 +215,5 @@
 //////////////////////////////////////
 /**
- * converts surface to a new SDL_Surface, that is loadable by openGL
+ * @brief converts surface to a new SDL_Surface, that is loadable by openGL
  * @param surface the Surface to convert
  * @param hasAlpha if the newly created Surface has an alpha channel, true is returned otherwise false.
@@ -266,5 +277,5 @@
 
 /**
- *  Loads a Texture to the openGL-environment.
+ * @brief Loads a Texture to the openGL-environment.
  * @param surface the Image to load to openGL
  * @returns The ID of the texture.
@@ -277,5 +288,5 @@
 
   int      errorCode = 0;           //!< the error code for the texture loading functions
-  GLuint   texture;                 //!< the OpenGL texture handle
+  GLuint   texture = 0;             //!< the OpenGL texture handle
   int      mipmapLevel = 0;         //!< the maximum mipmap level for this texture
   int      mipmapWidth = 0;         //!< the width of the mipmap
@@ -287,19 +298,6 @@
 
   /* Create an OpenGL texture for the image */
-  glGenTextures(1, &texture);
-  glBindTexture(target, texture);
-
-  glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);
-  glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT);
-
-  glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
-  glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
+  this->generateTexture(texture, target);
   glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_PRIORITY, this->priority);
-
-
-  /* control the mipmap levels */
-  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MIN_LOD, 5);
-  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MAX_LOD, 0);
 
   /* build the Texture  OpenGL V >= 1.1 */
@@ -330,2 +328,21 @@
 }
 
+void Texture::generateTexture(GLuint& texture, GLenum target)
+{
+  if (!glIsTexture(texture))
+  {
+    glGenTextures(1, &texture);
+  }
+  glBindTexture(target, texture);
+
+  glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);
+  glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT);
+
+  glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+  glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+  /* control the mipmap levels */
+  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MIN_LOD, 5);
+  glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MAX_LOD, 0);
+}
+
Index: /branches/water/src/lib/graphics/importer/texture.h
===================================================================
--- /branches/water/src/lib/graphics/importer/texture.h	(revision 7699)
+++ /branches/water/src/lib/graphics/importer/texture.h	(revision 7700)
@@ -18,5 +18,6 @@
   {
     public:
-      Texture(const std::string& imageName = "", GLenum target = GL_TEXTURE_2D);
+      Texture(GLenum target = GL_TEXTURE_2D);
+      Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
       Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
       virtual ~Texture();
@@ -50,4 +51,5 @@
     private:
       void init();
+      static void generateTexture(GLuint& texture, GLenum target);
 
     private:
Index: /branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- /branches/water/src/world_entities/environments/mapped_water.cc	(revision 7699)
+++ /branches/water/src/world_entities/environments/mapped_water.cc	(revision 7700)
@@ -24,4 +24,5 @@
 
 MappedWater::MappedWater(const TiXmlElement* root)
+ : texture(GL_TEXTURE_2D)
 {
   this->setClassID(CL_MAPPED_WATER, "MappedWater");
@@ -30,4 +31,6 @@
   if (root != NULL)
     this->loadParams(root);
+    
+    mat.setDiffuseMap(&this->texture, 0);
 }
 
@@ -58,9 +61,16 @@
   //glEnable(GL_LIGHTING);
 
-  Material mat;
-  mat.setDiffuseMap("pictures/ground.tga", GL_TEXTURE_2D, 0);
+ 
   //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1);
   //mat.setTransparency(1.0);
   //mat.setDiffuse(1.0, 0, .1);
+ 
+ 
+  // HACK
+
+  //glDisable(GL_BLEND);
+  //glActiveTexture(GL_TEXTURE0);
+  //glBindTexture(GL_TEXTURE_2D, this->texture);
+
   mat.select();
 
@@ -94,7 +104,87 @@
 }
 
-void MappedWater::activateReflection() {}
-void MappedWater::deactivateReflection() {}
+void MappedWater::activateReflection()
+{
+  // Change the view port to be the size of the texture we will render to
+  // HACK
+  int textureSize = 512;
+  glPushAttrib(GL_VIEWPORT_BIT);
+  glViewport(0,0, textureSize, textureSize);
 
-void MappedWater::activateRefraction() {}
-void MappedWater::deactivateRefraction() {}
+  // Clear the color and depth bits, reset the matrix and position our camera.
+//  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//  glLoadIdentity();
+  //g_Camera.Look();
+
+  // So we don't affect any other objects in the world we push on a new matrix
+  //glPushMatrix();
+
+  // If our camera is above the water we will render the scene flipped upside down.
+  // In order to line up the reflection nicely with the world we have to translate
+  // the world to the position of our reflected surface, multiplied by two.
+  //if(g_Camera.Position().y > waterHeight)
+  //{
+      // Translate the world, then flip it upside down
+   //   glTranslatef(0.0f, waterHeight*2.0f, 0.0f);
+    //  glScalef(1.0, -1.0, 1.0);
+
+      // Since the world is updside down we need to change the culling to FRONT
+      //glCullFace(GL_FRONT);
+
+      // Set our plane equation and turn clipping on
+     // double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
+   //   glEnable(GL_CLIP_PLANE0);
+     // glClipPlane(GL_CLIP_PLANE0, plane);
+
+      // Render the world upside down and clipped (only render the top flipped).
+      // If we don't turn OFF caustics for the reflection texture we get horrible
+      // artifacts in the water.  That is why we set bRenderCaustics to FALSE.
+      //RenderWorld(false);
+
+      // Turn clipping off
+     // glDisable(GL_CLIP_PLANE0);
+
+      // Restore back-face culling
+    //  glCullFace(GL_BACK);
+  //}
+  /*else
+  {
+      // If the camera is below the water we don't want to flip the world,
+      // but just render it clipped so only the top is drawn.
+      double plane[4] = {0.0, 1.0, 0.0, waterHeight};
+      glEnable(GL_CLIP_PLANE0);
+      glClipPlane(GL_CLIP_PLANE0, plane);
+      RenderWorld(true);
+      glDisable(GL_CLIP_PLANE0);
+  }*/
+
+  // Restore the previous matrix
+  //glPopMatrix();
+
+    // Bind the current scene to our reflection texture
+  //glBindTexture(GL_TEXTURE_2D, g_Texture[REFLECTION_ID]);
+  
+  
+  
+ glBindTexture(GL_TEXTURE_2D, texture.getTexture());
+ // ;
+ // mat.setDiffuseMap(&texture, 0);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
+  
+  glPopAttrib();
+}
+
+void MappedWater::deactivateReflection()
+{
+
+}
+
+void MappedWater::activateRefraction()
+{
+
+}
+
+void MappedWater::deactivateRefraction()
+{
+
+}
Index: /branches/water/src/world_entities/environments/mapped_water.h
===================================================================
--- /branches/water/src/world_entities/environments/mapped_water.h	(revision 7699)
+++ /branches/water/src/world_entities/environments/mapped_water.h	(revision 7700)
@@ -10,4 +10,5 @@
 #include "world_entity.h"
 #include "material.h"
+#include "texture.h"
 
 
@@ -34,4 +35,7 @@
   private:
     float           waterHeight;       //!< y-coord of the Water
+    Material        mat;
+    
+    Texture         texture;
 
 };
