3 * Copyright 2012 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #include "gl/GrGLInterface.h"
12 #ifndef GL_GLEXT_PROTOTYPES
13 #define GL_GLEXT_PROTOTYPES
16 #include "GLES2/gl2.h"
17 #include "GLES2/gl2ext.h"
20 #define GET_PROC(name) \
21 interface->fFunctions.f ## name = (GrGL ## name ## Proc) GetProcAddress(ghANGLELib, "gl" #name);
23 const GrGLInterface* GrGLCreateANGLEInterface() {
25 static HMODULE ghANGLELib = NULL;
27 if (NULL == ghANGLELib) {
28 // We load the ANGLE library and never let it go
29 ghANGLELib = LoadLibrary("libGLESv2.dll");
31 if (NULL == ghANGLELib) {
32 // We can't setup the interface correctly w/o the DLL
36 GrGLInterface* interface = SkNEW(GrGLInterface);
37 interface->fStandard = kGLES_GrGLStandard;
39 GrGLInterface::Functions* functions = &interface->fFunctions;
41 GET_PROC(ActiveTexture);
42 GET_PROC(AttachShader);
43 GET_PROC(BindAttribLocation);
45 GET_PROC(BindTexture);
46 functions->fBindVertexArray =
47 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES");
51 GET_PROC(BufferSubData);
54 GET_PROC(ClearStencil);
56 GET_PROC(CompileShader);
57 GET_PROC(CompressedTexImage2D);
58 GET_PROC(CopyTexSubImage2D);
59 GET_PROC(CreateProgram);
60 GET_PROC(CreateShader);
62 GET_PROC(DeleteBuffers);
63 GET_PROC(DeleteProgram);
64 GET_PROC(DeleteShader);
65 GET_PROC(DeleteTextures);
66 functions->fDeleteVertexArrays =
67 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES");
70 GET_PROC(DisableVertexAttribArray);
72 GET_PROC(DrawElements);
74 GET_PROC(EnableVertexAttribArray);
79 GET_PROC(GenerateMipmap);
80 GET_PROC(GenTextures);
81 functions->fGenVertexArrays =
82 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES");
83 GET_PROC(GetBufferParameteriv);
85 GET_PROC(GetIntegerv);
86 GET_PROC(GetProgramInfoLog);
87 GET_PROC(GetProgramiv);
88 GET_PROC(GetShaderInfoLog);
89 GET_PROC(GetShaderiv);
92 GET_PROC(GetUniformLocation);
94 GET_PROC(LinkProgram);
95 GET_PROC(PixelStorei);
98 GET_PROC(ShaderSource);
99 GET_PROC(StencilFunc);
100 GET_PROC(StencilFuncSeparate);
101 GET_PROC(StencilMask);
102 GET_PROC(StencilMaskSeparate);
104 GET_PROC(StencilOpSeparate);
105 GET_PROC(TexImage2D);
106 GET_PROC(TexParameteri);
107 GET_PROC(TexParameteriv);
108 GET_PROC(TexSubImage2D);
109 #if GL_ARB_texture_storage
110 GET_PROC(TexStorage2D);
111 #elif GL_EXT_texture_storage
112 functions->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
116 GET_PROC(Uniform1fv);
117 GET_PROC(Uniform1iv);
121 GET_PROC(Uniform2fv);
122 GET_PROC(Uniform2iv);
126 GET_PROC(Uniform3fv);
127 GET_PROC(Uniform3iv);
131 GET_PROC(Uniform4fv);
132 GET_PROC(Uniform4iv);
134 GET_PROC(UniformMatrix2fv);
135 GET_PROC(UniformMatrix3fv);
136 GET_PROC(UniformMatrix4fv);
137 GET_PROC(UseProgram);
138 GET_PROC(VertexAttrib4fv);
139 GET_PROC(VertexAttribPointer);
141 GET_PROC(BindFramebuffer);
142 GET_PROC(BindRenderbuffer);
143 GET_PROC(CheckFramebufferStatus);
144 GET_PROC(DeleteFramebuffers);
145 GET_PROC(DeleteRenderbuffers);
146 GET_PROC(FramebufferRenderbuffer);
147 GET_PROC(FramebufferTexture2D);
148 GET_PROC(GenFramebuffers);
149 GET_PROC(GenRenderbuffers);
150 GET_PROC(GetFramebufferAttachmentParameteriv);
151 GET_PROC(GetRenderbufferParameteriv);
152 GET_PROC(RenderbufferStorage);
154 functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
155 functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
157 #if GL_ES_VERSION_3_0
158 functions->fMapBufferRange = GET_PROC(glMapBufferRange);
159 functions->fFlushMappedBufferRange = GET_PROC(glFlushMappedBufferRange);
161 functions->fMapBufferRange = (GrGLMapBufferRangeProc) eglGetProcAddress("glMapBufferRange");
162 functions->fFlushMappedBufferRange = (GrGLFlushMappedBufferRangeProc) eglGetProcAddress("glFlushMappedBufferRange");
165 functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glInsertEventMarkerEXT");
166 functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glPushGroupMarkerEXT");
167 functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glPopGroupMarkerEXT");
169 #if GL_ES_VERSION_3_0
170 GET_PROC(InvalidateFramebuffer);
171 GET_PROC(InvalidateSubFramebuffer);
173 functions->fInvalidateFramebuffer = (GrGLInvalidateFramebufferProc) eglGetProcAddress("glInvalidateFramebuffer");
174 functions->fInvalidateSubFramebuffer = (GrGLInvalidateSubFramebufferProc) eglGetProcAddress("glInvalidateSubFramebuffer");
176 functions->fInvalidateBufferData = (GrGLInvalidateBufferDataProc) eglGetProcAddress("glInvalidateBufferData");
177 functions->fInvalidateBufferSubData = (GrGLInvalidateBufferSubDataProc) eglGetProcAddress("glInvalidateBufferSubData");
178 functions->fInvalidateTexImage = (GrGLInvalidateTexImageProc) eglGetProcAddress("glInvalidateTexImage");
179 functions->fInvalidateTexSubImage = (GrGLInvalidateTexSubImageProc) eglGetProcAddress("glInvalidateTexSubImage");
181 interface->fExtensions.init(kGLES_GrGLStandard,
182 functions->fGetString,
183 functions->fGetStringi,
184 functions->fGetIntegerv);