summary refs log tree commit diff
path: root/src/main.cpp
blob: 9153530571badc93e473aad2e79a8d82c23da312 (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
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>

#include "Game.hpp"
#include "Render.hpp"
#include "World/World.hpp"

int main() {
    if (!glfwInit()) {
        std::cout << "Failed to initialize GLFW" << std::endl;
        return 1;
    }

    try {
        MC::GFX::Window window(APP_NAME, WINDOW_WIDTH, WINDOW_HEIGHT);
        window.detach();

        auto render_control = std::make_shared<MC::Render::Control>();

        std::thread render_thread{[&window, render_control] {
            MC::Render render{window, render_control};
            render.run();
        }};
        render_thread.detach();

        MC::Game game{window, render_control};
        game.run();
    } catch (std::runtime_error& error) {
        std::cout << "An error occurred: " << error.what() << std::endl;
        glfwTerminate();
        return 1;
    }

    glfwTerminate();
    return 0;
}