Hello,
I'm trying to get tgui working in my project and after trying a lot of things, nothing appears to be drawn,
and im not sure what is the problem. I'm using the latest dev version compiled from source (0.8-dev).
basicly, what i did is, in the header file
And in the cpp file
Init() function
The handleInput() function:
and lastly the Draw() function
But window is just empty.
Thanks!
I'm trying to get tgui working in my project and after trying a lot of things, nothing appears to be drawn,
and im not sure what is the problem. I'm using the latest dev version compiled from source (0.8-dev).
basicly, what i did is, in the header file
Code Select
tgui::Gui gui;
tgui::Button::Ptr m_buttonQuit;
tgui::Theme m_theme;
And in the cpp file
Init() function
Code Select
try
{
gui.setTarget(game->getWindow()); // getWindow returns the sf::RenderWindow
m_theme.load("Themes/Black.txt");
m_buttonQuit = tgui::Button::create();
m_buttonQuit->setRenderer(m_theme.getRenderer("Button"));
m_buttonQuit->setText("Quit");
m_buttonQuit->setPosition((game->getWindow().getSize().x / 2), ((game->getWindow().getSize().y / 2) + 100));
m_buttonQuit->setSize(20, 20);
m_buttonQuit->connect("pressed", [&]() { game->Quit(); });
gui.add(m_buttonQuit);
}
catch (const tgui::Exception& e)
{
std::cerr << "TGUI Exception: " << e.what() << std::endl;
}
The handleInput() function:
Code Select
sf::Event event;
while (game->getWindow().pollEvent(event))
{ a lot of stuff here
gui.handleEvent(event);
}
and lastly the Draw() function
Code Select
game->getWindow().display();
gui.draw();
But window is just empty.
Thanks!