luminance-0.7.2: Type-safe, type-level and stateless graphics framework

Copyright(C) 2015 Dimitri Sabadie
LicenseBSD3
MaintainerDimitri Sabadie <dimitri.sabadie@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Graphics.Luminance.Geometry

Contents

Description

 

Synopsis

Geometry creation

data Geometry

A Geometry represents a GPU version of a mesh; that is, vertices attached with indices and a geometry mode. You can have Geometry in two flavours:

  • direct geometry: doesn’t require any indices as all vertices are unique and in the right order to connect vertices between each other ;
  • indexed geometry: requires indices to know how to connect and share vertices between each other.

Instances

data GeometryMode

The GeometryMode is used to specify how vertices should be connected between each other.

A Point mode won’t connect vertices at all and will leave them as a vertices cloud.

A Line mode will connect vertices two-by-two. You then have to provide pairs of indices to correctly connect vertices and form lines.

A Triangle mode will connect vertices three-by-three. You then have to provide triplets of indices to correctly connect vertices and form triangles.

Constructors

Point 
Line 
Triangle 

createGeometry :: forall f m v. (Foldable f, MonadIO m, MonadResource m, Storable v, Vertex v) => f v -> Maybe (f Word32) -> GeometryMode -> m Geometry

This function is the single one to create Geometry. It takes a Foldable type of vertices used to provide the Geometry with vertices and might take a Foldable of indices (Word32). If you don’t pass indices (Nothing), you end up with a direct geometry. Otherwise, you get an indexed geometry. You also have to provide a GeometryMode to state how you want the vertices to be connected with each other.

nubDirect :: (Foldable f, Ord a, Integral i) => f a -> ([a], [i])

O (n log n)

Turn direct geometry data into indirect data. This function removes duplicate vertices from the data you pass in and registers indices in consequence.