Browse Source

Shaders: document what line-related code is shared with the Ui lib.

pull/651/merge
Vladimír Vondruš 1 year ago
parent
commit
1817c50507
  1. 3
      src/Magnum/Shaders/Implementation/lineMiterLimit.h
  2. 9
      src/Magnum/Shaders/Line.h
  3. 3
      src/Magnum/Shaders/Line.in.frag
  4. 3
      src/Magnum/Shaders/Line.in.vert
  5. 3
      src/Magnum/Shaders/LineGL.cpp
  6. 2
      src/Magnum/Shaders/Test/LineTest.cpp

3
src/Magnum/Shaders/Implementation/lineMiterLimit.h

@ -32,6 +32,9 @@
namespace Magnum { namespace Shaders { namespace Implementation {
/* These helpers, along with tests, are copied verbatim between the Shaders and
Ui libraries */
inline Float lineMiterLengthLimit(const char*
#if !defined(CORRADE_NO_ASSERT) && !defined(CORRADE_STANDARD_ASSERT)
const name

9
src/Magnum/Shaders/Line.h

@ -46,6 +46,9 @@ namespace Magnum { namespace Shaders {
@see @ref LineGL::capStyle(), @ref LineGL::Configuration::setCapStyle()
*/
enum class LineCapStyle: UnsignedByte {
/* Keep these in sync with Ui::LineCapStyle (except for the related links,
of course). The images are used directly from there. */
/**
* [Butt cap](https://en.wikipedia.org/wiki/Butt_joint). The line is cut
* off right at the endpoint. Lines of zero length will be invisible.
@ -95,6 +98,9 @@ enum class LineCapStyle: UnsignedByte {
@see @ref LineGL::joinStyle(), @ref LineGL::Configuration::setJoinStyle()
*/
enum class LineJoinStyle: UnsignedByte {
/* Keep these in sync with Ui::LineJoinStyle (except for the related links,
of course). The images are used directly from there. */
/**
* [Miter join](https://en.wikipedia.org/wiki/Miter_joint). The outer edges
* of both line segments extend until they intersect.
@ -156,6 +162,9 @@ The type is 32-bit in order to match the default type of the
bits.
*/
enum class LineVertexAnnotation: UnsignedInt {
/* Keep these in sync with the internal Ui::LineLayer LineVertexAnnotation*
constants and ANNOTATION_* defines in Line.in.vert. */
/**
* The point extends upwards assuming a left-to-right direction of the line
* segment. If not set, it extends downwards. Visualized as `U` in the

3
src/Magnum/Shaders/Line.in.frag

@ -24,6 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
/* This file, along with *.in.vert, is copied verbatim between the Shaders
and Ui libraries */
mediump float lineBlendFactor(
in highp vec2 centerDistanceSigned,
in highp float halfSegmentLength,

3
src/Magnum/Shaders/Line.in.vert

@ -24,6 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
/* This file, along with *.in.frag, is copied verbatim between the Shaders
and Ui libraries */
/* Point annotation, matching the LineVertexAnnotation enum bits */
#define ANNOTATION_UP_MASK 1u
#define ANNOTATION_JOIN_MASK 2u

3
src/Magnum/Shaders/LineGL.cpp

@ -124,7 +124,8 @@ template<UnsignedInt dimensions> typename LineGL<dimensions>::CompileState LineG
#endif
/* Cap and join style is needed by both the vertex and fragment shader,
prepare their defines just once for both */
prepare their defines just once for both. This snippet is shared between
Shaders::LineGL and Ui::LineLayerGL, keep in sync. */
Containers::StringView capStyleDefine, joinStyleDefine;
switch(configuration.capStyle()) {
case LineCapStyle::Butt:

2
src/Magnum/Shaders/Test/LineTest.cpp

@ -49,6 +49,8 @@ struct LineTest: TestSuite::Tester {
void materialUniformConstructNoInit();
void materialUniformSetters();
/* Miter limit tests are copied verbatim between the Shaders and Ui
libraries */
void materialUniformMiterLimit();
void materialUniformMiterLengthLimitInvalid();
void materialUniformMiterAngleLimitInvalid();

Loading…
Cancel
Save