Browse Source

Shaders: don't test for ES3 at runtime.

This only generates code that will be never executed. Tested with Flat
and Phong, the other shaders don't have rendering tests yet but since
the change is the same, I assume it will work there as well.
pull/364/head
Vladimír Vondruš 7 years ago
parent
commit
fd67e42df1
  1. 5
      src/Magnum/Shaders/DistanceFieldVector.cpp
  2. 5
      src/Magnum/Shaders/Flat.cpp
  3. 5
      src/Magnum/Shaders/MeshVisualizer.cpp
  4. 5
      src/Magnum/Shaders/Phong.cpp
  5. 5
      src/Magnum/Shaders/Vector.cpp
  6. 5
      src/Magnum/Shaders/VertexColor.cpp

5
src/Magnum/Shaders/DistanceFieldVector.cpp

@ -67,15 +67,16 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
GL::AbstractShaderProgram::attachShaders({vert, frag});
/* ES3 has this done in the shader directly */
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::Position::Location, "position");
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::TextureCoordinates::Location, "textureCoordinates");
}
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::AbstractShaderProgram::link());

5
src/Magnum/Shaders/Flat.cpp

@ -74,15 +74,16 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
attachShaders({vert, frag});
/* ES3 has this done in the shader directly */
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
if(flags & Flag::Textured) bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates");
}
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(link());

5
src/Magnum/Shaders/MeshVisualizer.cpp

@ -106,10 +106,10 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
if(geom) attachShader(*geom);
#endif
/* ES3 has this done in the shader directly */
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
@ -123,6 +123,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
}
#endif
}
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(link());

5
src/Magnum/Shaders/Phong.cpp

@ -110,10 +110,10 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l
attachShaders({vert, frag});
/* ES3 has this done in the shader directly */
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
@ -123,6 +123,7 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l
if(flags & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture))
bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates");
}
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(link());

5
src/Magnum/Shaders/Vector.cpp

@ -67,15 +67,16 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector() {
GL::AbstractShaderProgram::attachShaders({vert, frag});
/* ES3 has this done in the shader directly */
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::Position::Location, "position");
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::TextureCoordinates::Location, "textureCoordinates");
}
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::AbstractShaderProgram::link());

5
src/Magnum/Shaders/VertexColor.cpp

@ -67,15 +67,16 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor() {
attachShaders({vert, frag});
/* ES3 has this done in the shader directly */
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
bindAttributeLocation(Color3::Location, "color"); /* Color4 is the same */
}
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(link());

Loading…
Cancel
Save