Add glsl_type::field_type

Query the type of a structure field
This commit is contained in:
Ian Romanick
2010-04-19 15:40:01 -07:00
parent 3455ce6144
commit 8f755dcb67
2 changed files with 26 additions and 0 deletions
+15
View File
@@ -657,3 +657,18 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
return t;
}
const glsl_type *
glsl_type::field_type(const char *name) const
{
if (this->base_type != GLSL_TYPE_STRUCT)
return error_type;
for (unsigned i = 0; i < this->length; i++) {
if (strcmp(name, this->fields.structure[i].name) == 0)
return this->fields.structure[i].type;
}
return error_type;
}
+11
View File
@@ -332,6 +332,17 @@ struct glsl_type {
: error_type;
}
/**
* Get the type of a structure field
*
* \return
* Pointer to the type of the named field. If the type is not a structure
* or the named field does not exist, \c glsl_type::error_type is returned.
*/
const glsl_type *field_type(const char *name) const;
/**
* Query the number of elements in an array type
*