blob: e4f5467842c3c3f3d72e3ddc9975592b5dc86c69 [file] [log] [blame]
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#include "gl/GrGLInterface.h"
bsalomona721c812014-08-26 11:35:23 -070011#include "gl/GrGLAssembleInterface.h"
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000012
bsalomona721c812014-08-26 11:35:23 -070013#define WIN32_LEAN_AND_MEAN
14#include <windows.h>
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000015#include "EGL/egl.h"
16
bsalomona721c812014-08-26 11:35:23 -070017static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
18 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name);
bsalomon49f085d2014-09-05 13:34:00 -070019 if (proc) {
bsalomona721c812014-08-26 11:35:23 -070020 return proc;
21 }
22 return eglGetProcAddress(name);
23}
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000024
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000025const GrGLInterface* GrGLCreateANGLEInterface() {
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000026
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000027 static HMODULE ghANGLELib = NULL;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000028
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000029 if (NULL == ghANGLELib) {
30 // We load the ANGLE library and never let it go
31 ghANGLELib = LoadLibrary("libGLESv2.dll");
32 }
33 if (NULL == ghANGLELib) {
34 // We can't setup the interface correctly w/o the DLL
35 return NULL;
36 }
37
bsalomona721c812014-08-26 11:35:23 -070038 return GrGLAssembleGLESInterface(ghANGLELib, angle_get_gl_proc);
rmistry@google.combda03db2012-08-14 20:27:54 +000039}