Ok, I did not have any of that code. However it’s still not working, but probably because I don’t understand all the parameters correctly.
I wasn’t sure what “nParamObj” object was but according to another source I can use “GLint uniform_location” returned from glGetUniformLocationARB();
This is what I currently have based on what you’ve added:
glUseProgram(glsl_prog);
GLint uniform_location;
uniform_location = glGetUniformLocationARB( glsl_prog, “tex1”);
glUniform1iARB( uniform_location, texID);
glActiveTexture(GL_TEXTURE0 + texID);
…
glBindTexture(…
and the convolution vert:
void main() {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
finally the convolution frag:
define KERNEL_SIZE 9
uniform sampler2D tex1;
uniform float width;
uniform float height;
uniform float kernel[KERNEL_SIZE];
const float step_w = 1.0/width;
const float step_h = 1.0/height;
const vec2 offset[KERNEL_SIZE] = {
vec2(-step_w, -step_h), vec2(0.0, -step_h), vec2(step_w, -step_h),
vec2(-step_w, 0.0), vec2(0.0, 0.0), vec2(step_w, 0.0),
vec2(-step_w, step_h), vec2(0.0, step_h), vec2(step_w, step_h)
};
void main(void)
{
int i = 0;
vec4 sum = vec4(0.0);
for( i=0; i<KERNEL_SIZE; i++ )
{
vec4 tmp = texture2D(tex1, gl_TexCoord[0].st + offset[i]);
sum += tmp * kernel[i];
sum.a = 1.0;
}
gl_FragColor = sum;
}
What’s broken there?
Thanks,
Cameron