SFML community forums
Help => Graphics => Topic started by: mentor on June 08, 2014, 04:39:05 pm
-
I have a class that has Text and Font variables:
using namespace sf;
class MyClass {
private:
Font times;
Text song_name;
public:
MyClass();
~MyClass();
void DrawMethod(RenderWindow&);
};
In constructor I load font, I set song_name font, song_name character size, color - that works fine. But when I try to use setString I get an unhandled exception error.
MyClass::MyClass() {
times.loadFromFile("C:/Windows/Fonts/times.ttf");
song_name.setFont(times);
song_name.setCharacterSize(16);
song_name.setColor(Color::White);
song_name.setStyle(Text::Bold);
//***Above works!***
//But this doesn't:
song_name.setString("and here's some text");
}
Same happens when I try to draw my text:
void MyClass::DrawMethod(RenderWindow& win) {
win.draw(song_name);
}
What's happening?
-
What SFML version exactly? Built from source or using official binary?
What compiler?
Have you tried using a debugger to track it down?
-
SFML 2.1, official binary. My IDE is Visual Studio 2013.
No, I haven't tried debugger. I'll give it a try.
-
SFML 2.1, official binary. My IDE is Visual Studio 2013.
That won't work.
The official SFML 2.1 binaries are for VS2010.
Either switch to VS2010 or build SFML from source with/for VS2013. What you are doing at the moment won't ever work right.
-
The official SFML 2.1 binaries are for VS2010.
The official binaries are for VS 2010 and 2012.
SFML 2.1, official binary. My IDE is Visual Studio 2013.
So you got 3 options, downgrade to VS 2012 (not recommended), build SFML yourself, or grab a nightly build here (http://www.nightlybuilds.ch).
-
Whoops, missed the 2012 support. Thanks zsbzsb for the correction :)
-
I downloaded nightly build for Visual 2013 and now everything works. Thanks!