I've checked the working directory of my project(VS2015) and my font file is there, but the program still can't load it correctly. Informations in console are unreadable, maybe because of the encoding of my system. But, it seems their are some characters at the path string's head.
I'm sure that other parts of my code are correct, because when I commented font.loadFromFile() function call, the program works well.
here is the code:
#include <SFML/Graphics.hpp>
#include <imgui.h>
#include <imgui-SFML.h>
#include <SFML/System/Clock.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1024, 768), "SFML works!", sf::Style::Default);
window.setVerticalSyncEnabled(true);
// 绑定ImGui
ImGui::SFML::Init(window);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
// 读取字体
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Clock deltaClock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
// ImGui处理事件
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed)
window.close();
}
ImGui::SFML::Update(window, deltaClock.restart());
//ImGui::ShowTestWindow();
ImGui::Begin("test window 1");
ImGui::Button("Look at this pretty button");
ImGui::End();
ImGui::Begin("test2");
ImGui::Button("button");
ImGui::End();
window.clear(sf::Color(70, 120, 150));
window.draw(shape);
//window.draw(text);
ImGui::Render();
window.display();
}
ImGui::SFML::Shutdown();
return 0;
}