summaryrefslogtreecommitdiff
path: root/thirdparty/vulkan/loader/dxgi_loader.c
blob: c2a3fa56385b9c6f54dc144bbea69f72aefea543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "dxgi_loader.h"

#include <strsafe.h>

static HMODULE load_dxgi_module() {
    TCHAR systemPath[MAX_PATH] = "";
    GetSystemDirectory(systemPath, MAX_PATH);
    StringCchCat(systemPath, MAX_PATH, TEXT("\\dxgi.dll"));

    return LoadLibrary(systemPath);
}

typedef HRESULT (APIENTRY *PFN_CreateDXGIFactory1)(REFIID riid, void **ppFactory);

HRESULT dyn_CreateDXGIFactory1(REFIID riid, void **ppFactory) {
    PFN_CreateDXGIFactory1 fpCreateDXGIFactory1 =
        (PFN_CreateDXGIFactory1)GetProcAddress(load_dxgi_module(), "CreateDXGIFactory1");

    if (fpCreateDXGIFactory1 != NULL)
        return fpCreateDXGIFactory1(riid, ppFactory);

    return DXGI_ERROR_NOT_FOUND;
}