From 29a99494980d1cd2918f68d741f31340b60db580 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Fri, 26 Apr 2024 20:30:07 -0400 Subject: [PATCH] Testing out the threads with C++11 lambdas. --- sfmldemo/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sfmldemo/main.cpp b/sfmldemo/main.cpp index f1d14ff..0492ee0 100644 --- a/sfmldemo/main.cpp +++ b/sfmldemo/main.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include 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;