Shader: Removing const declaration of loadUniforms ivi-layer-management_version_0_9_5_rc
authorMichael Schuldt <michael.schuldt@bmw-carit.de>
Fri, 23 Dec 2011 10:03:01 +0000 (11:03 +0100)
committerMichael Schuldt <michael.schuldt@bmw-carit.de>
Fri, 23 Dec 2011 10:03:01 +0000 (11:03 +0100)
LayerManagerPlugins/Renderers/Platform/X11GLESRenderer/include/ShaderProgramGLES.h
LayerManagerPlugins/Renderers/Platform/X11GLESRenderer/src/ShaderProgramGLES.cpp
LayerManagerService/include/Shader.h
LayerManagerService/include/ShaderProgram.h
LayerManagerService/include/ShaderUniform.h
LayerManagerService/src/shader/Shader.cpp
LayerManagerService/src/shader/ShaderUniform.cpp

index 0550a36..6211815 100644 (file)
@@ -51,7 +51,7 @@ public:
      */
     virtual void use(void) const;
 
-    virtual int getUniformLocation(const char* name) const
+    virtual int getUniformLocation(const char* name) 
     {
         return glGetUniformLocation(m_progHandle, name);
     }
index 2be734c..27ccb32 100644 (file)
@@ -58,7 +58,7 @@ ShaderProgram* ShaderProgramGLES::createProgram(const std::string& vertName, con
        else
        {
                // load shader sources from file, compile and link them:
-               progHandle = RenderUtilLoadShaderSources(vertName.c_str(), fragName.c_str(), GL_FALSE);
+               progHandle = RenderUtilLoadShaderSources(vertName.c_str(), fragName.c_str(), GL_TRUE);
        }
 
     if (progHandle != 0)
index 42f8c67..b038a7b 100644 (file)
@@ -76,7 +76,7 @@ public:
      * used for position, size, etc... They need to be set separately
      * by loadCommonUniforms().
      */
-    void loadUniforms(void) const;
+    void loadUniforms(void);
 
     /**
      * Load uniform values for common surface properties, like position,
index fc1923f..65daa70 100644 (file)
@@ -110,7 +110,7 @@ public:
      */
     void unref(void);
 
-    virtual int getUniformLocation(const char* name) const = 0;
+    virtual int getUniformLocation(const char* name) = 0;
 
     virtual void uniform1iv(int location, int count, const int* v) const = 0;
 
index a586218..9d822b9 100644 (file)
@@ -114,7 +114,7 @@ public:
     /**
      * Load uniform data in current OpenGL context.
      */
-    void load(const ShaderProgram& program) const;
+    void load(ShaderProgram& program);
 
 private:
     /// the uniform name
index 1776d05..7b93f1a 100644 (file)
@@ -86,14 +86,14 @@ void Shader::setUniform(const ShaderUniform& uniform)
     m_uniformMap[name]->setData(uniform);
 }
 
-void Shader::loadUniforms(void) const
+void Shader::loadUniforms(void)
 {
     UniformMapConstIterator iter = m_uniformMap.begin();
     UniformMapConstIterator iterEnd = m_uniformMap.end();
 
     for (; iter != iterEnd; ++iter)
-    {
-        const ShaderUniform* uniform = (*iter).second;
+    {       
+        ShaderUniform* uniform = (*iter).second;
         uniform->load(m_program);
     }
 }
index ac8ecc3..37315ff 100644 (file)
@@ -174,11 +174,18 @@ void ShaderUniform::setData(const ShaderUniform& other)
     m_transpose = other.m_transpose;
 }
 
-void ShaderUniform::load(const ShaderProgram& program) const
+void ShaderUniform::load(ShaderProgram& program)
 {
+    LOG_DEBUG("ShaderUniform","Load Uniform " << getName() << " location " << m_location);
+    if ( m_location == 0 ) 
+    {
+        m_location = program.getUniformLocation(getName().c_str());
+    }
+    LOG_DEBUG("ShaderUniform","Load Uniform " << getName() << " location " << m_location);
     if (m_location == -1)
     {
         // TODO: error? or silently fail?
+        LOG_WARNING("ShaderUniform","Load Uniform failed, location not defined" );
         return;
     }
 
@@ -188,18 +195,22 @@ void ShaderUniform::load(const ShaderProgram& program) const
     switch (m_type)
     {
     case Vector1f:
+        LOG_DEBUG("ShaderUniform","Load Uniform1fv : " << values[0] );
         program.uniform1fv(m_location, m_count, values);
         break;
 
     case Vector2f:
+        LOG_DEBUG("ShaderUniform","Load Uniform2fv : " << values[0] << "," << values[1] );
         program.uniform2fv(m_location, m_count, values);
         break;
 
     case Vector3f:
+        LOG_DEBUG("ShaderUniform","Load Uniform3fv : " << values[0] << "," << values[1] << "," << values[2] );
         program.uniform3fv(m_location, m_count, values);
         break;
 
     case Vector4f:
+        LOG_DEBUG("ShaderUniform","Load Uniform4fv : " << values[0] << "," << values[1] << "," << values[2] << "," << values[3] );
         program.uniform4fv(m_location, m_count, values);
         break;