Browse Source

Split the OpenGL layer out, pt 20: adapted Shaders.

pull/233/head
Vladimír Vondruš 8 years ago
parent
commit
adb4547ba0
  1. 4
      src/Magnum/Shaders/AbstractVector.cpp
  2. 10
      src/Magnum/Shaders/AbstractVector.h
  3. 46
      src/Magnum/Shaders/DistanceFieldVector.cpp
  4. 14
      src/Magnum/Shaders/DistanceFieldVector.h
  5. 30
      src/Magnum/Shaders/Flat.cpp
  6. 10
      src/Magnum/Shaders/Flat.h
  7. 20
      src/Magnum/Shaders/Generic.h
  8. 16
      src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h
  9. 48
      src/Magnum/Shaders/MeshVisualizer.cpp
  10. 11
      src/Magnum/Shaders/MeshVisualizer.h
  11. 38
      src/Magnum/Shaders/Phong.cpp
  12. 22
      src/Magnum/Shaders/Phong.h
  13. 4
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  14. 4
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  15. 20
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  16. 4
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  17. 4
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  18. 4
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp
  19. 42
      src/Magnum/Shaders/Vector.cpp
  20. 10
      src/Magnum/Shaders/Vector.h
  21. 24
      src/Magnum/Shaders/VertexColor.cpp
  22. 4
      src/Magnum/Shaders/VertexColor.h

4
src/Magnum/Shaders/AbstractVector.cpp

