Hi,
I'm fairly new to SFML, so I might be missing something.
I've gone through a lot of information but nothing has helped.
After I load a font, the program just closes without any message.
I use SFML as a git submodule and build everything with CMake.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
project(Ironforge)
set(CMAKE_CXX_STANDARD 20)
set(BUILD_SHARED_LIBS FALSE)
add_subdirectory(dep/SFML)
add_executable(${PROJECT_NAME}
src/main.cpp
src/Application.cpp
src/State/StateManager.cpp
src/UI/Button.cpp
src/UI/MenuTabBar.cpp
src/WindowManager.cpp
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/dep/SFML/include)
set(DEBUG_LIBS
sfml-graphics-d)
set(RELEASE_LIBS
sfml-graphics
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(${PROJECT_NAME} PRIVATE ${DEBUG_LIBS})
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
target_link_libraries(${PROJECT_NAME} PRIVATE ${RELEASE_LIBS})
endif ()
After building the project and checking all dependencies and libraries through VS project settings ALL is correct. see screenshots.
I load the font in a class, which is in separate files
.h
#ifndef APPLICATION_H
#define APPLICATION_H
#include "macro.h"
#include "WindowManager.h"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/String.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Window/VideoMode.hpp>
#include "SFML/Graphics/Font.hpp"
class Application
{
public:
Application() = delete;
explicit Application(sf::VideoMode videoMode);
~Application();
DISABLE_COPY_ASSIGN(Application);
void run();
private:
void handleEvent();
void update(sf::Time dt);
void render();
sf::Font* font;
sf::RenderWindow window;
};
#endif // APPLICATION_H
.cpp relative only
Application::Application(sf::VideoMode videoMode)
: window(videoMode, APP_TITLE, sf::Style::None, sf::State::Fullscreen)
{
WindowManager::getInstance().setWindow(&window);
*font = sf::Font::loadFromFile("resources/fonts/Cthulhumbus.ttf").value();
}
The paths to the fonts are also specified correctly, because if you specify incorrectly in the console displays an error about it.
It's also worth pointing out that apart from fonts, everything loads fine, textures, etc.
Hope someone can help