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

Author Topic: Dear all, I have no way out about sf::Text and sf::Font  (Read 5685 times)

0 Members and 1 Guest are viewing this topic.

ahturin

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Dear all, I have no way out about sf::Text and sf::Font
« on: October 16, 2021, 01:28:11 pm »
Dear everyone,

I admitted I have no way out. I tried writing a sf::Text with sf::Font in my program with SFML 2.2 on Visual C++ 2008 Express Edition. It works fine.

But after I moved to Visual C++ 2019 and SFML 2.5. Same code, it doesn't show text.

Please review my program. I copied from this web sfml-dev.org (in Documentation page) and made some modify on my own:

==========================

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    sf::Texture texture;
    if (!texture.loadFromFile("test.png"))
        return EXIT_FAILURE;
    sf::Sprite sprite(texture);
    sf::Font font;
    if (!font.loadFromFile("arial.ttf"))
        return EXIT_FAILURE;

    sf::Text text("Hello SFML", font, 50);
    text.setString("AAA");
    text.setPosition(100, 300);

    // Start the game loop
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window: exit
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();
        window.draw(sprite);
        window.draw(text);
        window.display();
    }
    return EXIT_SUCCESS;
}

=================

When I build with Visual C++ Express 2008, SFML 2.2 ok it works fine. Please see the picture P1.PNG

same code, copied and pasted to build with Visual C++ 2019, SFML 2.5, it got errors about sf::Font I guess. the window showed up and disappeared. Please see P2.PNG

The main project I am working on Visual C++ 2019 and SFML 2.5 I need to make work.

Please please let me know where I missed or any ideas.

Thank you. Very thank you.

ahturin :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Dear all, I have no way out about sf::Text and sf::Font
« Reply #1 on: October 16, 2021, 11:35:16 pm »
Googling for the error code -1073741819 will give you lots of different things to try.

Did you create a brand new project or just upgrade the old one? If the latter, did you try with a clean project?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/