Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9818 in orxonox.OLD for branches/new_class_id


Ignore:
Timestamp:
Sep 25, 2006, 12:10:07 PM (18 years ago)
Author:
bensch
Message:

Switching to new Shader layout, with Shader and ShaderData. Shaders do not render for the time being

Location:
branches/new_class_id/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/Makefile.am

    r9806 r9818  
    99                light.cc \
    1010                shader.cc \
     11                shader_data.cc \
    1112                \
    1213                render2D/render_2d.cc \
  • branches/new_class_id/src/lib/graphics/shader.cc

    r9806 r9818  
    7474
    7575
    76 
     76Shader::Shader()
     77  : data(new ShaderData)
     78{
     79 
     80}
    7781
    7882/**
     
    8084*/
    8185Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
     86  : data(new ShaderData)
    8287{
    83   this->registerObject(this, Shader::_objectList);
    84   this->shaderProgram = 0;
    85   this->vertexShader = 0;
    86   this->fragmentShader = 0;
     88  if (!Shader::checkShaderAbility())
     89    PRINTF(2)("Your system does not support shaders\n");
     90  else
     91    this->load(vertexShaderFile, fragmentShaderFile);
    8792
    88   if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    89   {
    90     this->shaderProgram = glCreateProgramObjectARB();
    91 
    92     if (!vertexShaderFile.empty())
    93       this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
    94     if (!fragmentShaderFile.empty())
    95       this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
    96 
    97     this->linkShaderProgram();
    98 
    99   }
    100   else
    101   {
    102     PRINTF(2)("Shaders are not supported on your hardware\n");
    103   }
    10493}
    10594
     95const Shader* Shader::storedShader = NULL;
    10696
    107 /**
    108  * standard deconstructor
    109  */
    110 Shader::~Shader ()
     97void Shader::activateShader() const
    11198{
    112   if (this->shaderProgram == glGetHandleARB(GL_PROGRAM_OBJECT_ARB))
    113     Shader::deactivateShader();
    114 
    115   // delete what has to be deleted here
    116   this->deleteProgram(Shader::Vertex);
    117   this->deleteProgram(Shader::Fragment);
    118 
    119   if (this->fragmentShader != 0)
     99  if (likely (this->getProgram() != 0))
    120100  {
    121     glDetachObjectARB(this->shaderProgram, this->fragmentShader);
    122     glDeleteObjectARB(this->fragmentShader);
    123   }
    124   if (this->vertexShader != 0)
    125   {
    126     glDetachObjectARB(this->shaderProgram, this->vertexShader);
    127     glDeleteObjectARB(this->vertexShader);
    128   }
    129   if (this->shaderProgram != 0)
    130   {
    131     GLint status = 0;
    132     //glLinkProgramARB(this->shaderProgram);
    133     glDeleteObjectARB(this->shaderProgram);
    134     // link error checking
    135     glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_DELETE_STATUS_ARB, &status);
    136     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    137       this->printError(this->shaderProgram);
    138   }
    139 }
    140 
    141 Shader* Shader::storedShader = NULL;
    142 
    143 
    144 bool Shader::loadShaderProgramm(Shader::Type type, const std::string& fileName)
    145 {
    146   GLhandleARB shader = 0;
    147 
    148   if (type != Shader::Vertex && type != Shader::Fragment)
    149     return false;
    150   this->deleteProgram(type);
    151 
    152 
    153   std::string program;
    154   if (!readShader(fileName, program))
    155     return false;
    156 
    157   if (type == Shader::Vertex && GLEW_ARB_vertex_shader)
    158   {
    159     this->vertexShaderFile = fileName;
    160 
    161     shader = this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    162   }
    163 
    164   if (type == Shader::Fragment && GLEW_ARB_fragment_shader)
    165   {
    166     this->fragmentShaderFile = fileName;
    167 
    168     shader = this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
    169   }
    170 
    171   if (shader != 0)
    172   {
    173     GLint status = 0;
    174     const char* prog = program.c_str();
    175 
    176     glShaderSourceARB(shader, 1, &prog, NULL);
    177     glCompileShaderARB(shader);
    178     // checking on error.
    179     glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
    180     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    181       this->printError(shader);
    182     else
    183       glAttachObjectARB(this->shaderProgram, shader);
    184   }
    185   return true;
    186 }
    187 
    188 
    189 void Shader::linkShaderProgram()
    190 {
    191   GLint status = 0;
    192 
    193   glLinkProgramARB(this->shaderProgram);
    194   // link error checking
    195   glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &status);
    196   if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    197     this->printError(this->shaderProgram);
    198 }
    199 
    200 
    201 bool Shader::readShader(const std::string& fileName, std::string& output)
    202 {
    203   char lineBuffer[PARSELINELENGTH];
    204 
    205   std::ifstream shader;
    206   shader.open(fileName.c_str());
    207   if (!shader.is_open())
    208     return false;
    209 
    210 
    211   while (!shader.eof())
    212   {
    213     shader.getline(lineBuffer, PARSELINELENGTH);
    214     output += lineBuffer;
    215     output += "\n";
    216   }
    217 
    218 
    219   shader.close();
    220   return true;
    221 }
    222 
    223 
    224 
    225 void Shader::activateShader()
    226 {
    227   if (likely (this->shaderProgram != 0))
    228   {
    229     glUseProgramObjectARB(this->shaderProgram);
     101    glUseProgramObjectARB(this->getProgram());
    230102    Shader::storedShader = this;
    231103  }
    232104}
    233 
    234 void Shader::bindShader(const char* name, const float* value, size_t size)
    235 {
    236   if (likely (this->shaderProgram != 0))
    237   {
    238     glUseProgramObjectARB(this->shaderProgram);
    239 
    240     unsigned int location = glGetUniformLocationARB(this->shaderProgram, name);
    241     /* This is EXPENSIVE and should be avoided. */
    242 
    243     if      (size == 1)  glUniform1fvARB(location, 1, value);
    244     else if (size == 2)  glUniform2fvARB(location, 1, value);
    245     else if (size == 3)  glUniform3fvARB(location, 1, value);
    246     else if (size == 4)  glUniform4fvARB(location, 1, value);
    247     else if (size == 9)  glUniformMatrix3fvARB(location, 1, false, value);
    248     else if (size == 16) glUniformMatrix4fvARB(location, 1, false, value);
    249 
    250   }
    251 }
    252 
    253105void Shader::deactivateShader()
    254106{
     
    256108    glUseProgramObjectARB(0);
    257109  Shader::storedShader = NULL;
    258 }
    259 
    260 
    261 void Shader::deleteProgram(Shader::Type type)
    262 {
    263   GLint status = 0;
    264   if (type == Shader::Vertex && this->vertexShader != 0)
    265   {
    266     this->vertexShaderFile = "";
    267     glDetachObjectARB(this->shaderProgram, this->vertexShader);
    268     glDeleteObjectARB(this->vertexShader);
    269     glGetObjectParameterivARB(this->vertexShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
    270     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    271       Shader::printError(this->vertexShader);
    272     this->vertexShader = 0;
    273   }
    274   else if (type == Shader::Fragment && this->fragmentShader != 0)
    275   {
    276     this->fragmentShaderFile = "";
    277     glDetachObjectARB(this->shaderProgram, this->fragmentShader);
    278     glDeleteObjectARB(this->fragmentShader);
    279     glGetObjectParameterivARB(this->fragmentShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
    280     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    281       Shader::printError(this->fragmentShader);
    282     this->fragmentShader = 0;
    283   }
    284   else
    285     return;
    286 }
    287 
    288 
    289 void Shader::printError(GLhandleARB program)
    290 {
    291   if (program == 0)
    292     return;
    293 
    294   int infologLength = 0;
    295   int charsWritten  = 0;
    296   char *infoLog;
    297 
    298   glGetObjectParameterivARB(program, GL_OBJECT_INFO_LOG_LENGTH_ARB,
    299                             &infologLength);
    300 
    301   if (infologLength > 0)
    302   {
    303     infoLog = new char[infologLength+1];
    304     glGetInfoLogARB(program, infologLength, &charsWritten, infoLog);
    305     printf("%s\n", infoLog);
    306     delete[] infoLog;
    307   }
    308110}
    309111
     
    319121}
    320122
    321 void Shader::debug() const
    322 {
    323   PRINT(3)("Shader info: (SHADER: %d)\n", this->shaderProgram);
    324   if (this->vertexShader != 0)
    325   {
    326     /*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
    327         if (this->vertexShaderSource != NULL)
    328           for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
    329             PRINT(3)("%d: %s\n", i, this->vertexShaderSource->getEntry(i));
    330       }
    331       if (this->fragmentShader != 0)
    332       {
    333         PRINT(3)("FragmentShaderProgramm: number=%d, file='%s'\n", this->fragmentShader, this->fragmentShaderFile);
    334         if (this->fragmentShaderSource != NULL)
    335           for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
    336             PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
    337   }
    338 }
    339123
  • branches/new_class_id/src/lib/graphics/shader.h

    r9806 r9818  
    88
    99#include "base_object.h"
    10 #include "glincl.h"
    11 #include <vector>
    12 
     10#include "shader_data.h"
    1311
    1412// FORWARD DECLARATION
     
    2422  {
    2523  public:
    26     Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
    2724    Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
    2825    Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
     
    4542  };
    4643
    47   //! The Type of Shader.
    48   typedef enum
    49   {
    50     None       = 0,     //!< No Type at all
    51     Fragment   = 1,     //!< Fragment Shader.
    52     Vertex     = 2,     //!< Vertex Shader.
    53     Program    = 4,     //!< Compiled Shader Programm.
    54   }  Type;
    5544
    5645public:
    57   Shader(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
    58   virtual ~Shader();
     46  Shader();
     47  Shader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "");
     48
     49  Shader& operator=(const Shader& shader) { this->data = shader.data; return *this; };
     50  const ShaderData::Pointer& dataPointer() const { return data; };
     51  void acquireData(const ShaderData::Pointer& pointer) { this->data = pointer; };
     52
     53  bool load(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "")
     54    { return this->data->load(vertexShaderFile, fragmentShaderFile); }
    5955
    6056
    61   Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
     57  Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(*this, location); }
    6258
    63   GLhandleARB getProgram() const { return this->shaderProgram; }
    64   GLhandleARB getVertexS() const { return this->vertexShader; }
    65   GLhandleARB getFragmentS() const { return this->fragmentShader; }
     59  GLhandleARB getProgram() const { return this->data->getProgram(); }
     60  GLhandleARB getVertexS() const { return this->data->getVertexS(); }
     61  GLhandleARB getFragmentS() const { return this->data->getFragmentS(); }
     62
     63  void activateShader() const;
     64  static void deactivateShader();
     65
     66  void debug() const { this->data->debug(); };
     67
    6668
    6769  static bool checkShaderAbility();
    68   void activateShader();
    69   static void deactivateShader();
    70 
    71   void debug() const;
    7270
    7371  inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
    74   inline static Shader* getActiveShader() { return Shader::storedShader; };
    75   inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
     72  inline static const Shader* getActiveShader() { return Shader::storedShader; };
     73
     74  inline static void suspendShader() { const Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
    7675  inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
    7776
    78   static void printError(GLhandleARB program);
     77private:
     78  ShaderData::Pointer    data;
    7979
    80 private:
    81   void bindShader(const char* name, const float* value, size_t size);
    82   void linkShaderProgram();
    83   bool readShader(const std::string& fileName, std::string& output);
    84   bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
    85   void deleteProgram(Shader::Type type);
    86 
    87 private:
    88   std::string            fragmentShaderFile;
    89   std::string            vertexShaderFile;
    90 
    91   GLhandleARB            shaderProgram;
    92 
    93   GLhandleARB            vertexShader;
    94   GLhandleARB            fragmentShader;
    95 
    96 
    97   static Shader*         storedShader;
     80  static const Shader*         storedShader;
    9881};
    9982
  • branches/new_class_id/src/lib/graphics/shader_data.cc

    r9806 r9818  
    3838 * standard constructor
    3939*/
    40 Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    41 {
    42   this->registerObject(this, Shader::_objectList);
     40ShaderData::ShaderData ()
     41{
     42  this->registerObject(this, ShaderData::_objectList);
    4343  this->shaderProgram = 0;
    4444  this->vertexShader = 0;
    4545  this->fragmentShader = 0;
    46 
     46}
     47
     48
     49/// TODO fix that shaders are unloaded first. then loaded
     50bool ShaderData::load(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
     51{
    4752  if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    4853  {
     
    5055
    5156    if (!vertexShaderFile.empty())
    52       this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
     57      this->loadShaderProgramm(ShaderData::Vertex, vertexShaderFile);
    5358    if (!fragmentShaderFile.empty())
    54       this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
     59      this->loadShaderProgramm(ShaderData::Fragment, fragmentShaderFile);
    5560
    5661    this->linkShaderProgram();
     
    6267  }
    6368}
    64 
    6569
    6670/**
    6771 * standard deconstructor
    6872 */
    69 Shader::~Shader ()
     73ShaderData::~ShaderData ()
    7074{
    7175  if (this->shaderProgram == glGetHandleARB(GL_PROGRAM_OBJECT_ARB))
    72     Shader::deactivateShader();
     76    glUseProgramObjectARB(0);
    7377
    7478  // delete what has to be deleted here
    75   this->deleteProgram(Shader::Vertex);
    76   this->deleteProgram(Shader::Fragment);
     79  this->deleteProgram(ShaderData::Vertex);
     80  this->deleteProgram(ShaderData::Fragment);
    7781
    7882  if (this->fragmentShader != 0)
     
    98102}
    99103
    100 Shader* Shader::storedShader = NULL;
    101 
    102 
    103 bool Shader::loadShaderProgramm(Shader::Type type, const std::string& fileName)
     104bool ShaderData::loadShaderProgramm(ShaderData::Type type, const std::string& fileName)
    104105{
    105106  GLhandleARB shader = 0;
    106107
    107   if (type != Shader::Vertex && type != Shader::Fragment)
     108  if (type != ShaderData::Vertex && type != ShaderData::Fragment)
    108109    return false;
    109110  this->deleteProgram(type);
     
    114115    return false;
    115116
    116   if (type == Shader::Vertex && GLEW_ARB_vertex_shader)
     117  if (type == ShaderData::Vertex && GLEW_ARB_vertex_shader)
    117118  {
    118119    this->vertexShaderFile = fileName;
     
    121122  }
    122123
    123   if (type == Shader::Fragment && GLEW_ARB_fragment_shader)
     124  if (type == ShaderData::Fragment && GLEW_ARB_fragment_shader)
    124125  {
    125126    this->fragmentShaderFile = fileName;
     
    146147
    147148
    148 void Shader::linkShaderProgram()
     149void ShaderData::linkShaderProgram()
    149150{
    150151  GLint status = 0;
     
    158159
    159160
    160 bool Shader::readShader(const std::string& fileName, std::string& output)
     161bool ShaderData::readShader(const std::string& fileName, std::string& output)
    161162{
    162163  char lineBuffer[PARSELINELENGTH];
     
    180181}
    181182
    182 
    183 
    184 void Shader::activateShader()
    185 {
    186   if (likely (this->shaderProgram != 0))
    187   {
    188     glUseProgramObjectARB(this->shaderProgram);
    189     Shader::storedShader = this;
    190   }
    191 }
    192 
    193 void Shader::bindShader(const char* name, const float* value, size_t size)
     183void ShaderData::bindShader(const char* name, const float* value, size_t size)
    194184{
    195185  if (likely (this->shaderProgram != 0))
     
    210200}
    211201
    212 void Shader::deactivateShader()
    213 {
    214   if (storedShader != NULL)
    215     glUseProgramObjectARB(0);
    216   Shader::storedShader = NULL;
    217 }
    218 
    219 
    220 void Shader::deleteProgram(Shader::Type type)
     202void ShaderData::deleteProgram(ShaderData::Type type)
    221203{
    222204  GLint status = 0;
    223   if (type == Shader::Vertex && this->vertexShader != 0)
     205  if (type == ShaderData::Vertex && this->vertexShader != 0)
    224206  {
    225207    this->vertexShaderFile = "";
     
    228210    glGetObjectParameterivARB(this->vertexShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
    229211    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    230       Shader::printError(this->vertexShader);
     212      ShaderData::printError(this->vertexShader);
    231213    this->vertexShader = 0;
    232214  }
    233   else if (type == Shader::Fragment && this->fragmentShader != 0)
     215  else if (type == ShaderData::Fragment && this->fragmentShader != 0)
    234216  {
    235217    this->fragmentShaderFile = "";
     
    238220    glGetObjectParameterivARB(this->fragmentShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
    239221    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    240       Shader::printError(this->fragmentShader);
     222      ShaderData::printError(this->fragmentShader);
    241223    this->fragmentShader = 0;
    242224  }
     
    246228
    247229
    248 void Shader::printError(GLhandleARB program)
     230void ShaderData::printError(GLhandleARB program)
    249231{
    250232  if (program == 0)
     
    267249}
    268250
    269 bool Shader::checkShaderAbility()
    270 {
    271   if (GLEW_ARB_shader_objects &&
    272       GLEW_ARB_shading_language_100 &&
    273       GLEW_ARB_vertex_shader &&
    274       GLEW_ARB_fragment_shader)
    275     return true;
    276   else
    277     return false;
    278 }
    279 
    280 void Shader::debug() const
    281 {
    282   PRINT(3)("Shader info: (SHADER: %d)\n", this->shaderProgram);
     251void ShaderData::debug() const
     252{
     253  PRINT(3)("ShaderData info: (SHADER: %d)\n", this->shaderProgram);
    283254  if (this->vertexShader != 0)
    284255  {
  • branches/new_class_id/src/lib/graphics/shader_data.h

    r9806 r9818  
    99#include "base_object.h"
    1010
    11 #include "shader_types.h"
     11#include "glincl.h"
    1212#include <vector>
    13 
     13#include "count_pointer.h"
    1414
    1515// FORWARD DECLARATION
     
    2121{
    2222  ObjectListDeclaration(ShaderData);
     23  //! The Type of Shader.
     24  typedef enum  {
     25    None       = 0,     //!< No Type at all
     26    Fragment   = 1,     //!< Fragment Shader.
     27    Vertex     = 2,     //!< Vertex Shader.
     28    Program    = 4,     //!< Compiled Shader Programm.
     29  }  Type;
     30
     31 public:
     32  typedef CountPointer<ShaderData> Pointer;
    2333public:
    24   ShaderData(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
     34  ShaderData();
    2535  virtual ~ShaderData();
    2636
    27   Shaders::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
     37  bool load(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
     38
    2839
    2940  GLhandleARB getProgram() const { return this->shaderProgram; }
     
    3849  void linkShaderProgram();
    3950  bool readShader(const std::string& fileName, std::string& output);
    40   bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
    41   void deleteProgram(Shader::Type type);
     51  bool loadShaderProgramm(ShaderData::Type type, const std::string& fileName);
     52  void deleteProgram(ShaderData::Type type);
     53
     54  static void printError(GLhandleARB program);
    4255
    4356private:
     57
    4458  std::string            fragmentShaderFile;
    4559  std::string            vertexShaderFile;
  • branches/new_class_id/src/world_entities/environments/mapped_water.cc

    r9757 r9818  
    7777MappedWater::~MappedWater()
    7878{
    79   delete shader;
    8079  delete cam_uni;
    8180  delete color_uni;
     
    165164{
    166165  // load shader files
    167   shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
    168 
    169   this->shader->activateShader();
     166  shader = Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
     167
     168  this->shader.activateShader();
    170169  // Set the variable "reflection" to correspond to the first texture unit
    171170  Shader::Uniform(shader, "reflection").set(0);
     
    199198  cam_uni = new Shader::Uniform(shader, "cameraPos");
    200199
    201   this->shader->deactivateShader();
     200  this->shader.deactivateShader();
    202201}
    203202
     
    225224void MappedWater::resetWaterColor(float r, float g, float b)
    226225{
    227   this->shader->activateShader();
     226  this->shader.activateShader();
    228227  this->waterColor = Vector(r, g, b);
    229228
     
    231230  color_uni->set(waterColor.x, waterColor.y, waterColor.z, 1.0f);
    232231
    233   this->shader->deactivateShader();
     232  this->shader.deactivateShader();
    234233}
    235234
     
    240239void MappedWater::resetShineSize(float shine)
    241240{
    242   this->shader->activateShader();
     241  this->shader.activateShader();
    243242  this->shineSize = shine;
    244243
     
    246245  shineSize_uni->set(this->shineSize);
    247246
    248   this->shader->deactivateShader();
     247  this->shader.deactivateShader();
    249248}
    250249
     
    255254void MappedWater::resetShineStrength(float strength)
    256255{
    257   this->shader->activateShader();
     256  this->shader.activateShader();
    258257  this->shineStrength = strength;
    259258
     
    261260  shineStrength_uni->set(this->shineStrength);
    262261
    263   this->shader->deactivateShader();
     262  this->shader.deactivateShader();
    264263}
    265264
     
    270269void MappedWater::resetReflStrength(float strength)
    271270{
    272   this->shader->activateShader();
     271  this->shader.activateShader();
    273272  this->reflStrength = strength;
    274273
     
    276275  reflStrength_uni->set(this->reflStrength);
    277276
    278   this->shader->deactivateShader();
     277  this->shader.deactivateShader();
    279278}
    280279
     
    285284void MappedWater::resetRefraction(float refraction)
    286285{
    287   this->shader->activateShader();
     286  this->shader.activateShader();
    288287  this->refraction = refraction;
    289288
     
    291290  refr_uni->set(this->refraction);
    292291
    293   this->shader->deactivateShader();
     292  this->shader.deactivateShader();
    294293}
    295294
     
    302301void MappedWater::resetLightPos(float x, float y, float z)
    303302{
    304   this->shader->activateShader();
     303  this->shader.activateShader();
    305304  this->lightPos = Vector(x, y, z);
    306305
     
    308307  light_uni->set(lightPos.x, lightPos.y, lightPos.z, 1.0f);
    309308
    310   this->shader->deactivateShader();
     309  this->shader.deactivateShader();
    311310}
    312311
     
    556555  mat.select();
    557556
    558   this->shader->activateShader();
     557  this->shader.activateShader();
    559558
    560559  // reset the camera uniform to the current cam position
     
    595594  glEnd();
    596595
    597   this->shader->deactivateShader();
     596  this->shader.deactivateShader();
    598597
    599598  mat.unselect();
  • branches/new_class_id/src/world_entities/environments/mapped_water.h

    r9715 r9818  
    107107private:
    108108  Material                  mat;
    109   Shader*                   shader;
     109  Shader                    shader;
    110110  OrxGui::GLGuiBox*         box;
    111111
  • branches/new_class_id/src/world_entities/weather_effects/cloud_effect.cc

    r9760 r9818  
    7676    if (glIsTexture(noise3DTexName))
    7777        glDeleteTextures(1, &noise3DTexName);
    78 
    79     delete shader;
    8078}
    8179
     
    122120    this->skydome->setTexture(noise3DTexName);
    123121
    124     this->shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
     122    this->shader = Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
    125123                              ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
    126124
    127     this->shader->activateShader();
     125    this->shader.activateShader();
    128126
    129127    Shader::Uniform(shader, "Noise").set(0);
     
    133131    this->cloudcolor = new Shader::Uniform(shader, "CloudColor");
    134132
    135     this->shader->deactivateShader();
    136 
    137     this->skydome->setShader(shader);
     133    this->shader.deactivateShader();
     134
     135    this->skydome->setShader(&shader);
    138136}
    139137
     
    163161
    164162    // Can only be set after the loadParams call
    165     this->shader->activateShader();
     163    this->shader.activateShader();
    166164    Shader::Uniform(shader, "Scale").set(this->scale);
    167165    this->skycolor->set
     
    169167    this->cloudcolor->set
    170168    (cloudColor.x, cloudColor.y, cloudColor.z);
    171     this->shader->deactivateShader();
     169    this->shader.deactivateShader();
    172170
    173171    this->skydome->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);
     
    192190        this->offsetZ += 0.05 * dt * this->animationSpeed;
    193191
    194         this->shader->activateShader();
     192        this->shader.activateShader();
    195193        this->offset->set
    196194        (0.0f, 0.0f, offsetZ);
     
    258256        }
    259257
    260         this->shader->deactivateShader();
     258        this->shader.deactivateShader();
    261259    }
    262260}
  • branches/new_class_id/src/world_entities/weather_effects/cloud_effect.h

    r9760 r9818  
    143143
    144144    // SHADER STUFF
    145     Shader*          shader;
     145    Shader           shader;
    146146    Shader::Uniform* offset;
    147147    Shader::Uniform* skycolor;
Note: See TracChangeset for help on using the changeset viewer.