OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "gl/GrGLInterface.h" | 10 #include "gl/GrGLInterface.h" |
11 | 11 |
12 #ifndef GL_GLEXT_PROTOTYPES | 12 #ifndef GL_GLEXT_PROTOTYPES |
13 #define GL_GLEXT_PROTOTYPES | 13 #define GL_GLEXT_PROTOTYPES |
14 #endif | 14 #endif |
15 | 15 |
16 #include "GLES2/gl2.h" | 16 #include "GLES2/gl2.h" |
17 #include "GLES2/gl2ext.h" | 17 #include "GLES2/gl2ext.h" |
18 #include "EGL/egl.h" | 18 #include "EGL/egl.h" |
19 | 19 |
20 #define GET_PROC(name) \ | 20 #define GET_PROC(name) \ |
21 interface->f ## name = (GrGL ## name ## Proc) GetProcAddress(ghANGLELib, "gl
" #name); | 21 interface->fFunctions.f ## name = (GrGL ## name ## Proc) GetProcAddress(ghAN
GLELib, "gl" #name); |
22 | 22 |
23 const GrGLInterface* GrGLCreateANGLEInterface() { | 23 const GrGLInterface* GrGLCreateANGLEInterface() { |
24 | 24 |
25 static HMODULE ghANGLELib = NULL; | 25 static HMODULE ghANGLELib = NULL; |
26 | 26 |
27 if (NULL == ghANGLELib) { | 27 if (NULL == ghANGLELib) { |
28 // We load the ANGLE library and never let it go | 28 // We load the ANGLE library and never let it go |
29 ghANGLELib = LoadLibrary("libGLESv2.dll"); | 29 ghANGLELib = LoadLibrary("libGLESv2.dll"); |
30 } | 30 } |
31 if (NULL == ghANGLELib) { | 31 if (NULL == ghANGLELib) { |
32 // We can't setup the interface correctly w/o the DLL | 32 // We can't setup the interface correctly w/o the DLL |
33 return NULL; | 33 return NULL; |
34 } | 34 } |
35 | 35 |
36 GrGLInterface* interface = SkNEW(GrGLInterface); | 36 GrGLInterface* interface = SkNEW(GrGLInterface); |
37 interface->fStandard = kGLES_GrGLStandard; | 37 interface->fStandard = kGLES_GrGLStandard; |
38 | 38 |
| 39 GrGLInterface::Functions* functions = &interface->fFunctions; |
| 40 |
39 GET_PROC(ActiveTexture); | 41 GET_PROC(ActiveTexture); |
40 GET_PROC(AttachShader); | 42 GET_PROC(AttachShader); |
41 GET_PROC(BindAttribLocation); | 43 GET_PROC(BindAttribLocation); |
42 GET_PROC(BindBuffer); | 44 GET_PROC(BindBuffer); |
43 GET_PROC(BindTexture); | 45 GET_PROC(BindTexture); |
44 interface->fBindVertexArray = | 46 functions->fBindVertexArray = |
45 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES"); | 47 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES"); |
46 GET_PROC(BlendColor); | 48 GET_PROC(BlendColor); |
47 GET_PROC(BlendFunc); | 49 GET_PROC(BlendFunc); |
48 GET_PROC(BufferData); | 50 GET_PROC(BufferData); |
49 GET_PROC(BufferSubData); | 51 GET_PROC(BufferSubData); |
50 GET_PROC(Clear); | 52 GET_PROC(Clear); |
51 GET_PROC(ClearColor); | 53 GET_PROC(ClearColor); |
52 GET_PROC(ClearStencil); | 54 GET_PROC(ClearStencil); |
53 GET_PROC(ColorMask); | 55 GET_PROC(ColorMask); |
54 GET_PROC(CompileShader); | 56 GET_PROC(CompileShader); |
55 GET_PROC(CompressedTexImage2D); | 57 GET_PROC(CompressedTexImage2D); |
56 GET_PROC(CopyTexSubImage2D); | 58 GET_PROC(CopyTexSubImage2D); |
57 GET_PROC(CreateProgram); | 59 GET_PROC(CreateProgram); |
58 GET_PROC(CreateShader); | 60 GET_PROC(CreateShader); |
59 GET_PROC(CullFace); | 61 GET_PROC(CullFace); |
60 GET_PROC(DeleteBuffers); | 62 GET_PROC(DeleteBuffers); |
61 GET_PROC(DeleteProgram); | 63 GET_PROC(DeleteProgram); |
62 GET_PROC(DeleteShader); | 64 GET_PROC(DeleteShader); |
63 GET_PROC(DeleteTextures); | 65 GET_PROC(DeleteTextures); |
64 interface->fDeleteVertexArrays = | 66 functions->fDeleteVertexArrays = |
65 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES"
); | 67 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES"
); |
66 GET_PROC(DepthMask); | 68 GET_PROC(DepthMask); |
67 GET_PROC(Disable); | 69 GET_PROC(Disable); |
68 GET_PROC(DisableVertexAttribArray); | 70 GET_PROC(DisableVertexAttribArray); |
69 GET_PROC(DrawArrays); | 71 GET_PROC(DrawArrays); |
70 GET_PROC(DrawElements); | 72 GET_PROC(DrawElements); |
71 GET_PROC(Enable); | 73 GET_PROC(Enable); |
72 GET_PROC(EnableVertexAttribArray); | 74 GET_PROC(EnableVertexAttribArray); |
73 GET_PROC(Finish); | 75 GET_PROC(Finish); |
74 GET_PROC(Flush); | 76 GET_PROC(Flush); |
75 GET_PROC(FrontFace); | 77 GET_PROC(FrontFace); |
76 GET_PROC(GenBuffers); | 78 GET_PROC(GenBuffers); |
77 GET_PROC(GenerateMipmap); | 79 GET_PROC(GenerateMipmap); |
78 GET_PROC(GenTextures); | 80 GET_PROC(GenTextures); |
79 interface->fGenVertexArrays = | 81 functions->fGenVertexArrays = |
80 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); | 82 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); |
81 GET_PROC(GetBufferParameteriv); | 83 GET_PROC(GetBufferParameteriv); |
82 GET_PROC(GetError); | 84 GET_PROC(GetError); |
83 GET_PROC(GetIntegerv); | 85 GET_PROC(GetIntegerv); |
84 GET_PROC(GetProgramInfoLog); | 86 GET_PROC(GetProgramInfoLog); |
85 GET_PROC(GetProgramiv); | 87 GET_PROC(GetProgramiv); |
86 GET_PROC(GetShaderInfoLog); | 88 GET_PROC(GetShaderInfoLog); |
87 GET_PROC(GetShaderiv); | 89 GET_PROC(GetShaderiv); |
88 GET_PROC(GetString); | 90 GET_PROC(GetString); |
89 GET_PROC(GetUniformLocation); | 91 GET_PROC(GetUniformLocation); |
90 GET_PROC(LineWidth); | 92 GET_PROC(LineWidth); |
91 GET_PROC(LinkProgram); | 93 GET_PROC(LinkProgram); |
92 GET_PROC(PixelStorei); | 94 GET_PROC(PixelStorei); |
93 GET_PROC(ReadPixels); | 95 GET_PROC(ReadPixels); |
94 GET_PROC(Scissor); | 96 GET_PROC(Scissor); |
95 GET_PROC(ShaderSource); | 97 GET_PROC(ShaderSource); |
96 GET_PROC(StencilFunc); | 98 GET_PROC(StencilFunc); |
97 GET_PROC(StencilFuncSeparate); | 99 GET_PROC(StencilFuncSeparate); |
98 GET_PROC(StencilMask); | 100 GET_PROC(StencilMask); |
99 GET_PROC(StencilMaskSeparate); | 101 GET_PROC(StencilMaskSeparate); |
100 GET_PROC(StencilOp); | 102 GET_PROC(StencilOp); |
101 GET_PROC(StencilOpSeparate); | 103 GET_PROC(StencilOpSeparate); |
102 GET_PROC(TexImage2D); | 104 GET_PROC(TexImage2D); |
103 GET_PROC(TexParameteri); | 105 GET_PROC(TexParameteri); |
104 GET_PROC(TexParameteriv); | 106 GET_PROC(TexParameteriv); |
105 GET_PROC(TexSubImage2D); | 107 GET_PROC(TexSubImage2D); |
106 #if GL_ARB_texture_storage | 108 #if GL_ARB_texture_storage |
107 GET_PROC(TexStorage2D); | 109 GET_PROC(TexStorage2D); |
108 #elif GL_EXT_texture_storage | 110 #elif GL_EXT_texture_storage |
109 interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexSt
orage2DEXT"); | 111 functions->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexSt
orage2DEXT"); |
110 #endif | 112 #endif |
111 GET_PROC(Uniform1f); | 113 GET_PROC(Uniform1f); |
112 GET_PROC(Uniform1i); | 114 GET_PROC(Uniform1i); |
113 GET_PROC(Uniform1fv); | 115 GET_PROC(Uniform1fv); |
114 GET_PROC(Uniform1iv); | 116 GET_PROC(Uniform1iv); |
115 | 117 |
116 GET_PROC(Uniform2f); | 118 GET_PROC(Uniform2f); |
117 GET_PROC(Uniform2i); | 119 GET_PROC(Uniform2i); |
118 GET_PROC(Uniform2fv); | 120 GET_PROC(Uniform2fv); |
119 GET_PROC(Uniform2iv); | 121 GET_PROC(Uniform2iv); |
(...skipping 21 matching lines...) Expand all Loading... |
141 GET_PROC(DeleteFramebuffers); | 143 GET_PROC(DeleteFramebuffers); |
142 GET_PROC(DeleteRenderbuffers); | 144 GET_PROC(DeleteRenderbuffers); |
143 GET_PROC(FramebufferRenderbuffer); | 145 GET_PROC(FramebufferRenderbuffer); |
144 GET_PROC(FramebufferTexture2D); | 146 GET_PROC(FramebufferTexture2D); |
145 GET_PROC(GenFramebuffers); | 147 GET_PROC(GenFramebuffers); |
146 GET_PROC(GenRenderbuffers); | 148 GET_PROC(GenRenderbuffers); |
147 GET_PROC(GetFramebufferAttachmentParameteriv); | 149 GET_PROC(GetFramebufferAttachmentParameteriv); |
148 GET_PROC(GetRenderbufferParameteriv); | 150 GET_PROC(GetRenderbufferParameteriv); |
149 GET_PROC(RenderbufferStorage); | 151 GET_PROC(RenderbufferStorage); |
150 | 152 |
151 interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); | 153 functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE
S"); |
152 interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); | 154 functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu
fferOES"); |
153 return interface; | 155 return interface; |
154 } | 156 } |
OLD | NEW |