Hello. I am learning C++ and SFML under Linux(Pop!_OS 22.04 LTS). I run some code ()to display some text on my window, I have no error when running, but the text does not display. Please help me.
Note: I did the library inclusions and the constants declaration in another file(.hpp).
#include "main.hpp"
#include <iostream>
sf::Font font;
int main(){
void gestionEntrees(sf::Event, sf::RenderWindow &window);
void chargerPolice();
sf::Text txt;
txt.setFont(font);
txt.setString("Hello, World.");
txt.setCharacterSize(26);
txt.setFillColor(sf::Color::Blue);
txt.setStyle(sf::Text::Bold | sf::Text::Underlined);
sf::RenderWindow window(sf::VideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32), "Mon premier jeu", sf::Style::Titlebar | sf::Style::Resize | sf::Style::Close);
window.setVerticalSyncEnabled(true);
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)){
// fermeture de la fenĂȘtre lorsque l'utilisateur le souhaite
gestionEntrees(event, window);
}
window.clear(sf::Color::White);
window.draw(txt);
window.display();
}
return 0;
}
void gestionEntrees(sf::Event event, sf::RenderWindow &window){
if (event.type == sf::Event::Closed)
window.close();
}
//Load font
void chargerPolice(){
if (!font.loadFromFile("/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttc"))
throw("Erreur de chargement de police");
}