]> git.tdb.fi Git - libs/gl.git/commitdiff
Uniform handling fixes
authorMikko Rasa <tdb@tdb.fi>
Fri, 24 Aug 2012 21:47:01 +0000 (00:47 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 24 Aug 2012 21:47:01 +0000 (00:47 +0300)
Initialize strides to zero, and return a location of -1 for uniforms in
blocks.

source/program.cpp

index 8892bcf1ed7861b632c7c0bc5089ed53e61b4756..ffcc4a6c81bd3db1f3aa4c0315676dd1c5e6d1e2 100644 (file)
@@ -254,6 +254,8 @@ void Program::link()
                        info.block = 0;
                        info.name = name;
                        info.size = size;
+                       info.array_stride = 0;
+                       info.matrix_stride = 0;
                        info.type = type;
                        uniforms_by_index[i] = &info;
                }
@@ -373,14 +375,14 @@ int Program::get_uniform_location(const string &n) const
                                add an offset. */
                                unsigned offset = lexical_cast<unsigned>(n.substr(open_bracket+1, n.size()-2-open_bracket));
                                i = uniforms.find(n.substr(0, open_bracket)+"[0]");
-                               if(i!=uniforms.end() && offset<i->second.size)
+                               if(i!=uniforms.end() && !i->second.block && offset<i->second.size)
                                        return i->second.location+offset;
                        }
                }
                return -1;
        }
 
-       return i->second.location;
+       return i->second.block ? -1 : i->second.location;
 }
 
 void Program::bind() const