Hello.
My current code to draw a button looks like this:
namespace foo
{
std::vector<std::pair<sf::Text, sf::RectangleShape>> buttons;
void newButton(...)
{
sf::Font bla;
bla.loadFromFile("...");
sf::text blub;
blub.setFont(bla);
buttons.push_back(std::make_pair(blub, rectangle));
//I think i can leave the rectangle-initialization out, because this works fine
}
void drawButtons(sf::RenderWindow &window)
{
for(std::pair<sf::Text, sf::RectangleShape> b : buttons)
{
window.draw(b.second);
window.draw(b.first); //It fails here, because I set the Font
}
}
}
What I'm doing wrong? Obviously I'm not supposed to add the font before pushing it on a vector, but I need the font set[complet size of the sf::Text] for the rectangle-initialization.