return TEXTURE_2D;
}
- GLint Program::getUniformLocation(const std::string &name) const
+ bool Program::isUniformDefined(const std::string &name) const
{
unsigned int subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript);
size_t numUniforms = uniformIndex.size();
for(size_t location = 0; location < numUniforms; location++)
{
- const int index = uniformIndex[location].index;
- const bool isArray = uniforms[index]->isArray();
+ const unsigned int index = uniformIndex[location].index;
+ if((uniformIndex[location].name == baseName) && ((index == GL_INVALID_INDEX) ||
+ ((uniforms[index]->isArray() && uniformIndex[location].element == subscript) ||
+ (subscript == GL_INVALID_INDEX))))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ GLint Program::getUniformLocation(const std::string &name) const
+ {
+ unsigned int subscript = GL_INVALID_INDEX;
+ std::string baseName = es2::ParseUniformName(name, &subscript);
- if(uniformIndex[location].name == baseName &&
- ((isArray && uniformIndex[location].element == subscript) ||
+ size_t numUniforms = uniformIndex.size();
+ for(size_t location = 0; location < numUniforms; location++)
+ {
+ const unsigned int index = uniformIndex[location].index;
+ if((index != GL_INVALID_INDEX) && (uniformIndex[location].name == baseName) &&
+ ((uniforms[index]->isArray() && uniformIndex[location].element == subscript) ||
(subscript == GL_INVALID_INDEX)))
{
return (GLint)location;
static GLenum floatType[] = { GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4 };
static GLenum boolType[] = { GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3, GL_BOOL_VEC4 };
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
return false;
}
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
bool Program::setUniform1iv(GLint location, GLsizei count, const GLint *v)
{
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
static GLenum uintType[] = { GL_UNSIGNED_INT, GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT_VEC3, GL_UNSIGNED_INT_VEC4 };
static GLenum boolType[] = { GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3, GL_BOOL_VEC4 };
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
bool Program::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
{
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
static GLenum uintType[] = { GL_UNSIGNED_INT, GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT_VEC3, GL_UNSIGNED_INT_VEC4 };
static GLenum boolType[] = { GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3, GL_BOOL_VEC4 };
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
bool Program::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params)
{
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
bool Program::getUniformiv(GLint location, GLsizei *bufSize, GLint *params)
{
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
bool Program::getUniformuiv(GLint location, GLsizei *bufSize, GLuint *params)
{
- if(location < 0 || location >= (int)uniformIndex.size())
+ if(location < 0 || location >= (int)uniformIndex.size() || (uniformIndex[location].index == GL_INVALID_INDEX))
{
return false;
}
GLint numUniforms = static_cast<GLint>(uniformIndex.size());
for(GLint location = 0; location < numUniforms; location++)
{
- if(uniformIndex[location].element != 0)
+ if((uniformIndex[location].element != 0) || (uniformIndex[location].index == GL_INVALID_INDEX))
{
continue;
}
}
else UNREACHABLE(shader);
- if(location == -1) // Not previously defined
+ if(!isUniformDefined(name))
{
uniforms.push_back(uniform);
- unsigned int index = static_cast<unsigned int>(uniforms.size() - 1);
+ unsigned int index = (blockInfo.index == -1) ? static_cast<unsigned int>(uniforms.size() - 1) : GL_INVALID_INDEX;
for(int i = 0; i < uniform->size(); i++)
{