https://drive.google.com/file/d/1NQ3TmGzIDqNzuf2F6pHVJbfp4BtOjAMj/view?usp=sharing Hello, as you can see in the png file, I am creating a shape using 21 points with vertexarray as linestrip, and drawing it on the screen. The shape comes out exactly as I want when using linestrip, but when I apply the same points with convexShape, the shape doesn't come out as I expect. What could be the reason for this? Am I making a mistake somewhere? Here is my code.
int main()
{
sf::RenderWindow window(sf::VideoMode(1366, 768), "testing",sf::Style::Default, sf::ContextSettings(0, 0, 8));
std::vector<sf::Vector2f> points = style.getPoints();
points.emplace_back(0, 0);
points.emplace_back(0.851345, 9.18748);
points.emplace_back(3.37638, 18.0621);
points.emplace_back(7.48914, 26.3216);
points.emplace_back(13.0495, 33.6848);
points.emplace_back(19.8683, 39.9009);
points.emplace_back(27.7131, 44.7582);
points.emplace_back(36.3168, 48.0913);
points.emplace_back(45.3866, 49.7867);
points.emplace_back(54.6134, 49.7867);
points.emplace_back(63.6831, 48.0913);
points.emplace_back(72.2869, 44.7582);
points.emplace_back(80.1317, 39.9009);
points.emplace_back(86.9504, 33.6848);
points.emplace_back(92.5109, 26.3216);
points.emplace_back(96.6236, 18.0621);
points.emplace_back(99.1487, 9.18748);
points.emplace_back(100, 0);
points.emplace_back(100, 100);
points.emplace_back(0, 100);
points.emplace_back(0, 0);
sf::VertexArray va;
va.setPrimitiveType(sf::PrimitiveType::LineStrip);
va.resize(points.size());
for (std::size_t i = 0; i < va.getVertexCount(); i++)
{
va[i].position = points[i];
}
sf::Transform ts1;
ts1.translate(100, 200);
sf::ConvexShape shape;
shape.setPointCount(points.size());
for (std::size_t i = 0; i < shape.getPointCount(); i++)
{
shape.setPoint(i, points[i]);
}
shape.setPosition(300, 200);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
window.draw(va, ts1);
window.draw(shape);
window.display();
}
return 0;
}