Testing out the threads with C++11 lambdas.

master
Zed A. Shaw 5 months ago
parent d2dfb72775
commit 29a9949498
  1. 12
      sfmldemo/main.cpp

@ -4,7 +4,7 @@
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/System.hpp>
#include <SFML/Window/Event.hpp>
void ImGui_setup(sf::RenderWindow &window) {
@ -48,6 +48,16 @@ int main() {
sf::Clock clock;
sf::Time tick = clock.getElapsedTime();
// very cool, c++11 lambdas doing a 1 second slept thread
sf::Thread thread([](){
for(int i = 0; i < 10; i++) {
fmt::print("I'm a thread. {}\n", i);
sf::sleep(sf::seconds(1));
}
});
thread.launch();
while (window.isOpen()) {
sf::Event event;

Loading…
Cancel
Save