Given a vertex shader that looks something like
#version 400 compatibility
const int max_valence = 6;
in int valence;
in vec3 patch_data[1 + 2 * max_valence];
...
What is the the proper way to map the data to the correct vertex attribs? I’m trying to use a VBO, but I can’t figure out how to pass that large of a value in. glVertexAttribPointer takes at most a vector of size 4. What’s the correct way to get the vertex attributes into the shader?
Arrays of vertex attributes are legal in OpenGL. However, each member of the array takes up a separate attribute index. They are allocated contiguously, starting from whatever attribute index you give
patch_data. Since you’re using GLSL 4.00, you should also be specifying attribute locations explicitly withlayout(location = #).So if you do this:
Then
patch_datawill cover all attribute indices on the half-open range from 1 to1 + (1 + 2 * max_valence).Each array entry is, from the OpenGL side, a separate attribute. Therefore, you need a separate
glVertexAttribPointercall for each separate array index.So if your array data in memory looks like an array of 13 vec3’s, tightly packed, then you need to do this: