aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
blob: 4f26c06afe865786b8a48d312e092004f61716a4 (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

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "EGL/egl.h"

static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
    GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name);
    if (proc) {
        return proc;
    }
    return eglGetProcAddress(name);
}

const GrGLInterface* GrGLCreateANGLEInterface() {

    static HMODULE ghANGLELib = nullptr;

    if (nullptr == ghANGLELib) {
        // We load the ANGLE library and never let it go
        ghANGLELib = LoadLibrary("libGLESv2.dll");
    }
    if (nullptr == ghANGLELib) {
        // We can't setup the interface correctly w/o the DLL
        return nullptr;
    }

    return GrGLAssembleGLESInterface(ghANGLELib, angle_get_gl_proc);
}