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.GL.CoordTrans

Contents

- Controlling the Viewport
- Matrices
- Normal Transformation
- Generating Texture Coordinates

Description

This module corresponds to section 2.11 (Coordinate Transformations) of the OpenGL 2.1 specs.

Synopsis

- depthRange :: StateVar (GLclampd, GLclampd)
- data Position = Position !GLint !GLint
- data Size = Size !GLsizei !GLsizei
- viewport :: StateVar (Position, Size)
- maxViewportDims :: GettableStateVar Size
- data MatrixMode
  - = Modelview GLsizei
  - | Projection
  - | Texture
  - | Color
  - | MatrixPalette
- matrixMode :: StateVar MatrixMode
- data MatrixOrder
  - = ColumnMajor
  - | RowMajor
- class Storable c => MatrixComponent c where
  - rotate :: c -> Vector3 c -> IO ()
  - translate :: Vector3 c -> IO ()
  - scale :: c -> c -> c -> IO ()
- class Matrix (m :: Type -> Type) where
  - withNewMatrix :: MatrixComponent c => MatrixOrder -> (Ptr c -> IO ()) -> IO (m c)
  - withMatrix :: MatrixComponent c => m c -> (MatrixOrder -> Ptr c -> IO a) -> IO a
  - newMatrix :: MatrixComponent c => MatrixOrder -> [c] -> IO (m c)
  - getMatrixComponents :: MatrixComponent c => MatrixOrder -> m c -> IO [c]
- matrix :: (Matrix m, MatrixComponent c) => Maybe MatrixMode -> StateVar (m c)
- multMatrix :: (Matrix m, MatrixComponent c) => m c -> IO ()
- data GLmatrix a
- loadIdentity :: IO ()
- ortho :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
- frustum :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
- depthClamp :: StateVar Capability
- activeTexture :: StateVar TextureUnit
- preservingMatrix :: IO a -> IO a
- unsafePreservingMatrix :: IO a -> IO a
- stackDepth :: Maybe MatrixMode -> GettableStateVar GLsizei
- maxStackDepth :: MatrixMode -> GettableStateVar GLsizei
- rescaleNormal :: StateVar Capability
- normalize :: StateVar Capability
- data Plane a = Plane !a !a !a !a
- data TextureCoordName
  - = S
  - | T
  - | R
  - | Q
- data TextureGenMode
  - = EyeLinear (Plane GLdouble)
  - | ObjectLinear (Plane GLdouble)
  - | SphereMap
  - | NormalMap
  - | ReflectionMap
- textureGenMode :: TextureCoordName -> StateVar (Maybe TextureGenMode)

# Controlling the Viewport

depthRange :: StateVar (GLclampd, GLclampd) Source #

After clipping and division by w, depth coordinates range from -1 to 1, corresponding to the near and far clipping planes. `depthRange` specifies a linear mapping of the normalized depth coordinates in this range to window depth coordinates. Regardless of the actual depth buffer implementation, window coordinate depth values are treated as though they range from 0 through 1 (like color components). Thus, the values accepted by `depthRange` are both clamped to this range before they are accepted.

The initial setting of (0, 1) maps the near plane to 0 and the far plane to 1. With this mapping, the depth buffer range is fully utilized.

It is not necessary that the near value be less than the far value. Reverse mappings such as (1, 0) are acceptable.

data Position Source #

A 2-dimensional position, measured in pixels.

Constructors

Position !GLint !GLint |

#### Instances

Instances details

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

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

compare :: Position -> Position -> Ordering Source #

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

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

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

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

max :: Position -> Position -> Position Source #

min :: Position -> Position -> Position Source #

data Size Source #

A 2-dimensional size, measured in pixels.

Constructors

Size !GLsizei !GLsizei |

#### Instances

Instances details

