Hello board,
I’m trying to get a particular shader (code is pasted below) to write to each element of gl_FragData. However, when I try to compile the shader, it gives me a rather unexplainable error:
(0) : fatal error C9999: marking a sampler that is not a scalar
#version 120
uniform sampler2DRect input_image[gl_MaxDrawBuffers];
void main()
{
vec2 coord = (gl_TexCoord[0].xy - 0.5) * 2.0 + 0.5;
for (int i = 0; i < gl_MaxDrawBuffers; i++)
{
gl_FragData[i] = texture2DRect(input_image[i], coord);
}
}
I tried a couple of other things and it also gave me a rather weird error:
(0) : fatal error C9999: Array access to non-array
The code I used to get that error is below (notice the 0 instead of i in gl_TexCoord)
#version 120
uniform sampler2DRect input_image[gl_MaxDrawBuffers];
void main()
{
vec2 coord = (gl_TexCoord[0].xy - 0.5) * 2.0 + 0.5;
for (int i = 0; i < 2; i++)
{
gl_FragData[i] = texture2DRect(input_image[0], coord);
}
}
I couldn’t really get my head around it, but I saw it in other places on the net, so I couldn’t really think that there was something wrong with my code. As a final solution, I replaced the for loop by the code that the for loop should have executed. This code ran just fine. Too bad this didn’t give me an explanation why the others didn’t work.
#version 120
uniform sampler2DRect input_image[gl_MaxDrawBuffers];
void main()
{
vec2 coord = (gl_TexCoord[0].xy - 0.5) * 2.0 + 0.5;
gl_FragData[0] = texture2DRect(input_image[0], coord);
gl_FragData[1] = texture2DRect(input_image[1], coord);
gl_FragData[2] = texture2DRect(input_image[2], coord);
gl_FragData[3] = texture2DRect(input_image[3], coord);
gl_FragData[4] = texture2DRect(input_image[4], coord);
gl_FragData[5] = texture2DRect(input_image[5], coord);
gl_FragData[6] = texture2DRect(input_image[6], coord);
gl_FragData[7] = texture2DRect(input_image[7], coord);
}
I’m running Mac OS X 10.5.6, Gefore 9400M, GLSL version 1.2. I’m using PyOpenGL 3.0.0c1 to run my OpenGL and GLSL code. Hope somebody can make heads or tails out of it, cause I sure can’t.