summaryrefslogtreecommitdiff
path: root/game/main.cpp
blob: c78c41e2a3f09dc41faff4baee3720d505d0dc67 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <asl/print.hpp>
#include <asl/buffer.hpp>

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_vulkan.h>

#define VK_NO_STDDEF_H
#define VK_NO_STDINT_H
#define VK_NO_PROTOTYPES
#include <vulkan.h>

int SDL_main(int /* argc */, char* /* argv */[])
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* window = SDL_CreateWindow("HK-21 - 460nm", 1280, 720, SDL_WINDOW_VULKAN);

    SDL_ShowWindow(window);

    asl::buffer<const char*> instance_extensions;
    asl::buffer<const char*> device_extensions;
    asl::buffer<const char*> layers;

    {
        uint32_t count = 0;
        const char* const* extensions = SDL_Vulkan_GetInstanceExtensions(&count);
        for (uint32_t i = 0; i < count; ++i)
        {
            instance_extensions.push(extensions[i]); // NOLINT(*-pointer-arithmetic)
        }
    }

    layers.push("VK_LAYER_KHRONOS_validation");
    layers.push("VK_LAYER_LUNARG_monitor");

    instance_extensions.push(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);

    device_extensions.push(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
   
    bool running = true;
    while (running)
    {
        SDL_Event e;
        while (SDL_PollEvent(&e))
        {
            if (e.type == SDL_EVENT_QUIT || (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_ESCAPE))
            {
                running = false;
            }
        }

        SDL_Delay(16);
    }

    SDL_DestroyWindow(window);
    SDL_Quit();
    
    return 0;
}