summaryrefslogtreecommitdiffstats
path: root/test/window_test.cpp
blob: 2136488a7a21587ff7a2dd730663d432095eab02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "wrapsdl2.hpp"
#include "video.hpp"

#include <iostream>
#include <thread>
#include <mutex>

int main(int argc, char *argv[]) {
    wrapsdl2::initialize();

    {
        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();

        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();
    return 0;
}