summaryrefslogtreecommitdiffstats
path: root/test/window_test.cpp
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2019-01-21 15:26:43 +0100
committerNao Pross <naopross@thearcway.org>2019-01-21 15:27:10 +0100
commit46a28a711fd730828ae5596f68ef3510a20b7b31 (patch)
tree95e1d89c6213fbb140e9b9c767eccdabab2eb369 /test/window_test.cpp
parentAdd window test (diff)
downloadlibwsdl2-46a28a711fd730828ae5596f68ef3510a20b7b31.tar.gz
libwsdl2-46a28a711fd730828ae5596f68ef3510a20b7b31.zip
Make window_test threaded
Diffstat (limited to 'test/window_test.cpp')
-rw-r--r--test/window_test.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/window_test.cpp b/test/window_test.cpp
index 70fcb1a..2136488 100644
--- a/test/window_test.cpp
+++ b/test/window_test.cpp
@@ -2,21 +2,37 @@
#include "video.hpp"
#include <iostream>
+#include <thread>
+#include <mutex>
int main(int argc, char *argv[]) {
wrapsdl2::initialize();
{
- wrapsdl2::window win("Window Test", 800, 600);
+ using namespace wrapsdl2;
+
+ window win("Window Test", 800, 600);
+ std::mutex win_mutex;
std::cout << "press ENTER to show the window" << std::endl;
std::cin.get();
win.show();
- win.update();
+
+ std::thread win_update([&]() {
+ std::lock_guard<std::mutex> lock(win_mutex);
+ while (win.is_open()) {
+ win.update();
+ wrapsdl2::delay(200);
+
+
+ }
+ });
std::cout << "press ENTER to quit" << std::endl;
std::cin.get();
+
+ win_update.join();
}
wrapsdl2::quit();