Hello!
I have one problem.
#include <SFML/Graphics.hpp>
struct CFontd
{
sf::Font * font;
CFontd() {
font = new sf::Font();
font->loadFromFile( "arial.ttf" );
}
} Font;
struct CFont
{
sf::Text Text;
CFont() {
Text.setFont( *Font.font );
Text.setString( "0" );
}
};
int main() {
CFont Test;
sf::RenderWindow App( sf::VideoMode( 800, 600 ), "SFML works!" );
while( App.isOpen() )
{
sf::Event ev;
while( App.pollEvent( ev ) )
{
if( ev.type == sf::Event::Closed || ev.type == sf::Event::KeyPressed )
App.close();
}
App.display();
}
return 0;
}
All goes ok. But when I change implementation of CFontd class to
struct CFontd
{
sf::Font font;
CFontd() {
font.loadFromFile( "arial.ttf" );
}
} Font;
and of course
CFont() {
Text.setFont( Font.font );
Text.setString( "0" );
}
I get unhandled exception after press any key (so i get ue when app closes).
So my question is: Why I can't use local "sf::Font" object in global objects?