Testing out the threads with C++11 lambdas.
This commit is contained in:
parent
d2dfb72775
commit
29a9949498
1 changed files with 11 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <SFML/Graphics/CircleShape.hpp>
|
#include <SFML/Graphics/CircleShape.hpp>
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include <SFML/System/Clock.hpp>
|
#include <SFML/System.hpp>
|
||||||
#include <SFML/Window/Event.hpp>
|
#include <SFML/Window/Event.hpp>
|
||||||
|
|
||||||
void ImGui_setup(sf::RenderWindow &window) {
|
void ImGui_setup(sf::RenderWindow &window) {
|
||||||
|
@ -48,6 +48,16 @@ int main() {
|
||||||
sf::Clock clock;
|
sf::Clock clock;
|
||||||
sf::Time tick = clock.getElapsedTime();
|
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()) {
|
while (window.isOpen()) {
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue