From fcea05e316c6cc9ae190c0703e2cc2236fb94280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 29 Jun 2014 10:09:28 +0200 Subject: [PATCH] Detecting whether ANGLE is used as GLES2 implementation. --- src/Magnum/Context.h | 12 +++++++++++- src/Magnum/Implementation/detectedDriver.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 90aa81797..6399b6597 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -178,7 +178,17 @@ class MAGNUM_EXPORT Context { enum class DetectedDriver: UnsignedShort { #ifndef MAGNUM_TARGET_GLES /** Binary AMD desktop drivers on Windows and Linux */ - AMD = 1 << 0 + AMD = 1 << 0, + #endif + + #ifdef MAGNUM_TARGET_GLES2 + /** + * OpenGL ES 2.0 implementation by ANGLE (translated to D3D9), used + * by browsers on Windows for Native Client and WebGL. As the WebGL + * specification explicitly disallows exposing driver information + * to the application, this check cannot be done reliably. + */ + ProbablyAngle = 1 << 1 #endif }; diff --git a/src/Magnum/Implementation/detectedDriver.cpp b/src/Magnum/Implementation/detectedDriver.cpp index d672bb71e..60ada7803 100644 --- a/src/Magnum/Implementation/detectedDriver.cpp +++ b/src/Magnum/Implementation/detectedDriver.cpp @@ -40,6 +40,17 @@ auto Context::detectedDriver() -> Context::DetectedDrivers { return *_detectedDrivers |= DetectedDriver::AMD; #endif + /* OpenGL ES 2.0 implementation using ANGLE. Taken from + http://stackoverflow.com/a/20149090 */ + #ifdef MAGNUM_TARGET_GLES2 + { + Range1Di range; + glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range.data()); + if(range.min() == 1 && range.max() == 1) + return *_detectedDrivers |= DetectedDriver::ProbablyAngle; + } + #endif + return *_detectedDrivers; }