| 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 #include "gl/GrGLExtensions.h" | 9 #include "gl/GrGLExtensions.h" |
| 10 #include "gl/GrGLInterface.h" | 10 #include "gl/GrGLInterface.h" |
| 11 #include "../GrGLUtil.h" | 11 #include "../GrGLUtil.h" |
| 12 | 12 |
| 13 #define GL_GLEXT_PROTOTYPES | 13 #define GL_GLEXT_PROTOTYPES |
| 14 #include "osmesa_wrapper.h" | 14 #include "osmesa_wrapper.h" |
| 15 | 15 |
| 16 #define GR_GL_GET_PROC(F) interface->f ## F = (GrGL ## F ## Proc) \ | 16 #define GR_GL_GET_PROC(F) interface->f ## F = (GrGL ## F ## Proc) \ |
| 17 OSMesaGetProcAddress("gl" #F); | 17 OSMesaGetProcAddress("gl" #F); |
| 18 #define GR_GL_GET_PROC_SUFFIX(F, S) interface->f ## F = (GrGL ## F ## Proc) \ | 18 #define GR_GL_GET_PROC_SUFFIX(F, S) interface->f ## F = (GrGL ## F ## Proc) \ |
| 19 OSMesaGetProcAddress("gl" #F #S); | 19 OSMesaGetProcAddress("gl" #F #S); |
| 20 | 20 |
| 21 // We use OSMesaGetProcAddress for every gl function to avoid accidentally using | 21 // We use OSMesaGetProcAddress for every gl function to avoid accidentally using |
| 22 // non-Mesa gl functions. | 22 // non-Mesa gl functions. |
| 23 | 23 |
| 24 const GrGLInterface* GrGLCreateMesaInterface() { | 24 const GrGLInterface* GrGLCreateMesaInterface() { |
| 25 if (NULL != OSMesaGetCurrentContext()) { | 25 if (NULL != OSMesaGetCurrentContext()) { |
| 26 | 26 |
| 27 GrGLGetStringProc getString = | 27 GrGLGetStringProc getString = (GrGLGetStringProc) OSMesaGetProcAddress("
glGetString"); |
| 28 (GrGLGetStringProc) OSMesaGetProcAddress("glGetString"); | 28 GrGLGetStringiProc getStringi = (GrGLGetStringiProc) OSMesaGetProcAddres
s("glGetStringi"); |
| 29 GrGLGetStringiProc glGetStringi = | 29 GrGLGetIntegervProc getIntegerv = |
| 30 (GrGLGetStringiProc) OSMesaGetProcAddress("glGetStringi"); | 30 (GrGLGetIntegervProc) OSMesaGetProcAddress("glGetIntegerv"); |
| 31 GrGLGetIntegervProc glGetIntegerv = | |
| 32 (GrGLGetIntegervProc) OSMesaGetProcAddress("glGetIntegerv"); | |
| 33 | 31 |
| 34 GrGLExtensions extensions; | 32 GrGLExtensions extensions; |
| 35 if (!extensions.init(kDesktop_GrGLBinding, glGetString, glGetStringi, gl
GetIntegerv)) { | 33 if (!extensions.init(kDesktop_GrGLBinding, getString, getStringi, getInt
egerv)) { |
| 36 return NULL; | 34 return NULL; |
| 37 } | 35 } |
| 38 | 36 |
| 39 const char* versionString = (const char*) getString(GL_VERSION); | 37 const char* versionString = (const char*) getString(GL_VERSION); |
| 40 GrGLVersion glVer = GrGLGetVersionFromString(versionString); | 38 GrGLVersion glVer = GrGLGetVersionFromString(versionString); |
| 41 | 39 |
| 42 if (glVer < GR_GL_VER(1,5)) { | 40 if (glVer < GR_GL_VER(1,5)) { |
| 43 // We must have array and element_array buffer objects. | 41 // We must have array and element_array buffer objects. |
| 44 return NULL; | 42 return NULL; |
| 45 } | 43 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 delete interface; | 207 delete interface; |
| 210 return NULL; | 208 return NULL; |
| 211 } | 209 } |
| 212 GR_GL_GET_PROC(BindFragDataLocationIndexed); | 210 GR_GL_GET_PROC(BindFragDataLocationIndexed); |
| 213 interface->fBindingsExported = kDesktop_GrGLBinding; | 211 interface->fBindingsExported = kDesktop_GrGLBinding; |
| 214 return interface; | 212 return interface; |
| 215 } else { | 213 } else { |
| 216 return NULL; | 214 return NULL; |
| 217 } | 215 } |
| 218 } | 216 } |
| OLD | NEW |