Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

try with the shader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.