lowgl-0.2.0.1: Basic gl wrapper and reference

Safe HaskellNone
LanguageHaskell2010

Graphics.GL.Low.Blending

Description

When blending is enabled, colors written to the color buffer will be blended using a formula with the color already there. The three options for the formula are:

where S and D are source and destination color components respectively. The factors s and d are computed blending factors which can depend on the alpha component of the source pixel, the destination pixel, or a specified constant color. See basicBlending for a common choice.

The order of rendering matters when using blending. The farther-away primitives should be rendered first to get transparent materials to look right. This means a depth test is unhelpful when using blending. Also blending many layers of transparent primitives can significantly degrade performance. For these reasons transparency effects may be better accomplished with an off-screen rendering pass followed by a suitable shader.

blending example program here

Synopsis

Documentation

enableBlending :: Blending -> IO () Source

Enable blending with the specified blending parameters.

disableBlending :: IO () Source

Disable alpha blending.

basicBlending :: Blending Source

This blending configuration is suitable for ordinary alpha blending transparency effects.

Blending
  { sFactor   = BlendSourceAlpha
  , dFactor   = BlendOneMinusSourceAlpha
  , blendFunc = FuncAdd }

data Blending Source

Blending parameters.

Instances

Default Blending

The default blending parameters have no effect if enabled. The result will be no blending effect.