summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/makefile2
-rw-r--r--test/window_test.cpp20
2 files changed, 19 insertions, 3 deletions
diff --git a/test/makefile b/test/makefile
index 11df431..ee8569a 100644
--- a/test/makefile
+++ b/test/makefile
@@ -1,7 +1,7 @@
# Compiler
CPP := c++
CFLAGS := -Wall -pedantic -std=c++17 -fPIC -I ../include -DDEBUG
-LFLAGS := ../build/libwrapsdl2.so -lSDL2
+LFLAGS := ../build/libwrapsdl2.so -lSDL2 -lpthread
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,build/%.o,$(SRCS))
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();