Show Size Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods showsPrec :: Int -> Size -> ShowS Source # show :: Size -> String Source # showList :: [Size] -> ShowS Source #
Eq Size Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods (==) :: Size -> Size -> Bool Source # (/=) :: Size -> Size -> Bool Source #
Ord Size Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods compare :: Size -> Size -> Ordering Source # (<) :: Size -> Size -> Bool Source # (<=) :: Size -> Size -> Bool Source # (>) :: Size -> Size -> Bool Source # (>=) :: Size -> Size -> Bool Source # max :: Size -> Size -> Size Source # min :: Size -> Size -> Size Source #

viewport :: StateVar (Position, Size) Source #

Controls the affine transformation from normalized device coordinates to window coordinates. The viewport state variable consists of the coordinates (x, y) of the lower left corner of the viewport rectangle, (in pixels, initial value (0,0)), and the size (width, height) of the viewport. When a GL context is first attached to a window, width and height are set to the dimensions of that window.

Let (xnd, ynd) be normalized device coordinates. Then the window coordinates (xw, yw) are computed as follows:

xw = (xnd + 1) (width / 2) + x

yw = (ynd + 1) (heigth / 2) + y

Viewport width and height are silently clamped to a range that depends on the implementation, see `maxViewportDims`.

maxViewportDims :: GettableStateVar Size Source #

The implementation-dependent maximum viewport width and height.

# Matrices

data MatrixMode Source #

A matrix stack.

Constructors

Modelview GLsizei | The modelview matrix stack of the specified vertex unit.
Projection | The projection matrix stack.
Texture | The texture matrix stack.
Color | The color matrix stack.
MatrixPalette | The matrix palette stack.

#### Instances

Instances details

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

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

compare :: MatrixMode -> MatrixMode -> Ordering Source #

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

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

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

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

max :: MatrixMode -> MatrixMode -> MatrixMode Source #

min :: MatrixMode -> MatrixMode -> MatrixMode Source #

matrixMode :: StateVar MatrixMode Source #

Controls which matrix stack is the target for subsequent matrix operations. The initial value is (`Modelview` 0).

data MatrixOrder Source #

Constructors

ColumnMajor |
RowMajor |

#### Instances

Instances details

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

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

compare :: MatrixOrder -> MatrixOrder -> Ordering Source #

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

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

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

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

max :: MatrixOrder -> MatrixOrder -> MatrixOrder Source #

min :: MatrixOrder -> MatrixOrder -> MatrixOrder Source #

class Storable c => MatrixComponent c where Source #

Minimal complete definition

getMatrix, loadMatrix, loadTransposeMatrix, multMatrix_, multTransposeMatrix, getUniformv, uniformMatrix4v, rotate, translate, scale

Methods

rotate :: c -> Vector3 c -> IO () Source #

translate :: Vector3 c -> IO () Source #

scale :: c -> c -> c -> IO () Source #

#### Instances

Instances details

MatrixComponent GLdouble Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GL.MatrixComponent

Methods

getMatrix :: GetPNameMatrix p => p -> Ptr GLdouble -> IO ()

loadMatrix :: Ptr GLdouble -> IO ()

loadTransposeMatrix :: Ptr GLdouble -> IO ()

multMatrix_ :: Ptr GLdouble -> IO ()

multTransposeMatrix :: Ptr GLdouble -> IO ()

getUniformv :: GLuint -> GLint -> Ptr GLdouble -> IO ()

uniformMatrix4v :: GLint -> GLsizei -> GLboolean -> Ptr GLdouble -> IO ()

rotate :: GLdouble -> Vector3 GLdouble -> IO () Source #

translate :: Vector3 GLdouble -> IO () Source #

scale :: GLdouble -> GLdouble -> GLdouble -> IO () Source #

MatrixComponent GLfloat Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GL.MatrixComponent

Methods

getMatrix :: GetPNameMatrix p => p -> Ptr GLfloat -> IO ()

loadMatrix :: Ptr GLfloat -> IO ()

loadTransposeMatrix :: Ptr GLfloat -> IO ()

multMatrix_ :: Ptr GLfloat -> IO ()

multTransposeMatrix :: Ptr GLfloat -> IO ()

