Add glsl_type::field_type
Query the type of a structure field
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user