summaryrefslogtreecommitdiff
path: root/src/window.c
blob: 9810a42cf1f92b195aeee45babecbb812b284b60 (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
#include "window.h"
#include "common.h"

window_t window_create(struct window_info *info)
{
    info->flags |= SDL_WINDOW_VULKAN;
    SDL_Vulkan_LoadLibrary(NULL);
    
    window_t window = SDL_CreateWindow(info->title, info->x, info->y,
                                       info->w, info->h, info->flags);
    if(window == NULL) {
        err("SDL_CreateWindow: failed");
    }
    
    return window;
}

void window_destroy(window_t window)
{
    SDL_DestroyWindow((SDL_Window *)window);
    SDL_Vulkan_UnloadLibrary();
}

int window_extension_info(window_t window, unsigned int *ext_count, const char **extensions)
{
    if(SDL_Vulkan_GetInstanceExtensions((SDL_Window *)window, ext_count, extensions) == SDL_FALSE) {
        err("SDL_Vulkan_GetInstanceExtensions: failed");
        return 1;
    }
    
    return 0;
}

int window_create_surface(window_t window, VkInstance instance, VkSurfaceKHR *surface)
{
    if(SDL_Vulkan_CreateSurface((SDL_Window *)window, instance, surface) == SDL_FALSE) {
        err("SDL_Vulkan_CreateSurface: failed");
        return 1;
    }
    
    return 0;
}