diff options
author | José Fonseca <jfonseca@vmware.com> | 2015-01-05 16:20:08 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2015-01-05 16:20:08 +0000 |
commit | 0396fa0d2efe03b336bfb82ff288ae32badec3ac (patch) | |
tree | 9e96f6eed04f227d3dc72cd06b784f1a4f1d105e /helpers | |
parent | f59d8671fff36da22236a4b270b93195889b7ff1 (diff) |
helpers: Move GL profile into a separate helper module.
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/CMakeLists.txt | 11 | ||||
-rw-r--r-- | helpers/glprofile.cpp | 48 | ||||
-rw-r--r-- | helpers/glprofile.hpp | 86 |
3 files changed, 145 insertions, 0 deletions
diff --git a/helpers/CMakeLists.txt b/helpers/CMakeLists.txt index 235ef36a..5d02d5b8 100644 --- a/helpers/CMakeLists.txt +++ b/helpers/CMakeLists.txt @@ -2,6 +2,17 @@ # API helpers +include_directories ( + ${CMAKE_BINARY_DIR}/dispatch + ${CMAKE_SOURCE_DIR}/dispatch +) + +add_convenience_library (glhelpers + glprofile.cpp + eglsize.cpp +) + + if (WIN32) add_convenience_library (d3dhelpers d3dshader.cpp diff --git a/helpers/glprofile.cpp b/helpers/glprofile.cpp new file mode 100644 index 00000000..b893adfb --- /dev/null +++ b/helpers/glprofile.cpp @@ -0,0 +1,48 @@ +/************************************************************************** + * + * Copyright 2014 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + + +#include "glprofile.hpp" + + +namespace glprofile { + + +std::ostream & +operator << (std::ostream &os, const Profile & profile) { + os << "OpenGL"; + if (profile.api == API_GLES) { + os << " ES"; + } + os << " " << profile.major << "." << profile.minor; + if (profile.api == API_GL && + profile.versionGreaterOrEqual(3, 2)) { + os << " " << (profile.core ? "core" : "compat"); + } + return os; +} + + +} /* namespace glprofile */ diff --git a/helpers/glprofile.hpp b/helpers/glprofile.hpp new file mode 100644 index 00000000..e8d9edbd --- /dev/null +++ b/helpers/glprofile.hpp @@ -0,0 +1,86 @@ +/************************************************************************** + * + * Copyright 2014 VMware, Inc. + * Copyright 2011 Jose Fonseca + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + +/* + * Representation and manipulation of OpenGL context profiles. + */ + + +#include <ostream> + + +#ifndef GLPROFILE_HPP +#define GLPROFILE_HPP + + +namespace glprofile { + + +enum Api { + API_GL = 0, + API_GLES +}; + + +struct Profile { + unsigned major:8; + unsigned minor:8; + unsigned api:1; + unsigned core:1; + + inline + Profile(Api _api = API_GL, unsigned _major = 1, unsigned _minor = 0, bool _core = false) { + api = _api; + major = _major; + minor = _minor; + core = _core; + } + + inline bool + versionGreaterOrEqual(unsigned refMajor, unsigned refMinor) const { + return major > refMajor || + (major == refMajor && minor >= refMinor); + } + + // Comparison operator, mainly for use in std::map + inline bool + operator < (const Profile & other) const { + return api < other.api || + major < other.major || + minor < other.minor || + core < other.core; + } +}; + + +std::ostream & +operator << (std::ostream &os, const Profile & profile); + + +} /* namespace glprofile */ + + +#endif // GLPROFILE_HPP |