SFML community forums
Help => Graphics => Topic started by: Carlows on June 21, 2013, 02:45:48 am
-
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?
-
Place your font in main.
-
It doesn't change anything, same error
-
Maybe you mixed debug and release of your program and dlls?
-
What do you mean? I paste all the files in /bin folder to system32 directly, is it wrong? I didn't understand how to setup the dll's when I read the tutorial yesterday, lol
-
Well, I link the debug version of the libraries and it works, thanks :)