頂点属性の配列は、OpenGLでは有効です。ただし、配列の各メンバーは個別の属性インデックスを使用します。それらは、指定した属性インデックスから開始して、連続して割り当てられますpatch_data
。GLSL 4.00を使用しているため、属性の場所も明示的に指定する必要がありますlayout(location = #)
。
したがって、これを行う場合:
layout(location = 1) in vec3 patch_data[1 + 2 * max_valence];
次にpatch_data
、1から。までのハーフオープン範囲のすべての属性インデックスをカバーします1 + (1 + 2 * max_valence)
。
各配列エントリは、OpenGL側から見ると、個別の属性です。glVertexAttribPointer
したがって、個別の配列インデックスごとに個別の呼び出しが必要です。
したがって、メモリ内の配列データが13個のvec3の配列のように見え、密集している場合は、次のようにする必要があります。
for(int attrib = 0; attrib < 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<void*>(baseOffset + (attrib * 3 * sizeof(float))) //Where baseOffset is the start of the array data in the buffer object.
);
}