blob: dc35400ba4ba50619e00d13aecd8c5653483cb0b [file] [log] [blame]
José Fonseca0396fa02015-01-05 16:20:08 +00001/**************************************************************************
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
39namespace glprofile {
40
41
42enum Api {
43 API_GL = 0,
44 API_GLES
45};
46
47
48struct 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é Fonsecaa44df7a2015-01-05 19:59:59 +000070 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é Fonseca0396fa02015-01-05 16:20:08 +000079 operator < (const Profile & other) const {
José Fonsecaa44df7a2015-01-05 19:59:59 +000080 return major < other.major ||
José Fonseca0396fa02015-01-05 16:20:08 +000081 minor < other.minor ||
José Fonsecaa44df7a2015-01-05 19:59:59 +000082 api < other.api ||
José Fonseca0396fa02015-01-05 16:20:08 +000083 core < other.core;
84 }
85};
86
87
88std::ostream &
89operator << (std::ostream &os, const Profile & profile);
90
91
José Fonsecaa44df7a2015-01-05 19:59:59 +000092Profile
93getCurrentContextProfile(void);
94
95
José Fonseca0396fa02015-01-05 16:20:08 +000096} /* namespace glprofile */
97
98
99#endif // GLPROFILE_HPP