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