1
Graphics / Add vertices to a vector
« on: April 24, 2018, 02:30:13 am »
I'm trying to draw about a hundred lines on the screen. So far I'm testing my code with adding only two vertices to a vector but the code won't compile because of
I'm not really experienced in C++ and any help would be greatly appreciated.
Here's my code so far.
error: expected primary-expression before ']' token vertices.push_back(line[]);
I'm not really experienced in C++ and any help would be greatly appreciated.
Here's my code so far.
std::vector <sf::Vertex> vertices;
sf::Vertex line[] =
{
sf::Vertex(sf::Vector2f(1, 0), sf::Color::Red),
sf::Vertex(sf::Vector2f(1, 150), sf::Color::Green),
};
sf::Vertex line2[] =
{
sf::Vertex(sf::Vector2f(3, 0), sf::Color::Red),
sf::Vertex(sf::Vector2f(3, 150), sf::Color::Green)
};
vertices.push_back(line[]);
vertices.push_back(line2[]);
sf::Vertex line[] =
{
sf::Vertex(sf::Vector2f(1, 0), sf::Color::Red),
sf::Vertex(sf::Vector2f(1, 150), sf::Color::Green),
};
sf::Vertex line2[] =
{
sf::Vertex(sf::Vector2f(3, 0), sf::Color::Red),
sf::Vertex(sf::Vector2f(3, 150), sf::Color::Green)
};
vertices.push_back(line[]);
vertices.push_back(line2[]);