1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <SFML/Graphics.hpp>
#include <iostream>
#include <array>
std::array<float, 48> PolygonArray = { 337.8, 657.25, 247.5, 654.25, 260, 366.5, 260, 366.5, 347.8, 257, 474.5, 235,
474.5, 235, 816.3, 211, 859.8, 372, 859.8, 372, 838.3, 432, 709, 566, 538, 562, 337.8, 657.25, 260, 366.5, 260, 366.5,
474.5, 235, 859.8, 372, 859.8, 372, 709, 566, 538, 562, 538, 562, 260, 366.5, 859.8, 372};
std::vector<sf::VertexArray> PolygonVector;
sf::VertexArray triangle(sf::Triangles, 3);
int main()
{
sf::RenderWindow window(sf::VideoMode(1200, 900), "Test");
for (int i = 0; i < PolygonArray.size()/6; i++) // / 6 = 3 * x,y = triangle
{
triangle[0].position = sf::Vector2f(PolygonArray[i * 6 + 0], PolygonArray[i * 6 + 1]);
triangle[1].position = sf::Vector2f(PolygonArray[i * 6 + 2], PolygonArray[i * 6 + 3]);
triangle[2].position = sf::Vector2f(PolygonArray[i * 6 + 4], PolygonArray[i * 6 + 5]);
triangle[0].color = triangle[1].color = triangle[2].color = sf::Color(255, i * 30, i * 30);
PolygonVector.push_back(triangle);
}
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.setFramerateLimit(30);
for (auto& it = PolygonVector.begin(); it != PolygonVector.end(); ++it)
{
window.draw(*it);
}
window.display();
}
}
|