Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 22, 2006, 2:58:51 PM (18 years ago)
Author:
bensch
Message:

HACK: Checking shader ability
@orxonoxers: make this faster

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

Legend:

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

    r9869 r9942  
    3535void Shader::Uniform::setV(unsigned int count, float* vv) const
    3636{
     37        if (Shader::isSupported())
    3738  switch (count)
    3839  {
     
    5354void Shader::Uniform::setV(unsigned int count, int* vv) const
    5455{
     56        if (Shader::isSupported())
    5557  switch (count)
    5658  {
  • trunk/src/lib/graphics/shader.h

    r9869 r9942  
    2222  {
    2323  public:
    24     Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
    25     Uniform(GLhandleARB shaderProgram, const std::string& location) { 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 { glUniform1f(this->uniform, v0); }
    28     void set(float v0, float v1) const { glUniform2f(this->uniform, v0, v1); }
    29     void set(float v0, float v1, float v2) const { glUniform3f(this->uniform, v0, v1, v2); }
    30     void set(float v0, float v1, float v2, float v3) const { 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 { glUniform1i(this->uniform, v0); }
    33     void set(int v0, int v1) const { glUniform2i(this->uniform, v0, v1); }
    34     void set(int v0, int v1, int v2) const { glUniform3i(this->uniform, v0, v1, v2); }
    35     void set(int v0, int v1, int v2, int v3) const { 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;
     
    6868
    6969  static bool checkShaderAbility();
     70  static bool isSupported() { return checkShaderAbility(); };
    7071
    7172  inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
Note: See TracChangeset for help on using the changeset viewer.