Index: /branches/new_class_id/src/lib/graphics/Makefile.am
===================================================================
--- /branches/new_class_id/src/lib/graphics/Makefile.am	(revision 9817)
+++ /branches/new_class_id/src/lib/graphics/Makefile.am	(revision 9818)
@@ -9,4 +9,5 @@
 		light.cc \
 		shader.cc \
+		shader_data.cc \
 		\
 		render2D/render_2d.cc \
Index: /branches/new_class_id/src/lib/graphics/shader.cc
===================================================================
--- /branches/new_class_id/src/lib/graphics/shader.cc	(revision 9817)
+++ /branches/new_class_id/src/lib/graphics/shader.cc	(revision 9818)
@@ -74,5 +74,9 @@
 
 
-
+Shader::Shader()
+  : data(new ShaderData)
+{
+  
+}
 
 /**
@@ -80,175 +84,23 @@
 */
 Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
+  : data(new ShaderData)
 {
-  this->registerObject(this, Shader::_objectList);
-  this->shaderProgram = 0;
-  this->vertexShader = 0;
-  this->fragmentShader = 0;
+  if (!Shader::checkShaderAbility())
+    PRINTF(2)("Your system does not support shaders\n");
+  else
+    this->load(vertexShaderFile, fragmentShaderFile);
 
-  if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
-  {
-    this->shaderProgram = glCreateProgramObjectARB();
-
-    if (!vertexShaderFile.empty())
-      this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
-    if (!fragmentShaderFile.empty())
-      this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
-
-    this->linkShaderProgram();
-
-  }
-  else
-  {
-    PRINTF(2)("Shaders are not supported on your hardware\n");
-  }
 }
 
+const Shader* Shader::storedShader = NULL;
 
-/**
- * standard deconstructor
- */
-Shader::~Shader ()
+void Shader::activateShader() const
 {
-  if (this->shaderProgram == glGetHandleARB(GL_PROGRAM_OBJECT_ARB))
-    Shader::deactivateShader();
-
-  // delete what has to be deleted here
-  this->deleteProgram(Shader::Vertex);
-  this->deleteProgram(Shader::Fragment);
-
-  if (this->fragmentShader != 0)
+  if (likely (this->getProgram() != 0))
   {
-    glDetachObjectARB(this->shaderProgram, this->fragmentShader);
-    glDeleteObjectARB(this->fragmentShader);
-  }
-  if (this->vertexShader != 0)
-  {
-    glDetachObjectARB(this->shaderProgram, this->vertexShader);
-    glDeleteObjectARB(this->vertexShader);
-  }
-  if (this->shaderProgram != 0)
-  {
-    GLint status = 0;
-    //glLinkProgramARB(this->shaderProgram);
-    glDeleteObjectARB(this->shaderProgram);
-    // link error checking
-    glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_DELETE_STATUS_ARB, &status);
-    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-      this->printError(this->shaderProgram);
-  }
-}
-
-Shader* Shader::storedShader = NULL;
-
-
-bool Shader::loadShaderProgramm(Shader::Type type, const std::string& fileName)
-{
-  GLhandleARB shader = 0;
-
-  if (type != Shader::Vertex && type != Shader::Fragment)
-    return false;
-  this->deleteProgram(type);
-
-
-  std::string program;
-  if (!readShader(fileName, program))
-    return false;
-
-  if (type == Shader::Vertex && GLEW_ARB_vertex_shader)
-  {
-    this->vertexShaderFile = fileName;
-
-    shader = this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
-  }
-
-  if (type == Shader::Fragment && GLEW_ARB_fragment_shader)
-  {
-    this->fragmentShaderFile = fileName;
-
-    shader = this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
-  }
-
-  if (shader != 0)
-  {
-    GLint status = 0;
-    const char* prog = program.c_str();
-
-    glShaderSourceARB(shader, 1, &prog, NULL);
-    glCompileShaderARB(shader);
-    // checking on error.
-    glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
-    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-      this->printError(shader);
-    else
-      glAttachObjectARB(this->shaderProgram, shader);
-  }
-  return true;
-}
-
-
-void Shader::linkShaderProgram()
-{
-  GLint status = 0;
-
-  glLinkProgramARB(this->shaderProgram);
-  // link error checking
-  glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &status);
-  if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-    this->printError(this->shaderProgram);
-}
-
-
-bool Shader::readShader(const std::string& fileName, std::string& output)
-{
-  char lineBuffer[PARSELINELENGTH];
-
-  std::ifstream shader;
-  shader.open(fileName.c_str());
-  if (!shader.is_open())
-    return false;
-
-
-  while (!shader.eof())
-  {
-    shader.getline(lineBuffer, PARSELINELENGTH);
-    output += lineBuffer;
-    output += "\n";
-  }
-
-
-  shader.close();
-  return true;
-}
-
-
-
-void Shader::activateShader()
-{
-  if (likely (this->shaderProgram != 0))
-  {
-    glUseProgramObjectARB(this->shaderProgram);
+    glUseProgramObjectARB(this->getProgram());
     Shader::storedShader = this;
   }
 }
