I'm trying to draw some text to a game, but I'm having trouble with it.
#include <SFML\Graphics.hpp>
sf::Font font;
int main()
{
sf::RenderWindow window( sf::VideoMode( 800, 600 ), "Texto" );
font.loadFromFile("BROADW.ttf");
sf::Text text;
text.setFont(font);
text.setCharacterSize(40);
text.setColor(sf::Color::Blue);
text.setPosition( 100.0f, 100.0f );
text.setString( "Hola Mundo!" );
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear( sf::Color::Black );
window.draw(text);
window.display();
}
return 0;
}
When I try to load the font, I'm getting this error: "Unhandled exception in 0x66c41f34 (msvcr100.dll) in Text.exe: 0xC0000005: Access violation reading location 0x00357000."
Even if I try to draw text without font, It doesn't draw anything. What's going on?