bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 GrGLExtensions_DEFINED |
| 9 | #define GrGLExtensions_DEFINED |
| 10 | |
| 11 | #include "GrGLInterface.h" |
| 12 | #include "SkString.h" |
| 13 | #include "SkTArray.h" |
| 14 | |
| 15 | /** |
| 16 | * This helper queries the current GL context for its extensions, remembers them, and can be |
| 17 | * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will |
| 18 | * use the latter if it is available. |
| 19 | */ |
| 20 | class GrGLExtensions { |
| 21 | public: |
| 22 | bool init(GrGLBinding binding, const GrGLInterface* iface) { |
| 23 | GrAssert(binding & iface->fBindingsExported); |
| 24 | return this->init(binding, iface->fGetString, iface->fGetStringi, iface->fGetIntegerv); |
| 25 | } |
| 26 | /** |
| 27 | * We sometimes need to use this class without having yet created a GrGLInterface. This version |
| 28 | * of init expects that getString is always non-NULL while getIntegerv and getStringi are non- |
| 29 | * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. |
| 30 | */ |
| 31 | bool init(GrGLBinding binding, |
| 32 | GrGLGetStringProc getString, |
| 33 | GrGLGetStringiProc getStringi, |
| 34 | GrGLGetIntegervProc getIntegerv); |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 35 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 36 | /** |
| 37 | * Queries whether an extension is present. This will fail if init() has not been called. |
| 38 | */ |
| 39 | bool has(const char*) const; |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 40 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 41 | void reset() { fStrings.reset(); } |
| 42 | |
| 43 | private: |
| 44 | SkTArray<SkString> fStrings; |
| 45 | }; |
| 46 | |
| 47 | #endif |