Browse Source

Shaders: extension support queries depend on selected GLSL version.

Also added GLSL 1.30 (GL 3.0) into version list. Should fix issues where
extension is supported but is not available in selected GLSL version.
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
0b4e6391a0
  1. 15
      src/Shaders/DistanceFieldVector.cpp
  2. 13
      src/Shaders/Flat.cpp
  3. 15
      src/Shaders/Phong.cpp
  4. 15
      src/Shaders/Vector.cpp
  5. 13
      src/Shaders/VertexColor.cpp

15
src/Shaders/DistanceFieldVector.cpp

@ -42,26 +42,25 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210});
const Version version = Context::current()->supportedVersion({Version::GL310, Version::GL300, Version::GL210});
#else
Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader frag(v, Shader::Type::Vertex);
Shader frag(version, Shader::Type::Vertex);
frag.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
AbstractShaderProgram::attachShader(frag);
Shader vert(v, Shader::Type::Fragment);
Shader vert(version, Shader::Type::Fragment);
vert.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("DistanceFieldVector.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
AbstractShaderProgram::attachShader(vert);
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>() ||
Context::current()->version() == Version::GL210)
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
#else
if(!Context::current()->isVersionSupported(Version::GLES300))
#endif
@ -73,7 +72,7 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
CORRADE_INTERNAL_ASSERT_OUTPUT(AbstractShaderProgram::link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
@ -84,7 +83,7 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
}
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
#endif
{
AbstractShaderProgram::setUniform(AbstractShaderProgram::uniformLocation("vectorTexture"),

13
src/Shaders/Flat.cpp

@ -41,26 +41,25 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(): transformationProject
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210});
const Version version = Context::current()->supportedVersion({Version::GL310, Version::GL300, Version::GL210});
#else
Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader frag(v, Shader::Type::Vertex);
Shader frag(version, Shader::Type::Vertex);
frag.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
attachShader(frag);
Shader vert(v, Shader::Type::Fragment);
Shader vert(version, Shader::Type::Fragment);
vert.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("Flat.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>() ||
Context::current()->version() == Version::GL210)
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
#else
if(!Context::current()->isVersionSupported(Version::GLES300))
#endif
@ -71,7 +70,7 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(): transformationProject
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");

15
src/Shaders/Phong.cpp

@ -35,19 +35,19 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210});
const Version version = Context::current()->supportedVersion({Version::GL310, Version::GL300, Version::GL210});
#else
Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader vert(v, Shader::Type::Vertex);
Shader vert(version, Shader::Type::Vertex);
vert.addSource(flags ? "#define TEXTURED\n" : "")
.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("Phong.vert"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);
Shader frag(v, Shader::Type::Fragment);
Shader frag(version, Shader::Type::Fragment);
frag.addSource(flags & Flag::AmbientTexture ? "#define AMBIENT_TEXTURE\n" : "")
.addSource(flags & Flag::DiffuseTexture ? "#define DIFFUSE_TEXTURE\n" : "")
.addSource(flags & Flag::SpecularTexture ? "#define SPECULAR_TEXTURE\n" : "")
@ -57,8 +57,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri
attachShader(frag);
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>() ||
Context::current()->version() == Version::GL210)
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
#else
if(!Context::current()->isVersionSupported(Version::GLES300))
#endif
@ -71,7 +70,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationMatrixUniform = uniformLocation("transformationMatrix");
@ -86,7 +85,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri
}
#ifndef MAGNUM_TARGET_GLES
if(flags && !Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>())
if(flags && !Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
#endif
{
if(flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureLayer);

15
src/Shaders/Vector.cpp

@ -42,26 +42,25 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector(): transformationPro
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210});
const Version version = Context::current()->supportedVersion({Version::GL310, Version::GL300, Version::GL210});
#else
Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader vert(v, Shader::Type::Vertex);
Shader vert(version, Shader::Type::Vertex);
vert.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
AbstractShaderProgram::attachShader(vert);
Shader frag(v, Shader::Type::Fragment);
Shader frag(version, Shader::Type::Fragment);
frag.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("Vector.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
AbstractShaderProgram::attachShader(frag);
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>() ||
Context::current()->version() == Version::GL210)
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
#else
if(!Context::current()->isVersionSupported(Version::GLES300))
#endif
@ -73,7 +72,7 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector(): transformationPro
CORRADE_INTERNAL_ASSERT_OUTPUT(AbstractShaderProgram::link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
@ -81,7 +80,7 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector(): transformationPro
}
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
#endif
{
AbstractShaderProgram::setUniform(AbstractShaderProgram::uniformLocation("vectorTexture"), AbstractVector<dimensions>::VectorTextureLayer);

13
src/Shaders/VertexColor.cpp

@ -41,26 +41,25 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor(): transfo
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
Version v = Context::current()->supportedVersion({Version::GL320, Version::GL210});
const Version version = Context::current()->supportedVersion({Version::GL310, Version::GL300, Version::GL210});
#else
Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader vert(v, Shader::Type::Vertex);
Shader vert(version, Shader::Type::Vertex);
vert.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);
Shader frag(v, Shader::Type::Fragment);
Shader frag(version, Shader::Type::Fragment);
frag.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("VertexColor.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
attachShader(frag);
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>() ||
Context::current()->version() == Version::GL210)
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
#else
if(!Context::current()->isVersionSupported(Version::GLES300))
#endif
@ -72,7 +71,7 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor(): transfo
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>())
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");

Loading…
Cancel
Save