1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Some useful drawing parameters.

use {glium};

/// The usual blending function to ensure that magnified texels are blended
/// properly with transparency.
pub const BLEND_FUNC_NORMAL : glium::Blend = glium::Blend {
  color:          glium::BlendingFunction::Addition {
    source:         glium::LinearBlendingFactor::SourceAlpha,
    destination:    glium::LinearBlendingFactor::OneMinusSourceAlpha
  },
  alpha:          glium::BlendingFunction::Addition {
    source:         glium::LinearBlendingFactor::One,
    destination:    glium::LinearBlendingFactor::One
  },
  constant_value: (0.0, 0.0, 0.0, 0.0)
};

/// Writing white source pixels will invert the destination pixel. Color
/// channels in the texture should all be equal to the alpha channel
/// (grayscale) so that 100% opaque regions are white and 100% transparent
/// regions are black.
pub const BLEND_FUNC_INVERT_COLOR : glium::Blend = glium::Blend {
  color:          glium::BlendingFunction::Addition {
    source:         glium::LinearBlendingFactor::OneMinusDestinationColor,
    destination:    glium::LinearBlendingFactor::OneMinusSourceAlpha
  },
  alpha:          glium::BlendingFunction::Max,
  constant_value: (0.0, 0.0, 0.0, 0.0)
};