Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9806 in orxonox.OLD


Ignore:
Timestamp:
Sep 24, 2006, 10:30:13 PM (18 years ago)
Author:
bensch
Message:

try with the shader

Location:
branches/new_class_id/src
Files:
1 added
13 edited
2 copied

Legend:

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

    r9761 r9806  
    2626                light.h \
    2727                shader.h \
     28                shader_data.h \
    2829                \
    2930                render2D/render_2d.h \
  • branches/new_class_id/src/lib/graphics/importer/static_model.h

    r9715 r9806  
    1010
    1111#include "material.h"
    12 #include "glincl.h"
    1312#include <vector>
    14 #include <list>
    1513
    1614// definition of different modes for setting up Faces
  • branches/new_class_id/src/lib/graphics/shader.cc

    r9715 r9806  
    3535ObjectListDefinition(Shader);
    3636
     37void Shader::Uniform::setV(unsigned int count, float* vv) const
     38{
     39  switch (count)
     40  {
     41    case 1:
     42    glUniform1fv(this->uniform, 1, vv);
     43    break;
     44    case 2:
     45    glUniform2fv(this->uniform, 2, vv);
     46    break;
     47    case 3:
     48    glUniform3fv(this->uniform, 3, vv);
     49    break;
     50    case 4:
     51    glUniform4fv(this->uniform, 4, vv);
     52    break;
     53  }
     54}
     55void Shader::Uniform::setV(unsigned int count, int* vv) const
     56{
     57  switch (count)
     58  {
     59    case 1:
     60    glUniform1iv(this->uniform, 1, vv);
     61    break;
     62    case 2:
     63    glUniform2iv(this->uniform, 2, vv);
     64    break;
     65    case 3:
     66    glUniform3iv(this->uniform, 3, vv);
     67    break;
     68    case 4:
     69    glUniform4iv(this->uniform, 4, vv);
     70    break;
     71  }
     72}
     73
     74
     75
     76
     77
    3778/**
    3879 * standard constructor
     
    4182{
    4283  this->registerObject(this, Shader::_objectList);
    43    this->shaderProgram = 0;
    44    this->vertexShader = 0;
    45    this->fragmentShader = 0;
    46 
    47    if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    48      {
    49        this->shaderProgram = glCreateProgramObjectARB();
    50 
    51        if (!vertexShaderFile.empty())
    52          this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
    53        if (!fragmentShaderFile.empty())
    54          this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
    55 
    56        this->linkShaderProgram();
    57 
    58     }
    59    else
    60      {
    61        PRINTF(2)("Shaders are not supported on your hardware\n");
    62      }
     84  this->shaderProgram = 0;
     85  this->vertexShader = 0;
     86  this->fragmentShader = 0;
     87
     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  }
    63104}
    64105
     
    91132    //glLinkProgramARB(this->shaderProgram);
    92133    glDeleteObjectARB(this->shaderProgram);
    93        // link error checking
     134    // link error checking
    94135    glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_DELETE_STATUS_ARB, &status);
    95136    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    96137      this->printError(this->shaderProgram);
    97138  }
    98 }
    99 
    100 Shader* Shader::getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    101 {
    102   return (Shader*)ResourceManager::getInstance()->load(vertexShaderFile, SHADER,  RP_LEVEL, fragmentShaderFile);
    103 }
    104 
    105 bool Shader::unload(Shader* shader)
    106 {
    107   return ResourceManager::getInstance()->unload(shader);
    108139}
    109140
     
    161192
    162193  glLinkProgramARB(this->shaderProgram);
    163        // link error checking
     194  // link error checking
    164195  glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &status);
    165196  if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
     
    203234void Shader::bindShader(const char* name, const float* value, size_t size)
    204235{
    205         if (likely (this->shaderProgram != 0)) {
    206                 glUseProgramObjectARB(this->shaderProgram);
    207 
    208                 unsigned int location = glGetUniformLocationARB(this->shaderProgram, name);
    209                 /* This is EXPENSIVE and should be avoided. */
    210 
    211                 if      (size == 1)  glUniform1fvARB(location, 1, value);
    212                 else if (size == 2)  glUniform2fvARB(location, 1, value);
    213                 else if (size == 3)  glUniform3fvARB(location, 1, value);
    214                 else if (size == 4)  glUniform4fvARB(location, 1, value);
    215                 else if (size == 9)  glUniformMatrix3fvARB(location, 1, false, value);
    216                 else if (size == 16) glUniformMatrix4fvARB(location, 1, false, value);
    217 
    218         }
     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  }
    219251}
    220252
    221253void Shader::deactivateShader()
    222254{
    223  if (storedShader != NULL)
    224    glUseProgramObjectARB(0);
    225  Shader::storedShader = NULL;
     255  if (storedShader != NULL)
     256    glUseProgramObjectARB(0);
     257  Shader::storedShader = NULL;
    226258}
    227259
     
    292324  if (this->vertexShader != 0)
    293325  {
    294 /*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
    295     if (this->vertexShaderSource != NULL)
    296       for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
    297         PRINT(3)("%d: %s\n", i, this->vertexShaderSource->getEntry(i));
    298   }
    299   if (this->fragmentShader != 0)
    300   {
    301     PRINT(3)("FragmentShaderProgramm: number=%d, file='%s'\n", this->fragmentShader, this->fragmentShaderFile);
    302     if (this->fragmentShaderSource != NULL)
    303       for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
    304         PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
    305   }
    306 }
    307 
     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}
     339
  • branches/new_class_id/src/lib/graphics/shader.h

    r9715 r9806  
    1616
    1717
    18 //! A class for ...
     18//! The Shader is a Class-wrapper around the OpenGL Shader Language (GLSL).
    1919class Shader : public BaseObject
    2020{
     
    3838    void set(int v0, int v1, int v2, int v3) const { glUniform4i(this->uniform, v0, v1, v2, v3); }
    3939
    40     void setV(unsigned int count, float* vv) const
    41     {
    42       switch (count)
    43       {
    44         case 1:
    45         glUniform1fv(this->uniform, 1, vv);
    46         break;
    47         case 2:
    48         glUniform2fv(this->uniform, 2, vv);
    49         break;
    50         case 3:
    51         glUniform3fv(this->uniform, 3, vv);
    52         break;
    53         case 4:
    54         glUniform4fv(this->uniform, 4, vv);
    55         break;
    56       }
    57     }
    58     void setV(unsigned int count, int* vv) const
    59     {
    60       switch (count)
    61       {
    62         case 1:
    63         glUniform1iv(this->uniform, 1, vv);
    64         break;
    65         case 2:
    66         glUniform2iv(this->uniform, 2, vv);
    67         break;
    68         case 3:
    69         glUniform3iv(this->uniform, 3, vv);
    70         break;
    71         case 4:
    72         glUniform4iv(this->uniform, 4, vv);
    73         break;
    74       }
    75     }
     40    void setV(unsigned int count, float* vv) const;
     41    void setV(unsigned int count, int* vv) const;
     42
    7643  private:
    7744    GLint uniform;
    7845  };
    7946
     47  //! The Type of Shader.
    8048  typedef enum
    8149  {
    82     None       = 0,
    83     Fragment   = 1,
    84     Vertex     = 2,
    85 
    86     Program    = 4,
    87   }
    88   Type;
     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;
    8955
    9056public:
    9157  Shader(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
    9258  virtual ~Shader();
    93   static Shader* getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile);
    94   static bool unload(Shader* shader);
    9559
     60
     61  Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
     62
     63  GLhandleARB getProgram() const { return this->shaderProgram; }
     64  GLhandleARB getVertexS() const { return this->vertexShader; }
     65  GLhandleARB getFragmentS() const { return this->fragmentShader; }
    9666
    9767  static bool checkShaderAbility();
    9868  void activateShader();
    99   void bindShader(const char* name, const float* value, size_t size);
    10069  static void deactivateShader();
    10170
    102 Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
     71  void debug() const;
    10372
    104   bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
    105   void deleteProgram(Shader::Type type);
    106 
    107   void linkShaderProgram();
    108 
    109 
    110   bool readShader(const std::string& fileName, std::string& output);
    111 
    112 
    113 inline static bool shaderActive() { return (Shader::storedShader != NULL)? true : false; };
     73  inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
    11474  inline static Shader* getActiveShader() { return Shader::storedShader; };
    11575  inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
    11676  inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
    11777
    118 
    119 
    120 
    121 GLhandleARB getProgram() const { return this->shaderProgram; }
    122   GLhandleARB getVertexS() const { return this->vertexShader; }
    123   GLhandleARB getFragmentS() const { return this->fragmentShader; }
    124 
    125   void debug() const;
    126 
    12778  static void printError(GLhandleARB program);
    12879
     80private:
     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);
    12986
    13087private:
  • branches/new_class_id/src/lib/graphics/shader_data.cc

    r9803 r9806  
    1616//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
    1717
    18 #include "shader.h"
     18#include "shader_data.h"
    1919
    2020#include "stdlibincl.h"
     
    3333
    3434
    35 ObjectListDefinition(Shader);
     35ObjectListDefinition(ShaderData);
    3636
    3737/**
     
    4141{
    4242  this->registerObject(this, Shader::_objectList);
    43    this->shaderProgram = 0;
    44    this->vertexShader = 0;
    45    this->fragmentShader = 0;
    46 
    47    if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    48      {
    49        this->shaderProgram = glCreateProgramObjectARB();
    50 
    51        if (!vertexShaderFile.empty())
    52          this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
    53        if (!fragmentShaderFile.empty())
    54          this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
    55 
    56        this->linkShaderProgram();
    57 
    58     }
    59    else
    60      {
    61        PRINTF(2)("Shaders are not supported on your hardware\n");
    62      }
     43  this->shaderProgram = 0;
     44  this->vertexShader = 0;
     45  this->fragmentShader = 0;
     46
     47  if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
     48  {
     49    this->shaderProgram = glCreateProgramObjectARB();
     50
     51    if (!vertexShaderFile.empty())
     52      this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
     53    if (!fragmentShaderFile.empty())
     54      this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
     55
     56    this->linkShaderProgram();
     57
     58  }
     59  else
     60  {
     61    PRINTF(2)("Shaders are not supported on your hardware\n");
     62  }
    6363}
    6464
     
    9191    //glLinkProgramARB(this->shaderProgram);
    9292    glDeleteObjectARB(this->shaderProgram);
    93        // link error checking
     93    // link error checking
    9494    glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_DELETE_STATUS_ARB, &status);
    9595    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    9696      this->printError(this->shaderProgram);
    9797  }
    98 }
    99 
    100 Shader* Shader::getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    101 {
    102   return (Shader*)ResourceManager::getInstance()->load(vertexShaderFile, SHADER,  RP_LEVEL, fragmentShaderFile);
    103 }
    104 
    105 bool Shader::unload(Shader* shader)
    106 {
    107   return ResourceManager::getInstance()->unload(shader);
    10898}
    10999
     
    161151
    162152  glLinkProgramARB(this->shaderProgram);
    163        // link error checking
     153  // link error checking
    164154  glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &status);
    165155  if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
     
    203193void Shader::bindShader(const char* name, const float* value, size_t size)
    204194{
    205         if (likely (this->shaderProgram != 0)) {
    206                 glUseProgramObjectARB(this->shaderProgram);
    207 
    208                 unsigned int location = glGetUniformLocationARB(this->shaderProgram, name);
    209                 /* This is EXPENSIVE and should be avoided. */
    210 
    211                 if      (size == 1)  glUniform1fvARB(location, 1, value);
    212                 else if (size == 2)  glUniform2fvARB(location, 1, value);
    213                 else if (size == 3)  glUniform3fvARB(location, 1, value);
    214                 else if (size == 4)  glUniform4fvARB(location, 1, value);
    215                 else if (size == 9)  glUniformMatrix3fvARB(location, 1, false, value);
    216                 else if (size == 16) glUniformMatrix4fvARB(location, 1, false, value);
    217 
    218         }
     195  if (likely (this->shaderProgram != 0))
     196  {
     197    glUseProgramObjectARB(this->shaderProgram);
     198
     199    unsigned int location = glGetUniformLocationARB(this->shaderProgram, name);
     200    /* This is EXPENSIVE and should be avoided. */
     201
     202    if      (size == 1)  glUniform1fvARB(location, 1, value);
     203    else if (size == 2)  glUniform2fvARB(location, 1, value);
     204    else if (size == 3)  glUniform3fvARB(location, 1, value);
     205    else if (size == 4)  glUniform4fvARB(location, 1, value);
     206    else if (size == 9)  glUniformMatrix3fvARB(location, 1, false, value);
     207    else if (size == 16) glUniformMatrix4fvARB(location, 1, false, value);
     208
     209  }
    219210}
    220211
    221212void Shader::deactivateShader()
    222213{
    223  if (storedShader != NULL)
    224    glUseProgramObjectARB(0);
    225  Shader::storedShader = NULL;
     214  if (storedShader != NULL)
     215    glUseProgramObjectARB(0);
     216  Shader::storedShader = NULL;
    226217}
    227218
     
    292283  if (this->vertexShader != 0)
    293284  {
    294 /*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
    295     if (this->vertexShaderSource != NULL)
    296       for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
    297         PRINT(3)("%d: %s\n", i, this->vertexShaderSource->getEntry(i));
    298   }
    299   if (this->fragmentShader != 0)
    300   {
    301     PRINT(3)("FragmentShaderProgramm: number=%d, file='%s'\n", this->fragmentShader, this->fragmentShaderFile);
    302     if (this->fragmentShaderSource != NULL)
    303       for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
    304         PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
    305   }
    306 }
    307 
     285    /*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
     286        if (this->vertexShaderSource != NULL)
     287          for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
     288            PRINT(3)("%d: %s\n", i, this->vertexShaderSource->getEntry(i));
     289      }
     290      if (this->fragmentShader != 0)
     291      {
     292        PRINT(3)("FragmentShaderProgramm: number=%d, file='%s'\n", this->fragmentShader, this->fragmentShaderFile);
     293        if (this->fragmentShaderSource != NULL)
     294          for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
     295            PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
     296  }
     297}
     298
  • branches/new_class_id/src/lib/graphics/shader_data.h

    r9803 r9806  
    11/*!
    2  * @file shader.h
     2 * @file shader_data.h
    33 * @brief Definition of the Shader rendering class
    44*/
    55
    6 #ifndef _SHADER_H
    7 #define _SHADER_H
     6#ifndef _SHADER_DATA_H
     7#define _SHADER_DATA_H
    88
    99#include "base_object.h"
    10 #include "glincl.h"
     10
     11#include "shader_types.h"
    1112#include <vector>
    1213
     
    1617
    1718
    18 //! A class for ...
    19 class Shader : public BaseObject
     19//! The ShaderData is a Class-wrapper around the OpenGL Shader Language (GLSL).
     20class ShaderData : public BaseObject
    2021{
    21   ObjectListDeclaration(Shader);
     22  ObjectListDeclaration(ShaderData);
    2223public:
    23   class Uniform
    24   {
    25   public:
    26     Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
    27     Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
    28     Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
     24  ShaderData(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
     25  virtual ~ShaderData();
    2926
    30     void set(float v0) const { glUniform1f(this->uniform, v0); }
    31     void set(float v0, float v1) const { glUniform2f(this->uniform, v0, v1); }
    32     void set(float v0, float v1, float v2) const { glUniform3f(this->uniform, v0, v1, v2); }
    33     void set(float v0, float v1, float v2, float v3) const { glUniform4f(this->uniform, v0, v1, v2, v3); }
     27  Shaders::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
    3428
    35     void set(int v0) const { glUniform1i(this->uniform, v0); }
    36     void set(int v0, int v1) const { glUniform2i(this->uniform, v0, v1); }
    37     void set(int v0, int v1, int v2) const { glUniform3i(this->uniform, v0, v1, v2); }
    38     void set(int v0, int v1, int v2, int v3) const { glUniform4i(this->uniform, v0, v1, v2, v3); }
    39 
    40     void setV(unsigned int count, float* vv) const
    41     {
    42       switch (count)
    43       {
    44         case 1:
    45         glUniform1fv(this->uniform, 1, vv);
    46         break;
    47         case 2:
    48         glUniform2fv(this->uniform, 2, vv);
    49         break;
    50         case 3:
    51         glUniform3fv(this->uniform, 3, vv);
    52         break;
    53         case 4:
    54         glUniform4fv(this->uniform, 4, vv);
    55         break;
    56       }
    57     }
    58     void setV(unsigned int count, int* vv) const
    59     {
    60       switch (count)
    61       {
    62         case 1:
    63         glUniform1iv(this->uniform, 1, vv);
    64         break;
    65         case 2:
    66         glUniform2iv(this->uniform, 2, vv);
    67         break;
    68         case 3:
    69         glUniform3iv(this->uniform, 3, vv);
    70         break;
    71         case 4:
    72         glUniform4iv(this->uniform, 4, vv);
    73         break;
    74       }
    75     }
    76   private:
    77     GLint uniform;
    78   };
    79 
    80   typedef enum
    81   {
    82     None       = 0,
    83     Fragment   = 1,
    84     Vertex     = 2,
    85 
    86     Program    = 4,
    87   }
    88   Type;
    89 
    90 public:
    91   Shader(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
    92   virtual ~Shader();
    93   static Shader* getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile);
    94   static bool unload(Shader* shader);
    95 
    96 
    97   static bool checkShaderAbility();
    98   void activateShader();
    99   void bindShader(const char* name, const float* value, size_t size);
    100   static void deactivateShader();
    101 
    102 Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
    103 
    104   bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
    105   void deleteProgram(Shader::Type type);
    106 
    107   void linkShaderProgram();
    108 
    109 
    110   bool readShader(const std::string& fileName, std::string& output);
    111 
    112 
    113 inline static bool shaderActive() { return (Shader::storedShader != NULL)? true : false; };
    114   inline static Shader* getActiveShader() { return Shader::storedShader; };
    115   inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
    116   inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
    117 
    118 
    119 
    120 
    121 GLhandleARB getProgram() const { return this->shaderProgram; }
     29  GLhandleARB getProgram() const { return this->shaderProgram; }
    12230  GLhandleARB getVertexS() const { return this->vertexShader; }
    12331  GLhandleARB getFragmentS() const { return this->fragmentShader; }
    12432
     33  void activateShader();
     34
    12535  void debug() const;
    126 
    127   static void printError(GLhandleARB program);
    128 
     36private:
     37  void bindShader(const char* name, const float* value, size_t size);
     38  void linkShaderProgram();
     39  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);
    12942
    13043private:
     
    13649  GLhandleARB            vertexShader;
    13750  GLhandleARB            fragmentShader;
    138 
    139 
    140   static Shader*         storedShader;
    14151};
    14252
    143 #endif /* _SHADER_H */
     53#endif /* _SHADER_DATA_H */
  • branches/new_class_id/src/lib/lang/base_object.cc

    r9805 r9806  
    3232  this->objectName = objectName;
    3333  this->xmlElem = NULL;
    34 
    35   //ClassList::addToClassList(this, this->classID, "BaseObject");
    3634}
    3735
     
    4543  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    4644  {
    47     PRINTF(5)("DELETING OBJECT %s::%s FROM %s\n", this->getClassCName(), getCName(), (*it)._objectList->name().c_str());
    4845    (*it)._objectList->unregisterObject((*it)._iterator);
    4946    delete (*it)._iterator;
     
    148145void BaseObject::listInheritance() const
    149146{
    150   PRINT(0)("Listing inheritance diagram for ....: ");
     147  PRINT(0)("Listing inheritance diagram for %s::%s: ", getClassCName(), getCName());
    151148  ClassList::const_iterator it;
    152149  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
  • branches/new_class_id/src/lib/sound/ogg_player.h

    r9762 r9806  
    100100
    101101
    102     std::string         _title;
    103     std::string         _artist;
    104     std::string         _album;
    105     std::string         _vendor;
     102    std::string         _title;               //!< Song Title.
     103    std::string         _artist;              //!< Artist Name of the current song.
     104    std::string         _album;               //!< Album Name of the current song.
     105    std::string         _vendor;              //!< Vendor Name of the current song.
    106106  };
    107107
  • branches/new_class_id/src/lib/sound/sound_buffer.cc

    r9805 r9806  
    1818#include "sound_buffer.h"
    1919
     20
    2021namespace OrxSound
    2122{
     23  ObjectListDefinition(SoundBuffer);
    2224  //////////////////
    2325  /* SOUND-BUFFER */
     
    2628      : data(new SoundBufferData)
    2729  {
     30    this->registerObject(this, SoundBuffer::_objectList);
    2831  }
    2932  /**
     
    3437      : data(new SoundBufferData)
    3538  {
     39    this->registerObject(this, SoundBuffer::_objectList);
    3640    this->load(fileName);
    3741  }
     
    3943  SoundBuffer::SoundBuffer(const SoundBuffer& buffer)
    4044      : data(buffer.data)
    41   {  }
     45  {
     46    this->registerObject(this, SoundBuffer::_objectList);
     47  }
    4248
    4349  SoundBuffer::SoundBuffer(const SoundBufferData::Pointer& dataPointer)
    4450      : data(dataPointer)
    45   {  };
     51  {
     52    this->registerObject(this, SoundBuffer::_objectList);
     53  };
     54
     55  SoundBuffer::~SoundBuffer()
     56  {
     57    printf("Deleting Object of type SoundBuffer\n");
     58  }
     59
    4660}
  • branches/new_class_id/src/lib/sound/sound_buffer.h

    r9805 r9806  
    77#define _SOUND_BUFFER_H
    88
     9#include "base_object.h"
    910#include "sound_buffer_data.h"
    1011
     
    1213{
    1314  //! A class that represents a datastructure to play Sounds.
    14   class SoundBuffer
     15  class SoundBuffer : virtual public BaseObject
    1516  {
     17    ObjectListDeclaration(SoundBuffer);
    1618  public:
    1719    SoundBuffer();
     
    1921    SoundBuffer(const SoundBufferData::Pointer& dataPointer);
    2022    SoundBuffer(const std::string& fileName);
     23    virtual ~SoundBuffer();
    2124
    2225    bool operator==(const SoundBuffer& buffer) const {return this->data == buffer.data; };
  • branches/new_class_id/src/orxonox.cc

    r9800 r9806  
    370370  Resources::NewResourceManager::getInstance()->addResourceSubPath("Texture", "pictures");
    371371
     372  Resources::NewResourceManager::getInstance()->addResourceSubPath("SoundBuffer", "sound");
     373  Resources::NewResourceManager::getInstance()->addResourceSubPath("SoundBuffer", "music");
     374
    372375  Resources::NewResourceManager::getInstance()->addKeepLevelName("Imediately");
    373376  Resources::NewResourceManager::getInstance()->addKeepLevelName("LevelEnd");
  • branches/new_class_id/src/world_entities/npcs/attractor_mine.cc

    r9757 r9806  
    6666
    6767  this->shader = NULL;
    68   if (likely(Shader::checkShaderAbility()))
    69     this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");
     68  //if (likely(Shader::checkShaderAbility()))
     69//    this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");
    7070
    7171  this->randomRotAxis = VECTOR_RAND(1);
     
    7878AttractorMine::~AttractorMine ()
    7979{
    80   if (this->shader)
    81     Shader::unload(this->shader);
    8280}
    83 
    8481
    8582void AttractorMine::loadParams(const TiXmlElement* root)
  • branches/new_class_id/src/world_entities/npcs/generic_npc.cc

    r9757 r9806  
    2929
    3030#include "loading/resource_manager.h"
     31#include "sound/resource_sound_buffer.h"
    3132
    3233#include "bsp_entity.h"
     
    8889  this->toList(OM_GROUP_00);
    8990
    90   this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
     91  this->soundBuffer = OrxSound::ResourceSoundBuffer("sound/rain.wav");
    9192
    9293  time = 30.0f;
  • branches/new_class_id/src/world_entities/npcs/generic_npc.h

    r9715 r9806  
    124124
    125125   OrxSound::SoundSource                   soundSource;
    126    OrxSound::SoundBuffer*                  soundBuffer;
     126   OrxSound::SoundBuffer                   soundBuffer;
    127127   float                                   soundVolume;
    128128
  • branches/new_class_id/src/world_entities/npcs/npc_test.cc

    r9716 r9806  
    4848
    4949  this->shader = NULL;
    50   if (likely(Shader::checkShaderAbility()))
    51     this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");
     50//  if (likely(Shader::checkShaderAbility()))
     51    //this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");
    5252
    5353  this->randomRotAxis = VECTOR_RAND(1);
     
    5959
    6060NPC2::~NPC2 ()
    61 {
    62   if (this->shader)
    63     Shader::unload(this->shader);
    64 }
     61{}
    6562
    6663
Note: See TracChangeset for help on using the changeset viewer.