@ -25,12 +25,12 @@
#include "AbstractVector.h"
#include "Magnum/Texture.h"
#include "Magnum/GL/Texture.h"
#include "Magnum/Shaders/visibility.h"
namespace Magnum { namespace Shaders {
template<UnsignedInt dimensions> AbstractVector<dimensions>& AbstractVector<dimensions>::bindVectorTexture(Texture2D& texture) {
template<UnsignedInt dimensions> AbstractVector<dimensions>& AbstractVector<dimensions>::bindVectorTexture(GL::Texture2D& texture) {
texture.bind(VectorTextureLayer);
return *this;
}

10
src/Magnum/Shaders/AbstractVector.h

@ -29,7 +29,7 @@
* @brief Class @ref Magnum::Shaders::AbstractVector, typedef @ref Magnum::Shaders::AbstractVector2D, @ref Magnum::Shaders::AbstractVector3D
*/
#include "Magnum/AbstractShaderProgram.h"
#include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/Shaders/Generic.h"
namespace Magnum { namespace Shaders {
@ -40,7 +40,7 @@ namespace Magnum { namespace Shaders {
See @ref DistanceFieldVector and @ref Vector for more information.
@see @ref shaders, @ref AbstractVector2D, @ref AbstractVector3D
*/
template<UnsignedInt dimensions> class AbstractVector: public AbstractShaderProgram {
template<UnsignedInt dimensions> class AbstractVector: public GL::AbstractShaderProgram {
public:
/**
* @brief Vertex position
@ -61,13 +61,13 @@ template<UnsignedInt dimensions> class AbstractVector: public AbstractShaderProg
* @brief Bind vector texture
* @return Reference to self (for method chaining)
*/
AbstractVector<dimensions>& bindVectorTexture(Texture2D& texture);
AbstractVector<dimensions>& bindVectorTexture(GL::Texture2D& texture);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief bindVectorTexture()
* @deprecated Use @ref bindVectorTexture() instead.
*/
CORRADE_DEPRECATED("use bindVectorTexture() instead") AbstractVector<dimensions>& setVectorTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindVectorTexture() instead") AbstractVector<dimensions>& setVectorTexture(GL::Texture2D& texture) {
return bindVectorTexture(texture);
}
#endif
@ -79,7 +79,7 @@ template<UnsignedInt dimensions> class AbstractVector: public AbstractShaderProg
#endif
enum: Int { VectorTextureLayer = 15 };
explicit AbstractVector(NoCreateT) noexcept: AbstractShaderProgram{NoCreate} {}
explicit AbstractVector(NoCreateT) noexcept: GL::AbstractShaderProgram{NoCreate} {}
explicit AbstractVector() = default;
~AbstractVector() = default;
};

46
src/Magnum/Shaders/DistanceFieldVector.cpp

@ -27,11 +27,11 @@
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
#include "Implementation/CreateCompatibilityShader.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace Shaders {
@ -50,50 +50,50 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment);
vert.addSource(rs.get("generic.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
frag.addSource(rs.get("DistanceFieldVector.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag}));
AbstractShaderProgram::attachShaders({vert, frag});
GL::AbstractShaderProgram::attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::Position::Location, "position");
AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::TextureCoordinates::Location, "textureCoordinates");
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::Position::Location, "position");
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::TextureCoordinates::Location, "textureCoordinates");
}
CORRADE_INTERNAL_ASSERT_OUTPUT(AbstractShaderProgram::link());
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::AbstractShaderProgram::link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(version))
#endif
{
_transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
_colorUniform = AbstractShaderProgram::uniformLocation("color");
_outlineColorUniform = AbstractShaderProgram::uniformLocation("outlineColor");
_outlineRangeUniform = AbstractShaderProgram::uniformLocation("outlineRange");
_smoothnessUniform = AbstractShaderProgram::uniformLocation("smoothness");
_transformationProjectionMatrixUniform = GL::AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
_colorUniform = GL::AbstractShaderProgram::uniformLocation("color");
_outlineColorUniform = GL::AbstractShaderProgram::uniformLocation("outlineColor");
_outlineRangeUniform = GL::AbstractShaderProgram::uniformLocation("outlineRange");
_smoothnessUniform = GL::AbstractShaderProgram::uniformLocation("smoothness");
}
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(version))
#endif
{
AbstractShaderProgram::setUniform(AbstractShaderProgram::uniformLocation("vectorTexture"),
GL::AbstractShaderProgram::setUniform(GL::AbstractShaderProgram::uniformLocation("vectorTexture"),
AbstractVector<dimensions>::VectorTextureLayer);
}

14
src/Magnum/Shaders/DistanceFieldVector.h

@ -92,7 +92,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @return Reference to self (for method chaining)
*/
DistanceFieldVector& setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) {
AbstractShaderProgram::setUniform(_transformationProjectionMatrixUniform, matrix);
GL::AbstractShaderProgram::setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
@ -103,7 +103,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @see @ref setOutlineColor()
*/
DistanceFieldVector& setColor(const Color4& color) {
AbstractShaderProgram::setUniform(_colorUniform, color);
GL::AbstractShaderProgram::setUniform(_colorUniform, color);
return *this;
}
@ -114,7 +114,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @see @ref setOutlineRange(), @ref setColor()
*/
DistanceFieldVector& setOutlineColor(const Color4& color) {
AbstractShaderProgram::setUniform(_outlineColorUniform, color);
GL::AbstractShaderProgram::setUniform(_outlineColorUniform, color);
return *this;
}
@ -133,7 +133,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @see @ref setOutlineColor()
*/
DistanceFieldVector& setOutlineRange(Float start, Float end) {
AbstractShaderProgram::setUniform(_outlineRangeUniform, Vector2(start, end));
GL::AbstractShaderProgram::setUniform(_outlineRangeUniform, Vector2(start, end));
return *this;
}
@ -146,18 +146,18 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* aliased). Initial value is @cpp 0.04f @ce.
*/
DistanceFieldVector& setSmoothness(Float value) {
AbstractShaderProgram::setUniform(_smoothnessUniform, value);
GL::AbstractShaderProgram::setUniform(_smoothnessUniform, value);
return *this;
}
#ifndef DOXYGEN_GENERATING_OUTPUT
/* Overloads to remove WTF-factor from method chaining order */
DistanceFieldVector<dimensions>& bindVectorTexture(Texture2D& texture) {
DistanceFieldVector<dimensions>& bindVectorTexture(GL::Texture2D& texture) {
AbstractVector<dimensions>::bindVectorTexture(texture);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use bindVectorTexture() instead") DistanceFieldVector<dimensions>& setVectorTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindVectorTexture() instead") DistanceFieldVector<dimensions>& setVectorTexture(GL::Texture2D& texture) {
return bindVectorTexture(texture);
}
#endif

30
src/Magnum/Shaders/Flat.cpp

@ -27,12 +27,12 @@
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/Texture.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
#include "Magnum/GL/Texture.h"
#include "Implementation/CreateCompatibilityShader.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace Shaders {
@ -53,13 +53,13 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment);
vert.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "")
.addSource(rs.get("generic.glsl"))
@ -67,14 +67,14 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
frag.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "")
.addSource(rs.get("Flat.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag}));
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
@ -84,7 +84,7 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(version))
#endif
{
_transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
@ -92,7 +92,7 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
}
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(version))
#endif
{
if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureLayer);
@ -105,7 +105,7 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
#endif
}
template<UnsignedInt dimensions> Flat<dimensions>& Flat<dimensions>::bindTexture(Texture2D& texture) {
template<UnsignedInt dimensions> Flat<dimensions>& Flat<dimensions>::bindTexture(GL::Texture2D& texture) {
if(_flags & Flag::Textured) texture.bind(TextureLayer);
return *this;
}

10
src/Magnum/Shaders/Flat.h

@ -29,8 +29,8 @@
* @brief Class @ref Magnum::Shaders::Flat, typedef @ref Magnum::Shaders::Flat2D, @ref Magnum::Shaders::Flat3D
*/
#include "Magnum/AbstractShaderProgram.h"
#include "Magnum/DimensionTraits.h"
#include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/Matrix4.h"
@ -85,7 +85,7 @@ Common rendering setup:
@see @ref shaders, @ref Flat2D, @ref Flat3D
*/
template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public AbstractShaderProgram {
template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public GL::AbstractShaderProgram {
public:
/**
* @brief Vertex position
@ -140,7 +140,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
* This function can be safely used for constructing (and later
* destructing) objects even without any OpenGL context being active.
*/
explicit Flat(NoCreateT) noexcept: AbstractShaderProgram{NoCreate} {}
explicit Flat(NoCreateT) noexcept: GL::AbstractShaderProgram{NoCreate} {}
/** @brief Flags */
Flags flags() const { return _flags; }
@ -175,13 +175,13 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
* Has effect only if @ref Flag::Textured is set.
* @see @ref setColor()
*/
Flat<dimensions>& bindTexture(Texture2D& texture);
Flat<dimensions>& bindTexture(GL::Texture2D& texture);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief bindTexture()
* @deprecated Use @ref bindTexture() instead.
*/
CORRADE_DEPRECATED("use bindTexture() instead") Flat<dimensions>& setTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindTexture() instead") Flat<dimensions>& setTexture(GL::Texture2D& texture) {
return bindTexture(texture);
}
#endif

20
src/Magnum/Shaders/Generic.h

@ -29,7 +29,7 @@
* @brief Struct @ref Magnum::Shaders::Generic, typedef @ref Magnum::Shaders::Generic2D, @ref Magnum::Shaders::Generic3D
*/
#include "Magnum/Attribute.h"
#include "Magnum/GL/Attribute.h"
namespace Magnum { namespace Shaders {
@ -51,21 +51,21 @@ template<UnsignedInt dimensions> struct Generic {
*
* @ref Vector2 in 2D and @ref Vector3 in 3D.
*/
typedef Attribute<0, T> Position;
typedef GL::Attribute<0, T> Position;
/**
* @brief 2D texture coordinates
*
* @ref Vector2.
*/
typedef Attribute<1, Vector2> TextureCoordinates;
typedef GL::Attribute<1, Vector2> TextureCoordinates;
/**
* @brief Vertex normal
*
* @ref Vector3, defined only in 3D.
*/
typedef Attribute<2, Vector3> Normal;
typedef GL::Attribute<2, Vector3> Normal;
/**
* @brief Vertex color
@ -73,7 +73,7 @@ template<UnsignedInt dimensions> struct Generic {
* @ref Color4, however defaults to @ref Color3 if @ref MAGNUM_BUILD_DEPRECATED
* is defined. See the constructor documentation for more information.
*/
struct Color: Attribute<3, Color4> {
struct Color: GL::Attribute<3, Color4> {
/**
* @brief Constructor
* @param components Component count
@ -100,9 +100,9 @@ typedef Generic<3> Generic3D;
#ifndef DOXYGEN_GENERATING_OUTPUT
struct BaseGeneric {
typedef Attribute<1, Vector2> TextureCoordinates;
typedef GL::Attribute<1, Vector2> TextureCoordinates;
struct Color: Attribute<3, Color4> {
struct Color: GL::Attribute<3, Color4> {
constexpr explicit Color(Components components, DataType dataType = DataType::Float, DataOptions dataOptions = DataOptions()): Attribute<3, Color4>{components, dataType, dataOptions} {}
#ifdef MAGNUM_BUILD_DEPRECATED
@ -112,12 +112,12 @@ struct BaseGeneric {
};
template<> struct Generic<2>: BaseGeneric {
typedef Attribute<0, Vector2> Position;
typedef GL::Attribute<0, Vector2> Position;
};
template<> struct Generic<3>: BaseGeneric {
typedef Attribute<0, Vector3> Position;
typedef Attribute<2, Vector3> Normal;
typedef GL::Attribute<0, Vector3> Position;
typedef GL::Attribute<2, Vector3> Normal;
};
#endif

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

@ -27,9 +27,9 @@
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
/* Enable only when compiling Shaders library and thus work around
"static symbol not used" warning when using this file for TextureTools */
@ -41,15 +41,15 @@ static void importShaderResources() {
namespace Magnum { namespace Shaders { namespace Implementation {
inline Shader createCompatibilityShader(const Utility::Resource& rs, Version version, Shader::Type type) {
Shader shader(version, type);
inline GL::Shader createCompatibilityShader(const Utility::Resource& rs, GL::Version version, GL::Shader::Type type) {
GL::Shader shader(version, type);
#ifndef MAGNUM_TARGET_GLES
if(Context::current().isExtensionDisabled<Extensions::GL::ARB::explicit_attrib_location>(version))
if(GL::Context::current().isExtensionDisabled<GL::Extensions::ARB::explicit_attrib_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n");
if(Context::current().isExtensionDisabled<Extensions::GL::ARB::shading_language_420pack>(version))
if(GL::Context::current().isExtensionDisabled<GL::Extensions::ARB::shading_language_420pack>(version))
shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n");
if(Context::current().isExtensionDisabled<Extensions::GL::ARB::explicit_uniform_location>(version))
if(GL::Context::current().isExtensionDisabled<GL::Extensions::ARB::explicit_uniform_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n");
#endif

48
src/Magnum/Shaders/MeshVisualizer.cpp

@ -28,11 +28,11 @@
#include <Corrade/Containers/Optional.h>
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
#include "Implementation/CreateCompatibilityShader.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace Shaders {
@ -40,15 +40,15 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
#ifndef MAGNUM_TARGET_GLES2
if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) {
#ifndef MAGNUM_TARGET_GLES
MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL320);
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4);
MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL320);
MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(GL::Extensions::ARB::geometry_shader4);
#elif !defined(MAGNUM_TARGET_WEBGL)
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::EXT::geometry_shader);
MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(GL::Extensions::EXT::geometry_shader);
#endif
}
#else
if(_flags & Flag::Wireframe)
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::standard_derivatives);
MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(GL::Extensions::OES::standard_derivatives);
#endif
#ifdef MAGNUM_BUILD_STATIC
@ -59,24 +59,24 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= Version::GL320);
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= GL::Version::GL320);
#elif !defined(MAGNUM_TARGET_WEBGL)
const Version version = Context::current().supportedVersion({Version::GLES310, Version::GLES300, Version::GLES200});
CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= Version::GLES310);
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= GL::Version::GLES310);
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment);
vert.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "")
.addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "")
#ifdef MAGNUM_TARGET_WEBGL
.addSource("#define SUBSCRIPTING_WORKAROUND\n")
#elif defined(MAGNUM_TARGET_GLES2)
.addSource(Context::current().detectedDriver() & Context::DetectedDriver::Angle ?
.addSource(GL::Context::current().detectedDriver() & GL::Context::DetectedDriver::Angle ?
"#define SUBSCRIPTING_WORKAROUND\n" : "")
#endif
.addSource(rs.get("generic.glsl"))
@ -86,18 +86,18 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
.addSource(rs.get("MeshVisualizer.frag"));
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Containers::Optional<Shader> geom;
Containers::Optional<GL::Shader> geom;
if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) {
geom = Implementation::createCompatibilityShader(rs, version, Shader::Type::Geometry);
geom = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Geometry);
geom->addSource(rs.get("MeshVisualizer.geom"));
}
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(geom) CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, *geom, frag}));
if(geom) CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, *geom, frag}));
else
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag}));
attachShaders({vert, frag});
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
@ -105,16 +105,16 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
#endif
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isVersionSupported(Version::GL310))
if(!GL::Context::current().isVersionSupported(GL::Version::GL310))
#endif
{
bindAttributeLocation(VertexIndex::Location, "vertexIndex");
@ -125,7 +125,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(version))
#endif
{
_transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");

11
src/Magnum/Shaders/MeshVisualizer.h

@ -29,10 +29,9 @@
* @brief Class @ref Magnum::Shaders::MeshVisualizer
*/
#include "Magnum/AbstractShaderProgram.h"
#include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Matrix4.h"
#include "Magnum/Shaders/visibility.h"
namespace Magnum { namespace Shaders {
@ -104,14 +103,14 @@ Rendering setup the same as above.
@see @ref shaders
@todo Understand and add support wireframe width/smoothness without GS
*/
class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
class MAGNUM_SHADERS_EXPORT MeshVisualizer: public GL::AbstractShaderProgram {
public:
/**
* @brief Vertex position
*
* @ref shaders-generic "Generic attribute", @ref Vector3.
*/
typedef Attribute<0, Vector3> Position;
typedef GL::Attribute<0, Vector3> Position;
/**
* @brief Vertex index
@ -123,7 +122,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* 3.1, OpenGL ES 3.0 and newer this value is provided by the shader
* itself, so the attribute is not needed.
*/
typedef Attribute<3, Float> VertexIndex;
typedef GL::Attribute<3, Float> VertexIndex;
/**
* @brief Flag
@ -169,7 +168,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* This function can be safely used for constructing (and later
* destructing) objects even without any OpenGL context being active.
*/
explicit MeshVisualizer(NoCreateT) noexcept: AbstractShaderProgram{NoCreate} {}
explicit MeshVisualizer(NoCreateT) noexcept: GL::AbstractShaderProgram{NoCreate} {}
/**
* @brief Set transformation and projection matrix

38
src/Magnum/Shaders/Phong.cpp

@ -27,12 +27,12 @@
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/Texture.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
#include "Magnum/GL/Texture.h"
#include "Implementation/CreateCompatibilityShader.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace Shaders {
@ -53,13 +53,13 @@ Phong::Phong(const Flags flags): _flags(flags) {
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment);
vert.addSource(flags ? "#define TEXTURED\n" : "")
.addSource(rs.get("generic.glsl"))
@ -69,14 +69,14 @@ Phong::Phong(const Flags flags): _flags(flags) {
.addSource(flags & Flag::SpecularTexture ? "#define SPECULAR_TEXTURE\n" : "")
.addSource(rs.get("Phong.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag}));
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
@ -87,7 +87,7 @@ Phong::Phong(const Flags flags): _flags(flags) {
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(version))
#endif
{
_transformationMatrixUniform = uniformLocation("transformationMatrix");
@ -102,7 +102,7 @@ Phong::Phong(const Flags flags): _flags(flags) {
}
#ifndef MAGNUM_TARGET_GLES
if(flags && !Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
if(flags && !GL::Context::current().isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(version))
#endif
{
if(flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureLayer);
@ -124,23 +124,23 @@ Phong::Phong(const Flags flags): _flags(flags) {
#endif
}
Phong& Phong::bindAmbientTexture(Texture2D& texture) {
Phong& Phong::bindAmbientTexture(GL::Texture2D& texture) {
if(_flags & Flag::AmbientTexture) texture.bind(AmbientTextureLayer);
return *this;
}
Phong& Phong::bindDiffuseTexture(Texture2D& texture) {
Phong& Phong::bindDiffuseTexture(GL::Texture2D& texture) {
if(_flags & Flag::DiffuseTexture) texture.bind(DiffuseTextureLayer);
return *this;
}
Phong& Phong::bindSpecularTexture(Texture2D& texture) {
Phong& Phong::bindSpecularTexture(GL::Texture2D& texture) {
if(_flags & Flag::SpecularTexture) texture.bind(SpecularTextureLayer);
return *this;
}
Phong& Phong::bindTextures(Texture2D* ambient, Texture2D* diffuse, Texture2D* specular) {
AbstractTexture::bind(AmbientTextureLayer, {ambient, diffuse, specular});
Phong& Phong::bindTextures(GL::Texture2D* ambient, GL::Texture2D* diffuse, GL::Texture2D* specular) {
GL::AbstractTexture::bind(AmbientTextureLayer, {ambient, diffuse, specular});
return *this;
}

22
src/Magnum/Shaders/Phong.h

@ -29,7 +29,7 @@
* @brief Class @ref Magnum::Shaders::Phong
*/
#include "Magnum/AbstractShaderProgram.h"
#include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Matrix4.h"
#include "Magnum/Shaders/Generic.h"
@ -88,7 +88,7 @@ part and then separate the alpha like this:
@see @ref shaders
*/
class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram {
public:
/**
* @brief Vertex position
@ -147,7 +147,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* This function can be safely used for constructing (and later
* destructing) objects even without any OpenGL context being active.
*/
explicit Phong(NoCreateT) noexcept: AbstractShaderProgram{NoCreate} {}
explicit Phong(NoCreateT) noexcept: GL::AbstractShaderProgram{NoCreate} {}
/** @brief Flags */
Flags flags() const { return _flags; }
@ -173,13 +173,13 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* Has effect only if @ref Flag::AmbientTexture is set.
* @see @ref bindTextures(), @ref setAmbientColor()
*/
Phong& bindAmbientTexture(Texture2D& texture);
Phong& bindAmbientTexture(GL::Texture2D& texture);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief bindAmbientTexture()
* @deprecated Use @ref bindAmbientTexture() instead.
*/
CORRADE_DEPRECATED("use bindAmbientTexture() instead") Phong& setAmbientTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindAmbientTexture() instead") Phong& setAmbientTexture(GL::Texture2D& texture) {
return bindAmbientTexture(texture);
}
#endif
@ -205,13 +205,13 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* Has effect only if @ref Flag::DiffuseTexture is set.
* @see @ref bindTextures(), @ref setDiffuseColor()
*/
Phong& bindDiffuseTexture(Texture2D& texture);
Phong& bindDiffuseTexture(GL::Texture2D& texture);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief bindDiffuseTexture()
* @deprecated Use @ref bindDiffuseTexture() instead.
*/
CORRADE_DEPRECATED("use bindDiffuseTexture() instead") Phong& setDiffuseTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindDiffuseTexture() instead") Phong& setDiffuseTexture(GL::Texture2D& texture) {
return bindDiffuseTexture(texture);
}
#endif
@ -238,13 +238,13 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* Has effect only if @ref Flag::SpecularTexture is set.
* @see @ref bindTextures(), @ref setSpecularColor()
*/
Phong& bindSpecularTexture(Texture2D& texture);
Phong& bindSpecularTexture(GL::Texture2D& texture);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief bindSpecularTexture()
* @deprecated Use @ref bindSpecularTexture() instead.
*/
CORRADE_DEPRECATED("use bindSpecularTexture() instead") Phong& setSpecularTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindSpecularTexture() instead") Phong& setSpecularTexture(GL::Texture2D& texture) {
return bindSpecularTexture(texture);
}
#endif
@ -259,13 +259,13 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @see @ref bindAmbientTexture(), @ref bindDiffuseTexture(),
* @ref bindSpecularTexture()
*/
Phong& bindTextures(Texture2D* ambient, Texture2D* diffuse, Texture2D* specular);
Phong& bindTextures(GL::Texture2D* ambient, GL::Texture2D* diffuse, GL::Texture2D* specular);
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief bindTextures()
* @deprecated Use @ref bindTextures() instead.
*/
CORRADE_DEPRECATED("use bindTextures() instead") Phong& setTextures(Texture2D* ambient, Texture2D* diffuse, Texture2D* specular) {
CORRADE_DEPRECATED("use bindTextures() instead") Phong& setTextures(GL::Texture2D* ambient, GL::Texture2D* diffuse, GL::Texture2D* specular) {
return bindTextures(ambient, diffuse, specular);
}
#endif

4
src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp

@ -23,12 +23,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/OpenGLTester.h"
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Shaders/DistanceFieldVector.h"
namespace Magnum { namespace Shaders { namespace Test {
struct DistanceFieldVectorGLTest: OpenGLTester {
struct DistanceFieldVectorGLTest: GL::OpenGLTester {
explicit DistanceFieldVectorGLTest();
void compile2D();

4
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -23,12 +23,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/OpenGLTester.h"
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Shaders/Flat.h"
namespace Magnum { namespace Shaders { namespace Test {
struct FlatGLTest: OpenGLTester {
struct FlatGLTest: GL::OpenGLTester {
explicit FlatGLTest();
void compile2D();

20
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -23,14 +23,14 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/OpenGLTester.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Shaders/MeshVisualizer.h"
namespace Magnum { namespace Shaders { namespace Test {
struct MeshVisualizerGLTest: OpenGLTester {
struct MeshVisualizerGLTest: GL::OpenGLTester {
explicit MeshVisualizerGLTest();
void compile();
@ -61,16 +61,16 @@ void MeshVisualizerGLTest::compile() {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void MeshVisualizerGLTest::compileWireframeGeometryShader() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not supported"));
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::geometry_shader4>())
CORRADE_SKIP(GL::Extensions::ARB::geometry_shader4::string() + std::string(" is not supported"));
#else
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::geometry_shader>())
CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not supported"));
if(!GL::Context::current().isExtensionSupported<GL::Extensions::EXT::geometry_shader>())
CORRADE_SKIP(GL::Extensions::EXT::geometry_shader::string() + std::string(" is not supported"));
#endif
#ifdef MAGNUM_TARGET_GLES
if(Context::current().isExtensionSupported<Extensions::GL::NV::shader_noperspective_interpolation>())
Debug() << "Using" << Extensions::GL::NV::shader_noperspective_interpolation::string();
if(GL::Context::current().isExtensionSupported<GL::Extensions::NV::shader_noperspective_interpolation>())
Debug() << "Using" << GL::Extensions::NV::shader_noperspective_interpolation::string();
#endif
Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe);

4
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -23,12 +23,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/OpenGLTester.h"
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Shaders/Phong.h"
namespace Magnum { namespace Shaders { namespace Test {
struct PhongGLTest: OpenGLTester {
struct PhongGLTest: GL::OpenGLTester {
explicit PhongGLTest();
void compile();

4
src/Magnum/Shaders/Test/VectorGLTest.cpp

@ -23,12 +23,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/OpenGLTester.h"
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Shaders/Vector.h"
namespace Magnum { namespace Shaders { namespace Test {
struct VectorGLTest: OpenGLTester {
struct VectorGLTest: GL::OpenGLTester {
explicit VectorGLTest();
void compile2D();

4
src/Magnum/Shaders/Test/VertexColorGLTest.cpp

@ -23,12 +23,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/OpenGLTester.h"
#include "Magnum/GL/OpenGLTester.h"
#include "Magnum/Shaders/VertexColor.h"
namespace Magnum { namespace Shaders { namespace Test {
struct VertexColorGLTest: OpenGLTester {
struct VertexColorGLTest: GL::OpenGLTester {
explicit VertexColorGLTest();
void compile2D();

42
src/Magnum/Shaders/Vector.cpp

@ -27,11 +27,11 @@
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
#include "Implementation/CreateCompatibilityShader.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace Shaders {
@ -50,48 +50,48 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector() {
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment);
vert.addSource(rs.get("generic.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
frag.addSource(rs.get("Vector.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag}));
AbstractShaderProgram::attachShaders({vert, frag});
GL::AbstractShaderProgram::attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::Position::Location, "position");
AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::TextureCoordinates::Location, "textureCoordinates");
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::Position::Location, "position");
GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector<dimensions>::TextureCoordinates::Location, "textureCoordinates");
}
CORRADE_INTERNAL_ASSERT_OUTPUT(AbstractShaderProgram::link());
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::AbstractShaderProgram::link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(version))
#endif
{
_transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
_backgroundColorUniform = AbstractShaderProgram::uniformLocation("backgroundColor");
_colorUniform = AbstractShaderProgram::uniformLocation("color");
_transformationProjectionMatrixUniform = GL::AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
_backgroundColorUniform = GL::AbstractShaderProgram::uniformLocation("backgroundColor");
_colorUniform = GL::AbstractShaderProgram::uniformLocation("color");
}
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(version))
#endif
{
AbstractShaderProgram::setUniform(AbstractShaderProgram::uniformLocation("vectorTexture"), AbstractVector<dimensions>::VectorTextureLayer);
GL::AbstractShaderProgram::setUniform(GL::AbstractShaderProgram::uniformLocation("vectorTexture"), AbstractVector<dimensions>::VectorTextureLayer);
}
}

10
src/Magnum/Shaders/Vector.h

@ -89,7 +89,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
* @return Reference to self (for method chaining)
*/
Vector& setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) {
AbstractShaderProgram::setUniform(_transformationProjectionMatrixUniform, matrix);
GL::AbstractShaderProgram::setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
@ -101,7 +101,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
* @see @ref setColor()
*/
Vector& setBackgroundColor(const Color4& color) {
AbstractShaderProgram::setUniform(_backgroundColorUniform, color);
GL::AbstractShaderProgram::setUniform(_backgroundColorUniform, color);
return *this;
}
@ -112,18 +112,18 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
* @see @ref setBackgroundColor()
*/
Vector& setColor(const Color4& color) {
AbstractShaderProgram::setUniform(_colorUniform, color);
GL::AbstractShaderProgram::setUniform(_colorUniform, color);
return *this;
}
#ifndef DOXYGEN_GENERATING_OUTPUT
/* Overloads to remove WTF-factor from method chaining order */
Vector<dimensions>& bindVectorTexture(Texture2D& texture) {
Vector<dimensions>& bindVectorTexture(GL::Texture2D& texture) {
AbstractVector<dimensions>::bindVectorTexture(texture);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use bindVectorTexture() instead") Vector<dimensions>& setVectorTexture(Texture2D& texture) {
CORRADE_DEPRECATED("use bindVectorTexture() instead") Vector<dimensions>& setVectorTexture(GL::Texture2D& texture) {
return bindVectorTexture(texture);
}
#endif

24
src/Magnum/Shaders/VertexColor.cpp

@ -27,11 +27,11 @@
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Shader.h"
#include "Implementation/CreateCompatibilityShader.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace Shaders {
@ -50,26 +50,26 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor() {
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
const GL::Version version = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment);
vert.addSource(rs.get("generic.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
frag.addSource(rs.get("VertexColor.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag}));
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
if(!GL::Context::current().isVersionSupported(GL::Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
@ -79,7 +79,7 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor() {
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(version))
#endif
{
_transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");

4
src/Magnum/Shaders/VertexColor.h

@ -29,8 +29,8 @@
* @brief Class @ref Magnum::Shaders::VertexColor
*/
#include "Magnum/AbstractShaderProgram.h"
#include "Magnum/DimensionTraits.h"
#include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/Matrix4.h"
@ -63,7 +63,7 @@ Common rendering setup:
@see @ref shaders, @ref VertexColor2D, @ref VertexColor3D
*/
template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT VertexColor: public AbstractShaderProgram {
template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT VertexColor: public GL::AbstractShaderProgram {
public:
/**
* @brief Vertex position

Loading…
Cancel
Save