-
-void Shader::bindShader(const char* name, const float* value, size_t size)
-{
-  if (likely (this->shaderProgram != 0))
-  {
-    glUseProgramObjectARB(this->shaderProgram);
-
-    unsigned int location = glGetUniformLocationARB(this->shaderProgram, name);
-    /* This is EXPENSIVE and should be avoided. */
-
-    if      (size == 1)  glUniform1fvARB(location, 1, value);
-    else if (size == 2)  glUniform2fvARB(location, 1, value);
-    else if (size == 3)  glUniform3fvARB(location, 1, value);
-    else if (size == 4)  glUniform4fvARB(location, 1, value);
-    else if (size == 9)  glUniformMatrix3fvARB(location, 1, false, value);
-    else if (size == 16) glUniformMatrix4fvARB(location, 1, false, value);
-
-  }
-}
-
 void Shader::deactivateShader()
 {
@@ -256,54 +108,4 @@
     glUseProgramObjectARB(0);
   Shader::storedShader = NULL;
-}
-
-
-void Shader::deleteProgram(Shader::Type type)
-{
-  GLint status = 0;
-  if (type == Shader::Vertex && this->vertexShader != 0)
-  {
-    this->vertexShaderFile = "";
-    glDetachObjectARB(this->shaderProgram, this->vertexShader);
-    glDeleteObjectARB(this->vertexShader);
-    glGetObjectParameterivARB(this->vertexShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
-    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-      Shader::printError(this->vertexShader);
-    this->vertexShader = 0;
-  }
-  else if (type == Shader::Fragment && this->fragmentShader != 0)
-  {
-    this->fragmentShaderFile = "";
-    glDetachObjectARB(this->shaderProgram, this->fragmentShader);
-    glDeleteObjectARB(this->fragmentShader);
-    glGetObjectParameterivARB(this->fragmentShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
-    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-      Shader::printError(this->fragmentShader);
-    this->fragmentShader = 0;
-  }
-  else
-    return;
-}
-
-
-void Shader::printError(GLhandleARB program)
-{
-  if (program == 0)
-    return;
-
-  int infologLength = 0;
-  int charsWritten  = 0;
-  char *infoLog;
-
-  glGetObjectParameterivARB(program, GL_OBJECT_INFO_LOG_LENGTH_ARB,
-                            &infologLength);
-
-  if (infologLength > 0)
-  {
-    infoLog = new char[infologLength+1];
-    glGetInfoLogARB(program, infologLength, &charsWritten, infoLog);
-    printf("%s\n", infoLog);
-    delete[] infoLog;
-  }
 }
 
@@ -319,21 +121,3 @@
 }
 
-void Shader::debug() const
-{
-  PRINT(3)("Shader info: (SHADER: %d)\n", this->shaderProgram);
-  if (this->vertexShader != 0)
-  {
-    /*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
-        if (this->vertexShaderSource != NULL)
-          for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
-            PRINT(3)("%d: %s\n", i, this->vertexShaderSource->getEntry(i));
-      }
-      if (this->fragmentShader != 0)
-      {
-        PRINT(3)("FragmentShaderProgramm: number=%d, file='%s'\n", this->fragmentShader, this->fragmentShaderFile);
-        if (this->fragmentShaderSource != NULL)
-          for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
-            PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
-  }
-}
 
Index: /branches/new_class_id/src/lib/graphics/shader.h
===================================================================
--- /branches/new_class_id/src/lib/graphics/shader.h	(revision 9817)
+++ /branches/new_class_id/src/lib/graphics/shader.h	(revision 9818)
@@ -8,7 +8,5 @@
 
 #include "base_object.h"
-#include "glincl.h"
-#include <vector>
-
+#include "shader_data.h"
 
 // FORWARD DECLARATION
@@ -24,5 +22,4 @@
   {
   public:
-    Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
     Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
     Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
@@ -45,55 +42,41 @@
   };
 
-  //! The Type of Shader.
-  typedef enum
-  {
-    None       = 0,     //!< No Type at all
-    Fragment   = 1,     //!< Fragment Shader.
-    Vertex     = 2,     //!< Vertex Shader.
-    Program    = 4,     //!< Compiled Shader Programm.
-  }  Type;
 
 public:
-  Shader(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
-  virtual ~Shader();
+  Shader();
+  Shader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "");
+
+  Shader& operator=(const Shader& shader) { this->data = shader.data; return *this; };
+  const ShaderData::Pointer& dataPointer() const { return data; };
+  void acquireData(const ShaderData::Pointer& pointer) { this->data = pointer; };
+
+  bool load(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "")
+    { return this->data->load(vertexShaderFile, fragmentShaderFile); }
 
 
-  Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
+  Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(*this, location); }
 
-  GLhandleARB getProgram() const { return this->shaderProgram; }
-  GLhandleARB getVertexS() const { return this->vertexShader; }
-  GLhandleARB getFragmentS() const { return this->fragmentShader; }
+  GLhandleARB getProgram() const { return this->data->getProgram(); }
+  GLhandleARB getVertexS() const { return this->data->getVertexS(); }
+  GLhandleARB getFragmentS() const { return this->data->getFragmentS(); }
+
+  void activateShader() const;
+  static void deactivateShader();
+
+  void debug() const { this->data->debug(); };
+
 
   static bool checkShaderAbility();
-  void activateShader();
-  static void deactivateShader();
-
-  void debug() const;
 
   inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
-  inline static Shader* getActiveShader() { return Shader::storedShader; };
-  inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
+  inline static const Shader* getActiveShader() { return Shader::storedShader; };
+
+  inline static void suspendShader() { const Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
   inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
 
-  static void printError(GLhandleARB program);
+private:
+  ShaderData::Pointer    data;
 
-private:
-  void bindShader(const char* name, const float* value, size_t size);
-  void linkShaderProgram();
-  bool readShader(const std::string& fileName, std::string& output);
-  bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
-  void deleteProgram(Shader::Type type);
-
-private:
-  std::string            fragmentShaderFile;
-  std::string            vertexShaderFile;
-
-  GLhandleARB            shaderProgram;
-
-  GLhandleARB            vertexShader;
-  GLhandleARB            fragmentShader;
-
-
-  static Shader*         storedShader;
+  static const Shader*         storedShader;
 };
 
Index: /branches/new_class_id/src/lib/graphics/shader_data.cc
===================================================================
--- /branches/new_class_id/src/lib/graphics/shader_data.cc	(revision 9817)
+++ /branches/new_class_id/src/lib/graphics/shader_data.cc	(revision 9818)
@@ -38,11 +38,16 @@
  * standard constructor
 */
-Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
-{
-  this->registerObject(this, Shader::_objectList);
+ShaderData::ShaderData ()
+{
+  this->registerObject(this, ShaderData::_objectList);
   this->shaderProgram = 0;
   this->vertexShader = 0;
   this->fragmentShader = 0;
-
+}
+
+
+/// TODO fix that shaders are unloaded first. then loaded
+bool ShaderData::load(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
+{
   if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
   {
@@ -50,7 +55,7 @@
 
     if (!vertexShaderFile.empty())
-      this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
+      this->loadShaderProgramm(ShaderData::Vertex, vertexShaderFile);
     if (!fragmentShaderFile.empty())
-      this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
+      this->loadShaderProgramm(ShaderData::Fragment, fragmentShaderFile);
 
     this->linkShaderProgram();
@@ -62,17 +67,16 @@
   }
 }
-
 
 /**
  * standard deconstructor
  */
-Shader::~Shader ()
+ShaderData::~ShaderData ()
 {
   if (this->shaderProgram == glGetHandleARB(GL_PROGRAM_OBJECT_ARB))
-    Shader::deactivateShader();
+    glUseProgramObjectARB(0);
 
   // delete what has to be deleted here
-  this->deleteProgram(Shader::Vertex);
-  this->deleteProgram(Shader::Fragment);
+  this->deleteProgram(ShaderData::Vertex);
+  this->deleteProgram(ShaderData::Fragment);
 
   if (this->fragmentShader != 0)
@@ -98,12 +102,9 @@
 }
 
-Shader* Shader::storedShader = NULL;
-
-
-bool Shader::loadShaderProgramm(Shader::Type type, const std::string& fileName)
+bool ShaderData::loadShaderProgramm(ShaderData::Type type, const std::string& fileName)
 {
   GLhandleARB shader = 0;
 
-  if (type != Shader::Vertex && type != Shader::Fragment)
+  if (type != ShaderData::Vertex && type != ShaderData::Fragment)
     return false;
   this->deleteProgram(type);
@@ -114,5 +115,5 @@
     return false;
 
-  if (type == Shader::Vertex && GLEW_ARB_vertex_shader)
+  if (type == ShaderData::Vertex && GLEW_ARB_vertex_shader)
   {
     this->vertexShaderFile = fileName;
@@ -121,5 +122,5 @@
   }
 
-  if (type == Shader::Fragment && GLEW_ARB_fragment_shader)
+  if (type == ShaderData::Fragment && GLEW_ARB_fragment_shader)
   {
     this->fragmentShaderFile = fileName;
@@ -146,5 +147,5 @@
 
 
-void Shader::linkShaderProgram()
+void ShaderData::linkShaderProgram()
 {
   GLint status = 0;
@@ -158,5 +159,5 @@
 
 
-bool Shader::readShader(const std::string& fileName, std::string& output)
+bool ShaderData::readShader(const std::string& fileName, std::string& output)
 {
   char lineBuffer[PARSELINELENGTH];
@@ -180,16 +181,5 @@
 }
 
-
-
-void Shader::activateShader()
-{
-  if (likely (this->shaderProgram != 0))
-  {
-    glUseProgramObjectARB(this->shaderProgram);
-    Shader::storedShader = this;
-  }
-}
-
-void Shader::bindShader(const char* name, const float* value, size_t size)
+void ShaderData::bindShader(const char* name, const float* value, size_t size)
 {
   if (likely (this->shaderProgram != 0))
@@ -210,16 +200,8 @@
 }
 
-void Shader::deactivateShader()
-{
-  if (storedShader != NULL)
-    glUseProgramObjectARB(0);
-  Shader::storedShader = NULL;
-}
-
-
-void Shader::deleteProgram(Shader::Type type)
+void ShaderData::deleteProgram(ShaderData::Type type)
 {
   GLint status = 0;
-  if (type == Shader::Vertex && this->vertexShader != 0)
+  if (type == ShaderData::Vertex && this->vertexShader != 0)
   {
     this->vertexShaderFile = "";
@@ -228,8 +210,8 @@
     glGetObjectParameterivARB(this->vertexShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-      Shader::printError(this->vertexShader);
+      ShaderData::printError(this->vertexShader);
     this->vertexShader = 0;
   }
-  else if (type == Shader::Fragment && this->fragmentShader != 0)
+  else if (type == ShaderData::Fragment && this->fragmentShader != 0)
   {
     this->fragmentShaderFile = "";
@@ -238,5 +220,5 @@
     glGetObjectParameterivARB(this->fragmentShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
-      Shader::printError(this->fragmentShader);
+      ShaderData::printError(this->fragmentShader);
     this->fragmentShader = 0;
   }
@@ -246,5 +228,5 @@
 
 
-void Shader::printError(GLhandleARB program)
+void ShaderData::printError(GLhandleARB program)
 {
   if (program == 0)
@@ -267,18 +249,7 @@
 }
 
-bool Shader::checkShaderAbility()
-{
-  if (GLEW_ARB_shader_objects &&
-      GLEW_ARB_shading_language_100 &&
-      GLEW_ARB_vertex_shader &&
-      GLEW_ARB_fragment_shader)
-    return true;
-  else
-    return false;
-}
-
-void Shader::debug() const
-{
-  PRINT(3)("Shader info: (SHADER: %d)\n", this->shaderProgram);
+void ShaderData::debug() const
+{
+  PRINT(3)("ShaderData info: (SHADER: %d)\n", this->shaderProgram);
   if (this->vertexShader != 0)
   {
Index: /branches/new_class_id/src/lib/graphics/shader_data.h
===================================================================
--- /branches/new_class_id/src/lib/graphics/shader_data.h	(revision 9817)
+++ /branches/new_class_id/src/lib/graphics/shader_data.h	(revision 9818)
@@ -9,7 +9,7 @@
 #include "base_object.h"
 
-#include "shader_types.h"
+#include "glincl.h"
 #include <vector>
-
+#include "count_pointer.h"
 
 // FORWARD DECLARATION
@@ -21,9 +21,20 @@
 {
   ObjectListDeclaration(ShaderData);
+  //! The Type of Shader.
+  typedef enum  {
+    None       = 0,     //!< No Type at all
+    Fragment   = 1,     //!< Fragment Shader.
+    Vertex     = 2,     //!< Vertex Shader.
+    Program    = 4,     //!< Compiled Shader Programm.
+  }  Type;
+
+ public:
+  typedef CountPointer<ShaderData> Pointer;
 public:
-  ShaderData(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
+  ShaderData();
   virtual ~ShaderData();
 
-  Shaders::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
+  bool load(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
+
 
   GLhandleARB getProgram() const { return this->shaderProgram; }
@@ -38,8 +49,11 @@
   void linkShaderProgram();
   bool readShader(const std::string& fileName, std::string& output);
-  bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
-  void deleteProgram(Shader::Type type);
+  bool loadShaderProgramm(ShaderData::Type type, const std::string& fileName);
+  void deleteProgram(ShaderData::Type type);
+
+  static void printError(GLhandleARB program);
 
 private:
+
   std::string            fragmentShaderFile;
   std::string            vertexShaderFile;
Index: /branches/new_class_id/src/world_entities/environments/mapped_water.cc
===================================================================
--- /branches/new_class_id/src/world_entities/environments/mapped_water.cc	(revision 9817)
+++ /branches/new_class_id/src/world_entities/environments/mapped_water.cc	(revision 9818)
@@ -77,5 +77,4 @@
 MappedWater::~MappedWater()
 {
-  delete shader;
   delete cam_uni;
   delete color_uni;
@@ -165,7 +164,7 @@
 {
   // load shader files
-  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
-
-  this->shader->activateShader();
+  shader = 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);
@@ -199,5 +198,5 @@
   cam_uni = new Shader::Uniform(shader, "cameraPos");
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -225,5 +224,5 @@
 void MappedWater::resetWaterColor(float r, float g, float b)
 {
-  this->shader->activateShader();
+  this->shader.activateShader();
   this->waterColor = Vector(r, g, b);
 
@@ -231,5 +230,5 @@
   color_uni->set(waterColor.x, waterColor.y, waterColor.z, 1.0f);
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -240,5 +239,5 @@
 void MappedWater::resetShineSize(float shine)
 {
-  this->shader->activateShader();
+  this->shader.activateShader();
   this->shineSize = shine;
 
@@ -246,5 +245,5 @@
   shineSize_uni->set(this->shineSize);
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -255,5 +254,5 @@
 void MappedWater::resetShineStrength(float strength)
 {
-  this->shader->activateShader();
+  this->shader.activateShader();
   this->shineStrength = strength;
 
@@ -261,5 +260,5 @@
   shineStrength_uni->set(this->shineStrength);
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -270,5 +269,5 @@
 void MappedWater::resetReflStrength(float strength)
 {
-  this->shader->activateShader();
+  this->shader.activateShader();
   this->reflStrength = strength;
 
@@ -276,5 +275,5 @@
   reflStrength_uni->set(this->reflStrength);
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -285,5 +284,5 @@
 void MappedWater::resetRefraction(float refraction)
 {
-  this->shader->activateShader();
+  this->shader.activateShader();
   this->refraction = refraction;
 
@@ -291,5 +290,5 @@
   refr_uni->set(this->refraction);
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -302,5 +301,5 @@
 void MappedWater::resetLightPos(float x, float y, float z)
 {
-  this->shader->activateShader();
+  this->shader.activateShader();
   this->lightPos = Vector(x, y, z);
 
@@ -308,5 +307,5 @@
   light_uni->set(lightPos.x, lightPos.y, lightPos.z, 1.0f);
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 }
 
@@ -556,5 +555,5 @@
   mat.select();
 
-  this->shader->activateShader();
+  this->shader.activateShader();
 
   // reset the camera uniform to the current cam position
@@ -595,5 +594,5 @@
   glEnd();
 
-  this->shader->deactivateShader();
+  this->shader.deactivateShader();
 
   mat.unselect();
Index: /branches/new_class_id/src/world_entities/environments/mapped_water.h
===================================================================
--- /branches/new_class_id/src/world_entities/environments/mapped_water.h	(revision 9817)
+++ /branches/new_class_id/src/world_entities/environments/mapped_water.h	(revision 9818)
@@ -107,5 +107,5 @@
 private:
   Material                  mat;
-  Shader*                   shader;
+  Shader                    shader;
   OrxGui::GLGuiBox*         box;
 
Index: /branches/new_class_id/src/world_entities/weather_effects/cloud_effect.cc
===================================================================
--- /branches/new_class_id/src/world_entities/weather_effects/cloud_effect.cc	(revision 9817)
+++ /branches/new_class_id/src/world_entities/weather_effects/cloud_effect.cc	(revision 9818)
@@ -76,6 +76,4 @@
     if (glIsTexture(noise3DTexName))
         glDeleteTextures(1, &noise3DTexName);
-
-    delete shader;
 }
 
@@ -122,8 +120,8 @@
     this->skydome->setTexture(noise3DTexName);
 
-    this->shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
+    this->shader = Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
                               ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
 
-    this->shader->activateShader();
+    this->shader.activateShader();
 
     Shader::Uniform(shader, "Noise").set(0);
@@ -133,7 +131,7 @@
     this->cloudcolor = new Shader::Uniform(shader, "CloudColor");
 
-    this->shader->deactivateShader();
-
-    this->skydome->setShader(shader);
+    this->shader.deactivateShader();
+
+    this->skydome->setShader(&shader);
 }
 
@@ -163,5 +161,5 @@
 
     // Can only be set after the loadParams call
-    this->shader->activateShader();
+    this->shader.activateShader();
     Shader::Uniform(shader, "Scale").set(this->scale);
     this->skycolor->set
@@ -169,5 +167,5 @@
     this->cloudcolor->set
     (cloudColor.x, cloudColor.y, cloudColor.z);
-    this->shader->deactivateShader();
+    this->shader.deactivateShader();
 
     this->skydome->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);
@@ -192,5 +190,5 @@
         this->offsetZ += 0.05 * dt * this->animationSpeed;
 
-        this->shader->activateShader();
+        this->shader.activateShader();
         this->offset->set
         (0.0f, 0.0f, offsetZ);
@@ -258,5 +256,5 @@
         }
 
-        this->shader->deactivateShader();
+        this->shader.deactivateShader();
     }
 }
Index: /branches/new_class_id/src/world_entities/weather_effects/cloud_effect.h
===================================================================
--- /branches/new_class_id/src/world_entities/weather_effects/cloud_effect.h	(revision 9817)
+++ /branches/new_class_id/src/world_entities/weather_effects/cloud_effect.h	(revision 9818)
@@ -143,5 +143,5 @@
 
     // SHADER STUFF
-    Shader*          shader;
+    Shader           shader;
     Shader::Uniform* offset;
     Shader::Uniform* skycolor;
