2

I create my array this.kernel: it hast 48 elements and I want to pass it to my fragment shader.

When i call

 gl.uniform3fv(gl.getUniformLocation(this.program, "kernel"), 16, this.kernel);

kernel is defined in my shader:

uniform vec3 kernel[16]; 

I get an error for not enough arguments. I already looked up the specification etc, but don't find my problem -.-

void glUniform3fv(  GLint  location, GLsizei  count, const GLfloat * value);

Thanks for help

€: I converted this.kernel to a float32array but I still have this error.

€2: error in Chrome: not enough arguments

in Firefox: NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument

Pris0n
  • 350
  • 1
  • 5
  • 24

1 Answers1

3

Your this.kernel needs to be a Float32Array of length 48 (=3*16). You cannot use an array of vec3s.

Also the count is not used in WebGL. The function is (from WebGL Specification)

void uniform3fv(WebGLUniformLocation? location, Float32Array v);

Example usage:

gl.uniform3fv(gl.getUniformLocation(shaderProgram, "colors"), new Float32Array([0,1,2,3,4,5]));

See a complete example here: http://jsfiddle.net/mortennobel/URvtx/

Mortennobel
  • 3,383
  • 4
  • 29
  • 46
  • AH ok. I changed my array this.kernel to this.kernel = new Float32Array(this.kernel); The length is exactly 48 long. Just to be clear I meant the kernel in my shader is a vec3 Still getting the error not enough arguments. – Pris0n Jun 09 '13 at 08:59
  • Thank you. I experimented so much but it seems I forgot this variation. – Pris0n Jun 09 '13 at 13:08