Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Mac OS X 10.11.1] SFML 2.3.2: having problems with window.draw and window.close  (Read 2241 times)

0 Members and 1 Guest are viewing this topic.

vlgimen

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hello all,

It's been a while since I last ran an SFML code, so I decided to get the newest stable version out there and play around. I've just downloaded SFML 2.3, and there's something I'm not being able to figure out. I got the package from the website, put the frameworks and Xcode templates on the place they're supposed to be (following the website instructions), and created a project based on the SFML App template with all module flags checked, Compiler  "C++11 with Clang and libc++".

What's currently happening is that neither window.draw(sprite) nor window.draw(text) work in that sample code. It gets compiled with no warnings or errors, but whenever they're called I will get an EXC_BAD_ACCESS error. Declarations of sprite and text are done by default as follows:

sprite:
sf::Texture texture;
if (!texture.loadFromFile(resourcePath() + "cute_image.jpg")) {
    return EXIT_FAILURE;
}
sf::Sprite sprite(texture);

text:
sf::Font font;
if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
    return EXIT_FAILURE;
}
sf::Text text("Hello SFML", font, 50);
text.setColor(sf::Color::Black);

Now, trying to play with the code a bit, I changed the way sprite and text were set, and I could get it to run, with no more EXC_BAD_ACCESS happening on the window.draw(...) calls:

sprite:
// Load a sprite to display
sf::Texture texture;
sf::Sprite sprite;
if (!texture.loadFromFile(resourcePath() + "cute_image.jpg")) {
    return EXIT_FAILURE;
}
else
{
    sprite.setTexture(texture);
}

text:
// Create a graphical text to display
sf::Font font;
sf::Text text;
if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
    return EXIT_FAILURE;
}
else
{
    text.setFont(font);
    text.setString("Hello SFML");
    text.setCharacterSize(50);
    text.setColor(sf::Color::Black);
}

All done, code runs. However, when I leave the app (running via Xcode) by pressing escape (which is the key set to run window.close()), I get an EXC_BAD_ACCESS (code=EXC_I386_GPLFT):


Is there anything I'm overlooking? I wouldn't expect to change the way sprite and text were defined as per the template code, and also wouldn't expect to have this error when running window.close(). At least when I used SFML 2.1 in the past, the code just ran out of the box. Ah, and if this couldn't get bad enough, when I archive it exporting as a Mac app with no re-signing, it won't open, giving me a "quit unexpectedly" message.  :(

Any help is appreciated!

Thanks in advance for feedback!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
I'm guessing you didn't clean all of SFML 2.1. See http://en.sfml-dev.org/forums/index.php?topic=17398.msg125150#msg125150
SFML / OS X developer

vlgimen

  • Newbie
  • *
  • Posts: 2
    • View Profile
Indeed. Worked like a charm. Thanks a lot for your help!