0
试图在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();
}
我的代码仍然没有运行...!测试了一个类型的矢量,它工作正常...不工作这种类型,虽然....也尝试push_back(),但它也失败 –
我应该发布我的整个代码? –
抱歉,延迟。发布或发送给我,我会很高兴看。 –