Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include <TGUI/TGUI.hpp>
- void receiveMessage(tgui::ChatBox::Ptr chatBox, sf::Clock& clock)
- {
- while (true)
- {
- std::size_t number = 0;
- while (clock.getElapsedTime().asMilliseconds() >= 100)
- {
- clock.restart();
- chatBox->addLine(std::to_string(number++));
- }
- }
- }
- int main()
- {
- sf::RenderWindow window({ 400, 400 }, "TGUI Forum Bug Example");
- tgui::Gui gui(window);
- tgui::ChatBox::Ptr chatBox = std::make_shared<tgui::ChatBox>();
- chatBox->setTextSize(18);
- chatBox->setSize(400, 400);
- gui.add(chatBox);
- sf::Clock clock;
- sf::Thread thread(std::bind(&receiveMessage, chatBox, std::ref(clock)));
- thread.launch();
- while (window.isOpen())
- {
- sf::Event event;
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed) window.close();
- gui.handleEvent(event);
- }
- window.clear();
- gui.draw();
- window.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement