diff options
author | Alan Hourihane <[email protected]> | 2009-01-14 17:01:16 +0000 |
---|---|---|
committer | Alan Hourihane <[email protected]> | 2009-01-14 17:01:16 +0000 |
commit | e82784559e00cb534993c01309ad1832e9b3e56b (patch) | |
tree | 8c01cf08aa891114513ca8bd9fafe245be06f3f4 /progs/glsl/samplers.c | |
parent | 85dfed93fe2a6aace7dd2e08f97760e7062e6eb3 (diff) |
mesa: add new samplers_array test
Diffstat (limited to 'progs/glsl/samplers.c')
-rw-r--r-- | progs/glsl/samplers.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/progs/glsl/samplers.c b/progs/glsl/samplers.c index d2140097297..3fb8577d5e3 100644 --- a/progs/glsl/samplers.c +++ b/progs/glsl/samplers.c @@ -245,14 +245,22 @@ GenFragmentShader(GLint numSamplers) int s; p += sprintf(p, "// Generated fragment shader:\n"); +#ifndef SAMPLERS_ARRAY for (s = 0; s < numSamplers; s++) { p += sprintf(p, "uniform sampler2D tex%d;\n", s); } +#else + p += sprintf(p, "uniform sampler2D tex[%d];\n", numSamplers); +#endif p += sprintf(p, "void main()\n"); p += sprintf(p, "{\n"); p += sprintf(p, " vec4 color = vec4(0.0);\n"); for (s = 0; s < numSamplers; s++) { +#ifndef SAMPLERS_ARRAY p += sprintf(p, " color += texture2D(tex%d, gl_TexCoord[0].xy);\n", s); +#else + p += sprintf(p, " color += texture2D(tex[%d], gl_TexCoord[0].xy);\n", s); +#endif } p += sprintf(p, " gl_FragColor = color;\n"); p += sprintf(p, "}\n"); @@ -302,7 +310,11 @@ InitProgram(void) char uname[10]; GLint loc; +#ifndef SAMPLERS_ARRAY sprintf(uname, "tex%d", s); +#else + sprintf(uname, "tex[%d]", s); +#endif loc = glGetUniformLocation_func(Program, uname); assert(loc >= 0); |