Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-04-13 07:51:18 +0300
committerMike Erwin <significant.bit@gmail.com>2017-04-13 08:07:51 +0300
commit56e9629d96f1cc42b0ba47af562b14ed79b9ae2e (patch)
tree24e2d6b5403a0e1253949d4b2f539cb9c1425386 /intern
parentf7087109cefbddcf28cfb55be4ebf4ac6db89119 (diff)
Gawain: look up array uniforms correctly
Look up "name[0]" when asked for "name", since that marks the beginning of the array. We're comparing to the name stored in ShaderInterface which comes from glGetActiveUniform.
Diffstat (limited to 'intern')
-rw-r--r--intern/gawain/src/immediate.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/immediate.c
index f384887a2ad..f3fc046d2c5 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/immediate.c
@@ -754,8 +754,23 @@ void immUniform3fv(const char* name, const float data[3])
glUniform3fv(uniform->location, 1, data);
}
-void immUniformArray3fv(const char* name, const float *data, int count)
+// can increase this limit or move to another file
+#define MAX_UNIFORM_NAME_LEN 60
+
+void immUniformArray3fv(const char* bare_name, const float *data, int count)
{
+ // look up "name[0]" when given "name"
+ const size_t len = strlen(bare_name);
+#if TRUST_NO_ONE
+ assert(len <= MAX_UNIFORM_NAME_LEN);
+#endif
+ char name[MAX_UNIFORM_NAME_LEN];
+ strcpy(name, bare_name);
+ name[len + 0] = '[';
+ name[len + 1] = '0';
+ name[len + 2] = ']';
+ name[len + 3] = '\0';
+
GET_UNIFORM
glUniform3fv(uniform->location, count, data);
}