Jump to content

WebGL: Difference between revisions

7 bytes removed ,  12 October 2019
Line 6: Line 6:
==Usage (WebGL 1)==
==Usage (WebGL 1)==


===How to pass arrays as uniforms===
===Pass arrays as uniforms===
Use <code>gl.uniform1fv</code>, ..., <code>gl.uniform4fv</code> to pass an array of floats or <code>vec4</code>.
Use <code>gl.uniform1fv</code>, ..., <code>gl.uniform4fv</code> to pass an array of floats or <code>vec4</code>.
On Javascript, if you are using <code>gl.uniform4fv</code> and want a array of size <code>k</code> in your shader, you will need to pass an array of size 4 * k to the uniform function.
On Javascript, if you are using <code>gl.uniform4fv</code> and want a array of size <code>k</code> in your shader, you will need to pass an array of size 4 * k to the uniform function.