| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "GrGLUtil.h" | 9 #include "GrGLUtil.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (NULL != location) { | 41 if (NULL != location) { |
| 42 GrPrintf(" at\n\t%s", location); | 42 GrPrintf(" at\n\t%s", location); |
| 43 } | 43 } |
| 44 if (NULL != call) { | 44 if (NULL != call) { |
| 45 GrPrintf("\n\t\t%s", call); | 45 GrPrintf("\n\t\t%s", call); |
| 46 } | 46 } |
| 47 GrPrintf("\n"); | 47 GrPrintf("\n"); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 namespace { |
| 52 bool get_gl_version_for_mesa(const int mesaMajorVersion, |
| 53 int* major, |
| 54 int* minor) { |
| 55 switch (mesaMajorVersion) { |
| 56 case 2: |
| 57 case 3: |
| 58 case 4: |
| 59 case 5: |
| 60 case 6: |
| 61 *major = 1; |
| 62 *minor = mesaMajorVersion - 1; |
| 63 return true; |
| 64 case 7: |
| 65 *major = 2; |
| 66 *minor = 1; |
| 67 return true; |
| 68 case 8: |
| 69 *major = 3; |
| 70 *minor = 0; |
| 71 return true; |
| 72 case 9: |
| 73 *major = 3; |
| 74 *minor = 1; |
| 75 return true; |
| 76 default: |
| 77 return false; |
| 78 } |
| 79 } |
| 80 } |
| 81 |
| 51 /////////////////////////////////////////////////////////////////////////////// | 82 /////////////////////////////////////////////////////////////////////////////// |
| 52 | 83 |
| 53 #if GR_GL_LOG_CALLS | 84 #if GR_GL_LOG_CALLS |
| 54 bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START); | 85 bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START); |
| 55 #endif | 86 #endif |
| 56 | 87 |
| 57 #if GR_GL_CHECK_ERROR | 88 #if GR_GL_CHECK_ERROR |
| 58 bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START); | 89 bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START); |
| 59 #endif | 90 #endif |
| 60 | 91 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 123 } |
| 93 | 124 |
| 94 GrGLVersion GrGLGetVersionFromString(const char* versionString) { | 125 GrGLVersion GrGLGetVersionFromString(const char* versionString) { |
| 95 if (NULL == versionString) { | 126 if (NULL == versionString) { |
| 96 GrAssert(!"NULL GL version string."); | 127 GrAssert(!"NULL GL version string."); |
| 97 return 0; | 128 return 0; |
| 98 } | 129 } |
| 99 | 130 |
| 100 int major, minor; | 131 int major, minor; |
| 101 | 132 |
| 102 int n = sscanf(versionString, "%d.%d", &major, &minor); | 133 // check for mesa |
| 134 int mesaMajor, mesaMinor; |
| 135 int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, |
| 136 &mesaMajor, &mesaMinor); |
| 137 if (4 == n) { |
| 138 if (get_gl_version_for_mesa(mesaMajor, &major, &minor)) { |
| 139 return GR_GL_VER(major, minor); |
| 140 } else { |
| 141 return 0; |
| 142 } |
| 143 } |
| 144 |
| 145 n = sscanf(versionString, "%d.%d", &major, &minor); |
| 103 if (2 == n) { | 146 if (2 == n) { |
| 104 return GR_GL_VER(major, minor); | 147 return GR_GL_VER(major, minor); |
| 105 } | 148 } |
| 106 | 149 |
| 107 char profile[2]; | 150 char profile[2]; |
| 108 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, | 151 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, |
| 109 &major, &minor); | 152 &major, &minor); |
| 110 if (4 == n) { | 153 if (4 == n) { |
| 111 return GR_GL_VER(major, minor); | 154 return GR_GL_VER(major, minor); |
| 112 } | 155 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const GrGLubyte* v; | 222 const GrGLubyte* v; |
| 180 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); | 223 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); |
| 181 return GrGLGetGLSLVersionFromString((const char*) v); | 224 return GrGLGetGLSLVersionFromString((const char*) v); |
| 182 } | 225 } |
| 183 | 226 |
| 184 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { | 227 GrGLVendor GrGLGetVendor(const GrGLInterface* gl) { |
| 185 const GrGLubyte* v; | 228 const GrGLubyte* v; |
| 186 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); | 229 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VENDOR)); |
| 187 return GrGLGetVendorFromString((const char*) v); | 230 return GrGLGetVendorFromString((const char*) v); |
| 188 } | 231 } |
| OLD | NEW |