getUniformv :: GLuint -> GLint -> Ptr GLfloat -> IO ()

uniformMatrix4v :: GLint -> GLsizei -> GLboolean -> Ptr GLfloat -> IO ()

rotate :: GLfloat -> Vector3 GLfloat -> IO () Source #

translate :: Vector3 GLfloat -> IO () Source #

scale :: GLfloat -> GLfloat -> GLfloat -> IO () Source #

class Matrix (m :: Type -> Type) where Source #

Minimal complete definition

Nothing

Methods

withNewMatrix :: MatrixComponent c => MatrixOrder -> (Ptr c -> IO ()) -> IO (m c) Source #

Create a new matrix of the given order (containing undefined elements) and call the action to fill it with 4x4 elements.

withMatrix :: MatrixComponent c => m c -> (MatrixOrder -> Ptr c -> IO a) -> IO a Source #

Call the action with the given matrix. Note: The action is not allowed to modify the matrix elements!

newMatrix :: MatrixComponent c => MatrixOrder -> [c] -> IO (m c) Source #

getMatrixComponents :: MatrixComponent c => MatrixOrder -> m c -> IO [c] Source #

#### Instances

Instances details

Matrix GLmatrix Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

withNewMatrix :: MatrixComponent c => MatrixOrder -> (Ptr c -> IO ()) -> IO (GLmatrix c) Source #

withMatrix :: MatrixComponent c => GLmatrix c -> (MatrixOrder -> Ptr c -> IO a) -> IO a Source #

newMatrix :: MatrixComponent c => MatrixOrder -> [c] -> IO (GLmatrix c) Source #

getMatrixComponents :: MatrixComponent c => MatrixOrder -> GLmatrix c -> IO [c] Source #

matrix :: (Matrix m, MatrixComponent c) => Maybe MatrixMode -> StateVar (m c) Source #

multMatrix :: (Matrix m, MatrixComponent c) => m c -> IO () Source #

data GLmatrix a Source #

#### Instances

Instances details

Matrix GLmatrix Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

withNewMatrix :: MatrixComponent c => MatrixOrder -> (Ptr c -> IO ()) -> IO (GLmatrix c) Source #

withMatrix :: MatrixComponent c => GLmatrix c -> (MatrixOrder -> Ptr c -> IO a) -> IO a Source #

newMatrix :: MatrixComponent c => MatrixOrder -> [c] -> IO (GLmatrix c) Source #

getMatrixComponents :: MatrixComponent c => MatrixOrder -> GLmatrix c -> IO [c] Source #

MatrixComponent a => Uniform (GLmatrix a) Source # | Note: `uniformv` expects all matrices to be in `ColumnMajor` form.
Instance details Defined in Graphics.Rendering.OpenGL.GL.Shaders.Uniform Methods uniform :: UniformLocation -> StateVar (GLmatrix a) Source # uniformv :: UniformLocation -> GLsizei -> Ptr (GLmatrix a) -> IO () Source #
Show (GLmatrix a) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods showsPrec :: Int -> GLmatrix a -> ShowS Source # show :: GLmatrix a -> String Source # showList :: [GLmatrix a] -> ShowS Source #
Eq (GLmatrix a) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods (==) :: GLmatrix a -> GLmatrix a -> Bool Source # (/=) :: GLmatrix a -> GLmatrix a -> Bool Source #
Ord (GLmatrix a) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

compare :: GLmatrix a -> GLmatrix a -> Ordering Source #

(<) :: GLmatrix a -> GLmatrix a -> Bool Source #

(<=) :: GLmatrix a -> GLmatrix a -> Bool Source #

(>) :: GLmatrix a -> GLmatrix a -> Bool Source #

(>=) :: GLmatrix a -> GLmatrix a -> Bool Source #

max :: GLmatrix a -> GLmatrix a -> GLmatrix a Source #

min :: GLmatrix a -> GLmatrix a -> GLmatrix a Source #

loadIdentity :: IO () Source #

ortho :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO () Source #

frustum :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO () Source #

depthClamp :: StateVar Capability Source #

