Index: branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.cc	(revision 8025)
+++ branches/water/src/world_entities/environments/mapped_water.cc	(revision 8031)
@@ -42,11 +42,11 @@
   mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
   // load refraction texture
-  mat.setDiffuseMap("pictures/error_texture.png", GL_TEXTURE_2D, 1);
+  //mat.setDiffuseMap("pictures/error_texture.png", GL_TEXTURE_2D, 1);
   // load normal map
-  mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
+  //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", GL_TEXTURE_2D, 4);
+  //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 4);
 
 
@@ -60,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();
@@ -72,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
@@ -83,5 +83,5 @@
   // Since we stored the texture space with OpenGL, we can delete the image data
   delete [] pTextureReflection;
-  delete [] pTextureRefraction;
+  //delete [] pTextureRefraction;
 
 
@@ -148,5 +148,5 @@
   glBegin(GL_QUADS);
   // The back left vertice for the water
-  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV);            // Reflection texture
+  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0);//g_WaterUV);            // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move);        // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2);     // Normal map texture
@@ -156,5 +156,5 @@
 
   // The front left vertice for the water
-  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);                  // Reflection texture
+  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1);//0.0f);                  // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f - move);           // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, 0.0f, 0.0f + move2);          // Normal map texture
@@ -164,5 +164,5 @@
 
   // The front right vertice for the water
-  glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f);             // Reflection texture
+  glMultiTexCoord2f(GL_TEXTURE0, 1,1); //g_WaterUV, 0.0f);             // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move);         // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2);      // Normal map texture
@@ -172,5 +172,5 @@
 
   // The back right vertice for the water
-  glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV);        // Reflection texture
+  glMultiTexCoord2f(GL_TEXTURE0, 1,0);//g_WaterUV, g_WaterUV);        // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move);       // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);  // Normal map texture
@@ -243,5 +243,6 @@
 
   mat.select();
-  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
+  //glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
+  //mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, textureSize, textureSize);
 
   glPopMatrix();
@@ -250,5 +251,5 @@
 
 void MappedWater::activateRefraction()
-{/*
+{
   // To create the refraction and depth textures we do the same thing
   // we did for the reflection texture, except we don't need to turn
@@ -281,23 +282,24 @@
     double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; 
     glClipPlane(GL_CLIP_PLANE0, plane);
-  }*/
+  }
 }
 
 void MappedWater::deactivateRefraction()
-{/*
+{
   glDisable(GL_CLIP_PLANE0);
   glCullFace(GL_BACK);
 
   mat.select();
+  mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, textureSize, textureSize);
+
   // Bind the current scene to our refraction texture
 //  glBindTexture(GL_TEXTURE_2D, g_Texture[REFRACTION_ID]);
-  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
+//  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
 
   // Bind the current scene to our depth texture
 //  glBindTexture(GL_TEXTURE_2D, g_Texture[DEPTH_ID]);
-  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0);
+//  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0);
 
   glPopMatrix();
   glPopAttrib();
-  */
-}
+}
