| bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrGLUtil_DEFINED |
| 9 | #define GrGLUtil_DEFINED |
| 10 | |
| 11 | #include "gl/GrGLInterface.h" |
| bsalomon@google.com | 91bcc94 | 2012-05-07 17:28:41 +0000 | [diff] [blame] | 12 | #include "GrGLDefines.h" |
| bsalomon@google.com | 9c1f1ac | 2012-05-07 17:09:37 +0000 | [diff] [blame] | 13 | |
| 14 | //////////////////////////////////////////////////////////////////////////////// |
| 15 | |
| 16 | typedef uint32_t GrGLVersion; |
| 17 | typedef uint32_t GrGLSLVersion; |
| 18 | |
| 19 | #define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \ |
| 20 | static_cast<int>(minor)) |
| 21 | #define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \ |
| 22 | static_cast<int>(minor)) |
| 23 | |
| 24 | //////////////////////////////////////////////////////////////////////////////// |
| 25 | |
| 26 | /** |
| 27 | * Some drivers want the var-int arg to be zero-initialized on input. |
| 28 | */ |
| 29 | #define GR_GL_INIT_ZERO 0 |
| 30 | #define GR_GL_GetIntegerv(gl, e, p) \ |
| 31 | do { \ |
| 32 | *(p) = GR_GL_INIT_ZERO; \ |
| 33 | GR_GL_CALL(gl, GetIntegerv(e, p)); \ |
| 34 | } while (0) |
| 35 | |
| 36 | #define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p) \ |
| 37 | do { \ |
| 38 | *(p) = GR_GL_INIT_ZERO; \ |
| 39 | GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p)); \ |
| 40 | } while (0) |
| 41 | |
| 42 | #define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p) \ |
| 43 | do { \ |
| 44 | *(p) = GR_GL_INIT_ZERO; \ |
| 45 | GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p)); \ |
| 46 | } while (0) |
| 47 | #define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p) \ |
| 48 | do { \ |
| 49 | *(p) = GR_GL_INIT_ZERO; \ |
| 50 | GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p)); \ |
| 51 | } while (0) |
| 52 | |
| 53 | //////////////////////////////////////////////////////////////////////////////// |
| 54 | |
| 55 | /** |
| 56 | * Helpers for glGetString() |
| 57 | */ |
| 58 | |
| 59 | // these variants assume caller already has a string from glGetString() |
| 60 | GrGLVersion GrGLGetVersionFromString(const char* versionString); |
| 61 | GrGLBinding GrGLGetBindingInUseFromString(const char* versionString); |
| 62 | GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString); |
| 63 | bool GrGLHasExtensionFromString(const char* ext, const char* extensionString); |
| 64 | |
| 65 | // these variants call glGetString() |
| 66 | bool GrGLHasExtension(const GrGLInterface*, const char* ext); |
| 67 | GrGLBinding GrGLGetBindingInUse(const GrGLInterface*); |
| 68 | GrGLVersion GrGLGetVersion(const GrGLInterface*); |
| 69 | GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*); |
| 70 | |
| 71 | /** |
| 72 | * Helpers for glGetError() |
| 73 | */ |
| 74 | |
| 75 | extern void GrGLCheckErr(const GrGLInterface* gl, |
| 76 | const char* location, |
| 77 | const char* call); |
| 78 | |
| 79 | extern void GrGLClearErr(const GrGLInterface* gl); |
| 80 | |
| 81 | #endif |