From 9d1e202ead3a5ca0d1acf5df310a1ba252f1ed27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 19 Feb 2014 12:50:51 +0100 Subject: [PATCH] Shaders: forgot to add the file. Sorry :-) --- .../CreateCompatibilityShader.cpp | 51 +++++++++++++++++++ .../CreateCompatibilityShader.h | 36 +++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp create mode 100644 src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp new file mode 100644 index 000000000..1377e6976 --- /dev/null +++ b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp @@ -0,0 +1,51 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + Vladimír Vondruš + + 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 "CreateCompatibilityShader.h" + +#include + +#include "Magnum/Context.h" +#include "Magnum/Extensions.h" + +namespace Magnum { namespace Shaders { namespace Implementation { + +Shader createCompatibilityShader(const Version version, const Shader::Type type) { + Shader shader(version, type); + + #ifndef MAGNUM_TARGET_GLES + if(Context::current()->isExtensionDisabled(version)) + shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n"); + if(Context::current()->isExtensionDisabled(version)) + shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n"); + if(Context::current()->isExtensionDisabled(version)) + shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n"); + #endif + + shader.addSource(Utility::Resource("MagnumShaders").get("compatibility.glsl")); + return shader; +} + +}}} diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h new file mode 100644 index 000000000..bb8790629 --- /dev/null +++ b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h @@ -0,0 +1,36 @@ +#ifndef Magnum_Shaders_Implementation_CreateCompatibilityShader_h +#define Magnum_Shaders_Implementation_CreateCompatibilityShader_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + Vladimír Vondruš + + 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 "Magnum/Shader.h" + +namespace Magnum { namespace Shaders { namespace Implementation { + +Shader createCompatibilityShader(Version version, Shader::Type type); + +}}} + +#endif