Browse Source

Added convenience function Context::supportedVersion().

pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
818fdefbd6
  1. 11
      src/Context.cpp
  2. 22
      src/Context.h

11
src/Context.cpp

@ -247,4 +247,15 @@ Context::~Context() {
_current = nullptr;
}
Version Context::supportedVersion(initializer_list<Version> versions) const {
for(auto version: versions)
if(isVersionSupported(version)) return version;
#ifndef MAGNUM_TARGET_GLES
return Version::GL210;
#else
return Version::GLES200;
#endif
}
}

22
src/Context.h

@ -194,11 +194,31 @@ class MAGNUM_EXPORT Context {
return _supportedExtensions;
}
/** @brief Whether given OpenGL version is supported */
/**
* @brief Whether given OpenGL version is supported
*
* @see supportedVersion()
*/
inline bool isVersionSupported(Version version) const {
return _version >= version;
}
/**
* @brief Get supported OpenGL version
*
* Returns first supported OpenGL version from passed list. Convenient
* equivalent to subsequent isVersionSupported() calls, e.g.:
* @code
* Version v = isVersionSupported(Version::GL330) ? Version::GL330 : Version::GL210;
* Version v = supportedVersion({Version::GL330, Version::GL210});
* @endcode
*
* If no version from the list is supported, returns lowest available
* OpenGL version (@ref Version "Version::GL210" for desktop OpenGL,
* @ref Version "Version::GLES200" for OpenGL ES).
*/
Version supportedVersion(std::initializer_list<Version> versions) const;
/**
* @brief Whether given extension is supported
*

Loading…
Cancel
Save