Hi.
I am trying to integrate SFML and ImGui according to this
https://eliasdaler.github.io/using-imgui-with-sfml-pt1/(basic tutorial form "Elias Daler's Blog").
//
SFML working fine (I'm using DLL, not static) //
I have followed all the steps but I am getting linker errors.
https://imgur.com/G3nB8WiMy code is the same as on the website.
#include "imgui.h"
#include "imgui-SFML.h"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "");
window.setVerticalSyncEnabled(true);
ImGui::SFML::Init(window);
sf::Color bgColor;
float color[3] = { 0.f, 0.f, 0.f };
// let's use char array as buffer, see next part
// for instructions on using std::string with ImGui
char windowTitle[255] = "ImGui + SFML = <3";
window.setTitle(windowTitle);
window.resetGLStates(); // call it if you only draw ImGui. Otherwise not needed.
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::Begin("Sample window"); // begin window
// Background color edit
if (ImGui::ColorEdit3("Background color", color)) {
// this code gets called if color value changes, so
// the background color is upgraded automatically!
bgColor.r = static_cast<sf::Uint8>(color[0] * 255.f);
bgColor.g = static_cast<sf::Uint8>(color[1] * 255.f);
bgColor.b = static_cast<sf::Uint8>(color[2] * 255.f);
}
// Window title text edit
ImGui::InputText("Window title", windowTitle, 255);
if (ImGui::Button("Update window title")) {
// this code gets if user clicks on the button
// yes, you could have written if(ImGui::InputText(...))
// but I do this to show how buttons work :)
window.setTitle(windowTitle);
}
ImGui::End(); // end window
window.clear(bgColor); // fill background with color
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
}
This is a common problem. I read some forum topics and the solution is to link opengl32.lib to the project, and I did it , but I still get errors.
I have the assumption that I am wrong linking opengl32.lib. I found opengl32 lib in one of my Windows Kits which I use in my project.
(C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86\OpenGL32.Lib)
As the name suggests, I plugged OpenGL32.Lib to additional dependencies.
(my additional dependencies
https://imgur.com/5Zq33Q6)
Unfortunately for me it didn't work. Anyone have an idea what I should do?