OpenGL-2.2.1.1: A binding for the OpenGL graphics system

Portabilityportable
Stabilitystable
Maintainersven.panne@aedion.de

Graphics.Rendering.OpenGL.GL.VertexSpec

Contents

Description

This module corresponds to section 2.7 (Vertex Specification) of the OpenGL 2.1 specs.

Synopsis

Vertex Coordinates

class Vertex a where

Specify the (x, y, z, w) coordinates of a four-dimensional vertex. This must only be done during Graphics.Rendering.OpenGL.GL.BeginEnd.renderPrimitive, otherwise the behaviour is unspecified. The current values of the auxiliary vertex attributes are associated with the vertex.

Note that there is no such thing as a "current vertex" which could be retrieved.

Methods

vertex :: a -> IO ()

vertexv :: Ptr a -> IO ()

class VertexComponent a

The class of all types which can be used as a vertex coordinate.

Instances

data Vertex2 a

A vertex with z=0 and w=1.

Constructors

Vertex2 !a !a 

Instances

TrimmingPoint Vertex2 
Eq a => Eq (Vertex2 a) 
Ord a => Ord (Vertex2 a) 
Show a => Show (Vertex2 a) 
Storable a => Storable (Vertex2 a) 
VertexAttribComponent a => VertexAttrib (Vertex2 a) 
VertexComponent a => Vertex (Vertex2 a) 
UniformComponent a => Uniform (Vertex2 a) 
WindowPosComponent a => WindowPos (Vertex2 a) 
RasterPosComponent a => RasterPos (Vertex2 a) 

data Vertex3 a

A vertex with w=1.

Constructors

Vertex3 !a !a !a 

Instances

ControlPoint Vertex3 
TrimmingPoint Vertex3 
Eq a => Eq (Vertex3 a) 
Ord a => Ord (Vertex3 a) 
Show a => Show (Vertex3 a) 
Storable a => Storable (Vertex3 a) 
VertexAttribComponent a => VertexAttrib (Vertex3 a) 
VertexComponent a => Vertex (Vertex3 a) 
UniformComponent a => Uniform (Vertex3 a) 
WindowPosComponent a => WindowPos (Vertex3 a) 
RasterPosComponent a => RasterPos (Vertex3 a) 

data Vertex4 a

A fully-fledged four-dimensional vertex.

Constructors

Vertex4 !a !a !a !a 

Instances

ControlPoint Vertex4 
Eq a => Eq (Vertex4 a) 
Ord a => Ord (Vertex4 a) 
Show a => Show (Vertex4 a) 
Storable a => Storable (Vertex4 a) 
VertexAttribComponent a => VertexAttrib (Vertex4 a) 
VertexComponent a => Vertex (Vertex4 a) 
UniformComponent a => Uniform (Vertex4 a) 
RasterPosComponent a => RasterPos (Vertex4 a) 

Auxiliary Vertex Attributes

Apart from its coordinates in four-dimensional space, every vertex has associated auxiliary attributes: Its texture coordinates, a normal, a fog coordinate, and a color plus a secondary color. For every attribute, the OpenGL state contains its current value, which can be changed at any time.

Every attribute has a "natural" format via which it can be manipulated directly as part of the OpenGL state, e.g. the current texture coordinates are internally handled as TexCoord4 GLfloat. Different formats are converted to this format, e.g. the s, r, and t coordinates of a TexCoord3 GLint are converted to floating point values and a q coordinate of 1.0 is implicitly assumed.

Consequently, the vast majority of classes, functions, and data types in this module are for convenience only and offer no additional functionality.

Texture Coordinates

currentTextureCoords :: StateVar (TexCoord4 GLfloat)

The current texture coordinates (s, t, r, q) for the current texture unit (see Graphics.Rendering.OpenGL.GL.CoordTrans.activeTexture). The initial value is (0,0,0,1) for all texture units.

class TexCoord a where

Change the current texture coordinates of the current or given texture unit.

Methods

texCoord :: a -> IO ()

texCoordv :: Ptr a -> IO ()

