OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 glInterface.reset(NULL); | 38 glInterface.reset(NULL); |
39 return NULL; | 39 return NULL; |
40 } | 40 } |
41 interface->fBindingsExported = kDesktop_GrGLBinding; | 41 interface->fBindingsExported = kDesktop_GrGLBinding; |
42 interface->fActiveTexture = glActiveTexture; | 42 interface->fActiveTexture = glActiveTexture; |
43 interface->fAttachShader = glAttachShader; | 43 interface->fAttachShader = glAttachShader; |
44 interface->fBeginQuery = glBeginQuery; | 44 interface->fBeginQuery = glBeginQuery; |
45 interface->fBindAttribLocation = glBindAttribLocation; | 45 interface->fBindAttribLocation = glBindAttribLocation; |
46 interface->fBindBuffer = glBindBuffer; | 46 interface->fBindBuffer = glBindBuffer; |
47 if (ver >= GR_GL_VER(3,0)) { | 47 if (ver >= GR_GL_VER(3,0)) { |
48 #if GL_VERSION_3_0 | 48 #if GL_VERSION_3_0 |
49 interface->fBindFragDataLocation = glBindFragDataLocation; | 49 interface->fBindFragDataLocation = glBindFragDataLocation; |
50 #else | 50 #else |
51 interface->fBindFragDataLocation = GET_PROC(BindFragDataLocation
); | 51 GET_PROC(BindFragDataLocation); |
52 #endif | 52 #endif |
53 } | 53 } |
54 interface->fBindTexture = glBindTexture; | 54 interface->fBindTexture = glBindTexture; |
55 interface->fBlendFunc = glBlendFunc; | 55 interface->fBlendFunc = glBlendFunc; |
56 | 56 |
57 if (ver >= GR_GL_VER(1,4)) { | 57 if (ver >= GR_GL_VER(1,4)) { |
58 interface->fBlendColor = glBlendColor; | 58 interface->fBlendColor = glBlendColor; |
59 } else if (extensions.has("GL_ARB_imaging") || | 59 } else if (extensions.has("GL_ARB_imaging") || |
60 extensions.has("GL_EXT_blend_color")) { | 60 extensions.has("GL_EXT_blend_color")) { |
61 GET_PROC(BlendColor); | 61 GET_PROC(BlendColor); |
62 } | 62 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 interface->fStencilFuncSeparate = glStencilFuncSeparate; | 124 interface->fStencilFuncSeparate = glStencilFuncSeparate; |
125 interface->fStencilMask = glStencilMask; | 125 interface->fStencilMask = glStencilMask; |
126 interface->fStencilMaskSeparate = glStencilMaskSeparate; | 126 interface->fStencilMaskSeparate = glStencilMaskSeparate; |
127 interface->fStencilOp = glStencilOp; | 127 interface->fStencilOp = glStencilOp; |
128 interface->fStencilOpSeparate = glStencilOpSeparate; | 128 interface->fStencilOpSeparate = glStencilOpSeparate; |
129 // mac uses GLenum for internalFormat param (non-standard) | 129 // mac uses GLenum for internalFormat param (non-standard) |
130 // amounts to int vs. uint. | 130 // amounts to int vs. uint. |
131 interface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; | 131 interface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; |
132 interface->fTexParameteri = glTexParameteri; | 132 interface->fTexParameteri = glTexParameteri; |
133 interface->fTexParameteriv = glTexParameteriv; | 133 interface->fTexParameteriv = glTexParameteriv; |
134 #if GL_ARB_texture_storage || GL_VERSION_4_2 | 134 #if GL_ARB_texture_storage || GL_VERSION_4_2 |
135 interface->fTexStorage2D = glTexStorage2D | 135 interface->fTexStorage2D = glTexStorage2D |
136 #elif GL_EXT_texture_storage | 136 #elif GL_EXT_texture_storage |
137 interface->fTexStorage2D = glTexStorage2DEXT; | 137 interface->fTexStorage2D = glTexStorage2DEXT; |
138 #else | 138 #else |
139 if (ver >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { | 139 if (ver >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { |
140 GET_PROC(TexStorage2D); | 140 GET_PROC(TexStorage2D); |
141 } else if (extensions.has("GL_EXT_texture_storage")) { | 141 } else if (extensions.has("GL_EXT_texture_storage")) { |
142 GET_PROC_SUFFIX(TexStorage2D, EXT); | 142 GET_PROC_SUFFIX(TexStorage2D, EXT); |
143 } | 143 } |
144 #endif | 144 #endif |
145 interface->fTexSubImage2D = glTexSubImage2D; | 145 interface->fTexSubImage2D = glTexSubImage2D; |
146 interface->fUniform1f = glUniform1f; | 146 interface->fUniform1f = glUniform1f; |
147 interface->fUniform1i = glUniform1i; | 147 interface->fUniform1i = glUniform1i; |
148 interface->fUniform1fv = glUniform1fv; | 148 interface->fUniform1fv = glUniform1fv; |
149 interface->fUniform1iv = glUniform1iv; | 149 interface->fUniform1iv = glUniform1iv; |
150 interface->fUniform2f = glUniform2f; | 150 interface->fUniform2f = glUniform2f; |
151 interface->fUniform2i = glUniform2i; | 151 interface->fUniform2i = glUniform2i; |
152 interface->fUniform2fv = glUniform2fv; | 152 interface->fUniform2fv = glUniform2fv; |
153 interface->fUniform2iv = glUniform2iv; | 153 interface->fUniform2iv = glUniform2iv; |
154 interface->fUniform3f = glUniform3f; | 154 interface->fUniform3f = glUniform3f; |
155 interface->fUniform3i = glUniform3i; | 155 interface->fUniform3i = glUniform3i; |
156 interface->fUniform3fv = glUniform3fv; | 156 interface->fUniform3fv = glUniform3fv; |
157 interface->fUniform3iv = glUniform3iv; | 157 interface->fUniform3iv = glUniform3iv; |
158 interface->fUniform4f = glUniform4f; | 158 interface->fUniform4f = glUniform4f; |
159 interface->fUniform4i = glUniform4i; | 159 interface->fUniform4i = glUniform4i; |
160 interface->fUniform4fv = glUniform4fv; | 160 interface->fUniform4fv = glUniform4fv; |
161 interface->fUniform4iv = glUniform4iv; | 161 interface->fUniform4iv = glUniform4iv; |
162 interface->fUniform4fv = glUniform4fv; | 162 interface->fUniform4fv = glUniform4fv; |
163 interface->fUniformMatrix2fv = glUniformMatrix2fv; | 163 interface->fUniformMatrix2fv = glUniformMatrix2fv; |
164 interface->fUniformMatrix3fv = glUniformMatrix3fv; | 164 interface->fUniformMatrix3fv = glUniformMatrix3fv; |
165 interface->fUniformMatrix4fv = glUniformMatrix4fv; | 165 interface->fUniformMatrix4fv = glUniformMatrix4fv; |
166 interface->fUnmapBuffer = glUnmapBuffer; | 166 interface->fUnmapBuffer = glUnmapBuffer; |
167 interface->fUseProgram = glUseProgram; | 167 interface->fUseProgram = glUseProgram; |
168 interface->fVertexAttrib4fv = glVertexAttrib4fv; | 168 interface->fVertexAttrib4fv = glVertexAttrib4fv; |
169 interface->fVertexAttribPointer = glVertexAttribPointer; | 169 interface->fVertexAttribPointer = glVertexAttribPointer; |
170 interface->fViewport = glViewport; | 170 interface->fViewport = glViewport; |
171 | 171 |
| 172 if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object"
)) { |
| 173 // no ARB suffix for GL_ARB_vertex_array_object |
| 174 #if GL_ARB_vertex_array_object || GL_VERSION_3_0 |
| 175 interface->fBindVertexArray = glBindVertexArray; |
| 176 interface->fDeleteVertexArrays = glDeleteVertexArrays; |
| 177 interface->fGenVertexArrays = glGenVertexArrays; |
| 178 #else |
| 179 GET_PROC(BindVertexArray); |
| 180 GET_PROC(DeleteVertexArrays); |
| 181 GET_PROC(GenVertexArrays); |
| 182 #endif |
| 183 } |
| 184 |
172 if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { | 185 if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { |
173 // ARB extension doesn't use the ARB suffix on the function name | 186 // ARB extension doesn't use the ARB suffix on the function name |
174 #if GL_ARB_timer_query || GL_VERSION_3_3 | 187 #if GL_ARB_timer_query || GL_VERSION_3_3 |
175 interface->fQueryCounter = glQueryCounter; | 188 interface->fQueryCounter = glQueryCounter; |
176 interface->fGetQueryObjecti64v = glGetQueryObjecti64v; | 189 interface->fGetQueryObjecti64v = glGetQueryObjecti64v; |
177 interface->fGetQueryObjectui64v = glGetQueryObjectui64v; | 190 interface->fGetQueryObjectui64v = glGetQueryObjectui64v; |
178 #else | 191 #else |
179 interface->fQueryCounter = GET_PROC(QueryCounter); | 192 GET_PROC(QueryCounter); |
180 interface->fGetQueryObjecti64v = GET_PROC(GetQueryObjecti64v); | 193 GET_PROC(GetQueryObjecti64v); |
181 interface->fGetQueryObjectui64v = GET_PROC(GetQueryObjectui64v); | 194 GET_PROC(GetQueryObjectui64v); |
182 #endif | 195 #endif |
183 } else if (extensions.has("GL_EXT_timer_query")) { | 196 } else if (extensions.has("GL_EXT_timer_query")) { |
184 #if GL_EXT_timer_query | 197 #if GL_EXT_timer_query |
185 interface->fGetQueryObjecti64v = glGetQueryObjecti64vEXT; | 198 interface->fGetQueryObjecti64v = glGetQueryObjecti64vEXT; |
186 interface->fGetQueryObjectui64v = glGetQueryObjectui64vEXT; | 199 interface->fGetQueryObjectui64v = glGetQueryObjectui64vEXT; |
187 #else | 200 #else |
188 interface->fGetQueryObjecti64v = GET_PROC_SUFFIX(GetQueryObjecti
64v, EXT); | 201 GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
189 interface->fGetQueryObjectui64v = GET_PROC_SUFFIX(GetQueryObject
ui64v, EXT); | 202 GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
190 #endif | 203 #endif |
191 } | 204 } |
192 | 205 |
193 if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")
) { | 206 if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")
) { |
194 // ARB extension doesn't use the ARB suffix on the function names | 207 // ARB extension doesn't use the ARB suffix on the function names |
195 #if GL_VERSION_3_0 || GL_ARB_framebuffer_object | 208 #if GL_VERSION_3_0 || GL_ARB_framebuffer_object |
196 interface->fGenFramebuffers = glGenFramebuffers; | 209 interface->fGenFramebuffers = glGenFramebuffers; |
197 interface->fGetFramebufferAttachmentParameteriv = glGetFramebuff
erAttachmentParameteriv; | 210 interface->fGetFramebufferAttachmentParameteriv = glGetFramebuff
erAttachmentParameteriv; |
198 interface->fGetRenderbufferParameteriv = glGetRenderbufferParame
teriv; | 211 interface->fGetRenderbufferParameteriv = glGetRenderbufferParame
teriv; |
199 interface->fBindFramebuffer = glBindFramebuffer; | 212 interface->fBindFramebuffer = glBindFramebuffer; |
200 interface->fFramebufferTexture2D = glFramebufferTexture2D; | 213 interface->fFramebufferTexture2D = glFramebufferTexture2D; |
201 interface->fCheckFramebufferStatus = glCheckFramebufferStatus; | 214 interface->fCheckFramebufferStatus = glCheckFramebufferStatus; |
202 interface->fDeleteFramebuffers = glDeleteFramebuffers; | 215 interface->fDeleteFramebuffers = glDeleteFramebuffers; |
203 interface->fRenderbufferStorage = glRenderbufferStorage; | 216 interface->fRenderbufferStorage = glRenderbufferStorage; |
204 interface->fGenRenderbuffers = glGenRenderbuffers; | 217 interface->fGenRenderbuffers = glGenRenderbuffers; |
205 interface->fDeleteRenderbuffers = glDeleteRenderbuffers; | 218 interface->fDeleteRenderbuffers = glDeleteRenderbuffers; |
206 interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer; | 219 interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer; |
207 interface->fBindRenderbuffer = glBindRenderbuffer; | 220 interface->fBindRenderbuffer = glBindRenderbuffer; |
208 interface->fRenderbufferStorageMultisample = glRenderbufferStora
geMultisample; | 221 interface->fRenderbufferStorageMultisample = glRenderbufferStora
geMultisample; |
209 interface->fBlitFramebuffer = glBlitFramebuffer; | 222 interface->fBlitFramebuffer = glBlitFramebuffer; |
210 #else | 223 #else |
211 interface->fGenFramebuffers = GET_PROC(GenFramebuffers); | 224 GET_PROC(GenFramebuffers); |
212 interface->fGetFramebufferAttachmentParameteriv = GET_PROC(GetFr
amebufferAttachmentParameteriv); | 225 GET_PROC(GetFramebufferAttachmentParameteriv); |
213 interface->fGetRenderbufferParameteriv = GET_PROC(GetRenderbuffe
rParameteriv); | 226 GET_PROC(GetRenderbufferParameteriv); |
214 interface->fBindFramebuffer = GET_PROC(BindFramebuffer); | 227 GET_PROC(BindFramebuffer); |
215 interface->fFramebufferTexture2D = GET_PROC(FramebufferTexture2D
); | 228 GET_PROC(FramebufferTexture2D); |
216 interface->fCheckFramebufferStatus = GET_PROC(CheckFramebufferSt
atus); | 229 GET_PROC(CheckFramebufferStatus); |
217 interface->fDeleteFramebuffers = GET_PROC(DeleteFramebuffers); | 230 GET_PROC(DeleteFramebuffers); |
218 interface->fRenderbufferStorage = GET_PROC(RenderbufferStorage); | 231 GET_PROC(RenderbufferStorage); |
219 interface->fGenRenderbuffers = GET_PROC(GenRenderbuffers); | 232 GET_PROC(GenRenderbuffers); |
220 interface->fDeleteRenderbuffers = GET_PROC(DeleteRenderbuffers); | 233 GET_PROC(DeleteRenderbuffers); |
221 interface->fFramebufferRenderbuffer = GET_PROC(FramebufferRender
buffer); | 234 GET_PROC(FramebufferRenderbuffer); |
222 interface->fBindRenderbuffer = GET_PROC(BindRenderbuffer); | 235 GET_PROC(BindRenderbuffer); |
223 interface->fRenderbufferStorageMultisample = GET_PROC(Renderbuff
erStorageMultisample); | 236 GET_PROC(RenderbufferStorageMultisample); |
224 interface->fBlitFramebuffer = GET_PROC(BlitFramebuffer); | 237 GET_PROC(BlitFramebuffer); |
225 #endif | 238 #endif |
226 } else { | 239 } else { |
227 if (extensions.has("GL_EXT_framebuffer_object")) { | 240 if (extensions.has("GL_EXT_framebuffer_object")) { |
228 #if GL_EXT_framebuffer_object | 241 #if GL_EXT_framebuffer_object |
229 interface->fGenFramebuffers = glGenFramebuffersEXT; | 242 interface->fGenFramebuffers = glGenFramebuffersEXT; |
230 interface->fGetFramebufferAttachmentParameteriv = glGetFrame
bufferAttachmentParameterivEXT; | 243 interface->fGetFramebufferAttachmentParameteriv = glGetFramebuff
erAttachmentParameterivEXT; |
231 interface->fGetRenderbufferParameteriv = glGetRenderbufferPa
rameterivEXT; | 244 interface->fGetRenderbufferParameteriv = glGetRenderbufferParame
terivEXT; |
232 interface->fBindFramebuffer = glBindFramebufferEXT; | 245 interface->fBindFramebuffer = glBindFramebufferEXT; |
233 interface->fFramebufferTexture2D = glFramebufferTexture2DEXT
; | 246 interface->fFramebufferTexture2D = glFramebufferTexture2DEXT; |
234 interface->fCheckFramebufferStatus = glCheckFramebufferStatu
sEXT; | 247 interface->fCheckFramebufferStatus = glCheckFramebufferStatusEXT
; |
235 interface->fDeleteFramebuffers = glDeleteFramebuffersEXT; | 248 interface->fDeleteFramebuffers = glDeleteFramebuffersEXT; |
236 interface->fRenderbufferStorage = glRenderbufferStorageEXT; | 249 interface->fRenderbufferStorage = glRenderbufferStorageEXT; |
237 interface->fGenRenderbuffers = glGenRenderbuffersEXT; | 250 interface->fGenRenderbuffers = glGenRenderbuffersEXT; |
238 interface->fDeleteRenderbuffers = glDeleteRenderbuffersEXT; | 251 interface->fDeleteRenderbuffers = glDeleteRenderbuffersEXT; |
239 interface->fFramebufferRenderbuffer = glFramebufferRenderbuf
ferEXT; | 252 interface->fFramebufferRenderbuffer = glFramebufferRenderbufferE
XT; |
240 interface->fBindRenderbuffer = glBindRenderbufferEXT; | 253 interface->fBindRenderbuffer = glBindRenderbufferEXT; |
241 #else | 254 #else |
242 interface->fGenFramebuffers = GET_PROC_SUFFIX(GenFramebuffer
s, EXT); | 255 GET_PROC_SUFFIX(GenFramebuffers, EXT); |
243 interface->fGetFramebufferAttachmentParameteriv = GET_PROC_S
UFFIX(GetFramebufferAttachmentParameteriv, EXT); | 256 GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); |
244 interface->fGetRenderbufferParameteriv = GET_PROC_SUFFIX(Get
RenderbufferParameteriv, EXT); | 257 GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); |
245 interface->fBindFramebuffer = GET_PROC_SUFFIX(BindFramebuffe
r, EXT); | 258 GET_PROC_SUFFIX(BindFramebuffer, EXT); |
246 interface->fFramebufferTexture2D = GET_PROC_SUFFIX(Framebuff
erTexture2D, EXT); | 259 GET_PROC_SUFFIX(FramebufferTexture2D, EXT); |
247 interface->fCheckFramebufferStatus = GET_PROC_SUFFIX(CheckFr
amebufferStatus, EXT); | 260 GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); |
248 interface->fDeleteFramebuffers = GET_PROC_SUFFIX(DeleteFrame
buffers, EXT); | 261 GET_PROC_SUFFIX(DeleteFramebuffers, EXT); |
249 interface->fRenderbufferStorage = GET_PROC_SUFFIX(Renderbuff
erStorage, EXT); | 262 GET_PROC_SUFFIX(RenderbufferStorage, EXT); |
250 interface->fGenRenderbuffers = GET_PROC_SUFFIX(GenRenderbuff
ers, EXT); | 263 GET_PROC_SUFFIX(GenRenderbuffers, EXT); |
251 interface->fDeleteRenderbuffers = GET_PROC_SUFFIX(DeleteRend
erbuffers, EXT); | 264 GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); |
252 interface->fFramebufferRenderbuffer = GET_PROC_SUFFIX(Frameb
ufferRenderbuffer, EXT); | 265 GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); |
253 interface->fBindRenderbuffer = GET_PROC_SUFFIX(BindRenderbuf
fer, EXT); | 266 GET_PROC_SUFFIX(BindRenderbuffer, EXT); |
254 #endif | 267 #endif |
255 } | 268 } |
256 if (extensions.has("GL_EXT_framebuffer_multisample")) { | 269 if (extensions.has("GL_EXT_framebuffer_multisample")) { |
257 #if GL_EXT_framebuffer_multisample | 270 #if GL_EXT_framebuffer_multisample |
258 interface->fRenderbufferStorageMultisample = glRenderbufferS
torageMultisampleEXT; | 271 interface->fRenderbufferStorageMultisample = glRenderbufferStora
geMultisampleEXT; |
259 #else | 272 #else |
260 interface->fRenderbufferStorageMultisample = GET_PROC_SUFFIX
(RenderbufferStorageMultisample, EXT); | 273 GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); |
261 #endif | 274 #endif |
262 } | 275 } |
263 if (extensions.has("GL_EXT_framebuffer_blit")) { | 276 if (extensions.has("GL_EXT_framebuffer_blit")) { |
264 #if GL_EXT_framebuffer_blit | 277 #if GL_EXT_framebuffer_blit |
265 interface->fBlitFramebuffer = glBlitFramebufferEXT; | 278 interface->fBlitFramebuffer = glBlitFramebufferEXT; |
266 #else | 279 #else |
267 interface->fBlitFramebuffer = GET_PROC_SUFFIX(BlitFramebuffe
r, EXT); | 280 GET_PROC_SUFFIX(BlitFramebuffer, EXT); |
268 #endif | 281 #endif |
269 } | 282 } |
270 } | 283 } |
271 if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended"
)) { | 284 if (ver >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended"
)) { |
272 // ARB extension doesn't use the ARB suffix on the function name | 285 // ARB extension doesn't use the ARB suffix on the function name |
273 #if GL_VERSION_3_3 || GL_ARB_blend_func_extended | 286 #if GL_VERSION_3_3 || GL_ARB_blend_func_extended |
274 interface->fBindFragDataLocationIndexed = glBindFragDataLocation
Indexed; | 287 interface->fBindFragDataLocationIndexed = glBindFragDataLocationInde
xed; |
275 #else | 288 #else |
276 interface->fBindFragDataLocationIndexed = GET_PROC(BindFragDataL
ocationIndexed); | 289 GET_PROC(BindFragDataLocationIndexed); |
277 #endif | 290 #endif |
278 } | 291 } |
279 } | 292 } |
280 glInterface.get()->ref(); | 293 glInterface.get()->ref(); |
281 return glInterface.get(); | 294 return glInterface.get(); |
282 } | 295 } |
OLD | NEW |