Hi! So I have this code:
// SFML Headers.
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Image.hpp>
#include <fstream>
int main() {
// Create the main window
sf::RenderWindow *window = new sf::RenderWindow(sf::VideoMode(800, 600), "Window");
sf::Font font; // Needed.
if (!font.loadFromFile("font.ttf")){
std::ofstream out("log.txt");
out << "Failed to load font from file!" << std::endl;
out.close();
}
// Loads it from file and sets it.
while (window->isOpen()) {
// Process events.
sf::Event event;
while (window->pollEvent(event)) {
// Close window: Exit.
if (event.type == sf::Event::Closed) {
window->close();
}
}
// Clear screen.
window->clear();
sf::Text text;
text.setFont(font);
text.setString("Hello, Menu!");
text.setCharacterSize(24);
text.setFillColor(sf::Color::White);
text.setStyle(sf::Text::Bold | sf::Text::Underlined);
// Update the window.
window->display();
}
return EXIT_SUCCESS;
}
For some reason this never displays anything in my window, which is just black box with no text at all. And in my main application (this is a minimal example.) it crashes on this line:
text.setFont(font);
I'm not sure why nothing displays? I followed tutorial to the word.