José Fonseca | 0396fa0 | 2015-01-05 16:20:08 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2014 VMware, Inc. |
| 4 | * Copyright 2011 Jose Fonseca |
| 5 | * All Rights Reserved. |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and associated documentation files (the "Software"), to deal |
| 9 | * in the Software without restriction, including without limitation the rights |
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | * copies of the Software, and to permit persons to whom the Software is |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | * THE SOFTWARE. |
| 24 | * |
| 25 | **************************************************************************/ |
| 26 | |
| 27 | /* |
| 28 | * Representation and manipulation of OpenGL context profiles. |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | #include <ostream> |
| 33 | |
| 34 | |
| 35 | #ifndef GLPROFILE_HPP |
| 36 | #define GLPROFILE_HPP |
| 37 | |
| 38 | |
| 39 | namespace glprofile { |
| 40 | |
| 41 | |
| 42 | enum Api { |
| 43 | API_GL = 0, |
| 44 | API_GLES |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | struct Profile { |
| 49 | unsigned major:8; |
| 50 | unsigned minor:8; |
| 51 | unsigned api:1; |
| 52 | unsigned core:1; |
| 53 | |
| 54 | inline |
| 55 | Profile(Api _api = API_GL, unsigned _major = 1, unsigned _minor = 0, bool _core = false) { |
| 56 | api = _api; |
| 57 | major = _major; |
| 58 | minor = _minor; |
| 59 | core = _core; |
| 60 | } |
| 61 | |
| 62 | inline bool |
| 63 | versionGreaterOrEqual(unsigned refMajor, unsigned refMinor) const { |
| 64 | return major > refMajor || |
| 65 | (major == refMajor && minor >= refMinor); |
| 66 | } |
| 67 | |
| 68 | // Comparison operator, mainly for use in std::map |
| 69 | inline bool |
José Fonseca | a44df7a | 2015-01-05 19:59:59 +0000 | [diff] [blame^] | 70 | operator == (const Profile & other) const { |
| 71 | return major == other.major && |
| 72 | minor == other.minor && |
| 73 | api == other.api && |
| 74 | core == other.core; |
| 75 | } |
| 76 | |
| 77 | // Comparison operator, mainly for use in std::map |
| 78 | inline bool |
José Fonseca | 0396fa0 | 2015-01-05 16:20:08 +0000 | [diff] [blame] | 79 | operator < (const Profile & other) const { |
José Fonseca | a44df7a | 2015-01-05 19:59:59 +0000 | [diff] [blame^] | 80 | return major < other.major || |
José Fonseca | 0396fa0 | 2015-01-05 16:20:08 +0000 | [diff] [blame] | 81 | minor < other.minor || |
José Fonseca | a44df7a | 2015-01-05 19:59:59 +0000 | [diff] [blame^] | 82 | api < other.api || |
José Fonseca | 0396fa0 | 2015-01-05 16:20:08 +0000 | [diff] [blame] | 83 | core < other.core; |
| 84 | } |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | std::ostream & |
| 89 | operator << (std::ostream &os, const Profile & profile); |
| 90 | |
| 91 | |
José Fonseca | a44df7a | 2015-01-05 19:59:59 +0000 | [diff] [blame^] | 92 | Profile |
| 93 | getCurrentContextProfile(void); |
| 94 | |
| 95 | |
José Fonseca | 0396fa0 | 2015-01-05 16:20:08 +0000 | [diff] [blame] | 96 | } /* namespace glprofile */ |
| 97 | |
| 98 | |
| 99 | #endif // GLPROFILE_HPP |