Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This function let's you specify an attribute index for a user defined shader attribute (not for a uniform, as your code sample suggests), which you later use when refering to the attribute.</p> <p>Say you have a vertex shader:</p> <pre><code>... attribute vec4 vertex; //or 'in vec4 vertex' in modern syntax attribute vec3 normal; ... </code></pre> <p>You then can bind indices to those variables, with</p> <pre><code>glBindAttribLocation(program, 0, "vertex"); glBindAttribLocation(program, 1, "normal"); </code></pre> <p>You can use whatever non-negative numbers you like (in a small range). Then when refering to these attributes you use their indices, e.g. in <code>glVertexAttribPointer</code> or <code>glEnableVertexAttribArray</code> functions.</p> <p>But keep in mind that <code>glBindAttribLocation</code> has to be called before linking the program. You can also omit it. Then OpenGL automatically binds indices to all used attributes during linking, which can later be queried by <code>glGetAttribLocation</code>. But with <code>glBindAttribLocation</code> you can establish your own attribute index semantics and keep them consistent.</p> <p>The newer GLSL versions even allow you to specify the attribute indices within the shader (using the <code>layout</code> syntax), removing the need for either <code>glBindAttribLocation</code> or <code>glGetAttribLocation</code>, but I'm not sure if this is supported in ES.</p> <p>But my answer doesn't tell you more than those "various" sites you looked at or any good OpenGL/GLSL book, so if you still don't get it, delve a little deeper into the basics of GLSL.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload