Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10143 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Dec 23, 2006, 2:04:28 PM (18 years ago)
Author:
bensch
Message:

Shader fixing

Location:
trunk/src/lib/graphics
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/shader.cc

    r10142 r10143  
    5252  }
    5353}
     54
    5455void Shader::Uniform::setV(unsigned int count, int* vv) const
    5556{
     
    9697    PRINTF(2)("Your system does not support shaders\n");
    9798  this->load(vertexShaderFile, fragmentShaderFile);
    98 
    9999}
    100100
  • trunk/src/lib/graphics/shader.h

    r10118 r10143  
    2222  {
    2323  public:
    24           Uniform(const Shader& shader, const std::string& location) { if (Shader::isSupported()) this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
    25           Uniform(GLhandleARB shaderProgram, const std::string& location) { if (Shader::isSupported()) this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
     24    Uniform(const Shader& shader, const std::string& location) { if (Shader::isSupported()) this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
     25  Uniform(GLhandleARB shaderProgram, const std::string& location) { if (Shader::isSupported()) this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
    2626
    27     void set(float v0) const { if (Shader::isSupported()) glUniform1f(this->uniform, v0); }
    28     void set(float v0, float v1) const { if (Shader::isSupported()) glUniform2f(this->uniform, v0, v1); }
    29     void set(float v0, float v1, float v2) const { if (Shader::isSupported()) glUniform3f(this->uniform, v0, v1, v2); }
    30     void set(float v0, float v1, float v2, float v3) const { if (Shader::isSupported()) glUniform4f(this->uniform, v0, v1, v2, v3); }
     27  void set(float v0) const { if (Shader::isSupported()) glUniform1f(this->uniform, v0); }
     28  void set(float v0, float v1) const { if (Shader::isSupported()) glUniform2f(this->uniform, v0, v1); }
     29  void set(float v0, float v1, float v2) const { if (Shader::isSupported()) glUniform3f(this->uniform, v0, v1, v2); }
     30  void set(float v0, float v1, float v2, float v3) const { if (Shader::isSupported()) glUniform4f(this->uniform, v0, v1, v2, v3); }
    3131
    32     void set(int v0) const { if (Shader::isSupported()) glUniform1i(this->uniform, v0); }
    33     void set(int v0, int v1) const { if (Shader::isSupported()) glUniform2i(this->uniform, v0, v1); }
    34     void set(int v0, int v1, int v2) const { if (Shader::isSupported()) glUniform3i(this->uniform, v0, v1, v2); }
    35     void set(int v0, int v1, int v2, int v3) const {if (Shader::isSupported())  glUniform4i(this->uniform, v0, v1, v2, v3); }
     32  void set(int v0) const { if (Shader::isSupported()) glUniform1i(this->uniform, v0); }
     33  void set(int v0, int v1) const { if (Shader::isSupported()) glUniform2i(this->uniform, v0, v1); }
     34  void set(int v0, int v1, int v2) const { if (Shader::isSupported()) glUniform3i(this->uniform, v0, v1, v2); }
     35  void set(int v0, int v1, int v2, int v3) const {if (Shader::isSupported())  glUniform4i(this->uniform, v0, v1, v2, v3); }
    3636
    3737    void setV(unsigned int count, float* vv) const;
     
    5353
    5454  bool load(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "")
    55     { return this->data->load(vertexShaderFile, fragmentShaderFile); }
     55  { return this->data->load(vertexShaderFile, fragmentShaderFile); }
    5656
    5757
     
    7171  static bool isSupported() { return checkShaderAbility(); };
    7272
    73   inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
     73inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
    7474  inline static const Shader* getActiveShader() { return Shader::storedShader; };
    7575
     
    7878
    7979private:
    80   ShaderData::Pointer    data;
     80  ShaderData::Pointer          data;
    8181
    8282  static const Shader*         storedShader;
  • trunk/src/lib/graphics/shader_data.cc

    r10114 r10143  
    6565    return true;
    6666  }
    67  
     67
    6868  return true;
    6969}
     
    7474ShaderData::~ShaderData ()
    7575{
     76  if (shaderProgram == 0)
     77    return;
     78
     79
    7680  if (this->shaderProgram == glGetHandleARB(GL_PROGRAM_OBJECT_ARB))
    7781    glUseProgramObjectARB(0);
Note: See TracChangeset for help on using the changeset viewer.