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(),但它也失敗 –
我應該發佈我的整個代碼? –
抱歉,延遲。發佈或發送給我,我會很高興看。 –