まず、倍精度浮動小数点数はほぼすべてのGPUでサポートされていないため、使用できません。したがって、構造体のメンバーを浮動小数点数に変更するだけです...
glslで同じ構造体を定義します。
struct myVertStruct
{
float x, y, z; // for spacial coords
float nx, ny, nz; // for normals
float u, v; // for texture coords
float a, b; // just a couple of custom properties
} myStructName;
次に、c / c ++で構造体配列をインスタンス化し、vboを作成し、それにメモリを割り当ててから、シェーダーにバインドします。
struct myVertStruct
{
float x, y, z; // for spacial coords
float nx, ny, nz; // for normals
float u, v; // for texture coords
float a, b; // just a couple of custom properties
};
GLuint vboID;
myVertStruct myStructs[100]; // just using 100 verts for the sake of the example
// .... fill struct array;
glGenBuffers(1,&vboID);
次に、属性をバインドすると、次のようになります。
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glVertexAttribPointer(0, sizeof(myVertStruct) * 100, GL_FLOAT, GL_FALSE, 0, &struct);
glBindBuffer(GL_ARRAY_BUFFER, 0);
...次に、上記で使用したglslセグメントを使用して作成したシェーダープログラムにvboをバインドします。