Browse Source

Shaders: prefix GLSL workaround macros with MAGNUM_.

In order to prepare them for being included for all shader code, not
just own builtin shaders.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
8f04685470
  1. 4
      src/Magnum/DebugTools/TextureImage.vert
  2. 4
      src/Magnum/Shaders/FullScreenTriangle.glsl
  3. 8
      src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h
  4. 6
      src/Magnum/Shaders/compatibility.glsl

4
src/Magnum/DebugTools/TextureImage.vert

@ -23,12 +23,12 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef DISABLE_GL_MAGNUM_shader_vertex_id
#ifdef MAGNUM_DISABLE_GL_MAGNUM_shader_vertex_id
in lowp vec4 position;
#endif
void main() {
#ifndef DISABLE_GL_MAGNUM_shader_vertex_id
#ifndef MAGNUM_DISABLE_GL_MAGNUM_shader_vertex_id
gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0,
(gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0);
#else

4
src/Magnum/Shaders/FullScreenTriangle.glsl

@ -25,7 +25,7 @@
/* Inputs */
#if !defined(NEW_GLSL) || defined(DISABLE_GL_MAGNUM_shader_vertex_id)
#if !defined(NEW_GLSL) || defined(MAGNUM_DISABLE_GL_MAGNUM_shader_vertex_id)
#ifndef NEW_GLSL
#define in attribute
#endif
@ -33,7 +33,7 @@ in lowp vec4 position;
#endif
void fullScreenTriangle() {
#if defined(NEW_GLSL) && !defined(DISABLE_GL_MAGNUM_shader_vertex_id)
#if defined(NEW_GLSL) && !defined(MAGNUM_DISABLE_GL_MAGNUM_shader_vertex_id)
gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0,
(gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0);
#else

8
src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h

@ -49,16 +49,16 @@ inline GL::Shader createCompatibilityShader(const Utility::Resource& rs, GL::Ver
#ifndef MAGNUM_TARGET_GLES
if(GL::Context::current().isExtensionDisabled<GL::Extensions::ARB::explicit_attrib_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n"_s);
shader.addSource("#define MAGNUM_DISABLE_GL_ARB_explicit_attrib_location\n"_s);
if(GL::Context::current().isExtensionDisabled<GL::Extensions::ARB::shading_language_420pack>(version))
shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n"_s);
shader.addSource("#define MAGNUM_DISABLE_GL_ARB_shading_language_420pack\n"_s);
if(GL::Context::current().isExtensionDisabled<GL::Extensions::ARB::explicit_uniform_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n"_s);
shader.addSource("#define MAGNUM_DISABLE_GL_ARB_explicit_uniform_location\n"_s);
#endif
#ifndef MAGNUM_TARGET_GLES2
if(type == GL::Shader::Type::Vertex && GL::Context::current().isExtensionDisabled<GL::Extensions::MAGNUM::shader_vertex_id>(version))
shader.addSource("#define DISABLE_GL_MAGNUM_shader_vertex_id\n"_s);
shader.addSource("#define MAGNUM_DISABLE_GL_MAGNUM_shader_vertex_id\n"_s);
#endif
shader.addSource(rs.getString("compatibility.glsl"_s));

6
src/Magnum/Shaders/compatibility.glsl

@ -27,18 +27,18 @@
#define NEW_GLSL
#endif
#if !defined(GL_ES) && defined(GL_ARB_explicit_attrib_location) && !defined(DISABLE_GL_ARB_explicit_attrib_location)
#if !defined(GL_ES) && defined(GL_ARB_explicit_attrib_location) && !defined(MAGNUM_DISABLE_GL_ARB_explicit_attrib_location)
#extension GL_ARB_explicit_attrib_location: enable
#define EXPLICIT_ATTRIB_LOCATION
#endif
#if !defined(GL_ES) && defined(GL_ARB_shading_language_420pack) && !defined(DISABLE_GL_ARB_shading_language_420pack)
#if !defined(GL_ES) && defined(GL_ARB_shading_language_420pack) && !defined(MAGNUM_DISABLE_GL_ARB_shading_language_420pack)
#extension GL_ARB_shading_language_420pack: enable
#define RUNTIME_CONST
#define EXPLICIT_BINDING
#endif
#if !defined(GL_ES) && defined(GL_ARB_explicit_uniform_location) && !defined(DISABLE_GL_ARB_explicit_uniform_location)
#if !defined(GL_ES) && defined(GL_ARB_explicit_uniform_location) && !defined(MAGNUM_DISABLE_GL_ARB_explicit_uniform_location)
#extension GL_ARB_explicit_uniform_location: enable
#define EXPLICIT_UNIFORM_LOCATION
#endif

Loading…
Cancel
Save