was trying to add some new buttons and stuff to the project, but ended up with the following problems
16:04:54:436 1>D:\SFML-3.0.0\include\SFML\Window\Event.inl(45,19): error C2338: static_assert failed: 'TEventSubtype must be a subtype of sf::Event'
16:04:54:436 1>(compiling source file 'main.cpp')
16:04:54:436 1> D:\SFML-3.0.0\include\SFML\Window\Event.inl(45,19):
16:04:54:436 1> the template instantiation context (the oldest one first) is
16:04:54:436 1> C:\Users\Username\source\repos\TGUI learning\main.cpp(32,20):
16:04:54:436 1> see reference to function template instantiation 'sf::Event::Event<std::optional<sf::Event>>(const TEventSubtype &)' being compiled
16:04:54:436 1> with
16:04:54:436 1> [
16:04:54:436 1> TEventSubtype=std::optional<sf::Event>
16:04:54:436 1> ]
16:04:54:643 1>Done building project "TGUI learning.vcxproj" -- FAILED.
for some reason, the following code ends up with errors above
#include <TGUI/TGUI.hpp>
#include <TGUI/Core.hpp>
#include <TGUI/Backend/SFML-Graphics.hpp>
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode({ 800, 600 }), "TGUI learning");
tgui::Gui gui(window);
while (window.isOpen()) {
while (const auto event = window.pollEvent()) {
if (event->is<sf::Event::Closed>()) {
window.close();
}
gui.handleEvent(event);
}
window.clear();
gui.draw();
window.display();
}
return 0;
}
but the example on the TGUI learning page
#include <TGUI/TGUI.hpp>
#include <TGUI/Backend/SFML-Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode({ 800, 600 }), "TGUI learning");
tgui::Gui gui{ window };
gui.mainLoop(); // See below for how to use your own main loop
}
actually works
i have triple checked connection errors with sfml, TGUI, but it is not it, also if you comment the parts of the sfml/TGUI code that ends up with errors, it will compile and work just fine
//#include <TGUI/TGUI.hpp>
//#include <TGUI/Core.hpp>
//#include <TGUI/Backend/SFML-Graphics.hpp>
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode({ 800, 600 }), "TGUI learning");
//tgui::Gui gui(window);
while (window.isOpen()) {
while (const auto event = window.pollEvent()) {
if (event->is<sf::Event::Closed>()) {
window.close();
}
//gui.handleEvent(event);
}
window.clear();
//gui.draw();
window.display();
}
return 0;
}
so this code will actually work
the thing is that you need to handle events with tgui via giving not a pointer, but an actual value, so you need to firstly dereference it
gui.handleEvent(*event);