Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.opengl.org/wiki/Vertex_Shader#Multiple_attributes" rel="noreferrer">Arrays of vertex attributes</a> are legal in OpenGL. However, each member of the array takes up a <em>separate</em> attribute index. They are allocated contiguously, starting from whatever attribute index you give <code>patch_data</code>. Since you're using GLSL 4.00, you should also be specifying attribute locations explicitly with <code>layout(location = #)</code>.</p> <p>So if you do this:</p> <pre><code>layout(location = 1) in vec3 patch_data[1 + 2 * max_valence]; </code></pre> <p>Then <code>patch_data</code> will cover all attribute indices on the half-open range from 1 to <code>1 + (1 + 2 * max_valence)</code>.</p> <p>Each array entry is, from the OpenGL side, a <em>separate attribute</em>. Therefore, you need a separate <a href="http://www.opengl.org/wiki/GLAPI/glVertexAttribPointer" rel="noreferrer"><code>glVertexAttribPointer</code></a> call for each separate array index.</p> <p>So if your array data in memory looks like an array of 13 vec3's, tightly packed, then you need to do this:</p> <pre><code>for(int attrib = 0; attrib &lt; 1 + (2 * max_valence); ++attrib) { glVertexAttribPointer(attrib + 1, //Attribute index starts at 1. 3, //Each attribute is a vec3. GL_FLOAT, //Change as appropriate to the data you're passing. GL_FALSE, //Change as appropriate to the data you're passing. sizeof(float) * 3 * (1 + (2 * max_valence)), //Assuming that these array attributes aren't interleaved with anything else. reinterpret_cast&lt;void*&gt;(baseOffset + (attrib * 3 * sizeof(float))) //Where baseOffset is the start of the array data in the buffer object. ); } </code></pre>
 

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