是否可以使用矢量用于opengl顶点数组?

时间:2013-04-20 21:29:28

标签: c++ opengl

我希望我的班级Vector3f存储我的长方体的索引点(由三角形组成)。

这就是我要向矢量推送的内容。

    vector<Vector3f> I;

    I.push_back(Vector3f(1,   0,   2));     //front
    I.push_back(Vector3f(2,   0,   3));
    I.push_back(Vector3f(4,   5,   7));         //back
    I.push_back(Vector3f(7,   5,   6));
    I.push_back(Vector3f(0,   4,   3));     //left
    I.push_back(Vector3f(3,   4,   7));     
    I.push_back(Vector3f(5,   1,   6));     //right
    I.push_back(Vector3f(6,   1,   2));
    I.push_back(Vector3f(7,   6,   3));     //up
    I.push_back(Vector3f(3,   6,   2));
    I.push_back(Vector3f(1,   0,   5));     //down
    I.push_back(Vector3f(5,   0,   4));

顶点数组可以从类中读取吗?

1 个答案:

答案 0 :(得分:1)

假设您的Vector3f是POD

&I[0]会将float *提供给glBufferData