mirror of https://github.com/mosra/magnum.git
Browse Source
167 additions, 341 deletions. I think that speaks for itself about benefits of this base class.pull/518/head
16 changed files with 178 additions and 352 deletions
@ -1,70 +0,0 @@
|
||||
#ifndef Magnum_Shaders_AbstractVector_h |
||||
#define Magnum_Shaders_AbstractVector_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#ifdef MAGNUM_BUILD_DEPRECATED |
||||
/** @file
|
||||
* @brief Typedef @ref Magnum::Shaders::AbstractVector, alias @ref Magnum::Shaders::AbstractVector2D, @ref Magnum::Shaders::AbstractVector3D |
||||
* @m_deprecated_since_latest Use @ref Magnum/Shaders/AbstractVectorGL.h, the |
||||
* @ref Magnum::Shaders::AbstractVectorGL "AbstractVectorGL" class and |
||||
* related typedefs instead. |
||||
*/ |
||||
#endif |
||||
|
||||
#include "Magnum/configure.h" |
||||
|
||||
#ifdef MAGNUM_BUILD_DEPRECATED |
||||
#include <Corrade/Utility/Macros.h> |
||||
|
||||
#include "Magnum/Shaders/AbstractVectorGL.h" |
||||
|
||||
CORRADE_DEPRECATED_FILE("use Magnum/Shaders/AbstractVectorGL.h, the AbstractVectorGL class and related typedefs instead") |
||||
|
||||
namespace Magnum { namespace Shaders { |
||||
|
||||
/** @brief @copybrief AbstractVectorGL
|
||||
* @m_deprecated_since_latest Use @ref AbstractVectorGL instead. |
||||
*/ |
||||
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */ |
||||
template<UnsignedInt dimensions> using AbstractVector CORRADE_DEPRECATED_ALIAS("use AbstractVectorGL instead") = AbstractVectorGL<dimensions>; |
||||
#endif |
||||
|
||||
/** @brief @copybrief AbstractVectorGL2D
|
||||
* @m_deprecated_since_latest Use @ref AbstractVectorGL2D instead. |
||||
*/ |
||||
typedef CORRADE_DEPRECATED("use AbstractVectorGL2D instead") AbstractVectorGL2D AbstractVector2D; |
||||
|
||||
/** @brief @copybrief AbstractVectorGL3D
|
||||
* @m_deprecated_since_latest Use @ref AbstractVectorGL3D instead. |
||||
*/ |
||||
typedef CORRADE_DEPRECATED("use AbstractVectorGL3D instead") AbstractVectorGL3D AbstractVector3D; |
||||
|
||||
}} |
||||
#else |
||||
#error use Magnum/Shaders/AbstractVectorGL.h, the AbstractVectorGL class and related typedefs instead |
||||
#endif |
||||
|
||||
#endif |
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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 "AbstractVectorGL.h" |
||||
|
||||
#include "Magnum/GL/Texture.h" |
||||
#include "Magnum/Shaders/visibility.h" |
||||
|
||||
namespace Magnum { namespace Shaders { |
||||
|
||||
template<UnsignedInt dimensions> AbstractVectorGL<dimensions>& AbstractVectorGL<dimensions>::bindVectorTexture(GL::Texture2D& texture) { |
||||
texture.bind(VectorTextureUnit); |
||||
return *this; |
||||
} |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
template class MAGNUM_SHADERS_EXPORT AbstractVectorGL<2>; |
||||
template class MAGNUM_SHADERS_EXPORT AbstractVectorGL<3>; |
||||
#endif |
||||
|
||||
}} |
||||
@ -1,134 +0,0 @@
|
||||
#ifndef Magnum_Shaders_AbstractVectorGL_h |
||||
#define Magnum_Shaders_AbstractVectorGL_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class @ref Magnum::Shaders::AbstractVectorGL, typedef @ref Magnum::Shaders::AbstractVectorGL2D, @ref Magnum::Shaders::AbstractVectorGL3D |
||||
* @m_since_latest |
||||
*/ |
||||
|
||||
#include "Magnum/GL/AbstractShaderProgram.h" |
||||
#include "Magnum/Shaders/GenericGL.h" |
||||
|
||||
namespace Magnum { namespace Shaders { |
||||
|
||||
/**
|
||||
@brief Base for vector OpenGL shaders |
||||
@m_since_latest |
||||
|
||||
See @ref DistanceFieldVectorGL and @ref VectorGL for more information. |
||||
@see @ref shaders, @ref AbstractVectorGL2D, @ref AbstractVectorGL3D |
||||
*/ |
||||
template<UnsignedInt dimensions> class AbstractVectorGL: public GL::AbstractShaderProgram { |
||||
public: |
||||
/**
|
||||
* @brief Vertex position |
||||
* |
||||
* @ref shaders-generic "Generic attribute", |
||||
* @ref Magnum::Vector2 "Vector2" in 2D, @ref Magnum::Vector3 "Vector3" |
||||
* in 3D. |
||||
*/ |
||||
typedef typename GenericGL<dimensions>::Position Position; |
||||
|
||||
/**
|
||||
* @brief 2D texture coordinates |
||||
* |
||||
* @ref shaders-generic "Generic attribute", |
||||
* @ref Magnum::Vector2 "Vector2". |
||||
*/ |
||||
typedef typename GenericGL<dimensions>::TextureCoordinates TextureCoordinates; |
||||
|
||||
enum: UnsignedInt { |
||||
/**
|
||||
* Color shader output. @ref shaders-generic "Generic output", |
||||
* present always. Expects three- or four-component floating-point |
||||
* or normalized buffer attachment. |
||||
*/ |
||||
ColorOutput = GenericGL<dimensions>::ColorOutput |
||||
}; |
||||
|
||||
/** @brief Copying is not allowed */ |
||||
AbstractVectorGL(const AbstractVectorGL<dimensions>&) = delete; |
||||
|
||||
/** @brief Move constructor */ |
||||
AbstractVectorGL(AbstractVectorGL<dimensions>&&) noexcept = default; |
||||
|
||||
/** @brief Copying is not allowed */ |
||||
AbstractVectorGL<dimensions>& operator=(const AbstractVectorGL<dimensions>&) = delete; |
||||
|
||||
/** @brief Move assignment */ |
||||
AbstractVectorGL<dimensions>& operator=(AbstractVectorGL<dimensions>&&) noexcept = default; |
||||
|
||||
/** @{
|
||||
* @name Texture binding |
||||
*/ |
||||
|
||||
/**
|
||||
* @brief Bind vector texture |
||||
* @return Reference to self (for method chaining) |
||||
* |
||||
* @see @ref DistanceFieldVectorGL::Flag::TextureTransformation, |
||||
* @ref VectorGL::Flag::TextureTransformation, |
||||
* @ref DistanceFieldVectorGL::setTextureMatrix(), |
||||
* @ref VectorGL::setTextureMatrix() |
||||
*/ |
||||
AbstractVectorGL<dimensions>& bindVectorTexture(GL::Texture2D& texture); |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
protected: |
||||
#else |
||||
private: |
||||
#endif |
||||
/* Those textures are quite specific (and likely reused multiple times
|
||||
per frame for e.g. text rendering, so put them in a specific slot. |
||||
Older iOS (and iOS WebGL) has only 8 texture units, so can't go |
||||
above that. Unit 7 is used by TextureTools::DistanceField. */ |
||||
enum: Int { VectorTextureUnit = 6 }; |
||||
|
||||
explicit AbstractVectorGL(NoCreateT) noexcept: GL::AbstractShaderProgram{NoCreate} {} |
||||
explicit AbstractVectorGL() = default; |
||||
~AbstractVectorGL() = default; |
||||
}; |
||||
|
||||
/**
|
||||
@brief Base for two-dimensional vector OpenGL shaders |
||||
@m_since_latest |
||||
*/ |
||||
typedef AbstractVectorGL<2> AbstractVectorGL2D; |
||||
|
||||
/**
|
||||
@brief Base for three-dimensional vector OpenGL shader |
||||
@m_since_latest |
||||
*/ |
||||
typedef AbstractVectorGL<3> AbstractVectorGL3D; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue