OpenGL-3.0.3.0: A binding for the OpenGL graphics system

Copyright | (c) Sven Panne 2002-2019
License | BSD3
Maintainer | Sven Panne <svenpanne@gmail.com>
Stability | stable
Portability | portable
Safe Haskell | None
Language | Haskell2010

Graphics.Rendering.OpenGL.GLU.Tessellation

Contents

- Polygon description
- Combining vertices
- Tessellation parameters
- Tessellator type
- Contour extraction
- Triangulation
- Tessellation into primitives

Description

This module corresponds to chapter 5 (Polygon Tessellation) of the GLU specs.

Synopsis

- data AnnotatedVertex v = AnnotatedVertex (Vertex3 GLdouble) v
- newtype ComplexContour v = ComplexContour [AnnotatedVertex v]
- newtype ComplexPolygon v = ComplexPolygon [ComplexContour v]
- data WeightedProperties v = WeightedProperties (GLfloat, v) (GLfloat, v) (GLfloat, v) (GLfloat, v)
- type Combiner v = Vertex3 GLdouble -> WeightedProperties v -> v
- data TessWinding
  - = TessWindingOdd
  - | TessWindingNonzero
  - | TessWindingPositive
  - | TessWindingNegative
  - | TessWindingAbsGeqTwo
- type Tolerance = GLdouble
- type Tessellator (p :: Type -> Type) v = TessWinding -> Tolerance -> Normal3 GLdouble -> Combiner v -> ComplexPolygon v -> IO (p v)
- newtype SimpleContour v = SimpleContour [AnnotatedVertex v]
- newtype PolygonContours v = PolygonContours [SimpleContour v]
- extractContours :: Storable v => Tessellator PolygonContours v
- type TriangleVertex v = AnnotatedVertex (v, EdgeFlag)
- data Triangle v = Triangle (TriangleVertex v) (TriangleVertex v) (TriangleVertex v)
- newtype Triangulation v = Triangulation [Triangle v]
- triangulate :: Storable v => Tessellator Triangulation v
- data Primitive v = Primitive PrimitiveMode [AnnotatedVertex v]
- newtype SimplePolygon v = SimplePolygon [Primitive v]
- tessellate :: Storable v => Tessellator SimplePolygon v

# Polygon description

data AnnotatedVertex v Source #

The basic building block in tessellation is a 3D vertex with an associated property, e.g. color, texture coordinates, etc.

Constructors

AnnotatedVertex (Vertex3 GLdouble) v |

#### Instances

Instances details

Storable v => Storable (AnnotatedVertex v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

sizeOf :: AnnotatedVertex v -> Int Source #

alignment :: AnnotatedVertex v -> Int Source #

peekElemOff :: Ptr (AnnotatedVertex v) -> Int -> IO (AnnotatedVertex v) Source #

pokeElemOff :: Ptr (AnnotatedVertex v) -> Int -> AnnotatedVertex v -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (AnnotatedVertex v) Source #

pokeByteOff :: Ptr b -> Int -> AnnotatedVertex v -> IO () Source #

peek :: Ptr (AnnotatedVertex v) -> IO (AnnotatedVertex v) Source #

poke :: Ptr (AnnotatedVertex v) -> AnnotatedVertex v -> IO () Source #

Eq v => Eq (AnnotatedVertex v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: AnnotatedVertex v -> AnnotatedVertex v -> Bool Source # (/=) :: AnnotatedVertex v -> AnnotatedVertex v -> Bool Source #
Ord v => Ord (AnnotatedVertex v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: AnnotatedVertex v -> AnnotatedVertex v -> Ordering Source #

(<) :: AnnotatedVertex v -> AnnotatedVertex v -> Bool Source #

(<=) :: AnnotatedVertex v -> AnnotatedVertex v -> Bool Source #

(>) :: AnnotatedVertex v -> AnnotatedVertex v -> Bool Source #

(>=) :: AnnotatedVertex v -> AnnotatedVertex v -> Bool Source #

max :: AnnotatedVertex v -> AnnotatedVertex v -> AnnotatedVertex v Source #

min :: AnnotatedVertex v -> AnnotatedVertex v -> AnnotatedVertex v Source #

newtype ComplexContour v Source #

A complex contour, which can be self-intersecting and/or concave.

Constructors

ComplexContour [AnnotatedVertex v] |

#### Instances

Instances details

Eq v => Eq (ComplexContour v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: ComplexContour v -> ComplexContour v -> Bool Source # (/=) :: ComplexContour v -> ComplexContour v -> Bool Source #
Ord v => Ord (ComplexContour v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: ComplexContour v -> ComplexContour v -> Ordering Source #

(<) :: ComplexContour v -> ComplexContour v -> Bool Source #

(<=) :: ComplexContour v -> ComplexContour v -> Bool Source #

(>) :: ComplexContour v -> ComplexContour v -> Bool Source #

(>=) :: ComplexContour v -> ComplexContour v -> Bool Source #

max :: ComplexContour v -> ComplexContour v -> ComplexContour v Source #

min :: ComplexContour v -> ComplexContour v -> ComplexContour v Source #

newtype ComplexPolygon v Source #

A complex (possibly concave) polygon, represented by one or more complex and possibly intersecting contours.

Constructors

ComplexPolygon [ComplexContour v] |

#### Instances

Instances details

Eq v => Eq (ComplexPolygon v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: ComplexPolygon v -> ComplexPolygon v -> Bool Source # (/=) :: ComplexPolygon v -> ComplexPolygon v -> Bool Source #
Ord v => Ord (ComplexPolygon v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: ComplexPolygon v -> ComplexPolygon v -> Ordering Source #

(<) :: ComplexPolygon v -> ComplexPolygon v -> Bool Source #

(<=) :: ComplexPolygon v -> ComplexPolygon v -> Bool Source #

(>) :: ComplexPolygon v -> ComplexPolygon v -> Bool Source #

(>=) :: ComplexPolygon v -> ComplexPolygon v -> Bool Source #

max :: ComplexPolygon v -> ComplexPolygon v -> ComplexPolygon v Source #

min :: ComplexPolygon v -> ComplexPolygon v -> ComplexPolygon v Source #

# Combining vertices

data WeightedProperties v Source #

Four vertex properties (cf. `AnnotatedVertex`) with associated weigths summing up to 1.0.

Constructors

WeightedProperties (GLfloat, v) (GLfloat, v) (GLfloat, v) (GLfloat, v) |

#### Instances

Instances details

Eq v => Eq (WeightedProperties v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: WeightedProperties v -> WeightedProperties v -> Bool Source # (/=) :: WeightedProperties v -> WeightedProperties v -> Bool Source #
Ord v => Ord (WeightedProperties v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: WeightedProperties v -> WeightedProperties v -> Ordering Source #

(<) :: WeightedProperties v -> WeightedProperties v -> Bool Source #

(<=) :: WeightedProperties v -> WeightedProperties v -> Bool Source #

(>) :: WeightedProperties v -> WeightedProperties v -> Bool Source #

(>=) :: WeightedProperties v -> WeightedProperties v -> Bool Source #

max :: WeightedProperties v -> WeightedProperties v -> WeightedProperties v Source #

min :: WeightedProperties v -> WeightedProperties v -> WeightedProperties v Source #

type Combiner v = Vertex3 GLdouble -> WeightedProperties v -> v Source #

A function combining given vertex properties into a property for a newly generated vertex

# Tessellation parameters

data TessWinding Source #

Constructors

TessWindingOdd |
TessWindingNonzero |
TessWindingPositive |
TessWindingNegative |
TessWindingAbsGeqTwo |

#### Instances

Instances details

Show TessWinding Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods showsPrec :: Int -> TessWinding -> ShowS Source # show :: TessWinding -> String Source # showList :: [TessWinding] -> ShowS Source #
Eq TessWinding Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: TessWinding -> TessWinding -> Bool Source # (/=) :: TessWinding -> TessWinding -> Bool Source #
Ord TessWinding Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: TessWinding -> TessWinding -> Ordering Source #

(<) :: TessWinding -> TessWinding -> Bool Source #

(<=) :: TessWinding -> TessWinding -> Bool Source #

(>) :: TessWinding -> TessWinding -> Bool Source #

(>=) :: TessWinding -> TessWinding -> Bool Source #

max :: TessWinding -> TessWinding -> TessWinding Source #

min :: TessWinding -> TessWinding -> TessWinding Source #

type Tolerance = GLdouble Source #

The relative tolerance under which two vertices can be combined (see `Combiner`). Multiplication with the largest coordinate magnitude of all polygon vertices yields the maximum distance between two mergeable vertices.

Note that merging is optional and the tolerance is only a hint.

# Tessellator type

type Tessellator (p :: Type -> Type) v = TessWinding -> Tolerance -> Normal3 GLdouble -> Combiner v -> ComplexPolygon v -> IO (p v) Source #

A general tessellator type.

Before tessellation of a complex polygon, all its vertices are projected into a plane perpendicular to the given normal. If the given normal is `Normal3 0 0 0`, a fitting plane of all vertices is used.

# Contour extraction

newtype SimpleContour v Source #

A simple, non-self-intersecting contour

Constructors

SimpleContour [AnnotatedVertex v] |

#### Instances

Instances details

Eq v => Eq (SimpleContour v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: SimpleContour v -> SimpleContour v -> Bool Source # (/=) :: SimpleContour v -> SimpleContour v -> Bool Source #
Ord v => Ord (SimpleContour v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: SimpleContour v -> SimpleContour v -> Ordering Source #

(<) :: SimpleContour v -> SimpleContour v -> Bool Source #

(<=) :: SimpleContour v -> SimpleContour v -> Bool Source #

(>) :: SimpleContour v -> SimpleContour v -> Bool Source #

(>=) :: SimpleContour v -> SimpleContour v -> Bool Source #

max :: SimpleContour v -> SimpleContour v -> SimpleContour v Source #

min :: SimpleContour v -> SimpleContour v -> SimpleContour v Source #

newtype PolygonContours v Source #

The contours of a complex polygon, represented by one or more non-intersecting simple contours

Constructors

PolygonContours [SimpleContour v] |

#### Instances

Instances details

Eq v => Eq (PolygonContours v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: PolygonContours v -> PolygonContours v -> Bool Source # (/=) :: PolygonContours v -> PolygonContours v -> Bool Source #
Ord v => Ord (PolygonContours v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: PolygonContours v -> PolygonContours v -> Ordering Source #

(<) :: PolygonContours v -> PolygonContours v -> Bool Source #

(<=) :: PolygonContours v -> PolygonContours v -> Bool Source #

(>) :: PolygonContours v -> PolygonContours v -> Bool Source #

(>=) :: PolygonContours v -> PolygonContours v -> Bool Source #

max :: PolygonContours v -> PolygonContours v -> PolygonContours v Source #

min :: PolygonContours v -> PolygonContours v -> PolygonContours v Source #

extractContours :: Storable v => Tessellator PolygonContours v Source #

# Triangulation

type TriangleVertex v = AnnotatedVertex (v, EdgeFlag) Source #

A triangle vertex with additional information about the edge it begins

data Triangle v Source #

A triangle, represented by three triangle vertices

Constructors

Triangle (TriangleVertex v) (TriangleVertex v) (TriangleVertex v) |

#### Instances

Instances details

Eq v => Eq (Triangle v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: Triangle v -> Triangle v -> Bool Source # (/=) :: Triangle v -> Triangle v -> Bool Source #
Ord v => Ord (Triangle v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: Triangle v -> Triangle v -> Ordering Source #

(<) :: Triangle v -> Triangle v -> Bool Source #

(<=) :: Triangle v -> Triangle v -> Bool Source #

(>) :: Triangle v -> Triangle v -> Bool Source #

(>=) :: Triangle v -> Triangle v -> Bool Source #

max :: Triangle v -> Triangle v -> Triangle v Source #

min :: Triangle v -> Triangle v -> Triangle v Source #

newtype Triangulation v Source #

A triangulation of a complex polygon

Constructors

Triangulation [Triangle v] |

#### Instances

Instances details

Eq v => Eq (Triangulation v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: Triangulation v -> Triangulation v -> Bool Source # (/=) :: Triangulation v -> Triangulation v -> Bool Source #
Ord v => Ord (Triangulation v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: Triangulation v -> Triangulation v -> Ordering Source #

(<) :: Triangulation v -> Triangulation v -> Bool Source #

(<=) :: Triangulation v -> Triangulation v -> Bool Source #

(>) :: Triangulation v -> Triangulation v -> Bool Source #

(>=) :: Triangulation v -> Triangulation v -> Bool Source #

max :: Triangulation v -> Triangulation v -> Triangulation v Source #

min :: Triangulation v -> Triangulation v -> Triangulation v Source #

triangulate :: Storable v => Tessellator Triangulation v Source #

# Tessellation into primitives

data Primitive v Source #

Constructors

Primitive PrimitiveMode [AnnotatedVertex v] |

#### Instances

Instances details

Eq v => Eq (Primitive v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: Primitive v -> Primitive v -> Bool Source # (/=) :: Primitive v -> Primitive v -> Bool Source #
Ord v => Ord (Primitive v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: Primitive v -> Primitive v -> Ordering Source #

(<) :: Primitive v -> Primitive v -> Bool Source #

(<=) :: Primitive v -> Primitive v -> Bool Source #

(>) :: Primitive v -> Primitive v -> Bool Source #

(>=) :: Primitive v -> Primitive v -> Bool Source #

max :: Primitive v -> Primitive v -> Primitive v Source #

min :: Primitive v -> Primitive v -> Primitive v Source #

newtype SimplePolygon v Source #

Constructors

SimplePolygon [Primitive v] |

#### Instances

Instances details

Eq v => Eq (SimplePolygon v) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GLU.Tessellation Methods (==) :: SimplePolygon v -> SimplePolygon v -> Bool Source # (/=) :: SimplePolygon v -> SimplePolygon v -> Bool Source #
Ord v => Ord (SimplePolygon v) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GLU.Tessellation

Methods

compare :: SimplePolygon v -> SimplePolygon v -> Ordering Source #

(<) :: SimplePolygon v -> SimplePolygon v -> Bool Source #

(<=) :: SimplePolygon v -> SimplePolygon v -> Bool Source #

(>) :: SimplePolygon v -> SimplePolygon v -> Bool Source #

(>=) :: SimplePolygon v -> SimplePolygon v -> Bool Source #

max :: SimplePolygon v -> SimplePolygon v -> SimplePolygon v Source #

min :: SimplePolygon v -> SimplePolygon v -> SimplePolygon v Source #

tessellate :: Storable v => Tessellator SimplePolygon v Source #