multiTexCoord :: TextureUnit -> a -> IO ()

multiTexCoordv :: TextureUnit -> Ptr a -> IO ()

class TexCoordComponent a

The class of all types which can be used as a texture coordinate.

newtype TexCoord1 a

Texture coordinates with t=0, r=0, and q=1.

Constructors

TexCoord1 a 

Instances

ControlPoint TexCoord1 
Eq a => Eq (TexCoord1 a) 
Ord a => Ord (TexCoord1 a) 
Show a => Show (TexCoord1 a) 
Storable a => Storable (TexCoord1 a) 
VertexAttribComponent a => VertexAttrib (TexCoord1 a) 
TexCoordComponent a => TexCoord (TexCoord1 a) 
UniformComponent a => Uniform (TexCoord1 a) 

data TexCoord2 a

Texture coordinates with r=0 and q=1.

Constructors

TexCoord2 !a !a 

Instances

ControlPoint TexCoord2 
Eq a => Eq (TexCoord2 a) 
Ord a => Ord (TexCoord2 a) 
Show a => Show (TexCoord2 a) 
Storable a => Storable (TexCoord2 a) 
VertexAttribComponent a => VertexAttrib (TexCoord2 a) 
TexCoordComponent a => TexCoord (TexCoord2 a) 
UniformComponent a => Uniform (TexCoord2 a) 

data TexCoord3 a

Texture coordinates with q=1.

Constructors

TexCoord3 !a !a !a 

Instances

ControlPoint TexCoord3 
Eq a => Eq (TexCoord3 a) 
Ord a => Ord (TexCoord3 a) 
Show a => Show (TexCoord3 a) 
Storable a => Storable (TexCoord3 a) 
VertexAttribComponent a => VertexAttrib (TexCoord3 a) 
TexCoordComponent a => TexCoord (TexCoord3 a) 
UniformComponent a => Uniform (TexCoord3 a) 

data TexCoord4 a

Fully-fledged four-dimensional texture coordinates.

Constructors

TexCoord4 !a !a !a !a 

Instances

ControlPoint TexCoord4 
Eq a => Eq (TexCoord4 a) 
Ord a => Ord (TexCoord4 a) 
Show a => Show (TexCoord4 a) 
Storable a => Storable (TexCoord4 a) 
VertexAttribComponent a => VertexAttrib (TexCoord4 a) 
TexCoordComponent a => TexCoord (TexCoord4 a) 
UniformComponent a => Uniform (TexCoord4 a) 

Normal

currentNormal :: StateVar (Normal3 GLfloat)

The current normal (x, y, z). The initial value is the unit vector (0, 0, 1).

class Normal a where

Change the current normal. Integral arguments are converted to floating-point with a linear mapping that maps the most positive representable integer value to 1.0, and the most negative representable integer value to -1.0.

Normals specified with normal or normalv need not have unit length. If Graphics.Rendering.OpenGL.GL.CoordTrans.normalize is enabled, then normals of any length specified with normal or normalv are normalized after transformation. If Graphics.Rendering.OpenGL.GL.CoordTrans.rescaleNormal is enabled, normals are scaled by a scaling factor derived from the modelview matrix. Graphics.Rendering.OpenGL.GL.CoordTrans.rescaleNormal requires that the originally specified normals were of unit length, and that the modelview matrix contains only uniform scales for proper results. Normalization is initially disabled.

Methods

normal :: a -> IO ()

normalv :: Ptr a -> IO ()

Instances

class NormalComponent a

The class of all types which can be used as a component of a normal.

data Normal3 a

Constructors

Normal3 !a !a !a 

Instances

ControlPoint Normal3 
Eq a => Eq (Normal3 a) 
Ord a => Ord (Normal3 a) 
Show a => Show (Normal3 a) 
Storable a => Storable (Normal3 a) 
VertexAttribComponent a => VertexAttrib (Normal3 a) 
NormalComponent a => Normal (Normal3 a) 
UniformComponent a => Uniform (Normal3 a) 

Fog Coordinate

currentFogCoord :: StateVar (FogCoord1 GLfloat)