activeTexture :: StateVar TextureUnit Source #

preservingMatrix :: IO a -> IO a Source #

Push the current matrix stack down by one, duplicating the current matrix, excute the given action, and pop the current matrix stack, replacing the current matrix with the one below it on the stack (i.e. restoring it to its previous state). The returned value is that of the given action. Note that a round-trip to the server is probably required. For a more efficient version, see `unsafePreservingMatrix`.

unsafePreservingMatrix :: IO a -> IO a Source #

A more efficient, but potentially dangerous version of `preservingMatrix`: The given action is not allowed to throw an exception or change the current matrix mode permanently.

stackDepth :: Maybe MatrixMode -> GettableStateVar GLsizei Source #

maxStackDepth :: MatrixMode -> GettableStateVar GLsizei Source #

# Normal Transformation

rescaleNormal :: StateVar Capability Source #

If `rescaleNormal` contains `Enabled`, normal vectors specified with `normal` are scaled by a scaling factor derived from the modelview matrix. `rescaleNormal` requires that the originally specified normals were of unit length, and that the modelview matrix contains only uniform scales for proper results. The initial value of `rescaleNormal` is `Disabled`.

normalize :: StateVar Capability Source #

If `normalize` contains `Enabled`, normal vectors specified with `normal` are scaled to unit length after transformation. The initial value of `normalize` is `Disabled`.

# Generating Texture Coordinates

data Plane a Source #

Constructors

Plane !a !a !a !a |

#### Instances

Instances details

Storable a => Storable (Plane a) Source # |

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

sizeOf :: Plane a -> Int Source #

alignment :: Plane a -> Int Source #

peekElemOff :: Ptr (Plane a) -> Int -> IO (Plane a) Source #

pokeElemOff :: Ptr (Plane a) -> Int -> Plane a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Plane a) Source #

pokeByteOff :: Ptr b -> Int -> Plane a -> IO () Source #

peek :: Ptr (Plane a) -> IO (Plane a) Source #

poke :: Ptr (Plane a) -> Plane a -> IO () Source #

Show a => Show (Plane a) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods showsPrec :: Int -> Plane a -> ShowS Source # show :: Plane a -> String Source # showList :: [Plane a] -> ShowS Source #
Eq a => Eq (Plane a) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods (==) :: Plane a -> Plane a -> Bool Source # (/=) :: Plane a -> Plane a -> Bool Source #
Ord a => Ord (Plane a) Source # |
Instance details Defined in Graphics.Rendering.OpenGL.GL.CoordTrans Methods compare :: Plane a -> Plane a -> Ordering Source # (<) :: Plane a -> Plane a -> Bool Source # (<=) :: Plane a -> Plane a -> Bool Source # (>) :: Plane a -> Plane a -> Bool Source # (>=) :: Plane a -> Plane a -> Bool Source # max :: Plane a -> Plane a -> Plane a Source # min :: Plane a -> Plane a -> Plane a Source #

data TextureCoordName Source #

Constructors

S |
T |
R |
Q |

#### Instances

Instances details

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

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

compare :: TextureCoordName -> TextureCoordName -> Ordering Source #

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

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

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

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

max :: TextureCoordName -> TextureCoordName -> TextureCoordName Source #

min :: TextureCoordName -> TextureCoordName -> TextureCoordName Source #

data TextureGenMode Source #

Constructors

EyeLinear (Plane GLdouble) |
ObjectLinear (Plane GLdouble) |
SphereMap |
NormalMap |
ReflectionMap |

#### Instances

Instances details

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

Instance details

Defined in Graphics.Rendering.OpenGL.GL.CoordTrans

Methods

compare :: TextureGenMode -> TextureGenMode -> Ordering Source #

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

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

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

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

max :: TextureGenMode -> TextureGenMode -> TextureGenMode Source #

min :: TextureGenMode -> TextureGenMode -> TextureGenMode Source #

textureGenMode :: TextureCoordName -> StateVar (Maybe TextureGenMode) Source #