|
1 |
|
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" |
|
11 |
|
12 #ifndef GL_GLEXT_PROTOTYPES |
|
13 #define GL_GLEXT_PROTOTYPES |
|
14 #endif |
|
15 |
|
16 #include "GLES2/gl2.h" |
|
17 #include "GLES2/gl2ext.h" |
|
18 #include "EGL/egl.h" |
|
19 |
|
20 #define GET_PROC(name) \ |
|
21 interface->fFunctions.f ## name = (GrGL ## name ## Proc) GetProcAddress(ghANGLELib, "gl" #name); |
|
22 |
|
23 const GrGLInterface* GrGLCreateANGLEInterface() { |
|
24 |
|
25 static HMODULE ghANGLELib = NULL; |
|
26 |
|
27 if (NULL == ghANGLELib) { |
|
28 // We load the ANGLE library and never let it go |
|
29 ghANGLELib = LoadLibrary("libGLESv2.dll"); |
|
30 } |
|
31 if (NULL == ghANGLELib) { |
|
32 // We can't setup the interface correctly w/o the DLL |
|
33 return NULL; |
|
34 } |
|
35 |
|
36 GrGLInterface* interface = SkNEW(GrGLInterface); |
|
37 interface->fStandard = kGLES_GrGLStandard; |
|
38 |
|
39 GrGLInterface::Functions* functions = &interface->fFunctions; |
|
40 |
|
41 GET_PROC(ActiveTexture); |
|
42 GET_PROC(AttachShader); |
|
43 GET_PROC(BindAttribLocation); |
|
44 GET_PROC(BindBuffer); |
|
45 GET_PROC(BindTexture); |
|
46 functions->fBindVertexArray = |
|
47 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES"); |
|
48 GET_PROC(BlendColor); |
|
49 GET_PROC(BlendFunc); |
|
50 GET_PROC(BufferData); |
|
51 GET_PROC(BufferSubData); |
|
52 GET_PROC(Clear); |
|
53 GET_PROC(ClearColor); |
|
54 GET_PROC(ClearStencil); |
|
55 GET_PROC(ColorMask); |
|
56 GET_PROC(CompileShader); |
|
57 GET_PROC(CompressedTexImage2D); |
|
58 GET_PROC(CopyTexSubImage2D); |
|
59 GET_PROC(CreateProgram); |
|
60 GET_PROC(CreateShader); |
|
61 GET_PROC(CullFace); |
|
62 GET_PROC(DeleteBuffers); |
|
63 GET_PROC(DeleteProgram); |
|
64 GET_PROC(DeleteShader); |
|
65 GET_PROC(DeleteTextures); |
|
66 functions->fDeleteVertexArrays = |
|
67 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES"); |
|
68 GET_PROC(DepthMask); |
|
69 GET_PROC(Disable); |
|
70 GET_PROC(DisableVertexAttribArray); |
|
71 GET_PROC(DrawArrays); |
|
72 GET_PROC(DrawElements); |
|
73 GET_PROC(Enable); |
|
74 GET_PROC(EnableVertexAttribArray); |
|
75 GET_PROC(Finish); |
|
76 GET_PROC(Flush); |
|
77 GET_PROC(FrontFace); |
|
78 GET_PROC(GenBuffers); |
|
79 GET_PROC(GenerateMipmap); |
|
80 GET_PROC(GenTextures); |
|
81 functions->fGenVertexArrays = |
|
82 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); |
|
83 GET_PROC(GetBufferParameteriv); |
|
84 GET_PROC(GetError); |
|
85 GET_PROC(GetIntegerv); |
|
86 GET_PROC(GetProgramInfoLog); |
|
87 GET_PROC(GetProgramiv); |
|
88 GET_PROC(GetShaderInfoLog); |
|
89 GET_PROC(GetShaderiv); |
|
90 GET_PROC(GetString); |
|
91 GET_PROC(GetUniformLocation); |
|
92 GET_PROC(LineWidth); |
|
93 GET_PROC(LinkProgram); |
|
94 GET_PROC(PixelStorei); |
|
95 GET_PROC(ReadPixels); |
|
96 GET_PROC(Scissor); |
|
97 GET_PROC(ShaderSource); |
|
98 GET_PROC(StencilFunc); |
|
99 GET_PROC(StencilFuncSeparate); |
|
100 GET_PROC(StencilMask); |
|
101 GET_PROC(StencilMaskSeparate); |
|
102 GET_PROC(StencilOp); |
|
103 GET_PROC(StencilOpSeparate); |
|
104 GET_PROC(TexImage2D); |
|
105 GET_PROC(TexParameteri); |
|
106 GET_PROC(TexParameteriv); |
|
107 GET_PROC(TexSubImage2D); |
|
108 #if GL_ARB_texture_storage |
|
109 GET_PROC(TexStorage2D); |
|
110 #elif GL_EXT_texture_storage |
|
111 functions->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT"); |
|
112 #endif |
|
113 GET_PROC(Uniform1f); |
|
114 GET_PROC(Uniform1i); |
|
115 GET_PROC(Uniform1fv); |
|
116 GET_PROC(Uniform1iv); |
|
117 |
|
118 GET_PROC(Uniform2f); |
|
119 GET_PROC(Uniform2i); |
|
120 GET_PROC(Uniform2fv); |
|
121 GET_PROC(Uniform2iv); |
|
122 |
|
123 GET_PROC(Uniform3f); |
|
124 GET_PROC(Uniform3i); |
|
125 GET_PROC(Uniform3fv); |
|
126 GET_PROC(Uniform3iv); |
|
127 |
|
128 GET_PROC(Uniform4f); |
|
129 GET_PROC(Uniform4i); |
|
130 GET_PROC(Uniform4fv); |
|
131 GET_PROC(Uniform4iv); |
|
132 |
|
133 GET_PROC(UniformMatrix2fv); |
|
134 GET_PROC(UniformMatrix3fv); |
|
135 GET_PROC(UniformMatrix4fv); |
|
136 GET_PROC(UseProgram); |
|
137 GET_PROC(VertexAttrib4fv); |
|
138 GET_PROC(VertexAttribPointer); |
|
139 GET_PROC(Viewport); |
|
140 GET_PROC(BindFramebuffer); |
|
141 GET_PROC(BindRenderbuffer); |
|
142 GET_PROC(CheckFramebufferStatus); |
|
143 GET_PROC(DeleteFramebuffers); |
|
144 GET_PROC(DeleteRenderbuffers); |
|
145 GET_PROC(FramebufferRenderbuffer); |
|
146 GET_PROC(FramebufferTexture2D); |
|
147 GET_PROC(GenFramebuffers); |
|
148 GET_PROC(GenRenderbuffers); |
|
149 GET_PROC(GetFramebufferAttachmentParameteriv); |
|
150 GET_PROC(GetRenderbufferParameteriv); |
|
151 GET_PROC(RenderbufferStorage); |
|
152 |
|
153 functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES"); |
|
154 functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES"); |
|
155 |
|
156 #if GL_EXT_debug_marker |
|
157 functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glInsertEventMarkerEXT"); |
|
158 functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glPushGroupMarkerEXT"); |
|
159 functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glPopGropuMarkerEXT"); |
|
160 #endif |
|
161 |
|
162 interface->fExtensions.init(kGLES_GrGLStandard, |
|
163 interface->fFunctions.fGetString, |
|
164 interface->fFunctions.fGetStringi, |
|
165 interface->fFunctions.fGetIntegerv); |
|
166 return interface; |
|
167 } |