The current fog coordinate. The initial value is 0.

class FogCoord a where

Change the current fog coordinate.

Methods

fogCoord :: a -> IO ()

fogCoordv :: Ptr a -> IO ()

class FogCoordComponent a

The class of all types which can be used as the fog coordinate.

Instances

newtype FogCoord1 a

A fog coordinate.

Constructors

FogCoord1 a 

Instances

Eq a => Eq (FogCoord1 a) 
Ord a => Ord (FogCoord1 a) 
Show a => Show (FogCoord1 a) 
Storable a => Storable (FogCoord1 a) 
VertexAttribComponent a => VertexAttrib (FogCoord1 a) 
FogCoordComponent a => FogCoord (FogCoord1 a) 
UniformComponent a => Uniform (FogCoord1 a) 

Color and Secondary Color

rgbaMode :: GettableStateVar Bool

If rgbaMode contains True, the color buffers store RGBA value. If color indexes are stored, it contains False.

class Color a where

Change the current color.

Methods

color :: a -> IO ()

colorv :: Ptr a -> IO ()

Instances

class SecondaryColor a where

Change the current secondary color.

Methods

secondaryColor :: a -> IO ()

secondaryColorv :: Ptr a -> IO ()

class ColorComponent a

The class of all types which can be used as a color component.

Instances

data Color3 a

Constructors

Color3 !a !a !a 

Instances

Eq a => Eq (Color3 a) 
Ord a => Ord (Color3 a) 
Show a => Show (Color3 a) 
Storable a => Storable (Color3 a) 
VertexAttribComponent a => VertexAttrib (Color3 a) 
ColorComponent a => SecondaryColor (Color3 a) 
ColorComponent a => Color (Color3 a) 
UniformComponent a => Uniform (Color3 a) 

data Color4 a

A fully-fledged RGBA color.

Constructors

Color4 !a !a !a !a 

Instances

ControlPoint Color4 
Eq a => Eq (Color4 a) 
Ord a => Ord (Color4 a) 
Show a => Show (Color4 a) 
Storable a => Storable (Color4 a) 
VertexAttribComponent a => VertexAttrib (Color4 a) 
ColorComponent a => Color (Color4 a) 
UniformComponent a => Uniform (Color4 a) 

class Index a where

Change the current color index.

Methods

index :: a -> IO ()

indexv :: Ptr a -> IO ()

Instances

class IndexComponent a

The class of all types which can be used as a color index.

Instances

newtype Index1 a

A color index.

Constructors

Index1 a 

Instances

ControlPoint Index1 
Eq a => Eq (Index1 a) 
Ord a => Ord (Index1 a) 
Show a => Show (Index1 a) 
Storable a => Storable (Index1 a) 
VertexAttribComponent a => VertexAttrib (Index1 a) 
IndexComponent a => Index (Index1 a) 
UniformComponent a => Uniform (Index1 a) 

Generic Vertex Attributes

newtype AttribLocation

Constructors

AttribLocation GLuint 

class VertexAttribComponent a where

The class of all types which can be used as a generic vertex attribute.

Methods

vertexAttrib1 :: AttribLocation -> a -> IO ()

vertexAttrib2 :: AttribLocation -> a -> a -> IO ()

vertexAttrib3 :: AttribLocation -> a -> a -> a -> IO ()

vertexAttrib4 :: AttribLocation -> a -> a -> a -> a -> IO ()

vertexAttrib1v :: AttribLocation -> Ptr a -> IO ()

vertexAttrib2v :: AttribLocation -> Ptr a -> IO ()

vertexAttrib3v :: AttribLocation -> Ptr a -> IO ()

vertexAttrib4v :: AttribLocation -> Ptr a -> IO ()

Texture Units

newtype TextureUnit

Identifies a texture unit via its number, which must be in the range of (0 .. maxTextureUnit).

Constructors

TextureUnit GLuint 

Instances

maxTextureUnit :: GettableStateVar TextureUnit

An implementation must support at least 2 texture units, but it may support up to 32 ones. This state variable can be used to query the actual implementation limit.