使用sfml,由于某些原因,我想将我的顶点存储在这样的列表中:
std::list<sf::Vertex> shape{};
shape.push_back(sf::Vertex(...);
但我真的不知道怎么打电话
window.draw(...);
我想它应该像这样的东西:
window.draw(shape.begin(), shape.size(), sf::LineStrip);
现在我猜它不起作用的原因是因为列表不支持随机访问......任何人都有想法吗?
SFML期望顶点在连续存储中给出。你可以这样做:
std::vector<sf::Vertex> vec(shape.begin(), shape.end()); // copy
window.draw(vec.data, vec.size(), sf::LineStrip);
当然,首先使用vector
(或VertexBuffer
)会更有效率。