summaryrefslogtreecommitdiff
path: root/glsl_types.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-06-09 17:27:31 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-06-11 13:51:42 -0700
commiteeedd355cfc2f0c578282657bd4259440a88742c (patch)
tree108af2b7b65b7e2edfec2f13950a3eca77ab0925 /glsl_types.cpp
parentab92d0e53eab9030742e5e6d938a5739e549f16c (diff)
Add glsl_types::field_index to get the location of a record field
Diffstat (limited to 'glsl_types.cpp')
-rw-r--r--glsl_types.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/glsl_types.cpp b/glsl_types.cpp
index 9487819a44..4b6a61a13c 100644
--- a/glsl_types.cpp
+++ b/glsl_types.cpp
@@ -718,3 +718,18 @@ glsl_type::field_type(const char *name) const
return error_type;
}
+
+
+int
+glsl_type::field_index(const char *name) const
+{
+ if (this->base_type != GLSL_TYPE_STRUCT)
+ return -1;
+
+ for (unsigned i = 0; i < this->length; i++) {
+ if (strcmp(name, this->fields.structure[i].name) == 0)
+ return i;
+ }
+
+ return -1;
+}