1
Graphics / Cannot call draw() from constant RenderTarget object.
« on: April 14, 2020, 05:49:02 pm »
Hi,
I made a function that is supposed to draw a text on a RenderTarget. But I an error message saying that "No instance of overloaded function could be found.". Here is my function:
But, it works fine when I remove the const before the RenderTarget:
Why? Isn't draw() a const function? And if it isn't, why wouldn't it be?
I made a function that is supposed to draw a text on a RenderTarget. But I an error message saying that "No instance of overloaded function could be found.". Here is my function:
void DrawStringInBox(const sf::RenderTarget &xindox, const std::string& String, const sf::Font& font) {
sf::Text text(String, font);
xindox.draw(text);
}
sf::Text text(String, font);
xindox.draw(text);
}
But, it works fine when I remove the const before the RenderTarget:
void DrawStringInBox(sf::RenderTarget &xindox, const std::string& String, const sf::Font& font) {
sf::Text text(String, font);
xindox.draw(text);
}
sf::Text text(String, font);
xindox.draw(text);
}
Why? Isn't draw() a const function? And if it isn't, why wouldn't it be?