【发布时间】:2016-09-24 00:46:35
【问题描述】:
试图在opengl中绘制顶点,但我只能将顶点中的一个元素分配给TaskTwoVerticesN,请帮助...!我究竟做错了什么?如果您需要所有代码,请告诉我,我可以通过电子邮件发送或在此处发布
typedef struct Vertex {
float XYZW[4];
float RGBA[4];
void SetCoords(float *coords) {
XYZW[0] = coords[0];
XYZW[1] = coords[1];
XYZW[2] = coords[2];
XYZW[3] = coords[3];
}
void SetColor(float *color) {
RGBA[0] = color[0];
RGBA[1] = color[1];
RGBA[2] = color[2];
RGBA[3] = color[3];
}
};
Vertex Vertices[] =
{
{ { 1.0f, 1.0f, 0.0f, 1.0f },{ 0.0f, 0.0f, 0.0f, 1.0f } }, // 0
{ { 0.0f, 1.4f, 0.0f, 1.0f },{ 0.0f, 0.0f, 1.0f, 1.0f } }, //
};
std::vector<Vertex>TaskTwoVerticesN;
void createObjects(void)
{
TaskTwoVerticesN.clear();
// and this, running them one by one in a for loop does not work either
TaskTwoVerticesN.insert(TaskTwoVerticesN.begin(), Vertices, Vertices + (sizeof(Vertices)/sizeof(Vertices[0])));
}
main(){
createObjects();
}
【问题讨论】: