diff --git a/Graphics/Rendering/OpenGL.hs b/Graphics/Rendering/OpenGL.hs
--- a/Graphics/Rendering/OpenGL.hs
+++ b/Graphics/Rendering/OpenGL.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -37,7 +37,11 @@
 -- extension                      | core since
 -- -------------------------------+------------
 -- GL_APPLE_packed_pixels         | 1.2
+-- GL_APPLE_ycbcr_422             |
+-- GL_ARB_copy_buffer             | 3.1
+-- GL_ARB_depth_buffer_float      | 3.0
 -- GL_ARB_depth_texture           | 1.4
+-- GL_ARB_half_float_pixel        | 3.0
 -- GL_ARB_imaging                 |
 -- GL_ARB_multisample             | 1.3
 -- GL_ARB_multitexture            | 1.3
@@ -53,8 +57,10 @@
 -- GL_ARB_texture_env_crossbar    | 1.4
 -- GL_ARB_texture_env_dot3        | 1.3
 -- GL_ARB_texture_mirrored_repeat | 1.4
+-- GL_ARB_texture_rectangle       | 3.1
 -- GL_ARB_transpose_matrix        | 1.3
 -- GL_ARB_vertex_buffer_object    | 1.5
+-- GL_ARB_vertex_shader           | 2.0
 -- GL_ARB_window_pos              | 1.4
 -- GL_EXT_abgr                    |
 -- GL_EXT_bgra                    | 1.2
@@ -72,6 +78,7 @@
 -- GL_EXT_fog_coord               | 1.4
 -- GL_EXT_histogram               |
 -- GL_EXT_multi_draw_arrays       | 1.4
+-- GL_EXT_packed_float            | 3.0
 -- GL_EXT_packed_pixels           | 1.2
 -- GL_EXT_polygon_offset          | 1.1
 -- GL_EXT_rescale_normal          | 1.2
@@ -84,10 +91,12 @@
 -- GL_EXT_texture                 | 1.1
 -- GL_EXT_texture3D               | 1.2
 -- GL_EXT_texture_lod_bias        | 1.4
+-- GL_EXT_texture_shared_exponent | 3.0
 -- GL_EXT_texture_object          | 1.1
 -- GL_EXT_vertex_array            | 1.1
 -- GL_HP_convolution_border_modes |
 -- GL_IBM_rasterpos_clip          |
+-- GL_MESA_ycbcr_texture          |
 -- GL_NV_blend_square             | 1.4
 -- GL_NV_depth_clamp              |
 -- GL_NV_fog_distance             |
diff --git a/Graphics/Rendering/OpenGL/GL.hs b/Graphics/Rendering/OpenGL/GL.hs
--- a/Graphics/Rendering/OpenGL/GL.hs
+++ b/Graphics/Rendering/OpenGL/GL.hs
@@ -1,7 +1,7 @@
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Antialiasing.hs b/Graphics/Rendering/OpenGL/GL/Antialiasing.hs
--- a/Graphics/Rendering/OpenGL/GL/Antialiasing.hs
+++ b/Graphics/Rendering/OpenGL/GL/Antialiasing.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Antialiasing
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/BasicTypes.hs b/Graphics/Rendering/OpenGL/GL/BasicTypes.hs
--- a/Graphics/Rendering/OpenGL/GL/BasicTypes.hs
+++ b/Graphics/Rendering/OpenGL/GL/BasicTypes.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.BasicTypes
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/BeginEnd.hs b/Graphics/Rendering/OpenGL/GL/BeginEnd.hs
--- a/Graphics/Rendering/OpenGL/GL/BeginEnd.hs
+++ b/Graphics/Rendering/OpenGL/GL/BeginEnd.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.BeginEnd
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Bitmaps.hs b/Graphics/Rendering/OpenGL/GL/Bitmaps.hs
--- a/Graphics/Rendering/OpenGL/GL/Bitmaps.hs
+++ b/Graphics/Rendering/OpenGL/GL/Bitmaps.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Bitmaps
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs b/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs
--- a/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs
+++ b/Graphics/Rendering/OpenGL/GL/BlendingFactor.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.BlendingFactor
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/BufferMode.hs b/Graphics/Rendering/OpenGL/GL/BufferMode.hs
--- a/Graphics/Rendering/OpenGL/GL/BufferMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/BufferMode.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.BufferMode
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/BufferObjects.hs b/Graphics/Rendering/OpenGL/GL/BufferObjects.hs
--- a/Graphics/Rendering/OpenGL/GL/BufferObjects.hs
+++ b/Graphics/Rendering/OpenGL/GL/BufferObjects.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.BufferObjects
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -22,6 +22,7 @@
 
    -- * Binding Buffer Objects
    BufferTarget(..), bindBuffer, arrayBufferBinding,
+   vertexAttribArrayBufferBinding,
 
    -- * Handling Buffer Data
    BufferUsage(..), bufferData, TransferDirection(..), bufferSubData,
@@ -49,11 +50,14 @@
             GetColorArrayBufferBinding,GetIndexArrayBufferBinding,
             GetTextureCoordArrayBufferBinding,GetEdgeFlagArrayBufferBinding,
             GetFogCoordArrayBufferBinding,GetSecondaryColorArrayBufferBinding,
-            GetPixelPackBufferBinding,GetPixelUnpackBufferBinding ),
-   getInteger1, maybeNullPtr )
+            GetPixelPackBufferBinding,GetPixelUnpackBufferBinding,
+            GetCopyReadBuffer,GetCopyWriteBuffer),
+   getInteger1, maybeNullPtr,
+   GetVertexAttribPName(GetVertexAttribArrayBufferBinding), getVertexAttribInteger1 )
 import Graphics.Rendering.OpenGL.GL.StateVar (
    GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
 import Graphics.Rendering.OpenGL.GL.VertexArrays ( ClientArrayType(..) )
+import Graphics.Rendering.OpenGL.GL.VertexSpec ( AttribLocation )
 import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
 
 --------------------------------------------------------------------------------
@@ -100,6 +104,8 @@
 
 data BufferTarget =
      ArrayBuffer
+   | CopyReadBuffer
+   | CopyWriteBuffer
    | ElementArrayBuffer
    | PixelPackBuffer
    | PixelUnpackBuffer
@@ -108,6 +114,8 @@
 marshalBufferTarget :: BufferTarget -> GLenum
 marshalBufferTarget x = case x of
    ArrayBuffer -> 0x8892
+   CopyReadBuffer -> 0x8F36
+   CopyWriteBuffer -> 0x8F37
    ElementArrayBuffer -> 0x8893
    PixelPackBuffer -> 0x88eb
    PixelUnpackBuffer -> 0x88ec
@@ -116,6 +124,8 @@
 bufferTargetToGetPName x = case x of
    ArrayBuffer -> GetArrayBufferBinding
    ElementArrayBuffer -> GetElementArrayBufferBinding
+   CopyReadBuffer -> GetCopyReadBuffer
+   CopyWriteBuffer -> GetCopyWriteBuffer
    PixelPackBuffer -> GetPixelPackBufferBinding
    PixelUnpackBuffer -> GetPixelUnpackBufferBinding
 
@@ -218,6 +228,13 @@
    makeGettableStateVar $ case t of
       MatrixIndexArray -> do recordInvalidEnum ; return Nothing
       _ -> bufferQuery clientArrayTypeToGetPName t
+
+
+vertexAttribArrayBufferBinding :: AttribLocation -> GettableStateVar (Maybe BufferObject)
+vertexAttribArrayBufferBinding location =
+   makeGettableStateVar $ do
+      buf <- getVertexAttribInteger1 (BufferObject . fromIntegral) location GetVertexAttribArrayBufferBinding
+      return $ if buf == noBufferObject then Nothing else Just buf
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/Capability.hs b/Graphics/Rendering/OpenGL/GL/Capability.hs
--- a/Graphics/Rendering/OpenGL/GL/Capability.hs
+++ b/Graphics/Rendering/OpenGL/GL/Capability.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Capability
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -44,6 +44,7 @@
    | CapLighting
    | CapTexture1D
    | CapTexture2D
+   | CapTextureRectangle
    | CapLineStipple
    | CapPolygonStipple
    | CapCullFace
@@ -134,6 +135,7 @@
    CapLighting -> Just 0xb50
    CapTexture1D -> Just 0xde0
    CapTexture2D -> Just 0xde1
+   CapTextureRectangle -> Just 0x84F5
    CapLineStipple -> Just 0xb24
    CapPolygonStipple -> Just 0xb42
    CapCullFace -> Just 0xb44
diff --git a/Graphics/Rendering/OpenGL/GL/Clipping.hs b/Graphics/Rendering/OpenGL/GL/Clipping.hs
--- a/Graphics/Rendering/OpenGL/GL/Clipping.hs
+++ b/Graphics/Rendering/OpenGL/GL/Clipping.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Clipping
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/ColorSum.hs b/Graphics/Rendering/OpenGL/GL/ColorSum.hs
--- a/Graphics/Rendering/OpenGL/GL/ColorSum.hs
+++ b/Graphics/Rendering/OpenGL/GL/ColorSum.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.ColorSum
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Colors.hs b/Graphics/Rendering/OpenGL/GL/Colors.hs
--- a/Graphics/Rendering/OpenGL/GL/Colors.hs
+++ b/Graphics/Rendering/OpenGL/GL/Colors.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Colors
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs b/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs
--- a/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs
+++ b/Graphics/Rendering/OpenGL/GL/ComparisonFunction.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.ComparisonFunction
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/ControlPoint.hs b/Graphics/Rendering/OpenGL/GL/ControlPoint.hs
--- a/Graphics/Rendering/OpenGL/GL/ControlPoint.hs
+++ b/Graphics/Rendering/OpenGL/GL/ControlPoint.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.ControlPoint
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/CoordTrans.hs b/Graphics/Rendering/OpenGL/GL/CoordTrans.hs
--- a/Graphics/Rendering/OpenGL/GL/CoordTrans.hs
+++ b/Graphics/Rendering/OpenGL/GL/CoordTrans.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.CoordTrans
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -20,7 +20,7 @@
 
    -- * Matrices
    MatrixMode(..), matrixMode,
-   Vector2(..), Vector3(..),
+   Vector1(..), Vector2(..), Vector3(..), Vector4(..),
    MatrixOrder(..), MatrixComponent(rotate,translate,scale), Matrix(..),
    currentMatrix, matrix, multMatrix, GLmatrix, loadIdentity,
    ortho, frustum, depthClamp,
@@ -51,8 +51,7 @@
 import Graphics.Rendering.OpenGL.GL.Exception ( bracket, unsafeBracket_ )
 import Graphics.Rendering.OpenGL.GL.Extensions (
    FunPtr, unsafePerformIO, Invoker, getProcAddress )
-import Graphics.Rendering.OpenGL.GL.PeekPoke (
-   peek1, peek2, peek3, peek4, poke2, poke3, poke4 )
+import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1, peek4, poke4 )
 import Graphics.Rendering.OpenGL.GL.QueryUtils (
    GetPName(GetDepthRange,GetViewport,GetMaxViewportDims,GetMatrixMode,
             GetModelviewMatrix,GetProjectionMatrix,
@@ -67,6 +66,8 @@
 import Graphics.Rendering.OpenGL.GL.StateVar (
    GettableStateVar, makeGettableStateVar, HasGetter(get), HasSetter(($=)),
    StateVar, makeStateVar )
+import Graphics.Rendering.OpenGL.GL.Tensor (
+   Vector1(..), Vector2(..), Vector3(..), Vector4(..) )
 import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
    marshalTextureUnit, unmarshalTextureUnit )
 import Graphics.Rendering.OpenGL.GL.VertexSpec ( TextureUnit )
@@ -206,28 +207,6 @@
                 (maybe recordInvalidValue glMatrixMode . marshalMatrixMode)
 
 foreign import CALLCONV unsafe "glMatrixMode" glMatrixMode :: GLenum -> IO ()
-
---------------------------------------------------------------------------------
-
-data Vector2 a = Vector2 !a !a
-   deriving ( Eq, Ord, Show )
-
-instance Storable a => Storable (Vector2 a) where
-   sizeOf    ~(Vector2 x _) = 2 * sizeOf x
-   alignment ~(Vector2 x _) = alignment x
-   peek                     = peek2 Vector2 . castPtr
-   poke ptr   (Vector2 x y) = poke2 (castPtr ptr) x y
-
---------------------------------------------------------------------------------
-
-data Vector3 a = Vector3 !a !a !a
-   deriving ( Eq, Ord, Show )
-
-instance Storable a => Storable (Vector3 a) where
-   sizeOf    ~(Vector3 x _ _) = 3 * sizeOf x
-   alignment ~(Vector3 x _ _) = alignment x
-   peek                       = peek3 Vector3 . castPtr
-   poke ptr   (Vector3 x y z) = poke3 (castPtr ptr) x y z
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/DataType.hs b/Graphics/Rendering/OpenGL/GL/DataType.hs
--- a/Graphics/Rendering/OpenGL/GL/DataType.hs
+++ b/Graphics/Rendering/OpenGL/GL/DataType.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.DataType
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -21,93 +21,106 @@
 
 --------------------------------------------------------------------------------
 
+-- basically table 3.2 (pixel data type parameter) plus a few additions
 data DataType =
-     Byte
-   | UnsignedByte
-   | Short
+     UnsignedByte
+   | Byte
    | UnsignedShort
-   | Int
+   | Short
    | UnsignedInt
+   | Int
+   | HalfFloat
    | Float
-   | TwoBytes
-   | ThreeBytes
-   | FourBytes
-   | Double
-   | Bitmap
    | UnsignedByte332
-   | UnsignedShort4444
-   | UnsignedShort5551
-   | UnsignedInt8888
-   | UnsignedInt1010102
    | UnsignedByte233Rev
    | UnsignedShort565
    | UnsignedShort565Rev
+   | UnsignedShort4444
    | UnsignedShort4444Rev
+   | UnsignedShort5551
    | UnsignedShort1555Rev
+   | UnsignedInt8888
    | UnsignedInt8888Rev
+   | UnsignedInt1010102
    | UnsignedInt2101010Rev
-   | UnsignedShort88
-   | UnsignedShort88Rev
    | UnsignedInt248
+   | UnsignedInt10f11f11fRev
+   | UnsignedInt5999Rev
+   | Float32UnsignedInt248Rev
+   | Bitmap                    -- pixel data, deprecated in 3.1
+   | UnsignedShort88           -- MESA_ycbcr_texture/APPLE_ycbcr_422
+   | UnsignedShort88Rev        -- MESA_ycbcr_texture/APPLE_ycbcr_422
+   | Double                    -- vertex arrays (EXT_vertex_array, now core)
+   | TwoBytes                  -- CallLists
+   | ThreeBytes                -- CallLists
+   | FourBytes                 -- CallLists
    deriving ( Eq, Ord, Show )
 
 marshalDataType :: DataType -> GLenum
 marshalDataType x = case x of
-   Byte -> 0x1400
    UnsignedByte -> 0x1401
-   Short -> 0x1402
+   Byte -> 0x1400
    UnsignedShort -> 0x1403
-   Int -> 0x1404
+   Short -> 0x1402
    UnsignedInt -> 0x1405
+   Int -> 0x1404
+   HalfFloat -> 0x140B
    Float -> 0x1406
-   TwoBytes -> 0x1407
-   ThreeBytes -> 0x1408
-   FourBytes -> 0x1409
-   Double -> 0x140a
-   Bitmap -> 0x1a00
    UnsignedByte332 -> 0x8032
-   UnsignedShort4444 -> 0x8033
-   UnsignedShort5551 -> 0x8034
-   UnsignedInt8888 -> 0x8035
-   UnsignedInt1010102 -> 0x8036
    UnsignedByte233Rev -> 0x8362
    UnsignedShort565 -> 0x8363
    UnsignedShort565Rev -> 0x8364
+   UnsignedShort4444 -> 0x8033
    UnsignedShort4444Rev -> 0x8365
+   UnsignedShort5551 -> 0x8034
    UnsignedShort1555Rev -> 0x8366
+   UnsignedInt8888 -> 0x8035
    UnsignedInt8888Rev -> 0x8367
+   UnsignedInt1010102 -> 0x8036
    UnsignedInt2101010Rev -> 0x8368
+   UnsignedInt248 -> 0x84fa
+   UnsignedInt10f11f11fRev -> 0x8C3B
+   UnsignedInt5999Rev -> 0x8C3E
+   Float32UnsignedInt248Rev -> 0x8DAD
+   Bitmap -> 0x1a00
    UnsignedShort88 -> 0x85ba
    UnsignedShort88Rev -> 0x85bb
-   UnsignedInt248 -> 0x84fa
+   Double -> 0x140a
+   TwoBytes -> 0x1407
+   ThreeBytes -> 0x1408
+   FourBytes -> 0x1409
 
 unmarshalDataType :: GLenum -> DataType
 unmarshalDataType x
-   | x == 0x1400 = Byte
    | x == 0x1401 = UnsignedByte
-   | x == 0x1402 = Short
+   | x == 0x1400 = Byte
    | x == 0x1403 = UnsignedShort
-   | x == 0x1404 = Int
+   | x == 0x1402 = Short
    | x == 0x1405 = UnsignedInt
+   | x == 0x1404 = Int
+   | x == 0x140B = HalfFloat
    | x == 0x1406 = Float
-   | x == 0x1407 = TwoBytes
-   | x == 0x1408 = ThreeBytes
-   | x == 0x1409 = FourBytes
-   | x == 0x140a = Double
-   | x == 0x1a00 = Bitmap
    | x == 0x8032 = UnsignedByte332
-   | x == 0x8033 = UnsignedShort4444
-   | x == 0x8034 = UnsignedShort5551
-   | x == 0x8035 = UnsignedInt8888
-   | x == 0x8036 = UnsignedInt1010102
    | x == 0x8362 = UnsignedByte233Rev
    | x == 0x8363 = UnsignedShort565
    | x == 0x8364 = UnsignedShort565Rev
+   | x == 0x8033 = UnsignedShort4444
    | x == 0x8365 = UnsignedShort4444Rev
+   | x == 0x8034 = UnsignedShort5551
    | x == 0x8366 = UnsignedShort1555Rev
+   | x == 0x8035 = UnsignedInt8888
    | x == 0x8367 = UnsignedInt8888Rev
+   | x == 0x8036 = UnsignedInt1010102
    | x == 0x8368 = UnsignedInt2101010Rev
+   | x == 0x84fa = UnsignedInt248
+   | x == 0x8C3B = UnsignedInt10f11f11fRev
+   | x == 0x8C3E = UnsignedInt5999Rev
+   | x == 0x8DAD = Float32UnsignedInt248Rev
+   | x == 0x1a00 = Bitmap
    | x == 0x85ba = UnsignedShort88
    | x == 0x85bb = UnsignedShort88Rev
-   | x == 0x84fa = UnsignedInt248
+   | x == 0x140a = Double
+   | x == 0x1407 = TwoBytes
+   | x == 0x1408 = ThreeBytes
+   | x == 0x1409 = FourBytes
    | otherwise = error ("unmarshalDataType: illegal value " ++ show x)
diff --git a/Graphics/Rendering/OpenGL/GL/DisplayLists.hs b/Graphics/Rendering/OpenGL/GL/DisplayLists.hs
--- a/Graphics/Rendering/OpenGL/GL/DisplayLists.hs
+++ b/Graphics/Rendering/OpenGL/GL/DisplayLists.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.DisplayLists
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Domain.hs b/Graphics/Rendering/OpenGL/GL/Domain.hs
--- a/Graphics/Rendering/OpenGL/GL/Domain.hs
+++ b/Graphics/Rendering/OpenGL/GL/Domain.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Domain
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs b/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs
--- a/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs
+++ b/Graphics/Rendering/OpenGL/GL/EdgeFlag.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.EdgeFlag
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Evaluators.hs b/Graphics/Rendering/OpenGL/GL/Evaluators.hs
--- a/Graphics/Rendering/OpenGL/GL/Evaluators.hs
+++ b/Graphics/Rendering/OpenGL/GL/Evaluators.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Evaluators
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Exception.hs b/Graphics/Rendering/OpenGL/GL/Exception.hs
--- a/Graphics/Rendering/OpenGL/GL/Exception.hs
+++ b/Graphics/Rendering/OpenGL/GL/Exception.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Exception
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Extensions.hs b/Graphics/Rendering/OpenGL/GL/Extensions.hs
--- a/Graphics/Rendering/OpenGL/GL/Extensions.hs
+++ b/Graphics/Rendering/OpenGL/GL/Extensions.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Extensions
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Face.hs b/Graphics/Rendering/OpenGL/GL/Face.hs
--- a/Graphics/Rendering/OpenGL/GL/Face.hs
+++ b/Graphics/Rendering/OpenGL/GL/Face.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Face
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Feedback.hs b/Graphics/Rendering/OpenGL/GL/Feedback.hs
--- a/Graphics/Rendering/OpenGL/GL/Feedback.hs
+++ b/Graphics/Rendering/OpenGL/GL/Feedback.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Feedback
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/FlushFinish.hs b/Graphics/Rendering/OpenGL/GL/FlushFinish.hs
--- a/Graphics/Rendering/OpenGL/GL/FlushFinish.hs
+++ b/Graphics/Rendering/OpenGL/GL/FlushFinish.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.FlushFinish
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Fog.hs b/Graphics/Rendering/OpenGL/GL/Fog.hs
--- a/Graphics/Rendering/OpenGL/GL/Fog.hs
+++ b/Graphics/Rendering/OpenGL/GL/Fog.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Fog
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Framebuffer.hs b/Graphics/Rendering/OpenGL/GL/Framebuffer.hs
--- a/Graphics/Rendering/OpenGL/GL/Framebuffer.hs
+++ b/Graphics/Rendering/OpenGL/GL/Framebuffer.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Framebuffer
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -16,7 +16,7 @@
 module Graphics.Rendering.OpenGL.GL.Framebuffer (
    -- * Querying the Buffer Configuration
    auxBuffers, doubleBuffer, stereoBuffer,
-   rgbaBits, stencilBits, depthBits, accumBits,
+   rgbaBits, stencilBits, depthBits, accumBits, rgbaSignedComponents,
 
    -- * Selecting a Buffer for Writing
    BufferMode(..), drawBuffer, drawBuffers, maxDrawBuffers,
@@ -58,12 +58,13 @@
    GetPName(GetAuxBuffers,GetDoublebuffer,GetStereo,GetRedBits,GetGreenBits,
             GetBlueBits,GetAlphaBits,GetStencilBits,GetDepthBits,
             GetAccumRedBits,GetAccumGreenBits,GetAccumBlueBits,
-            GetAccumAlphaBits,GetDrawBuffer,GetIndexWritemask,GetColorWritemask,
-            GetDepthWritemask,GetStencilWritemask,GetColorClearValue,
-            GetIndexClearValue,GetDepthClearValue,GetStencilClearValue,
-            GetAccumClearValue,GetMaxDrawBuffers,GetDrawBufferN),
-   getInteger1, getBoolean1, getBoolean4, getEnum1, getSizei1, getFloat1,
-   getFloat4, getDouble1 )
+            GetAccumAlphaBits,GetRGBASignedComponents,GetDrawBuffer,
+            GetIndexWritemask,GetColorWritemask,GetDepthWritemask,
+            GetStencilWritemask,GetColorClearValue,GetIndexClearValue,
+            GetDepthClearValue,GetStencilClearValue,GetAccumClearValue,
+            GetMaxDrawBuffers,GetDrawBufferN),
+   getInteger1, getInteger4, getBoolean1, getBoolean4, getEnum1, getSizei1,
+   getFloat1, getFloat4, getDouble1 )
 import Graphics.Rendering.OpenGL.GL.StateVar (
    HasGetter(get), GettableStateVar, makeGettableStateVar,
    SettableStateVar, makeSettableStateVar,
@@ -116,6 +117,15 @@
                     (getSizei1 id GetAccumGreenBits)
                     (getSizei1 id GetAccumBlueBits)
                     (getSizei1 id GetAccumAlphaBits)
+
+rgbaSignedComponents :: GettableStateVar (Color4 Bool)
+rgbaSignedComponents =
+   makeGettableStateVar $
+      getInteger4 (\r g b a -> Color4 (unmarshalGLboolean r)
+                                      (unmarshalGLboolean g)
+                                      (unmarshalGLboolean b)
+                                      (unmarshalGLboolean a))
+                  GetRGBASignedComponents
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/GLboolean.hs b/Graphics/Rendering/OpenGL/GL/GLboolean.hs
--- a/Graphics/Rendering/OpenGL/GL/GLboolean.hs
+++ b/Graphics/Rendering/OpenGL/GL/GLboolean.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.GLboolean
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Hints.hs b/Graphics/Rendering/OpenGL/GL/Hints.hs
--- a/Graphics/Rendering/OpenGL/GL/Hints.hs
+++ b/Graphics/Rendering/OpenGL/GL/Hints.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Hints
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/IOState.hs b/Graphics/Rendering/OpenGL/GL/IOState.hs
--- a/Graphics/Rendering/OpenGL/GL/IOState.hs
+++ b/Graphics/Rendering/OpenGL/GL/IOState.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.IOState
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/LineSegments.hs b/Graphics/Rendering/OpenGL/GL/LineSegments.hs
--- a/Graphics/Rendering/OpenGL/GL/LineSegments.hs
+++ b/Graphics/Rendering/OpenGL/GL/LineSegments.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.LineSegments
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PeekPoke.hs b/Graphics/Rendering/OpenGL/GL/PeekPoke.hs
--- a/Graphics/Rendering/OpenGL/GL/PeekPoke.hs
+++ b/Graphics/Rendering/OpenGL/GL/PeekPoke.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PeekPoke
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -15,7 +15,8 @@
 
 module Graphics.Rendering.OpenGL.GL.PeekPoke (
    poke1, poke2, poke3, poke4,
-   peek1, peek2, peek3, peek4
+   peek1, peek2, peek3, peek4,
+   peek1M, peek2M, peek3M, peek4M
 ) where
 
 import Foreign.Ptr ( Ptr )
@@ -63,24 +64,44 @@
 
 {-# INLINE peek2 #-}
 peek2 :: Storable a => (a -> a -> b) -> Ptr a -> IO b
-peek2 f ptr = do
-   x <- peekElemOff ptr 0
-   y <- peekElemOff ptr 1
-   return $ f x y
+peek2 f = peek2M $ \x y -> return (f x y)
 
 {-# INLINE peek3 #-}
 peek3 :: Storable a => (a -> a -> a -> b) -> Ptr a -> IO b
-peek3 f ptr = do
+peek3 f = peek3M $ \x y z -> return (f x y z)
+
+{-# INLINE peek4 #-}
+peek4 :: Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
+peek4 f = peek4M $ \x y z w -> return (f x y z w)
+
+--------------------------------------------------------------------------------
+
+{-# INLINE peek1M #-}
+peek1M :: Storable a => (a -> IO b) -> Ptr a -> IO b
+peek1M f ptr = do
    x <- peekElemOff ptr 0
+   f x
+
+{-# INLINE peek2M #-}
+peek2M :: Storable a => (a -> a -> IO b) -> Ptr a -> IO b
+peek2M f ptr = do
+   x <- peekElemOff ptr 0
    y <- peekElemOff ptr 1
+   f x y
+
+{-# INLINE peek3M #-}
+peek3M :: Storable a => (a -> a -> a -> IO b) -> Ptr a -> IO b
+peek3M f ptr = do
+   x <- peekElemOff ptr 0
+   y <- peekElemOff ptr 1
    z <- peekElemOff ptr 2
-   return $ f x y z
+   f x y z
 
-{-# INLINE peek4 #-}
-peek4 :: Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
-peek4 f ptr = do
+{-# INLINE peek4M #-}
+peek4M :: Storable a => (a -> a -> a -> a -> IO b) -> Ptr a -> IO b
+peek4M f ptr = do
    x <- peekElemOff ptr 0
    y <- peekElemOff ptr 1
    z <- peekElemOff ptr 2
    w <- peekElemOff ptr 3
-   return $ f x y z w
+   f x y z w
diff --git a/Graphics/Rendering/OpenGL/GL/PerFragment.hs b/Graphics/Rendering/OpenGL/GL/PerFragment.hs
--- a/Graphics/Rendering/OpenGL/GL/PerFragment.hs
+++ b/Graphics/Rendering/OpenGL/GL/PerFragment.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PerFragment
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelData.hs b/Graphics/Rendering/OpenGL/GL/PixelData.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelData.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelData.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelData
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelFormat.hs b/Graphics/Rendering/OpenGL/GL/PixelFormat.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelFormat.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelFormat.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelFormat
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/ColorTable.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Convolution.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.Convolution
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Histogram.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.Histogram
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Minmax.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.Minmax
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelMap.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelMap
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelStorage.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelStorage
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/PixelTransfer.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelTransfer
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Rasterization.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Reset.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs
--- a/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs
+++ b/Graphics/Rendering/OpenGL/GL/PixelRectangles/Sink.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PointParameter.hs b/Graphics/Rendering/OpenGL/GL/PointParameter.hs
--- a/Graphics/Rendering/OpenGL/GL/PointParameter.hs
+++ b/Graphics/Rendering/OpenGL/GL/PointParameter.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PointParameter
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Points.hs b/Graphics/Rendering/OpenGL/GL/Points.hs
--- a/Graphics/Rendering/OpenGL/GL/Points.hs
+++ b/Graphics/Rendering/OpenGL/GL/Points.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Points
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PolygonMode.hs b/Graphics/Rendering/OpenGL/GL/PolygonMode.hs
--- a/Graphics/Rendering/OpenGL/GL/PolygonMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/PolygonMode.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PolygonMode
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Polygons.hs b/Graphics/Rendering/OpenGL/GL/Polygons.hs
--- a/Graphics/Rendering/OpenGL/GL/Polygons.hs
+++ b/Graphics/Rendering/OpenGL/GL/Polygons.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Polygons
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs b/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
--- a/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.PrimitiveMode
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/QueryUtils.hs b/Graphics/Rendering/OpenGL/GL/QueryUtils.hs
--- a/Graphics/Rendering/OpenGL/GL/QueryUtils.hs
+++ b/Graphics/Rendering/OpenGL/GL/QueryUtils.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.QueryUtils
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -23,19 +23,30 @@
    getSizei1,
    getFloat1, getFloat2, getFloat3, getFloat4, getFloatv,
    getDouble1, getDouble2, getDouble4, getDoublev,
-   maybeNullPtr
+   maybeNullPtr,
+   AttribLocation(..), GetVertexAttribPName(..),
+   getVertexAttribInteger1, getVertexAttribEnum1, getVertexAttribBoolean1,
+   getVertexAttribFloat4, getVertexAttribIInteger4, getVertexAttribIuInteger4, 
+   GetVertexAttribPointerPName(..), getVertexAttribPointer
 ) where
 
 import Foreign.Marshal.Alloc ( alloca )
 import Foreign.Marshal.Array ( allocaArray )
 import Foreign.Ptr ( Ptr, nullPtr )
+import Foreign.Storable ( Storable(peek) )
 import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLsizei, GLfloat, GLdouble )
+   GLboolean, GLenum, GLint, GLsizei, GLuint, GLfloat, GLdouble )
+import Graphics.Rendering.OpenGL.GL.Extensions (
+   FunPtr, unsafePerformIO, Invoker, getProcAddress )
 import Graphics.Rendering.OpenGL.GL.PeekPoke ( peek1, peek2, peek3, peek4 )
 import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
 
 --------------------------------------------------------------------------------
 
+#include "HsOpenGLExt.h"
+
+--------------------------------------------------------------------------------
+
 data GetPName =
      GetCurrentColor
    | GetCurrentIndex
@@ -357,6 +368,7 @@
    | GetMaxTextureUnits
    | GetTextureCubeMap
    | GetMaxCubeMapTextureSize
+   | GetMaxRectangleTextureSize
    | GetNumCompressedTextureFormats
    | GetCompressedTextureFormats
    | GetMaxVertexUnits
@@ -414,8 +426,10 @@
    | GetPixelPackBufferBinding
    | GetPixelUnpackBufferBinding
    | GetDrawBufferN GLsizei
+   | GetRGBASignedComponents
+   | GetCopyReadBuffer
+   | GetCopyWriteBuffer
    -- GetWeightArrayBufferBinding
-   -- GetVertexAttribArrayBufferBinding
 
 marshalGetPName :: GetPName -> Maybe GLenum
 marshalGetPName x = case x of
@@ -739,6 +753,7 @@
    GetMaxTextureUnits -> Just 0x84e2
    GetTextureCubeMap -> Just 0x8513
    GetMaxCubeMapTextureSize -> Just 0x851c
+   GetMaxRectangleTextureSize -> Just 0x84F8
    GetNumCompressedTextureFormats -> Just 0x86a2
    GetCompressedTextureFormats -> Just 0x86a3
    GetMaxVertexUnits -> Just 0x86a4
@@ -796,8 +811,10 @@
    GetPixelPackBufferBinding -> Just 0x88ed
    GetPixelUnpackBufferBinding -> Just 0x88EF
    GetDrawBufferN i -> drawBufferIndexToEnum i
+   GetRGBASignedComponents -> Just 0x8C3C
+   GetCopyReadBuffer -> Just 0x8F36
+   GetCopyWriteBuffer -> Just 0x8F37
    -- GetWeightArrayBufferBinding -> Just 0x889e
-   -- GetVertexAttribArrayBufferBinding -> Just 0x889f
 
 --------------------------------------------------------------------------------
 
@@ -956,3 +973,84 @@
 maybeNullPtr :: b -> (Ptr a -> b) -> Ptr a -> b
 maybeNullPtr n f ptr | ptr == nullPtr = n
                      | otherwise      = f ptr
+--------------------------------------------------------------------------------
+
+newtype AttribLocation = AttribLocation GLuint
+   deriving ( Eq, Ord, Show )
+
+--------------------------------------------------------------------------------
+
+data GetVertexAttribPName =
+     GetVertexAttribArrayEnabled
+   | GetVertexAttribArraySize
+   | GetVertexAttribArrayStride
+   | GetVertexAttribArrayType
+   | GetVertexAttribArrayNormalized
+   | GetCurrentVertexAttrib
+   | GetVertexAttribArrayBufferBinding
+   | GetVertexAttribArrayInteger
+
+marshalGetVertexAttribPName :: GetVertexAttribPName -> GLenum
+marshalGetVertexAttribPName x = case x of
+   GetVertexAttribArrayEnabled -> 0x8622
+   GetVertexAttribArraySize -> 0x8623
+   GetVertexAttribArrayStride -> 0x8624
+   GetVertexAttribArrayType -> 0x8625
+   GetVertexAttribArrayNormalized -> 0x886A
+   GetCurrentVertexAttrib -> 0x8626
+   GetVertexAttribArrayBufferBinding -> 0x889F
+   GetVertexAttribArrayInteger -> 0x88FD
+
+--------------------------------------------------------------------------------
+
+getVertexAttribInteger1 :: (GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
+getVertexAttribInteger1 f location n = alloca $ \buf -> do
+   glGetVertexAttribivARB location (marshalGetVertexAttribPName n) buf
+   peek1 f buf
+
+getVertexAttribEnum1 :: (GLenum -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
+getVertexAttribEnum1 f = getVertexAttribInteger1 (f . fromIntegral)
+
+getVertexAttribBoolean1 :: (GLboolean -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
+getVertexAttribBoolean1 f = getVertexAttribInteger1 (f . fromIntegral)
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glGetVertexAttribivARB,AttribLocation -> GLenum -> Ptr GLint -> IO ())
+
+getVertexAttribFloat4 :: (GLfloat -> GLfloat -> GLfloat -> GLfloat -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
+getVertexAttribFloat4 f location n = alloca $ \buf -> do
+   glGetVertexAttribfvARB location (marshalGetVertexAttribPName n) buf
+   peek4 f buf
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glGetVertexAttribfvARB,AttribLocation -> GLenum -> Ptr GLfloat -> IO ())
+
+getVertexAttribIInteger4 :: (GLint -> GLint -> GLint -> GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
+getVertexAttribIInteger4 f location n = alloca $ \buf -> do
+   glGetVertexAttribIivARB location (marshalGetVertexAttribPName n) buf
+   peek4 f buf
+
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glGetVertexAttribIivARB,AttribLocation -> GLenum -> Ptr GLint -> IO ())
+
+getVertexAttribIuInteger4 :: (GLuint -> GLuint -> GLuint -> GLuint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
+getVertexAttribIuInteger4 f location n = alloca $ \buf -> do
+   glGetVertexAttribIuivARB location (marshalGetVertexAttribPName n) buf
+   peek4 f buf
+
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glGetVertexAttribIuivARB,AttribLocation -> GLenum -> Ptr GLuint -> IO ())
+
+--------------------------------------------------------------------------------
+
+data GetVertexAttribPointerPName =
+   VertexAttribArrayPointer
+
+marshalGetVertexAttribPointerPName :: GetVertexAttribPointerPName -> GLenum
+marshalGetVertexAttribPointerPName x = case x of
+   VertexAttribArrayPointer -> 0x8645
+
+--------------------------------------------------------------------------------
+
+getVertexAttribPointer :: AttribLocation -> GetVertexAttribPointerPName -> IO (Ptr a)
+getVertexAttribPointer location n = alloca $ \buf -> do
+   glGetVertexAttribPointervARB location (marshalGetVertexAttribPointerPName n) buf
+   peek buf
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glGetVertexAttribPointervARB,AttribLocation -> GLenum -> Ptr (Ptr a) -> IO ())
diff --git a/Graphics/Rendering/OpenGL/GL/RasterPos.hs b/Graphics/Rendering/OpenGL/GL/RasterPos.hs
--- a/Graphics/Rendering/OpenGL/GL/RasterPos.hs
+++ b/Graphics/Rendering/OpenGL/GL/RasterPos.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.RasterPos
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs b/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs
--- a/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs
+++ b/Graphics/Rendering/OpenGL/GL/ReadCopyPixels.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.ReadCopyPixels
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Rectangles.hs b/Graphics/Rendering/OpenGL/GL/Rectangles.hs
--- a/Graphics/Rendering/OpenGL/GL/Rectangles.hs
+++ b/Graphics/Rendering/OpenGL/GL/Rectangles.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Rectangles
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/RenderMode.hs b/Graphics/Rendering/OpenGL/GL/RenderMode.hs
--- a/Graphics/Rendering/OpenGL/GL/RenderMode.hs
+++ b/Graphics/Rendering/OpenGL/GL/RenderMode.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.RenderMode
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/SavingState.hs b/Graphics/Rendering/OpenGL/GL/SavingState.hs
--- a/Graphics/Rendering/OpenGL/GL/SavingState.hs
+++ b/Graphics/Rendering/OpenGL/GL/SavingState.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.SavingState
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Selection.hs b/Graphics/Rendering/OpenGL/GL/Selection.hs
--- a/Graphics/Rendering/OpenGL/GL/Selection.hs
+++ b/Graphics/Rendering/OpenGL/GL/Selection.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Selection
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Shaders.hs b/Graphics/Rendering/OpenGL/GL/Shaders.hs
--- a/Graphics/Rendering/OpenGL/GL/Shaders.hs
+++ b/Graphics/Rendering/OpenGL/GL/Shaders.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Shaders
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -39,6 +39,7 @@
 import Control.Monad.Fix ( MonadFix(..) )
 import Data.Int
 import Data.List ( genericLength, (\\) )
+import Data.Word
 import Foreign.C.String ( peekCAStringLen, withCAStringLen, withCAString )
 import Foreign.Marshal.Alloc ( alloca, allocaBytes )
 import Foreign.Marshal.Array ( allocaArray, withArray, peekArray )
@@ -410,28 +411,58 @@
 
 --------------------------------------------------------------------------------
 
+-- Table 2.9 of the OpenGL 3.1 spec: OpenGL Shading Language type tokens
 data VariableType =
      Float'
    | FloatVec2
    | FloatVec3
    | FloatVec4
-   | FloatMat2
-   | FloatMat3
-   | FloatMat4
    | Int'
    | IntVec2
    | IntVec3
    | IntVec4
+   | UnsignedInt'
+   | UnsignedIntVec2
+   | UnsignedIntVec3
+   | UnsignedIntVec4
    | Bool
    | BoolVec2
    | BoolVec3
    | BoolVec4
+   | FloatMat2
+   | FloatMat3
+   | FloatMat4
+   | FloatMat2x3
+   | FloatMat2x4
+   | FloatMat3x2
+   | FloatMat3x4
+   | FloatMat4x2
+   | FloatMat4x3
    | Sampler1D
    | Sampler2D
    | Sampler3D
    | SamplerCube
    | Sampler1DShadow
    | Sampler2DShadow
+   | Sampler1DArray
+   | Sampler2DArray
+   | Sampler1DArrayShadow
+   | Sampler2DArrayShadow
+   | SamplerCubeShadow
+   | Sampler2DRect
+   | Sampler2DRectShadow
+   | IntSampler1D
+   | IntSampler2D
+   | IntSampler3D
+   | IntSamplerCube
+   | IntSampler1DArray
+   | IntSampler2DArray
+   | UnsignedIntSampler1D
+   | UnsignedIntSampler2D
+   | UnsignedIntSampler3D
+   | UnsignedIntSamplerCube
+   | UnsignedIntSampler1DArray
+   | UnsignedIntSampler2DArray
    deriving ( Eq, Ord, Show )
 
 unmarshalVariableType :: GLenum -> VariableType
@@ -440,23 +471,52 @@
    | x == 0x8B50 = FloatVec2
    | x == 0x8B51 = FloatVec3
    | x == 0x8B52 = FloatVec4
-   | x == 0x8B5A = FloatMat2
-   | x == 0x8B5B = FloatMat3
-   | x == 0x8B5C = FloatMat4
    | x == 0x1404 = Int'
    | x == 0x8B53 = IntVec2
    | x == 0x8B54 = IntVec3
    | x == 0x8B55 = IntVec4
+   | x == 0x1405 = UnsignedInt'
+   | x == 0x8DC6 = UnsignedIntVec2
+   | x == 0x8DC7 = UnsignedIntVec3
+   | x == 0x8DC8 = UnsignedIntVec4
    | x == 0x8B56 = Bool
    | x == 0x8B57 = BoolVec2
    | x == 0x8B58 = BoolVec3
    | x == 0x8B59 = BoolVec4
+   | x == 0x8B5A = FloatMat2
+   | x == 0x8B5B = FloatMat3
+   | x == 0x8B5C = FloatMat4
+   | x == 0x8B65 = FloatMat2x3
+   | x == 0x8B66 = FloatMat2x4
+   | x == 0x8B67 = FloatMat3x2
+   | x == 0x8B68 = FloatMat3x4
+   | x == 0x8B69 = FloatMat4x2
+   | x == 0x8B6A = FloatMat4x3
    | x == 0x8B5D = Sampler1D
    | x == 0x8B5E = Sampler2D
    | x == 0x8B5F = Sampler3D
    | x == 0x8B60 = SamplerCube
    | x == 0x8B61 = Sampler1DShadow
    | x == 0x8B62 = Sampler2DShadow
+   | x == 0x8DC0 = Sampler1DArray
+   | x == 0x8DC1 = Sampler2DArray
+   | x == 0x8DC3 = Sampler1DArrayShadow
+   | x == 0x8DC4 = Sampler2DArrayShadow
+   | x == 0x8DC5 = SamplerCubeShadow
+   | x == 0x8B63 = Sampler2DRect
+   | x == 0x8B64 = Sampler2DRectShadow
+   | x == 0x8DC9 = IntSampler1D
+   | x == 0x8DCA = IntSampler2D
+   | x == 0x8DCB = IntSampler3D
+   | x == 0x8DCC = IntSamplerCube
+   | x == 0x8DCE = IntSampler1DArray
+   | x == 0x8DCF = IntSampler2DArray
+   | x == 0x8DD1 = UnsignedIntSampler1D
+   | x == 0x8DD2 = UnsignedIntSampler2D
+   | x == 0x8DD3 = UnsignedIntSampler3D
+   | x == 0x8DD4 = UnsignedIntSamplerCube
+   | x == 0x8DD6 = UnsignedIntSampler1DArray
+   | x == 0x8DD7 = UnsignedIntSampler2DArray
    | otherwise = error ("unmarshalVariableType: illegal value " ++ show x)
 
 --------------------------------------------------------------------------------
@@ -548,6 +608,33 @@
    uniform2v = glUniform2iv
    uniform3v = glUniform3iv
    uniform4v = glUniform4iv
+
+--------------------------------------------------------------------------------
+
+EXTENSION_ENTRY("OpenGL 2.0",glUniform1ui,UniformLocation -> GLuint -> IO ())
+EXTENSION_ENTRY("OpenGL 2.0",glUniform2ui,UniformLocation -> GLuint -> GLuint -> IO ())
+EXTENSION_ENTRY("OpenGL 2.0",glUniform3ui,UniformLocation -> GLuint -> GLuint -> GLuint -> IO ())
+EXTENSION_ENTRY("OpenGL 2.0",glUniform4ui,UniformLocation -> GLuint -> GLuint -> GLuint -> GLuint -> IO ())
+
+EXTENSION_ENTRY("OpenGL 2.0",glGetUniformuiv,Program -> UniformLocation -> Ptr GLuint -> IO ())
+
+EXTENSION_ENTRY("OpenGL 2.0",glUniform1uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("OpenGL 2.0",glUniform2uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("OpenGL 2.0",glUniform3uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("OpenGL 2.0",glUniform4uiv,UniformLocation -> GLsizei -> Ptr GLuint -> IO ())
+
+instance UniformComponent GLuint_ where
+   uniform1 = glUniform1ui
+   uniform2 = glUniform2ui
+   uniform3 = glUniform3ui
+   uniform4 = glUniform4ui
+
+   getUniform program location = glGetUniformuiv program location . castPtr
+
+   uniform1v = glUniform1uiv
+   uniform2v = glUniform2uiv
+   uniform3v = glUniform3uiv
+   uniform4v = glUniform4uiv
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GL/StateVar.hs b/Graphics/Rendering/OpenGL/GL/StateVar.hs
--- a/Graphics/Rendering/OpenGL/GL/StateVar.hs
+++ b/Graphics/Rendering/OpenGL/GL/StateVar.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.StateVar
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/StringQueries.hs b/Graphics/Rendering/OpenGL/GL/StringQueries.hs
--- a/Graphics/Rendering/OpenGL/GL/StringQueries.hs
+++ b/Graphics/Rendering/OpenGL/GL/StringQueries.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.StringQueries
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Tensor.hs b/Graphics/Rendering/OpenGL/GL/Tensor.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/Rendering/OpenGL/GL/Tensor.hs
@@ -0,0 +1,327 @@
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.Rendering.OpenGL.GL.Tensor
+-- Copyright   :  (c) Sven Panne 2002-2009
+-- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- This is a purely internal module for points, vectors and matrices.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.Rendering.OpenGL.GL.Tensor (
+   Vertex1(..), Vertex2(..), Vertex3(..), Vertex4(..),
+   Vector1(..), Vector2(..), Vector3(..), Vector4(..)
+) where
+
+import Control.Applicative ( Applicative(..) )
+import Control.Monad ( ap )
+import Data.Foldable ( Foldable(..) )
+import Data.Ix ( Ix )
+import Data.Traversable ( Traversable(..) )
+import Data.Typeable (
+   Typeable(..), mkTyCon, mkTyConApp, Typeable1(..), typeOfDefault )
+import Foreign.Ptr ( castPtr )
+import Foreign.Storable ( Storable(..) )
+import Graphics.Rendering.OpenGL.GL.PeekPoke (
+   poke1, poke2, poke3, poke4, peek1, peek2, peek3, peek4 )
+
+--------------------------------------------------------------------------------
+
+-- | A vertex with /y/=0, /z/=0 and /w/=1.
+newtype Vertex1 a = Vertex1 a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vertex1 where
+   fmap f (Vertex1 x) = Vertex1 (f x)
+
+instance Applicative Vertex1 where
+   pure a = Vertex1 a
+   Vertex1 f <*> Vertex1 x = Vertex1 (f x)
+
+instance Foldable Vertex1 where
+   foldr f a (Vertex1 x) = x `f ` a
+   foldl f a (Vertex1 x) = a `f` x
+   foldr1 _ (Vertex1 x) = x
+   foldl1 _ (Vertex1 x) = x
+
+instance Traversable Vertex1 where
+   traverse f (Vertex1 x) = pure Vertex1 <*> f x
+   sequenceA (Vertex1 x) =  pure Vertex1 <*> x
+   mapM f (Vertex1 x) = return Vertex1 `ap` f x
+   sequence (Vertex1 x) = return Vertex1 `ap` x
+
+instance Typeable1 Vertex1 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vertex1") []
+
+instance Typeable a => Typeable (Vertex1 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vertex1 a) where
+   sizeOf    ~(Vertex1 s) = sizeOf s
+   alignment ~(Vertex1 s) = alignment s
+   peek = peek1 Vertex1 . castPtr
+   poke ptr (Vertex1 s) = poke1 (castPtr ptr) s
+
+--------------------------------------------------------------------------------
+
+-- | A vertex with /z/=0 and /w/=1.
+data Vertex2 a = Vertex2 !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vertex2 where
+   fmap f (Vertex2 x y) = Vertex2 (f x) (f y)
+
+instance Applicative Vertex2 where
+   pure a = Vertex2 a a
+   Vertex2 f g <*> Vertex2 x y = Vertex2 (f x) (g y)
+
+instance Foldable Vertex2 where
+   foldr f a (Vertex2 x y) = x `f ` (y `f` a)
+   foldl f a (Vertex2 x y) = (a `f` x) `f` y
+   foldr1 f (Vertex2 x y) = x `f` y
+   foldl1 f (Vertex2 x y) = x `f` y
+
+instance Traversable Vertex2 where
+   traverse f (Vertex2 x y) = pure Vertex2 <*> f x <*> f y
+   sequenceA (Vertex2 x y) =  pure Vertex2 <*> x <*> y
+   mapM f (Vertex2 x y) = return Vertex2 `ap` f x `ap` f y
+   sequence (Vertex2 x y) = return Vertex2 `ap` x `ap` y
+
+instance Typeable1 Vertex2 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vertex2") []
+
+instance Typeable a => Typeable (Vertex2 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vertex2 a) where
+   sizeOf ~(Vertex2 x _) = 2 * sizeOf x
+   alignment ~(Vertex2 x _) = alignment x
+   peek = peek2 Vertex2 . castPtr
+   poke ptr (Vertex2 x y) = poke2 (castPtr ptr) x y
+
+--------------------------------------------------------------------------------
+
+-- | A vertex with /w/=1.
+data Vertex3 a = Vertex3 !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vertex3 where
+   fmap f (Vertex3 x y z) = Vertex3 (f x) (f y) (f z)
+
+instance Applicative Vertex3 where
+   pure a = Vertex3 a a a
+   Vertex3 f g h <*> Vertex3 x y z = Vertex3 (f x) (g y) (h z)
+
+instance Foldable Vertex3 where
+   foldr f a (Vertex3 x y z) = x `f ` (y `f` (z `f` a))
+   foldl f a (Vertex3 x y z) = ((a `f` x) `f` y) `f` z
+   foldr1 f (Vertex3 x y z) = x `f` (y `f` z)
+   foldl1 f (Vertex3 x y z) = (x `f` y) `f` z
+
+instance Traversable Vertex3 where
+   traverse f (Vertex3 x y z) = pure Vertex3 <*> f x <*> f y <*> f z
+   sequenceA (Vertex3 x y z) =  pure Vertex3 <*> x <*> y <*> z
+   mapM f (Vertex3 x y z) = return Vertex3 `ap` f x `ap` f y `ap` f z
+   sequence (Vertex3 x y z) = return Vertex3 `ap` x `ap` y `ap` z
+
+instance Typeable1 Vertex3 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vertex3") []
+
+instance Typeable a => Typeable (Vertex3 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vertex3 a) where
+   sizeOf ~(Vertex3 x _ _) = 3 * sizeOf x
+   alignment ~(Vertex3 x _ _) = alignment x
+   peek = peek3 Vertex3 . castPtr
+   poke ptr (Vertex3 x y z) = poke3 (castPtr ptr) x y z
+
+--------------------------------------------------------------------------------
+
+-- | A fully-fledged four-dimensional vertex.
+data Vertex4 a = Vertex4 !a !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vertex4 where
+   fmap f (Vertex4 x y z w) = Vertex4 (f x) (f y) (f z) (f w)
+
+instance Applicative Vertex4 where
+   pure a = Vertex4 a a a a
+   Vertex4 f g h i <*> Vertex4 x y z w = Vertex4 (f x) (g y) (h z) (i w)
+
+instance Foldable Vertex4 where
+   foldr f a (Vertex4 x y z w) = x `f ` (y `f` (z `f` (w `f` a)))
+   foldl f a (Vertex4 x y z w) = (((a `f` x) `f` y) `f` z) `f` w
+   foldr1 f (Vertex4 x y z w) = x `f` (y `f` (z `f` w))
+   foldl1 f (Vertex4 x y z w) = ((x `f` y) `f` z) `f` w
+
+instance Traversable Vertex4 where
+   traverse f (Vertex4 x y z w) = pure Vertex4 <*> f x <*> f y <*> f z <*> f w
+   sequenceA (Vertex4 x y z w) =  pure Vertex4 <*> x <*> y <*> z <*> w
+   mapM f (Vertex4 x y z w) = return Vertex4 `ap` f x `ap` f y `ap` f z `ap` f w
+   sequence (Vertex4 x y z w) = return Vertex4 `ap` x `ap` y `ap` z `ap` w
+
+instance Typeable1 Vertex4 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vertex4") []
+
+instance Typeable a => Typeable (Vertex4 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vertex4 a) where
+   sizeOf ~(Vertex4 x _ _ _) = 4 * sizeOf x
+   alignment ~(Vertex4 x _ _ _) = alignment x
+   peek = peek4 Vertex4 . castPtr
+   poke ptr (Vertex4 x y z w) = poke4 (castPtr ptr) x y z w
+
+--------------------------------------------------------------------------------
+
+-- | A one-dimensional vector.
+newtype Vector1 a = Vector1 a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vector1 where
+   fmap f (Vector1 x) = Vector1 (f x)
+
+instance Applicative Vector1 where
+   pure a = Vector1 a
+   Vector1 f <*> Vector1 x = Vector1 (f x)
+
+instance Foldable Vector1 where
+   foldr f a (Vector1 x) = x `f ` a
+   foldl f a (Vector1 x) = a `f` x
+   foldr1 _ (Vector1 x) = x
+   foldl1 _ (Vector1 x) = x
+
+instance Traversable Vector1 where
+   traverse f (Vector1 x) = pure Vector1 <*> f x
+   sequenceA (Vector1 x) =  pure Vector1 <*> x
+   mapM f (Vector1 x) = return Vector1 `ap` f x
+   sequence (Vector1 x) = return Vector1 `ap` x
+
+instance Typeable1 Vector1 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vector1") []
+
+instance Typeable a => Typeable (Vector1 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vector1 a) where
+   sizeOf    ~(Vector1 s) = sizeOf s
+   alignment ~(Vector1 s) = alignment s
+   peek = peek1 Vector1 . castPtr
+   poke ptr (Vector1 s) = poke1 (castPtr ptr) s
+
+--------------------------------------------------------------------------------
+
+-- | A two-dimensional vector.
+data Vector2 a = Vector2 !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vector2 where
+   fmap f (Vector2 x y) = Vector2 (f x) (f y)
+
+instance Applicative Vector2 where
+   pure a = Vector2 a a
+   Vector2 f g <*> Vector2 x y = Vector2 (f x) (g y)
+
+instance Foldable Vector2 where
+   foldr f a (Vector2 x y) = x `f ` (y `f` a)
+   foldl f a (Vector2 x y) = (a `f` x) `f` y
+   foldr1 f (Vector2 x y) = x `f` y
+   foldl1 f (Vector2 x y) = x `f` y
+
+instance Traversable Vector2 where
+   traverse f (Vector2 x y) = pure Vector2 <*> f x <*> f y
+   sequenceA (Vector2 x y) =  pure Vector2 <*> x <*> y
+   mapM f (Vector2 x y) = return Vector2 `ap` f x `ap` f y
+   sequence (Vector2 x y) = return Vector2 `ap` x `ap` y
+
+instance Typeable1 Vector2 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vector2") []
+
+instance Typeable a => Typeable (Vector2 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vector2 a) where
+   sizeOf ~(Vector2 x _) = 2 * sizeOf x
+   alignment ~(Vector2 x _) = alignment x
+   peek = peek2 Vector2 . castPtr
+   poke ptr (Vector2 x y) = poke2 (castPtr ptr) x y
+
+--------------------------------------------------------------------------------
+
+-- | A three-dimensional vector.
+data Vector3 a = Vector3 !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vector3 where
+   fmap f (Vector3 x y z) = Vector3 (f x) (f y) (f z)
+
+instance Applicative Vector3 where
+   pure a = Vector3 a a a
+   Vector3 f g h <*> Vector3 x y z = Vector3 (f x) (g y) (h z)
+
+instance Foldable Vector3 where
+   foldr f a (Vector3 x y z) = x `f ` (y `f` (z `f` a))
+   foldl f a (Vector3 x y z) = ((a `f` x) `f` y) `f` z
+   foldr1 f (Vector3 x y z) = x `f` (y `f` z)
+   foldl1 f (Vector3 x y z) = (x `f` y) `f` z
+
+instance Traversable Vector3 where
+   traverse f (Vector3 x y z) = pure Vector3 <*> f x <*> f y <*> f z
+   sequenceA (Vector3 x y z) =  pure Vector3 <*> x <*> y <*> z
+   mapM f (Vector3 x y z) = return Vector3 `ap` f x `ap` f y `ap` f z
+   sequence (Vector3 x y z) = return Vector3 `ap` x `ap` y `ap` z
+
+instance Typeable1 Vector3 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vector3") []
+
+instance Typeable a => Typeable (Vector3 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vector3 a) where
+   sizeOf ~(Vector3 x _ _) = 3 * sizeOf x
+   alignment ~(Vector3 x _ _) = alignment x
+   peek = peek3 Vector3 . castPtr
+   poke ptr (Vector3 x y z) = poke3 (castPtr ptr) x y z
+
+--------------------------------------------------------------------------------
+
+-- | A four-dimensional vector.
+data Vector4 a = Vector4 !a !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Vector4 where
+   fmap f (Vector4 x y z w) = Vector4 (f x) (f y) (f z) (f w)
+
+instance Applicative Vector4 where
+   pure a = Vector4 a a a a
+   Vector4 f g h i <*> Vector4 x y z w = Vector4 (f x) (g y) (h z) (i w)
+
+instance Foldable Vector4 where
+   foldr f a (Vector4 x y z w) = x `f ` (y `f` (z `f` (w `f` a)))
+   foldl f a (Vector4 x y z w) = (((a `f` x) `f` y) `f` z) `f` w
+   foldr1 f (Vector4 x y z w) = x `f` (y `f` (z `f` w))
+   foldl1 f (Vector4 x y z w) = ((x `f` y) `f` z) `f` w
+
+instance Traversable Vector4 where
+   traverse f (Vector4 x y z w) = pure Vector4 <*> f x <*> f y <*> f z <*> f w
+   sequenceA (Vector4 x y z w) =  pure Vector4 <*> x <*> y <*> z <*> w
+   mapM f (Vector4 x y z w) = return Vector4 `ap` f x `ap` f y `ap` f z `ap` f w
+   sequence (Vector4 x y z w) = return Vector4 `ap` x `ap` y `ap` z `ap` w
+
+instance Typeable1 Vector4 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Vector4") []
+
+instance Typeable a => Typeable (Vector4 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Vector4 a) where
+   sizeOf ~(Vector4 x _ _ _) = 4 * sizeOf x
+   alignment ~(Vector4 x _ _ _) = alignment x
+   peek = peek4 Vector4 . castPtr
+   poke ptr (Vector4 x y z w) = poke4 (castPtr ptr) x y z w
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing.hs b/Graphics/Rendering/OpenGL/GL/Texturing.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Application.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Application
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -19,7 +19,8 @@
 
 import Graphics.Rendering.OpenGL.GL.BasicTypes ( Capability )
 import Graphics.Rendering.OpenGL.GL.Capability (
-   EnableCap(CapTexture1D,CapTexture2D,CapTexture3D,CapTextureCubeMap),
+   EnableCap(CapTexture1D,CapTexture2D,CapTexture3D,CapTextureCubeMap,
+             CapTextureRectangle),
    makeCapability )
 import Graphics.Rendering.OpenGL.GL.StateVar ( StateVar )
 import Graphics.Rendering.OpenGL.GL.Texturing.Specification (
@@ -37,4 +38,4 @@
     Texture2D -> CapTexture2D
     Texture3D -> CapTexture3D
     TextureCubeMap -> CapTextureCubeMap
-    TextureRectangle -> error "ToDo: TextureRectangle"
+    TextureRectangle -> CapTextureRectangle
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Environments.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Environments
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Objects.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Objects
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Parameters.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Parameters
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs b/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/PixelInternalFormat.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -83,6 +83,10 @@
    | CompressedSRGBAlpha
    | CompressedSLuminance
    | CompressedSLuminanceAlpha
+   | DepthComponent32f
+   | Depth32fStencil8
+   | RGB9E5
+   | R11fG11fB10f
    deriving ( Eq, Ord, Show )
 
 marshalPixelInternalFormat :: PixelInternalFormat -> GLint
@@ -147,6 +151,10 @@
    CompressedSRGBAlpha -> 0x8c49
    CompressedSLuminance -> 0x8c4a
    CompressedSLuminanceAlpha -> 0x8c4b
+   DepthComponent32f -> 0x8CAC
+   Depth32fStencil8 -> 0x8CAD
+   RGB9E5 -> 0x8C3D
+   R11fG11fB10f -> 0x8C3A
 
 -- *sigh* The OpenGL API is sometimes a bit creative in its usage of types...
 marshalPixelInternalFormat' :: PixelInternalFormat -> GLenum
@@ -214,6 +222,9 @@
    | x == 0x8c49 = CompressedSRGBAlpha
    | x == 0x8c4a = CompressedSLuminance
    | x == 0x8c4b = CompressedSLuminanceAlpha
+   | x == 0x8CAC = DepthComponent32f
+   | x == 0x8CAD = Depth32fStencil8
+   | x == 0x8C3D = RGB9E5
    -- legacy values
    | x == 1 = Luminance'
    | x == 2 = LuminanceAlpha'
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Queries.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Queries
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -14,9 +14,9 @@
 
 module Graphics.Rendering.OpenGL.GL.Texturing.Queries (
    TextureQuery, textureInternalFormat, textureSize1D, textureSize2D,
-   textureSize3D, textureBorder, textureRGBASizes, textureIntensitySize,
-   textureLuminanceSize, textureIndexSize, textureDepthBits,
-   textureCompressedImageSize, textureProxyOK
+   textureSize3D, textureBorder, textureRGBASizes, textureSharedSize,
+   textureIntensitySize, textureLuminanceSize, textureIndexSize,
+   textureDepthBits, textureCompressedImageSize, textureProxyOK
 ) where
 
 import Control.Monad ( liftM2, liftM3, liftM4 )
@@ -56,6 +56,7 @@
    | DepthBits
    | TextureCompressedImageSize
    | TextureCompressed
+   | TextureSharedSize
 
 marshalTexLevelParameter :: TexLevelParameter -> GLenum
 marshalTexLevelParameter x = case x of
@@ -74,6 +75,7 @@
    DepthBits -> 0x0D56
    TextureCompressedImageSize -> 0x86A0
    TextureCompressed -> 0x86A1
+   TextureSharedSize -> 0x8C3F
 
 --------------------------------------------------------------------------------
 
@@ -117,6 +119,11 @@
              (getTexLevelParameteri fromIntegral NoProxy t level TextureGreenSize)
              (getTexLevelParameteri fromIntegral NoProxy t level TextureBlueSize )
              (getTexLevelParameteri fromIntegral NoProxy t level TextureAlphaSize)
+
+textureSharedSize :: TextureQuery GLsizei
+textureSharedSize t level =
+   makeGettableStateVar $
+      getTexLevelParameteri fromIntegral NoProxy t level TextureSharedSize
 
 textureIntensitySize :: TextureQuery GLsizei
 textureIntensitySize t level =
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs b/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Specification
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -34,7 +34,10 @@
    CompressedPixelData(..),
    compressedTexImage1D, compressedTexImage2D, compressedTexImage3D,
    compressedTexSubImage1D, compressedTexSubImage2D, compressedTexSubImage3D,
-   getCompressedTexImage
+   getCompressedTexImage,
+
+  -- * Implementation-Dependent Limits
+  maxTextureSize
 ) where
 
 import Foreign.Marshal.Array ( peekArray, allocaArray )
@@ -49,7 +52,9 @@
 import Graphics.Rendering.OpenGL.GL.PixelRectangles (
    PixelInternalFormat, PixelData, Proxy(..) )
 import Graphics.Rendering.OpenGL.GL.QueryUtils (
-   GetPName(GetNumCompressedTextureFormats,GetCompressedTextureFormats),
+   GetPName(GetNumCompressedTextureFormats,GetCompressedTextureFormats,
+            GetMaxTextureSize,GetMax3DTextureSize,GetMaxCubeMapTextureSize,
+            GetMaxRectangleTextureSize),
    getInteger1, getIntegerv)
 import Graphics.Rendering.OpenGL.GL.StateVar (
    GettableStateVar, makeGettableStateVar )
@@ -307,3 +312,16 @@
       glCompressedTexSubImage3DARB (marshalTextureTarget Texture3D) level xOff yOff zOff w h d
 
 EXTENSION_ENTRY("GL_ARB_texture_compression or OpenGL 1.3",glCompressedTexSubImage3DARB,GLenum -> GLint -> GLint -> GLint -> GLint -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLsizei -> Ptr a -> IO ())
+
+--------------------------------------------------------------------------------
+
+maxTextureSize :: TextureTarget -> GettableStateVar GLsizei
+maxTextureSize = makeGettableStateVar . getInteger1 fromIntegral . textureTargetToMaxQuery
+
+textureTargetToMaxQuery :: TextureTarget -> GetPName
+textureTargetToMaxQuery x = case x of
+   Texture1D -> GetMaxTextureSize
+   Texture2D -> GetMaxTextureSize
+   Texture3D -> GetMax3DTextureSize
+   TextureCubeMap -> GetMaxCubeMapTextureSize
+   TextureRectangle -> GetMaxRectangleTextureSize
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs b/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/TexParameter.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.TexParameter
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs b/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/TextureTarget.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs b/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs
--- a/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs
+++ b/Graphics/Rendering/OpenGL/GL/Texturing/TextureUnit.hs
@@ -2,7 +2,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GL/VertexArrays.hs b/Graphics/Rendering/OpenGL/GL/VertexArrays.hs
--- a/Graphics/Rendering/OpenGL/GL/VertexArrays.hs
+++ b/Graphics/Rendering/OpenGL/GL/VertexArrays.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.VertexArrays
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -28,7 +28,10 @@
    ArrayIndex, NumArrayIndices, NumIndexBlocks,
    arrayElement, drawArrays, multiDrawArrays, drawElements, multiDrawElements,
    drawRangeElements, maxElementsVertices, maxElementsIndices, lockArrays,
-   primitiveRestartIndex
+   primitiveRestartIndex,
+
+   -- * Generic Vertex Attribute Arrays
+   vertexAttribPointer, vertexAttribArray
 ) where
 
 import Foreign.Marshal.Alloc ( alloca )
@@ -38,13 +41,15 @@
    EnableCap(CapVertexArray,CapNormalArray,CapColorArray,CapIndexArray,
              CapTextureCoordArray,CapEdgeFlagArray,CapFogCoordArray,
              CapSecondaryColorArray,CapMatrixIndexArray,CapPrimitiveRestart),
-   makeCapability )
+   makeCapability, unmarshalCapability )
 import Graphics.Rendering.OpenGL.GL.BasicTypes (
-   GLboolean, GLenum, GLint, GLuint, GLsizei, Capability(Enabled) )
+   GLboolean, GLenum, GLint, GLuint, GLsizei, Capability(Disabled,Enabled) )
 import Graphics.Rendering.OpenGL.GL.DataType (
    DataType(..), marshalDataType, unmarshalDataType )
 import Graphics.Rendering.OpenGL.GL.Extensions (
    FunPtr, unsafePerformIO, Invoker, getProcAddress )
+import Graphics.Rendering.OpenGL.GL.GLboolean (
+   marshalGLboolean, unmarshalGLboolean )
 import Graphics.Rendering.OpenGL.GL.QueryUtils (
    GetPName(GetVertexArraySize,GetVertexArrayType,GetVertexArrayStride,
             GetNormalArrayType,GetNormalArrayStride,GetColorArraySize,
@@ -57,7 +62,10 @@
             GetMaxElementsVertices,GetMaxElementsIndices,
             GetClientActiveTexture,GetArrayElementLockFirst,
             GetArrayElementLockCount,GetPrimitiveRestartIndex),
-   getInteger1, getEnum1, getSizei1 )
+   getInteger1, getEnum1, getSizei1, AttribLocation,
+   GetVertexAttribPName(..),
+   getVertexAttribInteger1, getVertexAttribEnum1, getVertexAttribBoolean1,
+   GetVertexAttribPointerPName(..), getVertexAttribPointer )
 import Graphics.Rendering.OpenGL.GL.PrimitiveMode ( marshalPrimitiveMode )
 import Graphics.Rendering.OpenGL.GL.BeginEnd ( PrimitiveMode )
 import Graphics.Rendering.OpenGL.GL.StateVar (
@@ -67,6 +75,7 @@
    TextureUnit, marshalTextureUnit, unmarshalTextureUnit )
 import Graphics.Rendering.OpenGL.GLU.ErrorsInternal (
    recordInvalidEnum, recordInvalidValue )
+import Graphics.Rendering.OpenGL.GL.VertexSpec ( IntegerHandling(..) )
 
 --------------------------------------------------------------------------------
 
@@ -307,13 +316,6 @@
 
 --------------------------------------------------------------------------------
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttribPointer,GLuint -> GLint -> GLenum -> GLboolean -> GLsizei -> Ptr a -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glDisableVertexAttribArray,GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glEnableVertexAttribArray,GLuint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glGetVertexAttribPointerv,GLuint -> GLenum -> Ptr (Ptr a) -> IO ())
-
---------------------------------------------------------------------------------
-
 data InterleavedArrays =
      V2f
    | V3f
@@ -363,7 +365,7 @@
    makeStateVar (getClientState arrayType) (setClientState arrayType)
 
 getClientState :: ClientArrayType -> IO Capability
-getClientState = get . makeCapability . clientArrayTypeToEnableCap
+getClientState arrayType = get . makeCapability . clientArrayTypeToEnableCap $ arrayType
 
 setClientState :: ClientArrayType -> Capability -> IO ()
 setClientState arrayType val =
@@ -525,3 +527,49 @@
 
 foreign import CALLCONV unsafe "glGetPointerv" glGetPointerv ::
    GLenum -> Ptr (Ptr a) -> IO ()
+
+--------------------------------------------------------------------------------
+
+vertexAttribPointer :: AttribLocation -> StateVar (IntegerHandling, VertexArrayDescriptor a)
+vertexAttribPointer location = undefined
+   makeStateVar (getVertexAttribPointer_ location) (setVertexAttribPointer location)
+
+getVertexAttribPointer_ :: AttribLocation -> IO (IntegerHandling, VertexArrayDescriptor a)
+getVertexAttribPointer_ location = do
+   i <- getVertexAttribBoolean1 unmarshalGLboolean location GetVertexAttribArrayInteger
+   h <- if i
+           then return KeepIntegral
+           else do f <- getVertexAttribBoolean1 unmarshalGLboolean location GetVertexAttribArrayNormalized
+                   return $ if f then ToNormalizedFloat else ToFloat
+   n <- getVertexAttribInteger1 id location GetVertexAttribArraySize
+   d <- getVertexAttribEnum1 unmarshalDataType location GetVertexAttribArrayType
+   s <- getVertexAttribInteger1 fromIntegral location GetVertexAttribArrayStride
+   p <- getVertexAttribPointer location VertexAttribArrayPointer
+   return (h, VertexArrayDescriptor n d s p)
+
+setVertexAttribPointer :: AttribLocation -> (IntegerHandling, VertexArrayDescriptor a) -> IO ()
+setVertexAttribPointer location (h, VertexArrayDescriptor n d s p) = case h of
+   ToFloat -> glVertexAttribPointerARB location n md (marshalGLboolean False) s p
+   ToNormalizedFloat -> glVertexAttribPointerARB location n md (marshalGLboolean True) s p
+   KeepIntegral -> glVertexAttribIPointer location n md s p
+  where md = marshalDataType d
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttribPointerARB,AttribLocation -> GLint -> GLenum -> GLboolean -> GLsizei -> Ptr a -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribIPointer,AttribLocation -> GLint -> GLenum -> GLsizei -> Ptr a -> IO ())
+
+--------------------------------------------------------------------------------
+
+vertexAttribArray :: AttribLocation -> StateVar Capability
+vertexAttribArray location =
+   makeStateVar (getVertexAttribArray location) (flip setVertexAttribArray location)
+
+getVertexAttribArray :: AttribLocation -> IO Capability
+getVertexAttribArray location =
+   getVertexAttribBoolean1 unmarshalCapability location GetVertexAttribArrayEnabled
+
+setVertexAttribArray :: Capability -> AttribLocation -> IO ()
+setVertexAttribArray Disabled = glDisableVertexAttribArrayARB
+setVertexAttribArray Enabled = glEnableVertexAttribArrayARB
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glDisableVertexAttribArrayARB,AttribLocation -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glEnableVertexAttribArrayARB,AttribLocation -> IO ())
diff --git a/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs b/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs
new file mode 100644
--- /dev/null
+++ b/Graphics/Rendering/OpenGL/GL/VertexAttributes.hs
@@ -0,0 +1,366 @@
+-- #hide
+--------------------------------------------------------------------------------
+-- |
+-- Module      :  Graphics.Rendering.OpenGL.GL.VertexAttributes
+-- Copyright   :  (c) Sven Panne 2002-2009
+-- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
+-- 
+-- Maintainer  :  sven.panne@aedion.de
+-- Stability   :  stable
+-- Portability :  portable
+--
+-- This is a purely internal module for auxiliary vertex attributes.
+--
+--------------------------------------------------------------------------------
+
+module Graphics.Rendering.OpenGL.GL.VertexAttributes (
+   TexCoord1(..), TexCoord2(..), TexCoord3(..), TexCoord4(..),
+   Normal3(..),
+   FogCoord1(..),
+   Color3(..), Color4(..),
+   Index1(..)
+) where
+
+import Control.Applicative ( Applicative(..) )
+import Control.Monad ( ap )
+import Data.Foldable ( Foldable(..) )
+import Data.Ix ( Ix )
+import Data.Traversable ( Traversable(..) )
+import Data.Typeable (
+   Typeable(..), mkTyCon, mkTyConApp, Typeable1(..), typeOfDefault )
+import Foreign.Ptr ( castPtr )
+import Foreign.Storable ( Storable(..) )
+import Graphics.Rendering.OpenGL.GL.PeekPoke (
+   peek1, poke2, poke3, poke4, poke1, peek2, peek3, peek4 )
+
+--------------------------------------------------------------------------------
+
+-- | Texture coordinates with /t/=0, /r/=0, and /q/=1.
+newtype TexCoord1 a = TexCoord1 a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor TexCoord1 where
+   fmap f (TexCoord1 x) = TexCoord1 (f x)
+
+instance Applicative TexCoord1 where
+   pure a = TexCoord1 a
+   TexCoord1 f <*> TexCoord1 x = TexCoord1 (f x)
+
+instance Foldable TexCoord1 where
+   foldr f a (TexCoord1 x) = x `f ` a
+   foldl f a (TexCoord1 x) = a `f` x
+   foldr1 _ (TexCoord1 x) = x
+   foldl1 _ (TexCoord1 x) = x
+
+instance Traversable TexCoord1 where
+   traverse f (TexCoord1 x) = pure TexCoord1 <*> f x
+   sequenceA (TexCoord1 x) =  pure TexCoord1 <*> x
+   mapM f (TexCoord1 x) = return TexCoord1 `ap` f x
+   sequence (TexCoord1 x) = return TexCoord1 `ap` x
+
+instance Typeable1 TexCoord1 where
+   typeOf1 _ = mkTyConApp (mkTyCon "TexCoord1") []
+
+instance Typeable a => Typeable (TexCoord1 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (TexCoord1 a) where
+   sizeOf    ~(TexCoord1 s) = sizeOf s
+   alignment ~(TexCoord1 s) = alignment s
+   peek = peek1 TexCoord1 . castPtr
+   poke ptr (TexCoord1 s) = poke1 (castPtr ptr) s
+
+--------------------------------------------------------------------------------
+
+-- | Texture coordinates with /r/=0 and /q/=1.
+data TexCoord2 a = TexCoord2 !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor TexCoord2 where
+   fmap f (TexCoord2 x y) = TexCoord2 (f x) (f y)
+
+instance Applicative TexCoord2 where
+   pure a = TexCoord2 a a
+   TexCoord2 f g <*> TexCoord2 x y = TexCoord2 (f x) (g y)
+
+instance Foldable TexCoord2 where
+   foldr f a (TexCoord2 x y) = x `f ` (y `f` a)
+   foldl f a (TexCoord2 x y) = (a `f` x) `f` y
+   foldr1 f (TexCoord2 x y) = x `f` y
+   foldl1 f (TexCoord2 x y) = x `f` y
+
+instance Traversable TexCoord2 where
+   traverse f (TexCoord2 x y) = pure TexCoord2 <*> f x <*> f y
+   sequenceA (TexCoord2 x y) =  pure TexCoord2 <*> x <*> y
+   mapM f (TexCoord2 x y) = return TexCoord2 `ap` f x `ap` f y
+   sequence (TexCoord2 x y) = return TexCoord2 `ap` x `ap` y
+
+instance Typeable1 TexCoord2 where
+   typeOf1 _ = mkTyConApp (mkTyCon "TexCoord2") []
+
+instance Typeable a => Typeable (TexCoord2 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (TexCoord2 a) where
+   sizeOf ~(TexCoord2 x _) = 2 * sizeOf x
+   alignment ~(TexCoord2 x _) = alignment x
+   peek = peek2 TexCoord2 . castPtr
+   poke ptr (TexCoord2 x y) = poke2 (castPtr ptr) x y
+
+--------------------------------------------------------------------------------
+
+-- | Texture coordinates with /q/=1.
+data TexCoord3 a = TexCoord3 !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor TexCoord3 where
+   fmap f (TexCoord3 x y z) = TexCoord3 (f x) (f y) (f z)
+
+instance Applicative TexCoord3 where
+   pure a = TexCoord3 a a a
+   TexCoord3 f g h <*> TexCoord3 x y z = TexCoord3 (f x) (g y) (h z)
+
+instance Foldable TexCoord3 where
+   foldr f a (TexCoord3 x y z) = x `f ` (y `f` (z `f` a))
+   foldl f a (TexCoord3 x y z) = ((a `f` x) `f` y) `f` z
+   foldr1 f (TexCoord3 x y z) = x `f` (y `f` z)
+   foldl1 f (TexCoord3 x y z) = (x `f` y) `f` z
+
+instance Traversable TexCoord3 where
+   traverse f (TexCoord3 x y z) = pure TexCoord3 <*> f x <*> f y <*> f z
+   sequenceA (TexCoord3 x y z) =  pure TexCoord3 <*> x <*> y <*> z
+   mapM f (TexCoord3 x y z) = return TexCoord3 `ap` f x `ap` f y `ap` f z
+   sequence (TexCoord3 x y z) = return TexCoord3 `ap` x `ap` y `ap` z
+
+instance Typeable1 TexCoord3 where
+   typeOf1 _ = mkTyConApp (mkTyCon "TexCoord3") []
+
+instance Typeable a => Typeable (TexCoord3 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (TexCoord3 a) where
+   sizeOf ~(TexCoord3 x _ _) = 3 * sizeOf x
+   alignment ~(TexCoord3 x _ _) = alignment x
+   peek = peek3 TexCoord3 . castPtr
+   poke ptr (TexCoord3 x y z) = poke3 (castPtr ptr) x y z
+
+--------------------------------------------------------------------------------
+
+-- | Fully-fledged four-dimensional texture coordinates.
+data TexCoord4 a = TexCoord4 !a !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor TexCoord4 where
+   fmap f (TexCoord4 x y z w) = TexCoord4 (f x) (f y) (f z) (f w)
+
+instance Applicative TexCoord4 where
+   pure a = TexCoord4 a a a a
+   TexCoord4 f g h i <*> TexCoord4 x y z w = TexCoord4 (f x) (g y) (h z) (i w)
+
+instance Foldable TexCoord4 where
+   foldr f a (TexCoord4 x y z w) = x `f ` (y `f` (z `f` (w `f` a)))
+   foldl f a (TexCoord4 x y z w) = (((a `f` x) `f` y) `f` z) `f` w
+   foldr1 f (TexCoord4 x y z w) = x `f` (y `f` (z `f` w))
+   foldl1 f (TexCoord4 x y z w) = ((x `f` y) `f` z) `f` w
+
+instance Traversable TexCoord4 where
+   traverse f (TexCoord4 x y z w) = pure TexCoord4 <*> f x <*> f y <*> f z <*> f w
+   sequenceA (TexCoord4 x y z w) =  pure TexCoord4 <*> x <*> y <*> z <*> w
+   mapM f (TexCoord4 x y z w) = return TexCoord4 `ap` f x `ap` f y `ap` f z `ap` f w
+   sequence (TexCoord4 x y z w) = return TexCoord4 `ap` x `ap` y `ap` z `ap` w
+
+instance Typeable1 TexCoord4 where
+   typeOf1 _ = mkTyConApp (mkTyCon "TexCoord4") []
+
+instance Typeable a => Typeable (TexCoord4 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (TexCoord4 a) where
+   sizeOf ~(TexCoord4 x _ _ _) = 4 * sizeOf x
+   alignment ~(TexCoord4 x _ _ _) = alignment x
+   peek = peek4 TexCoord4 . castPtr
+   poke ptr (TexCoord4 x y z w) = poke4 (castPtr ptr) x y z w
+
+--------------------------------------------------------------------------------
+
+-- A three-dimensional normal.
+data Normal3 a = Normal3 !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read) 
+instance Functor Normal3 where
+   fmap f (Normal3 x y z) = Normal3 (f x) (f y) (f z)
+
+instance Applicative Normal3 where
+   pure a = Normal3 a a a
+   Normal3 f g h <*> Normal3 x y z = Normal3 (f x) (g y) (h z)
+
+instance Foldable Normal3 where
+   foldr f a (Normal3 x y z) = x `f ` (y `f` (z `f` a))
+   foldl f a (Normal3 x y z) = ((a `f` x) `f` y) `f` z
+   foldr1 f (Normal3 x y z) = x `f` (y `f` z)
+   foldl1 f (Normal3 x y z) = (x `f` y) `f` z
+
+instance Traversable Normal3 where
+   traverse f (Normal3 x y z) = pure Normal3 <*> f x <*> f y <*> f z
+   sequenceA (Normal3 x y z) =  pure Normal3 <*> x <*> y <*> z
+   mapM f (Normal3 x y z) = return Normal3 `ap` f x `ap` f y `ap` f z
+   sequence (Normal3 x y z) = return Normal3 `ap` x `ap` y `ap` z
+
+instance Typeable1 Normal3 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Normal3") []
+
+instance Typeable a => Typeable (Normal3 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Normal3 a) where
+   sizeOf ~(Normal3 x _ _) = 3 * sizeOf x
+   alignment ~(Normal3 x _ _) = alignment x
+   peek = peek3 Normal3 . castPtr
+   poke ptr (Normal3 x y z) = poke3 (castPtr ptr) x y z
+
+--------------------------------------------------------------------------------
+
+-- | A fog coordinate.
+newtype FogCoord1 a = FogCoord1 a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor FogCoord1 where
+   fmap f (FogCoord1 x) = FogCoord1 (f x)
+
+instance Applicative FogCoord1 where
+   pure a = FogCoord1 a
+   FogCoord1 f <*> FogCoord1 x = FogCoord1 (f x)
+
+instance Foldable FogCoord1 where
+   foldr f a (FogCoord1 x) = x `f ` a
+   foldl f a (FogCoord1 x)  = a `f` x
+   foldr1 _ (FogCoord1 x) = x
+   foldl1 _ (FogCoord1 x) = x
+
+instance Traversable FogCoord1 where
+   traverse f (FogCoord1 x) = pure FogCoord1 <*> f x
+   sequenceA (FogCoord1 x) =  pure FogCoord1 <*> x
+   mapM f (FogCoord1 x) = return FogCoord1 `ap` f x
+   sequence (FogCoord1 x) = return FogCoord1 `ap` x
+
+instance Typeable1 FogCoord1 where
+   typeOf1 _ = mkTyConApp (mkTyCon "FogCoord1") []
+
+instance Typeable a => Typeable (FogCoord1 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (FogCoord1 a) where
+   sizeOf    ~(FogCoord1 s) = sizeOf s
+   alignment ~(FogCoord1 s) = alignment s
+   peek = peek1 FogCoord1 . castPtr
+   poke ptr (FogCoord1 s) = poke1 (castPtr ptr) s
+
+--------------------------------------------------------------------------------
+
+-- An RGBA color with /A/=1.
+data Color3 a = Color3 !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Color3 where
+   fmap f (Color3 x y z) = Color3 (f x) (f y) (f z)
+
+instance Applicative Color3 where
+   pure a = Color3 a a a
+   Color3 f g h <*> Color3 x y z = Color3 (f x) (g y) (h z)
+
+instance Foldable Color3 where
+   foldr f a (Color3 x y z) = x `f ` (y `f` (z `f` a))
+   foldl f a (Color3 x y z) = ((a `f` x) `f` y) `f` z
+   foldr1 f (Color3 x y z) = x `f` (y `f` z)
+   foldl1 f (Color3 x y z) = (x `f` y) `f` z
+
+instance Traversable Color3 where
+   traverse f (Color3 x y z) = pure Color3 <*> f x <*> f y <*> f z
+   sequenceA (Color3 x y z) =  pure Color3 <*> x <*> y <*> z
+   mapM f (Color3 x y z) = return Color3 `ap` f x `ap` f y `ap` f z
+   sequence (Color3 x y z) = return Color3 `ap` x `ap` y `ap` z
+
+instance Typeable1 Color3 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Color3") []
+
+instance Typeable a => Typeable (Color3 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Color3 a) where
+   sizeOf ~(Color3 x _ _) = 3 * sizeOf x
+   alignment ~(Color3 x _ _) = alignment x
+   peek = peek3 Color3 . castPtr
+   poke ptr (Color3 x y z) = poke3 (castPtr ptr) x y z
+
+--------------------------------------------------------------------------------
+
+-- | A fully-fledged RGBA color.
+data Color4 a = Color4 !a !a !a !a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Color4 where
+   fmap f (Color4 x y z w) = Color4 (f x) (f y) (f z) (f w)
+
+instance Applicative Color4 where
+   pure a = Color4 a a a a
+   Color4 f g h i <*> Color4 x y z w = Color4 (f x) (g y) (h z) (i w)
+
+instance Foldable Color4 where
+   foldr f a (Color4 x y z w) = x `f ` (y `f` (z `f` (w `f` a)))
+   foldl f a (Color4 x y z w) = (((a `f` x) `f` y) `f` z) `f` w
+   foldr1 f (Color4 x y z w) = x `f` (y `f` (z `f` w))
+   foldl1 f (Color4 x y z w) = ((x `f` y) `f` z) `f` w
+
+instance Traversable Color4 where
+   traverse f (Color4 x y z w) = pure Color4 <*> f x <*> f y <*> f z <*> f w
+   sequenceA (Color4 x y z w) =  pure Color4 <*> x <*> y <*> z <*> w
+   mapM f (Color4 x y z w) = return Color4 `ap` f x `ap` f y `ap` f z `ap` f w
+   sequence (Color4 x y z w) = return Color4 `ap` x `ap` y `ap` z `ap` w
+
+instance Typeable1 Color4 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Color4") []
+
+instance Typeable a => Typeable (Color4 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Color4 a) where
+   sizeOf ~(Color4 x _ _ _) = 4 * sizeOf x
+   alignment ~(Color4 x _ _ _) = alignment x
+   peek = peek4 Color4 . castPtr
+   poke ptr (Color4 x y z w) = poke4 (castPtr ptr) x y z w
+
+--------------------------------------------------------------------------------
+
+-- | A color index.
+newtype Index1 a = Index1 a
+   deriving (Eq, Ord, Ix, Bounded, Show, Read)
+
+instance Functor Index1 where
+   fmap f (Index1 x) = Index1 (f x)
+
+instance Applicative Index1 where
+   pure a = Index1 a
+   Index1 f <*> Index1 x = Index1 (f x)
+
+instance Foldable Index1 where
+   foldr f a (Index1 x) = x `f ` a
+   foldl f a (Index1 x)  = a `f` x
+   foldr1 _ (Index1 x) = x
+   foldl1 _ (Index1 x) = x
+
+instance Traversable Index1 where
+   traverse f (Index1 x) = pure Index1 <*> f x
+   sequenceA (Index1 x) =  pure Index1 <*> x
+   mapM f (Index1 x) = return Index1 `ap` f x
+   sequence (Index1 x) = return Index1 `ap` x
+
+instance Typeable1 Index1 where
+   typeOf1 _ = mkTyConApp (mkTyCon "Index1") []
+
+instance Typeable a => Typeable (Index1 a) where
+   typeOf = typeOfDefault
+
+instance Storable a => Storable (Index1 a) where
+   sizeOf    ~(Index1 s) = sizeOf s
+   alignment ~(Index1 s) = alignment s
+   peek = peek1 Index1 . castPtr
+   poke ptr (Index1 s) = poke1 (castPtr ptr) s
diff --git a/Graphics/Rendering/OpenGL/GL/VertexSpec.hs b/Graphics/Rendering/OpenGL/GL/VertexSpec.hs
--- a/Graphics/Rendering/OpenGL/GL/VertexSpec.hs
+++ b/Graphics/Rendering/OpenGL/GL/VertexSpec.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GL.VertexSpec
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
@@ -17,7 +17,7 @@
    -- * Vertex Coordinates
    Vertex(..),
    VertexComponent,
-   Vertex2(..), Vertex3(..), Vertex4(..),
+   Vertex1(..), Vertex2(..), Vertex3(..), Vertex4(..),
 
    -- * Auxiliary Vertex Attributes
    -- $AuxiliaryVertexAttributes
@@ -49,7 +49,9 @@
    Index1(..),
 
    -- * Generic Vertex Attributes
-   AttribLocation(..), VertexAttrib, VertexAttribComponent(..),
+   IntegerHandling(..), AttribLocation(..),
+   currentVertexAttrib, currentVertexAttribI, currentVertexAttribIu,
+   VertexAttrib(..), VertexAttribComponent(..),
 
    -- * Texture Units
    TextureUnit(..), maxTextureUnit
@@ -57,6 +59,7 @@
 
 import Data.Int
 import Data.Word
+import Foreign.Marshal.Array ( allocaArray )
 import Foreign.Ptr ( Ptr, castPtr )
 import Foreign.Storable ( Storable(..) )
 import Graphics.Rendering.OpenGL.GL.BasicTypes (
@@ -66,17 +69,25 @@
    FunPtr, unsafePerformIO, Invoker, getProcAddress )
 import Graphics.Rendering.OpenGL.GL.GLboolean ( unmarshalGLboolean )
 import Graphics.Rendering.OpenGL.GL.PeekPoke (
-   poke1, poke2, poke3, poke4,
-   peek1, peek2, peek3, peek4 )
+   poke4, peek1M, peek2M, peek3M, peek4M )
 import Graphics.Rendering.OpenGL.GL.QueryUtils (
+   AttribLocation(..),
    GetPName(GetCurrentTextureCoords, GetCurrentNormal, GetCurrentFogCoord,
             GetCurrentColor, GetCurrentSecondaryColor, GetCurrentIndex,
             GetMaxTextureUnits,GetRGBAMode),
-   getBoolean1, getInteger1, getEnum1, getFloat1, getFloat3, getFloat4 )
+   getBoolean1, getInteger1, getEnum1, getFloat1, getFloat3, getFloat4,
+   GetVertexAttribPName(GetCurrentVertexAttrib),
+   getVertexAttribFloat4, getVertexAttribIInteger4, getVertexAttribIuInteger4  )
 import Graphics.Rendering.OpenGL.GL.StateVar (
    GettableStateVar, makeGettableStateVar, StateVar, makeStateVar )
+import Graphics.Rendering.OpenGL.GL.Tensor (
+   Vertex1(..), Vertex2(..), Vertex3(..), Vertex4(..),
+   Vector1(..), Vector2(..), Vector3(..), Vector4(..) )
 import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
    TextureUnit(..), marshalTextureUnit, unmarshalTextureUnit )
+import Graphics.Rendering.OpenGL.GL.VertexAttributes (
+   TexCoord1(..), TexCoord2(..), TexCoord3(..), TexCoord4(..),
+   Normal3(..), FogCoord1(..), Color3(..), Color4(..), Index1(..) )
 
 --------------------------------------------------------------------------------
 
@@ -227,48 +238,18 @@
    vertex  ::     a -> IO ()
    vertexv :: Ptr a -> IO ()
 
--- | A vertex with /z/=0 and /w/=1.
-data Vertex2 a = Vertex2 !a !a
-   deriving ( Eq, Ord, Show )
-
 instance VertexComponent a => Vertex (Vertex2 a) where
    vertex (Vertex2 x y) = vertex2 x y
    vertexv = vertex2v . (castPtr :: Ptr (Vertex2 b) -> Ptr b)
 
-instance Storable a => Storable (Vertex2 a) where
-   sizeOf    ~(Vertex2 x _) = 2 * sizeOf x
-   alignment ~(Vertex2 x _) = alignment x
-   peek                     = peek2 Vertex2 . castPtr
-   poke ptr   (Vertex2 x y) = poke2 (castPtr ptr) x y
-
--- | A vertex with /w/=1.
-data Vertex3 a = Vertex3 !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance VertexComponent a => Vertex (Vertex3 a) where
    vertex (Vertex3 x y z) = vertex3 x y z
    vertexv = vertex3v . (castPtr :: Ptr (Vertex3 b) -> Ptr b)
 
-instance Storable a => Storable (Vertex3 a) where
-   sizeOf    ~(Vertex3 x _ _) = 3 * sizeOf x
-   alignment ~(Vertex3 x _ _) = alignment x
-   peek                       = peek3 Vertex3 . castPtr
-   poke ptr   (Vertex3 x y z) = poke3 (castPtr ptr) x y z
-
--- | A fully-fledged four-dimensional vertex.
-data Vertex4 a = Vertex4 !a !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance VertexComponent a => Vertex (Vertex4 a) where
    vertex (Vertex4 x y z w) = vertex4 x y z w
    vertexv = vertex4v . (castPtr :: Ptr (Vertex4 b) -> Ptr b)
 
-instance Storable a => Storable (Vertex4 a) where
-   sizeOf    ~(Vertex4 x _ _ _) = 4 * sizeOf x
-   alignment ~(Vertex4 x _ _ _) = alignment x
-   peek                         = peek4 Vertex4 . castPtr
-   poke ptr   (Vertex4 x y z w) = poke4 (castPtr ptr) x y z w
-
 --------------------------------------------------------------------------------
 -- $AuxiliaryVertexAttributes
 -- Apart from its coordinates in four-dimensional space, every vertex has
@@ -560,11 +541,6 @@
    multiTexCoord  :: TextureUnit ->     a -> IO ()
    multiTexCoordv :: TextureUnit -> Ptr a -> IO ()
 
--- | Texture coordinates with /t/=0, /r/=0, and /q/=1.
-
-newtype TexCoord1 a = TexCoord1 a
-   deriving ( Eq, Ord, Show )
-
 instance TexCoordComponent a => TexCoord (TexCoord1 a) where
    texCoord (TexCoord1 s) = texCoord1 s
    texCoordv = texCoord1v . (castPtr :: Ptr (TexCoord1 b) -> Ptr b)
@@ -573,17 +549,6 @@
    multiTexCoordv u =
       multiTexCoord1v (marshalTextureUnit u) . (castPtr :: Ptr (TexCoord1 b) -> Ptr b)
 
-instance Storable a => Storable (TexCoord1 a) where
-   sizeOf    ~(TexCoord1 s) = sizeOf s
-   alignment ~(TexCoord1 s) = alignment s
-   peek                     = peek1 TexCoord1 . castPtr
-   poke ptr   (TexCoord1 s) = poke1 (castPtr ptr) s
-
--- | Texture coordinates with /r/=0 and /q/=1.
-
-data TexCoord2 a = TexCoord2 !a !a
-   deriving ( Eq, Ord, Show )
-
 instance TexCoordComponent a => TexCoord (TexCoord2 a) where
    texCoord (TexCoord2 s t) = texCoord2 s t
    texCoordv = texCoord2v . (castPtr :: Ptr (TexCoord2 b) -> Ptr b)
@@ -592,17 +557,6 @@
    multiTexCoordv u =
       multiTexCoord2v (marshalTextureUnit u) . (castPtr :: Ptr (TexCoord2 b) -> Ptr b)
 
-instance Storable a => Storable (TexCoord2 a) where
-   sizeOf    ~(TexCoord2 s _) = 2 * sizeOf s
-   alignment ~(TexCoord2 s _) = alignment s
-   peek                       = peek2 TexCoord2 . castPtr
-   poke ptr   (TexCoord2 s t) = poke2 (castPtr ptr) s t
-
--- | Texture coordinates with /q/=1.
-
-data TexCoord3 a = TexCoord3 !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance TexCoordComponent a => TexCoord (TexCoord3 a) where
    texCoord (TexCoord3 s t r) = texCoord3 s t r
    texCoordv = texCoord3v . (castPtr :: Ptr (TexCoord3 b) -> Ptr b)
@@ -611,17 +565,6 @@
    multiTexCoordv u =
       multiTexCoord3v (marshalTextureUnit u) . (castPtr :: Ptr (TexCoord3 b) -> Ptr b)
 
-instance Storable a => Storable (TexCoord3 a) where
-   sizeOf    ~(TexCoord3 s _ _) = 3 * sizeOf s
-   alignment ~(TexCoord3 s _ _) = alignment s
-   peek                         = peek3 TexCoord3 . castPtr
-   poke ptr   (TexCoord3 s t r) = poke3 (castPtr ptr) s t r
-
--- | Fully-fledged four-dimensional texture coordinates.
-
-data TexCoord4 a = TexCoord4 !a !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance TexCoordComponent a => TexCoord (TexCoord4 a) where
    texCoord (TexCoord4 s t r q) = texCoord4 s t r q
    texCoordv = texCoord4v . (castPtr :: Ptr (TexCoord4 b) -> Ptr b)
@@ -630,12 +573,6 @@
    multiTexCoordv u =
       multiTexCoord4v (marshalTextureUnit u) . (castPtr :: Ptr (TexCoord4 b) -> Ptr b)
 
-instance Storable a => Storable (TexCoord4 a) where
-   sizeOf    ~(TexCoord4 s _ _ _) = 4 * sizeOf s
-   alignment ~(TexCoord4 s _ _ _) = alignment s
-   peek                           = peek4 TexCoord4 . castPtr
-   poke ptr   (TexCoord4 s t r q) = poke4 (castPtr ptr) s t r q
-
 --------------------------------------------------------------------------------
 
 -- | The current normal (/x/, /y/, /z/). The initial value is the unit vector
@@ -734,21 +671,10 @@
    normal  ::     a -> IO ()
    normalv :: Ptr a -> IO ()
 
--- A three-dimensional normal.
-
-data Normal3 a = Normal3 !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance NormalComponent a => Normal (Normal3 a) where
    normal (Normal3 x y z) = normal3 x y z
    normalv = normal3v . (castPtr :: Ptr (Normal3 b) -> Ptr b)
 
-instance Storable a => Storable (Normal3 a) where
-   sizeOf    ~(Normal3 x _ _) = 3 * sizeOf x
-   alignment ~(Normal3 x _ _) = alignment x
-   peek                       = peek3 Normal3 . castPtr
-   poke ptr   (Normal3 x y z) = poke3 (castPtr ptr) x y z
-
 --------------------------------------------------------------------------------
 
 -- | The current fog coordinate. The initial value is 0.
@@ -765,12 +691,6 @@
    fogCoord1 :: a -> IO ()
    fogCoord1v :: Ptr a -> IO ()
 
-instance Storable a => Storable (FogCoord1 a) where
-   sizeOf    ~(FogCoord1 c) = sizeOf c
-   alignment ~(FogCoord1 c) = alignment c
-   peek                     = peek1 FogCoord1 . castPtr
-   poke ptr   (FogCoord1 c) = poke1 (castPtr ptr) c
-
 --------------------------------------------------------------------------------
 
 EXTENSION_ENTRY("GL_EXT_fog_coord or OpenGL 1.4",glFogCoordfEXT,GLfloat -> IO ())
@@ -797,11 +717,6 @@
    fogCoord  ::     a -> IO ()
    fogCoordv :: Ptr a -> IO ()
 
--- | A fog coordinate.
-
-newtype FogCoord1 a = FogCoord1 a
-   deriving ( Eq, Ord, Show )
-
 instance FogCoordComponent a => FogCoord (FogCoord1 a) where
    fogCoord (FogCoord1 c) = fogCoord1 c
    fogCoordv = fogCoord1v . (castPtr :: Ptr (FogCoord1 b) -> Ptr b)
@@ -1074,36 +989,14 @@
    color  ::     a -> IO ()
    colorv :: Ptr a -> IO ()
 
--- An RGBA color with /A/=1.
-
-data Color3 a = Color3 !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance ColorComponent a => Color (Color3 a) where
    color (Color3 r g b) = color3 r g b
    colorv = color3v . (castPtr :: Ptr (Color3 b) -> Ptr b)
 
-instance Storable a => Storable (Color3 a) where
-   sizeOf    ~(Color3 r _ _) = 3 * sizeOf r
-   alignment ~(Color3 r _ _) = alignment r
-   peek                      = peek3 Color3 . castPtr
-   poke ptr   (Color3 r g b) = poke3 (castPtr ptr) r g b
-
--- | A fully-fledged RGBA color.
-
-data Color4 a = Color4 !a !a !a !a
-   deriving ( Eq, Ord, Show )
-
 instance ColorComponent a => Color (Color4 a) where
    color (Color4 r g b a) = color4 r g b a
    colorv = color4v . (castPtr :: Ptr (Color4 b) -> Ptr b)
 
-instance Storable a => Storable (Color4 a) where
-   sizeOf    ~(Color4 r _ _ _) = 4 * sizeOf r
-   alignment ~(Color4 r _ _ _) = alignment r
-   peek                        = peek4 Color4 . castPtr
-   poke ptr   (Color4 r g b a) = poke4 (castPtr ptr) r g b a
-
 --------------------------------------------------------------------------------
 
 -- | Change the current secondary color.
@@ -1200,186 +1093,459 @@
    index  ::     a -> IO ()  -- Collision with Prelude.index
    indexv :: Ptr a -> IO ()
 
--- | A color index.
-
-newtype Index1 a = Index1 a
-   deriving ( Eq, Ord, Show )
-
 instance IndexComponent a => Index (Index1 a) where
    index (Index1 i) = index1 i
    indexv = index1v . (castPtr :: Ptr (Index1 b) -> Ptr b)
 
-instance Storable a => Storable (Index1 a) where
-   sizeOf    ~(Index1 s) = sizeOf s
-   alignment ~(Index1 s) = alignment s
-   peek                  = peek1 Index1 . castPtr
-   poke ptr   (Index1 s) = poke1 (castPtr ptr) s
-
 --------------------------------------------------------------------------------
 
-newtype AttribLocation = AttribLocation GLuint
+data IntegerHandling =
+     ToFloat
+   | ToNormalizedFloat
+   | KeepIntegral
    deriving ( Eq, Ord, Show )
 
 --------------------------------------------------------------------------------
 
+currentVertexAttrib :: AttribLocation -> StateVar (Vertex4 GLfloat)
+currentVertexAttrib location =
+   makeStateVar
+      (getVertexAttribFloat4 Vertex4 location GetCurrentVertexAttrib)
+      (vertexAttrib ToFloat location)
+
+currentVertexAttribI :: AttribLocation -> StateVar (Vertex4 GLint)
+currentVertexAttribI location =
+   makeStateVar
+      (getVertexAttribIInteger4 Vertex4 location GetCurrentVertexAttrib)
+      (vertexAttrib ToNormalizedFloat location)
+
+currentVertexAttribIu :: AttribLocation -> StateVar (Vertex4 GLuint)
+currentVertexAttribIu location =
+   makeStateVar
+      (getVertexAttribIuInteger4 Vertex4 location GetCurrentVertexAttrib)
+      (vertexAttrib KeepIntegral location)
+
+--------------------------------------------------------------------------------
+-- The generic vertex attribute API is not as orthogonal as we would like.
+-- Minimal methods: vertexAttrib4v and vertexAttrib4Nv and vertexAttrib4Iv
+
 -- | The class of all types which can be used as a generic vertex attribute.
+-- NOTE: Do not use the methods of this class directly, they were only exported
+-- by accident and will be hidden in future versions of this package.
 
-class VertexAttribComponent a where
+class (Storable a, Num a) => VertexAttribComponent a where
    vertexAttrib1 :: AttribLocation -> a -> IO ()
    vertexAttrib2 :: AttribLocation -> a -> a -> IO ()
    vertexAttrib3 :: AttribLocation -> a -> a -> a -> IO ()
    vertexAttrib4 :: AttribLocation -> a -> a -> a -> a -> IO ()
 
+   vertexAttrib1N :: AttribLocation -> a -> IO ()
+   vertexAttrib2N :: AttribLocation -> a -> a -> IO ()
+   vertexAttrib3N :: AttribLocation -> a -> a -> a -> IO ()
+   vertexAttrib4N :: AttribLocation -> a -> a -> a -> a -> IO ()
+
+   vertexAttrib1I :: AttribLocation -> a -> IO ()
+   vertexAttrib2I :: AttribLocation -> a -> a -> IO ()
+   vertexAttrib3I :: AttribLocation -> a -> a -> a -> IO ()
+   vertexAttrib4I :: 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 ()
 
+   vertexAttrib1Nv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib2Nv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib3Nv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib4Nv :: AttribLocation -> Ptr a -> IO ()
+
+   vertexAttrib1Iv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib2Iv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib3Iv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib4Iv :: AttribLocation -> Ptr a -> IO ()
+
+   vertexAttrib1 location x = vertexAttrib4 location x 0 0 1
+   vertexAttrib2 location x y = vertexAttrib4 location x y 0 1
+   vertexAttrib3 location x y z = vertexAttrib4 location x y z 1
+   vertexAttrib4 location x y z w = allocaArray 4 $ \buf -> do
+                                       poke4 buf x y z w
+                                       vertexAttrib4v location buf
+
+   vertexAttrib1N location x = vertexAttrib4N location x 0 0 1
+   vertexAttrib2N location x y = vertexAttrib4N location x y 0 1
+   vertexAttrib3N location x y z = vertexAttrib4N location x y z 1
+   vertexAttrib4N location x y z w = allocaArray 4 $ \buf -> do
+                                       poke4 buf x y z w
+                                       vertexAttrib4Nv location buf
+
+   vertexAttrib1I location x = vertexAttrib4I location x 0 0 1
+   vertexAttrib2I location x y = vertexAttrib4I location x y 0 1
+   vertexAttrib3I location x y z = vertexAttrib4I location x y z 1
+   vertexAttrib4I location x y z w = allocaArray 4 $ \buf -> do
+                                       poke4 buf x y z w
+                                       vertexAttrib4Iv location buf
+
+   vertexAttrib1v location = peek1M $ vertexAttrib1 location
+   vertexAttrib2v location = peek2M $ vertexAttrib2 location
+   vertexAttrib3v location = peek3M $ vertexAttrib3 location
+
+   vertexAttrib1Nv location = peek1M $ vertexAttrib1N location
+   vertexAttrib2Nv location = peek2M $ vertexAttrib2N location
+   vertexAttrib3Nv location = peek3M $ vertexAttrib3N location
+
+   vertexAttrib1Iv location = peek1M $ vertexAttrib1I location
+   vertexAttrib2Iv location = peek2M $ vertexAttrib2I location
+   vertexAttrib3Iv location = peek3M $ vertexAttrib3I location
+
 --------------------------------------------------------------------------------
 
-EXTENSION_ENTRY("OpenGL 2.0",glGetVertexAttribdv,GLuint -> GLenum -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glGetVertexAttribfv,GLuint -> GLenum -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glGetVertexAttribiv,GLuint -> GLenum -> Ptr GLint -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4bvARB,AttribLocation -> Ptr GLbyte -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NbvARB,AttribLocation -> Ptr GLbyte -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4bv,AttribLocation -> Ptr GLbyte -> IO ())
 
+instance VertexAttribComponent GLbyte_ where
+   vertexAttrib4v = glVertexAttrib4bvARB
+   vertexAttrib4Nv = glVertexAttrib4NbvARB
+   vertexAttrib4Iv = glVertexAttribI4bv
+
 --------------------------------------------------------------------------------
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib1s,AttribLocation -> GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib2s,AttribLocation -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib3s,AttribLocation -> GLshort -> GLshort -> GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4s,AttribLocation -> GLshort -> GLshort -> GLshort -> GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NubARB,AttribLocation -> GLubyte -> GLubyte -> GLubyte -> GLubyte -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4ubvARB,AttribLocation -> Ptr GLubyte -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NubvARB,AttribLocation -> Ptr GLubyte -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4ubv,AttribLocation -> Ptr GLubyte -> IO ())
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib1sv,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib2sv,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib3sv,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4sv,AttribLocation -> Ptr GLshort -> IO ())
+instance VertexAttribComponent GLubyte_ where
+   vertexAttrib4N = glVertexAttrib4NubARB
+   vertexAttrib4v = glVertexAttrib4ubvARB
+   vertexAttrib4Nv = glVertexAttrib4NubvARB
+   vertexAttrib4Iv = glVertexAttribI4ubv
 
+--------------------------------------------------------------------------------
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1sARB,AttribLocation -> GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2sARB,AttribLocation -> GLshort -> GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3sARB,AttribLocation -> GLshort -> GLshort -> GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4sARB,AttribLocation -> GLshort -> GLshort -> GLshort -> GLshort -> IO ())
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1svARB,AttribLocation -> Ptr GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2svARB,AttribLocation -> Ptr GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3svARB,AttribLocation -> Ptr GLshort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4svARB,AttribLocation -> Ptr GLshort -> IO ())
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NsvARB,AttribLocation -> Ptr GLshort -> IO ())
+
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4sv,AttribLocation -> Ptr GLshort -> IO ())
+
 instance VertexAttribComponent GLshort_ where
-   vertexAttrib1 = glVertexAttrib1s
-   vertexAttrib2 = glVertexAttrib2s
-   vertexAttrib3 = glVertexAttrib3s
-   vertexAttrib4 = glVertexAttrib4s
+   vertexAttrib1 = glVertexAttrib1sARB
+   vertexAttrib2 = glVertexAttrib2sARB
+   vertexAttrib3 = glVertexAttrib3sARB
+   vertexAttrib4 = glVertexAttrib4sARB
 
-   vertexAttrib1v = glVertexAttrib1sv
-   vertexAttrib2v = glVertexAttrib2sv
-   vertexAttrib3v = glVertexAttrib3sv
-   vertexAttrib4v = glVertexAttrib4sv
+   vertexAttrib1v = glVertexAttrib1svARB
+   vertexAttrib2v = glVertexAttrib2svARB
+   vertexAttrib3v = glVertexAttrib3svARB
+   vertexAttrib4v = glVertexAttrib4svARB
 
+   vertexAttrib4Nv = glVertexAttrib4NsvARB
+
+   vertexAttrib4Iv = glVertexAttribI4sv
+
 --------------------------------------------------------------------------------
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib1f,AttribLocation -> GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib2f,AttribLocation -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib3f,AttribLocation -> GLfloat -> GLfloat -> GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4f,AttribLocation -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4usvARB,AttribLocation -> Ptr GLushort -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NusvARB,AttribLocation -> Ptr GLushort -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4usv,AttribLocation -> Ptr GLushort -> IO ())
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib1fv,AttribLocation -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib2fv,AttribLocation -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib3fv,AttribLocation -> Ptr GLfloat -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4fv,AttribLocation -> Ptr GLfloat -> IO ())
+instance VertexAttribComponent GLushort_ where
+   vertexAttrib4v = glVertexAttrib4usvARB
+   vertexAttrib4Nv = glVertexAttrib4NusvARB
+   vertexAttrib4Iv = glVertexAttribI4usv
 
-instance VertexAttribComponent GLfloat_ where
-   vertexAttrib1 = glVertexAttrib1f
-   vertexAttrib2 = glVertexAttrib2f
-   vertexAttrib3 = glVertexAttrib3f
-   vertexAttrib4 = glVertexAttrib4f
+--------------------------------------------------------------------------------
 
-   vertexAttrib1v = glVertexAttrib1fv
-   vertexAttrib2v = glVertexAttrib2fv
-   vertexAttrib3v = glVertexAttrib3fv
-   vertexAttrib4v = glVertexAttrib4fv
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1i,AttribLocation -> GLint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2i,AttribLocation -> GLint -> GLint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3i,AttribLocation -> GLint -> GLint -> GLint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4i,AttribLocation -> GLint -> GLint -> GLint -> GLint -> IO ())
 
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4ivARB,AttribLocation -> Ptr GLint -> IO ())
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NivARB,AttribLocation -> Ptr GLint -> IO ())
+
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1iv,AttribLocation -> Ptr GLint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2iv,AttribLocation -> Ptr GLint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3iv,AttribLocation -> Ptr GLint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4iv,AttribLocation -> Ptr GLint -> IO ())
+
+instance VertexAttribComponent GLint_ where
+   vertexAttrib1I = glVertexAttribI1i
+   vertexAttrib2I = glVertexAttribI2i
+   vertexAttrib3I = glVertexAttribI3i
+   vertexAttrib4I = glVertexAttribI4i
+
+   vertexAttrib4v = glVertexAttrib4ivARB
+
+   vertexAttrib4Nv = glVertexAttrib4NivARB
+
+   vertexAttrib1Iv = glVertexAttribI1iv
+   vertexAttrib2Iv = glVertexAttribI2iv
+   vertexAttrib3Iv = glVertexAttribI3iv
+   vertexAttrib4Iv = glVertexAttribI4iv
+
 --------------------------------------------------------------------------------
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib1d,AttribLocation -> GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib2d,AttribLocation -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib3d,AttribLocation -> GLdouble -> GLdouble -> GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4d,AttribLocation -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1ui,AttribLocation -> GLuint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2ui,AttribLocation -> GLuint -> GLuint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3ui,AttribLocation -> GLuint -> GLuint -> GLuint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4ui,AttribLocation -> GLuint -> GLuint -> GLuint -> GLuint -> IO ())
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib1dv,AttribLocation -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib2dv,AttribLocation -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib3dv,AttribLocation -> Ptr GLdouble -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4dv,AttribLocation -> Ptr GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4uivARB,AttribLocation -> Ptr GLuint -> IO ())
 
-instance VertexAttribComponent GLdouble_ where
-   vertexAttrib1 = glVertexAttrib1d
-   vertexAttrib2 = glVertexAttrib2d
-   vertexAttrib3 = glVertexAttrib3d
-   vertexAttrib4 = glVertexAttrib4d
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4NuivARB,AttribLocation -> Ptr GLuint -> IO ())
 
-   vertexAttrib1v = glVertexAttrib1dv
-   vertexAttrib2v = glVertexAttrib2dv
-   vertexAttrib3v = glVertexAttrib3dv
-   vertexAttrib4v = glVertexAttrib4dv
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI1uiv,AttribLocation -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI2uiv,AttribLocation -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI3uiv,AttribLocation -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("GL_EXT_gpu_shader4 or OpenGL 3.0",glVertexAttribI4uiv,AttribLocation -> Ptr GLuint -> IO ())
 
+instance VertexAttribComponent GLuint_ where
+   vertexAttrib1I = glVertexAttribI1ui
+   vertexAttrib2I = glVertexAttribI2ui
+   vertexAttrib3I = glVertexAttribI3ui
+   vertexAttrib4I = glVertexAttribI4ui
+
+   vertexAttrib4v = glVertexAttrib4uivARB
+
+   vertexAttrib4Nv = glVertexAttrib4NuivARB
+
+   vertexAttrib1Iv = glVertexAttribI1uiv
+   vertexAttrib2Iv = glVertexAttribI2uiv
+   vertexAttrib3Iv = glVertexAttribI3uiv
+   vertexAttrib4Iv = glVertexAttribI4uiv
+
 --------------------------------------------------------------------------------
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4bv,AttribLocation -> Ptr GLbyte -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4ubv,AttribLocation -> Ptr GLubyte -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4usv,AttribLocation -> Ptr GLushort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4iv,AttribLocation -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4uiv,AttribLocation -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1fARB,AttribLocation -> GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2fARB,AttribLocation -> GLfloat -> GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3fARB,AttribLocation -> GLfloat -> GLfloat -> GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4fARB,AttribLocation -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ())
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Nbv,AttribLocation -> Ptr GLbyte -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Nubv,AttribLocation -> Ptr GLubyte -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Nusv,AttribLocation -> Ptr GLushort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Niv,AttribLocation -> Ptr GLint -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Nuiv,AttribLocation -> Ptr GLuint -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1fvARB,AttribLocation -> Ptr GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2fvARB,AttribLocation -> Ptr GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3fvARB,AttribLocation -> Ptr GLfloat -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4fvARB,AttribLocation -> Ptr GLfloat -> IO ())
 
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Nsv,AttribLocation -> Ptr GLshort -> IO ())
-EXTENSION_ENTRY("OpenGL 2.0",glVertexAttrib4Nub,AttribLocation -> GLubyte -> GLubyte -> GLubyte -> GLubyte -> IO ())
+instance VertexAttribComponent GLfloat_ where
+   vertexAttrib1 = glVertexAttrib1fARB
+   vertexAttrib2 = glVertexAttrib2fARB
+   vertexAttrib3 = glVertexAttrib3fARB
+   vertexAttrib4 = glVertexAttrib4fARB
 
+   vertexAttrib1v = glVertexAttrib1fvARB
+   vertexAttrib2v = glVertexAttrib2fvARB
+   vertexAttrib3v = glVertexAttrib3fvARB
+   vertexAttrib4v = glVertexAttrib4fvARB
+
+   vertexAttrib4Nv = vertexAttrib4v
+
+   vertexAttrib4Iv = vertexAttrib4IvRealFrac
+
+vertexAttrib4IvRealFrac :: (Storable a, RealFrac a) => AttribLocation -> Ptr a -> IO ()
+vertexAttrib4IvRealFrac location = peek4M $ \x y z w ->
+   vertexAttrib4I location (toGLint x) (toGLint y) (toGLint z) (toGLint w)
+
+-- formula 2.6 from the OpenGL 3.1 spec
+toGLint :: RealFrac a => a -> GLint
+toGLint = truncate . (fromIntegral (maxBound :: GLint) *). clamp
+   where clamp = max (-1.0) . min 1.0
+
 --------------------------------------------------------------------------------
 
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1dARB,AttribLocation -> GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2dARB,AttribLocation -> GLdouble -> GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3dARB,AttribLocation -> GLdouble -> GLdouble -> GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4dARB,AttribLocation -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ())
+
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib1dvARB,AttribLocation -> Ptr GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib2dvARB,AttribLocation -> Ptr GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib3dvARB,AttribLocation -> Ptr GLdouble -> IO ())
+EXTENSION_ENTRY("GL_ARB_vertex_shader or OpenGL 2.0",glVertexAttrib4dvARB,AttribLocation -> Ptr GLdouble -> IO ())
+
+instance VertexAttribComponent GLdouble_ where
+   vertexAttrib1 = glVertexAttrib1dARB
+   vertexAttrib2 = glVertexAttrib2dARB
+   vertexAttrib3 = glVertexAttrib3dARB
+   vertexAttrib4 = glVertexAttrib4dARB
+
+   vertexAttrib1v = glVertexAttrib1dvARB
+   vertexAttrib2v = glVertexAttrib2dvARB
+   vertexAttrib3v = glVertexAttrib3dvARB
+   vertexAttrib4v = glVertexAttrib4dvARB
+
+   vertexAttrib4Nv = vertexAttrib4v
+
+   vertexAttrib4Iv = vertexAttrib4IvRealFrac
+
+--------------------------------------------------------------------------------
+
 class VertexAttrib a where
-   vertexAttrib  :: AttribLocation ->     a -> IO ()
-   vertexAttribv :: AttribLocation -> Ptr a -> IO ()
+   vertexAttrib  :: IntegerHandling -> AttribLocation ->     a -> IO ()
+   vertexAttribv :: IntegerHandling -> AttribLocation -> Ptr a -> IO ()
 
+instance VertexAttribComponent a => VertexAttrib (Vertex1 a) where
+   vertexAttrib ToFloat location (Vertex1 i) = vertexAttrib1 location i
+   vertexAttrib ToNormalizedFloat location (Vertex1 i) = vertexAttrib1N location i
+   vertexAttrib KeepIntegral location (Vertex1 i) = vertexAttrib1I location i
+
+   vertexAttribv ToFloat location = vertexAttrib1v location . (castPtr :: Ptr (Vertex1 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib1Nv location . (castPtr :: Ptr (Vertex1 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib1Iv location . (castPtr :: Ptr (Vertex1 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Vertex2 a) where
-   vertexAttrib location (Vertex2 x y) = vertexAttrib2 location x y
-   vertexAttribv location = vertexAttrib2v location . (castPtr :: Ptr (Vertex2 b) -> Ptr b)
+   vertexAttrib ToFloat location (Vertex2 x y) = vertexAttrib2 location x y
+   vertexAttrib ToNormalizedFloat location (Vertex2 x y) = vertexAttrib2N location x y
+   vertexAttrib KeepIntegral location (Vertex2 x y) = vertexAttrib2I location x y
 
+   vertexAttribv ToFloat location = vertexAttrib2v location . (castPtr :: Ptr (Vertex2 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib2Nv location . (castPtr :: Ptr (Vertex2 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib2Iv location . (castPtr :: Ptr (Vertex2 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Vertex3 a) where
-   vertexAttrib location (Vertex3 x y z) = vertexAttrib3 location x y z
-   vertexAttribv location = vertexAttrib3v location . (castPtr :: Ptr (Vertex3 b) -> Ptr b)
+   vertexAttrib ToFloat location (Vertex3 x y z) = vertexAttrib3 location x y z
+   vertexAttrib ToNormalizedFloat location (Vertex3 x y z) = vertexAttrib3N location x y z
+   vertexAttrib KeepIntegral location (Vertex3 x y z) = vertexAttrib3I location x y z
 
+   vertexAttribv ToFloat location = vertexAttrib3v location . (castPtr :: Ptr (Vertex3 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib3Nv location . (castPtr :: Ptr (Vertex3 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib3Iv location . (castPtr :: Ptr (Vertex3 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Vertex4 a) where
-   vertexAttrib location (Vertex4 x y z w) = vertexAttrib4 location x y z w
-   vertexAttribv location = vertexAttrib4v location . (castPtr :: Ptr (Vertex4 b) -> Ptr b)
+   vertexAttrib ToFloat location (Vertex4 x y z w) = vertexAttrib4 location x y z w
+   vertexAttrib ToNormalizedFloat location (Vertex4 x y z w) = vertexAttrib4N location x y z w
+   vertexAttrib KeepIntegral location (Vertex4 x y z w) = vertexAttrib4I location x y z w
 
+   vertexAttribv ToFloat location = vertexAttrib4v location . (castPtr :: Ptr (Vertex4 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib4Nv location . (castPtr :: Ptr (Vertex4 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib4Iv location . (castPtr :: Ptr (Vertex4 b) -> Ptr b)
+
+instance VertexAttribComponent a => VertexAttrib (Vector1 a) where
+   vertexAttrib ToFloat location (Vector1 i) = vertexAttrib1 location i
+   vertexAttrib ToNormalizedFloat location (Vector1 i) = vertexAttrib1N location i
+   vertexAttrib KeepIntegral location (Vector1 i) = vertexAttrib1I location i
+
+   vertexAttribv ToFloat location = vertexAttrib1v location . (castPtr :: Ptr (Vector1 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib1Nv location . (castPtr :: Ptr (Vector1 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib1Iv location . (castPtr :: Ptr (Vector1 b) -> Ptr b)
+
+instance VertexAttribComponent a => VertexAttrib (Vector2 a) where
+   vertexAttrib ToFloat location (Vector2 x y) = vertexAttrib2 location x y
+   vertexAttrib ToNormalizedFloat location (Vector2 x y) = vertexAttrib2N location x y
+   vertexAttrib KeepIntegral location (Vector2 x y) = vertexAttrib2I location x y
+
+   vertexAttribv ToFloat location = vertexAttrib2v location . (castPtr :: Ptr (Vector2 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib2Nv location . (castPtr :: Ptr (Vector2 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib2Iv location . (castPtr :: Ptr (Vector2 b) -> Ptr b)
+
+instance VertexAttribComponent a => VertexAttrib (Vector3 a) where
+   vertexAttrib ToFloat location (Vector3 x y z) = vertexAttrib3 location x y z
+   vertexAttrib ToNormalizedFloat location (Vector3 x y z) = vertexAttrib3N location x y z
+   vertexAttrib KeepIntegral location (Vector3 x y z) = vertexAttrib3I location x y z
+
+   vertexAttribv ToFloat location = vertexAttrib3v location . (castPtr :: Ptr (Vector3 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib3Nv location . (castPtr :: Ptr (Vector3 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib3Iv location . (castPtr :: Ptr (Vector3 b) -> Ptr b)
+
+instance VertexAttribComponent a => VertexAttrib (Vector4 a) where
+   vertexAttrib ToFloat location (Vector4 x y z w) = vertexAttrib4 location x y z w
+   vertexAttrib ToNormalizedFloat location (Vector4 x y z w) = vertexAttrib4N location x y z w
+   vertexAttrib KeepIntegral location (Vector4 x y z w) = vertexAttrib4I location x y z w
+
+   vertexAttribv ToFloat location = vertexAttrib4v location . (castPtr :: Ptr (Vector4 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib4Nv location . (castPtr :: Ptr (Vector4 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib4Iv location . (castPtr :: Ptr (Vector4 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (TexCoord1 a) where
-   vertexAttrib location (TexCoord1 s) = vertexAttrib1 location s
-   vertexAttribv location = vertexAttrib1v location . (castPtr :: Ptr (TexCoord1 b) -> Ptr b)
+   vertexAttrib ToFloat location (TexCoord1 s) = vertexAttrib1 location s
+   vertexAttrib ToNormalizedFloat location (TexCoord1 s) = vertexAttrib1N location s
+   vertexAttrib KeepIntegral location (TexCoord1 s) = vertexAttrib1I location s
 
+   vertexAttribv ToFloat location = vertexAttrib1v location . (castPtr :: Ptr (TexCoord1 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib1Nv location . (castPtr :: Ptr (TexCoord1 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib1Iv location . (castPtr :: Ptr (TexCoord1 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (TexCoord2 a) where
-   vertexAttrib location (TexCoord2 s t) = vertexAttrib2 location s t
-   vertexAttribv location = vertexAttrib2v location . (castPtr :: Ptr (TexCoord2 b) -> Ptr b)
+   vertexAttrib ToFloat location (TexCoord2 s t) = vertexAttrib2 location s t
+   vertexAttrib ToNormalizedFloat location (TexCoord2 s t) = vertexAttrib2N location s t
+   vertexAttrib KeepIntegral location (TexCoord2 s t) = vertexAttrib2I location s t
 
+   vertexAttribv ToFloat location = vertexAttrib2v location . (castPtr :: Ptr (TexCoord2 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib2Nv location . (castPtr :: Ptr (TexCoord2 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib2Iv location . (castPtr :: Ptr (TexCoord2 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (TexCoord3 a) where
-   vertexAttrib location (TexCoord3 s t u) = vertexAttrib3 location s t u
-   vertexAttribv location = vertexAttrib3v location . (castPtr :: Ptr (TexCoord3 b) -> Ptr b)
+   vertexAttrib ToFloat location (TexCoord3 s t u) = vertexAttrib3 location s t u
+   vertexAttrib ToNormalizedFloat location (TexCoord3 s t u) = vertexAttrib3N location s t u
+   vertexAttrib KeepIntegral location (TexCoord3 s t u) = vertexAttrib3I location s t u
 
+   vertexAttribv ToFloat location = vertexAttrib3v location . (castPtr :: Ptr (TexCoord3 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib3Nv location . (castPtr :: Ptr (TexCoord3 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib3Iv location . (castPtr :: Ptr (TexCoord3 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (TexCoord4 a) where
-   vertexAttrib location (TexCoord4 s t u v) = vertexAttrib4 location s t u v
-   vertexAttribv location = vertexAttrib4v location . (castPtr :: Ptr (TexCoord4 b) -> Ptr b)
+   vertexAttrib ToFloat location (TexCoord4 s t u v) = vertexAttrib4 location s t u v
+   vertexAttrib ToNormalizedFloat location (TexCoord4 s t u v) = vertexAttrib4N location s t u v
+   vertexAttrib KeepIntegral location (TexCoord4 s t u v) = vertexAttrib4I location s t u v
 
+   vertexAttribv ToFloat location = vertexAttrib4v location . (castPtr :: Ptr (TexCoord4 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib4Nv location . (castPtr :: Ptr (TexCoord4 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib4Iv location . (castPtr :: Ptr (TexCoord4 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Normal3 a) where
-   vertexAttrib location (Normal3 x y z) = vertexAttrib3 location x y z
-   vertexAttribv location = vertexAttrib3v location . (castPtr :: Ptr (Normal3 b) -> Ptr b)
+   vertexAttrib ToFloat location (Normal3 x y z) = vertexAttrib3 location x y z
+   vertexAttrib ToNormalizedFloat location (Normal3 x y z) = vertexAttrib3N location x y z
+   vertexAttrib KeepIntegral location (Normal3 x y z) = vertexAttrib3I location x y z
 
+   vertexAttribv ToFloat location = vertexAttrib3v location . (castPtr :: Ptr (Normal3 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib3Nv location . (castPtr :: Ptr (Normal3 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib3Iv location . (castPtr :: Ptr (Normal3 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (FogCoord1 a) where
-   vertexAttrib location (FogCoord1 c) = vertexAttrib1 location c
-   vertexAttribv location = vertexAttrib1v location . (castPtr :: Ptr (FogCoord1 b) -> Ptr b)
+   vertexAttrib ToFloat location (FogCoord1 c) = vertexAttrib1 location c
+   vertexAttrib ToNormalizedFloat location (FogCoord1 c) = vertexAttrib1N location c
+   vertexAttrib KeepIntegral location (FogCoord1 c) = vertexAttrib1I location c
 
+   vertexAttribv ToFloat location = vertexAttrib1v location . (castPtr :: Ptr (FogCoord1 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib1Nv location . (castPtr :: Ptr (FogCoord1 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib1Iv location . (castPtr :: Ptr (FogCoord1 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Color3 a) where
-   vertexAttrib location (Color3 r g b) = vertexAttrib3 location r g b
-   vertexAttribv location = vertexAttrib3v location . (castPtr :: Ptr (Color3 b) -> Ptr b)
+   vertexAttrib ToFloat location (Color3 r g b) = vertexAttrib3 location r g b
+   vertexAttrib ToNormalizedFloat location (Color3 r g b) = vertexAttrib3N location r g b
+   vertexAttrib KeepIntegral location (Color3 r g b) = vertexAttrib3I location r g b
 
+   vertexAttribv ToFloat location = vertexAttrib3v location . (castPtr :: Ptr (Color3 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib3Nv location . (castPtr :: Ptr (Color3 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib3Iv location . (castPtr :: Ptr (Color3 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Color4 a) where
-   vertexAttrib location (Color4 r g b a) = vertexAttrib4 location r g b a
-   vertexAttribv location = vertexAttrib4v location . (castPtr :: Ptr (Color4 b) -> Ptr b)
+   vertexAttrib ToFloat location (Color4 r g b a) = vertexAttrib4 location r g b a
+   vertexAttrib ToNormalizedFloat location (Color4 r g b a) = vertexAttrib4N location r g b a
+   vertexAttrib KeepIntegral location (Color4 r g b a) = vertexAttrib4I location r g b a
 
+   vertexAttribv ToFloat location = vertexAttrib4v location . (castPtr :: Ptr (Color4 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib4Nv location . (castPtr :: Ptr (Color4 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib4Iv location . (castPtr :: Ptr (Color4 b) -> Ptr b)
+
 instance VertexAttribComponent a => VertexAttrib (Index1 a) where
-   vertexAttrib location (Index1 i) = vertexAttrib1 location i
-   vertexAttribv location = vertexAttrib1v location . (castPtr :: Ptr (Index1 b) -> Ptr b)
+   vertexAttrib ToFloat location (Index1 i) = vertexAttrib1 location i
+   vertexAttrib ToNormalizedFloat location (Index1 i) = vertexAttrib1N location i
+   vertexAttrib KeepIntegral location (Index1 i) = vertexAttrib1I location i
+
+   vertexAttribv ToFloat location = vertexAttrib1v location . (castPtr :: Ptr (Index1 b) -> Ptr b)
+   vertexAttribv ToNormalizedFloat location = vertexAttrib1Nv location . (castPtr :: Ptr (Index1 b) -> Ptr b)
+   vertexAttribv KeepIntegral location = vertexAttrib1Iv location . (castPtr :: Ptr (Index1 b) -> Ptr b)
 
 --------------------------------------------------------------------------------
 
diff --git a/Graphics/Rendering/OpenGL/GLU.hs b/Graphics/Rendering/OpenGL/GLU.hs
--- a/Graphics/Rendering/OpenGL/GLU.hs
+++ b/Graphics/Rendering/OpenGL/GLU.hs
@@ -1,7 +1,7 @@
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/Errors.hs b/Graphics/Rendering/OpenGL/GLU/Errors.hs
--- a/Graphics/Rendering/OpenGL/GLU/Errors.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Errors.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.Errors
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs b/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs
--- a/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs
+++ b/Graphics/Rendering/OpenGL/GLU/ErrorsInternal.hs
@@ -4,7 +4,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.ErrorsInternal
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/Initialization.hs b/Graphics/Rendering/OpenGL/GLU/Initialization.hs
--- a/Graphics/Rendering/OpenGL/GLU/Initialization.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Initialization.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.Initialization
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/Matrix.hs b/Graphics/Rendering/OpenGL/GLU/Matrix.hs
--- a/Graphics/Rendering/OpenGL/GLU/Matrix.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Matrix.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.Matrix
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs b/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs
--- a/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Mipmapping.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.Mipmapping
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/NURBS.hs b/Graphics/Rendering/OpenGL/GLU/NURBS.hs
--- a/Graphics/Rendering/OpenGL/GLU/NURBS.hs
+++ b/Graphics/Rendering/OpenGL/GLU/NURBS.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.NURBS
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/Quadrics.hs b/Graphics/Rendering/OpenGL/GLU/Quadrics.hs
--- a/Graphics/Rendering/OpenGL/GLU/Quadrics.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Quadrics.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.Quadrics
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/Graphics/Rendering/OpenGL/GLU/Tessellation.hs b/Graphics/Rendering/OpenGL/GLU/Tessellation.hs
--- a/Graphics/Rendering/OpenGL/GLU/Tessellation.hs
+++ b/Graphics/Rendering/OpenGL/GLU/Tessellation.hs
@@ -1,7 +1,7 @@
 --------------------------------------------------------------------------------
 -- |
 -- Module      :  Graphics.Rendering.OpenGL.GLU.Tessellation
--- Copyright   :  (c) Sven Panne 2002-2006
+-- Copyright   :  (c) Sven Panne 2002-2009
 -- License     :  BSD-style (see the file libraries/OpenGL/LICENSE)
 -- 
 -- Maintainer  :  sven.panne@aedion.de
diff --git a/OpenGL.cabal b/OpenGL.cabal
--- a/OpenGL.cabal
+++ b/OpenGL.cabal
@@ -1,5 +1,5 @@
 name:		OpenGL
-version:	2.2.2.0
+version:	2.2.3.0
 license:	BSD3
 license-file:	LICENSE
 maintainer:	Sven Panne <sven.panne@aedion.de>
@@ -17,10 +17,9 @@
 	about OpenGL, please see: <http://www.opengl.org/>.
 build-type:     Configure
 extra-source-files:
-	config.guess config.sub install-sh
-	configure.ac configure OpenGL.buildinfo.in
-        include/HsOpenGLConfig.h.in include/HsOpenGL.h.in
-	include/HsOpenGLExt.h include/HsOpenGLTypes.h
+	OpenGL.buildinfo.in README aclocal.m4 config.guess config.sub configure
+	configure.ac include/HsOpenGL.h.in include/HsOpenGLExt.h
+	include/HsOpenGLTypes.h install-sh include/HsOpenGLConfig.h.in
 extra-tmp-files:
 	config.log config.status autom4te.cache
 	OpenGL.buildinfo include/HsOpenGLConfig.h include/HsOpenGL.h
@@ -105,10 +104,12 @@
 	Graphics.Rendering.OpenGL.GL.PrimitiveMode,
 	Graphics.Rendering.OpenGL.GL.QueryUtils,
 	Graphics.Rendering.OpenGL.GL.RenderMode,
+	Graphics.Rendering.OpenGL.GL.Tensor,
 	Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat,
 	Graphics.Rendering.OpenGL.GL.Texturing.TexParameter,
 	Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget,
 	Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit,
+	Graphics.Rendering.OpenGL.GL.VertexAttributes,
 	Graphics.Rendering.OpenGL.GLU.ErrorsInternal
 c-sources:	cbits/HsOpenGL.c
 include-dirs:	include
diff --git a/README b/README
new file mode 100644
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+To build this package using Cabal directly from darcs, you must run
+"autoreconf" before the usual Cabal build steps (configure/build/install).
+autoreconf is included in the GNU autoconf tools.  There is no need to run
+the "configure" script: the "setup configure" step will do this for you.
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,288 @@
+# Extra autoconf macros for the Glasgow fptools
+#
+# To be a good autoconf citizen, names of local macros have prefixed with FP_ to
+# ensure we don't clash with any pre-supplied autoconf ones.
+
+dnl ** Map an arithmetic C type to a Haskell type.
+dnl    Based on autconf's AC_CHECK_SIZEOF.
+
+dnl FPTOOLS_CHECK_HTYPE(TYPE [, DEFAULT_VALUE, [, VALUE-FOR-CROSS-COMPILATION])
+AC_DEFUN([FPTOOLS_CHECK_HTYPE],
+[changequote(<<, >>)dnl
+dnl The name to #define.
+define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))dnl
+dnl The cache variable name.
+define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))dnl
+define(<<AC_CV_NAME_supported>>, translit(fptools_cv_htype_sup_$1, [ *], [_p]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(Haskell type for $1)
+AC_CACHE_VAL(AC_CV_NAME,
+[AC_CV_NAME_supported=yes
+fp_check_htype_save_cppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
+#include <stddef.h>
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
+#if HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
+#if HAVE_TIME_H
+# include <time.h>
+#endif
+
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#if HAVE_STRING_H
+# include <string.h>
+#endif
+
+#if HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+#if defined(HAVE_GL_GL_H)
+# include <GL/gl.h>
+#elif defined(HAVE_OPENGL_GL_H)
+# include <OpenGL/gl.h>
+#endif
+
+#if defined(HAVE_AL_AL_H)
+# include <AL/al.h>
+#elif defined(HAVE_OPENAL_AL_H)
+# include <OpenAL/al.h>
+#endif
+
+#if defined(HAVE_AL_ALC_H)
+# include <AL/alc.h>
+#elif defined(HAVE_OPENAL_ALC_H)
+# include <OpenAL/alc.h>
+#endif
+
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+typedef $1 testing;
+
+main() {
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
+    fprintf(f, "%s%d\n",
+           ((testing)(-1) < (testing)0) ? "Int" : "Word",
+           sizeof(testing)*8);
+  } else {
+    fprintf(f,"%s\n",
+           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
+           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
+  }
+  fclose(f);
+  exit(0);
+}]])],[AC_CV_NAME=`cat conftestval`],
+[ifelse([$2], , [AC_CV_NAME=NotReallyAType; AC_CV_NAME_supported=no], [AC_CV_NAME=$2])],
+[ifelse([$3], , [AC_CV_NAME=NotReallyATypeCross; AC_CV_NAME_supported=no], [AC_CV_NAME=$3])])
+CPPFLAGS="$fp_check_htype_save_cppflags"]) dnl
+if test "$AC_CV_NAME_supported" = yes; then
+  AC_MSG_RESULT($AC_CV_NAME)
+  AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to Haskell type for $1])
+else
+  AC_MSG_RESULT([not supported])
+fi
+undefine([AC_TYPE_NAME])dnl
+undefine([AC_CV_NAME])dnl
+undefine([AC_CV_NAME_supported])dnl
+])
+
+
+# FP_ARG_OPENGL
+# -------------
+AC_DEFUN([FP_ARG_OPENGL],
+[AC_ARG_ENABLE([opengl],
+  [AC_HELP_STRING([--enable-opengl],
+    [build a Haskell binding for OpenGL (GL/GLU). On Mac OS X, use
+     --enable-opengl=x11 to use X11 instead of the "native" libraries.
+     (default=autodetect)])],
+  [enable_opengl=$enableval],
+  [enable_opengl=yes])
+])# FP_ARG_OPENGL
+
+
+# FP_CHECK_QUARTZ_OPENGL
+# ----------------------
+AC_DEFUN([FP_CHECK_QUARTZ_OPENGL],
+[AC_REQUIRE([FP_ARG_OPENGL])
+AC_REQUIRE([AC_CANONICAL_TARGET])
+
+use_quartz_opengl=no
+if test x"$enable_opengl" = xyes; then
+  case $target_os in
+  darwin*)
+    AC_DEFINE([USE_QUARTZ_OPENGL], [1],
+              [Define to 1 if native OpenGL should be used on Mac OS X])
+    use_quartz_opengl=yes
+    ;;
+  esac
+fi
+
+GLU_FRAMEWORKS=
+GLUT_FRAMEWORKS=
+if test x"$use_quartz_opengl" = xyes; then
+  GLU_FRAMEWORKS=OpenGL
+  GLUT_FRAMEWORKS=GLUT
+fi
+AC_SUBST([GLU_FRAMEWORKS])
+AC_SUBST([GLUT_FRAMEWORKS])
+])# FP_CHECK_QUARTZ_OPENGL
+
+
+# FP_CHECK_WIN32
+# --------------
+# If Windows is the target platform (e.g. MinGW/MSYS or Cygwin with
+# -mno-cygwin), the variable "fp_is_win32" is set to "yes", otherwise (e.g. *nix
+# systems or plain Cygwin) it is set to "no".
+AC_DEFUN([FP_CHECK_WIN32],
+[AC_CACHE_CHECK([for Windows environment], [fp_cv_is_win32],
+  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
+#if !_WIN32
+   syntax error;
+#endif
+])], [fp_cv_is_win32=yes], [fp_cv_is_win32=no])])
+fp_is_win32="$fp_cv_is_win32"[]dnl
+])# FP_CHECK_WIN32
+
+
+# FP_PATH_XTRA
+# ------------
+# Same as AC_PATH_XTRA, but works even for broken Cygwins which try to include
+# the non-existant <gl/mesa_wgl.h> header when -mno-cygwin is used.
+AC_DEFUN([FP_PATH_XTRA],
+[AC_REQUIRE([FP_CHECK_WIN32])
+if test x"$fp_is_win32" = xyes; then
+  no_x=yes
+else
+  AC_PATH_XTRA
+fi
+])# FP_PATH_XTRA
+
+
+# FP_CHECK_GL_HELPER(LIBNAME, LIBS, INCLUDES, FUNCTION-BODY)
+# ----------------------------------------------------------
+# Try each library in LIBS to successfully link INCLUDES plus FUNCTION-BODY,
+# setting LIBNAME_CFLAGS and LIBNAME_LIBS to the corresponding values. Sets
+# no_LIBNAME to "yes" if no suitable library was found. (LIBNAME_CFLAGS0
+# contains the value of LIBNAME_CFLAGS without CPPFLAGS, and LIBNAME_LIBS0
+# contains the value of LIBNAME_LIBS without LDFLAGS, but these are only
+# used internally.)
+AC_DEFUN([FP_CHECK_GL_HELPER],
+[AC_CACHE_CHECK([for $1 library], [fp_cv_check_$1_lib],
+  [fp_cv_check_$1_lib="no"
+  fp_save_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS ${$1_CFLAGS}"
+  fp_save_LIBS="$LIBS"
+  for fp_try_lib in $2; do
+    # transform "-lfoo" to "foo.lib" when using cl
+    if test x"$CC" = xcl; then
+      fp_try_lib=`echo $fp_try_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
+    fi
+    LIBS="$fp_try_lib ${$1_LIBS} $fp_save_LIBS"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([$3], [$4])], [fp_cv_check_$1_lib="$fp_try_lib ${$1_LIBS}"; break])
+  done
+  LIBS="$fp_save_LIBS"
+  CPPFLAGS="$fp_save_CPPFLAGS"])
+
+  if test x"$fp_cv_check_$1_lib" = xno; then
+    no_$1=yes
+    $1_CFLAGS=
+    $1_LIBS=
+  else
+    $1_CFLAGS0="${$1_CFLAGS}"
+    $1_CFLAGS="$CPPFLAGS ${$1_CFLAGS0}"
+    $1_LIBS0="$fp_cv_check_$1_lib"
+    $1_LIBS="$LDFLAGS ${$1_LIBS0}"
+  fi
+])# FP_CHECK_GL_HELPER
+
+
+# FP_CHECK_GL
+# -----------
+AC_DEFUN([FP_CHECK_GL],
+[AC_REQUIRE([FP_PATH_XTRA])
+AC_REQUIRE([FP_CHECK_QUARTZ_OPENGL])
+AC_REQUIRE([FP_CHECK_WIN32])
+
+if test x"$use_quartz_opengl" = xno; then
+  AC_CHECK_FUNC(atan,[fp_libm_not_needed=yes],[fp_libm_not_needed=dunno])
+  if test x"$fp_libm_not_needed" = xdunno; then
+     AC_CHECK_LIB([m], [atan], [GL_LIBS="-lm $GL_LIBS"])
+  fi
+
+  if test x"$no_x" != xyes; then
+    test -n "$x_includes" && GL_CFLAGS="-I$x_includes $GL_CFLAGS"
+    test -n "$x_libraries" && GL_LIBS="-L$x_libraries -lX11 $GL_LIBS"
+  fi
+
+  FP_CHECK_GL_HELPER([GL], [-lGL -lopengl32], [@%:@include <GL/gl.h>], [glEnd()])
+
+  if test x"$fp_is_win32" = xyes; then
+    # Ugly: To get wglGetProcAddress on Windows, we have to link with
+    # opengl32.dll, too, even when we are using Cygwin with X11.
+    case "$GL_LIBS" in
+      *-lopengl32*|*opengl32.lib*) ;;
+      *) fp_save_LIBS="$LIBS"
+         LIBS="$LIBS -lopengl32"
+         AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <GL/gl.h>]], [[glEnd()]])],
+           [GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"])
+         LIBS="$fp_save_LIBS"
+         ;;
+    esac
+  fi
+fi
+AC_SUBST([GL_CFLAGS])
+AC_SUBST([GL_LIBS])
+])# FP_CHECK_GL
+
+
+# FP_CHECK_GLU
+# ------------
+AC_DEFUN([FP_CHECK_GLU],
+[AC_REQUIRE([FP_CHECK_GL])dnl
+GLU_CFLAGS="$GL_CFLAGS0"
+GLU_LIBS="$GL_LIBS0"
+
+if test x"$use_quartz_opengl" = xno; then
+  FP_CHECK_GL_HELPER([GLU], [-lglu32 -lGLU], [@%:@include <GL/glu.h>], [gluNewQuadric()])
+fi
+
+AC_SUBST([GLU_CFLAGS])
+AC_SUBST([GLU_LIBS])
+])# FP_CHECK_GLU
+
+
+# FP_ARG_COMPILER
+# -------------
+AC_DEFUN([FP_ARG_COMPILER],
+[AC_ARG_WITH([compiler],
+  [AC_HELP_STRING([--with-compiler@<:@=HC@:>@],
+    [use the given Haskell compiler (default=ghc)])],
+  [with_compiler=$withval],
+  [with_compiler=ghc])
+])# FP_ARG_COMPILER
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for Haskell OpenGL package 2.2.2.0.
+# Generated by GNU Autoconf 2.63 for Haskell OpenGL package 2.2.3.0.
 #
 # Report bugs to <sven.panne@aedion.de>.
 #
@@ -596,8 +596,8 @@
 # Identity of this package.
 PACKAGE_NAME='Haskell OpenGL package'
 PACKAGE_TARNAME='OpenGL'
-PACKAGE_VERSION='2.2.2.0'
-PACKAGE_STRING='Haskell OpenGL package 2.2.2.0'
+PACKAGE_VERSION='2.2.3.0'
+PACKAGE_STRING='Haskell OpenGL package 2.2.3.0'
 PACKAGE_BUGREPORT='sven.panne@aedion.de'
 
 ac_unique_file="include/HsOpenGL.h.in"
@@ -1280,7 +1280,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Haskell OpenGL package 2.2.2.0 to adapt to many kinds of systems.
+\`configure' configures Haskell OpenGL package 2.2.3.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1350,7 +1350,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Haskell OpenGL package 2.2.2.0:";;
+     short | recursive ) echo "Configuration of Haskell OpenGL package 2.2.3.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1445,7 +1445,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Haskell OpenGL package configure 2.2.2.0
+Haskell OpenGL package configure 2.2.3.0
 generated by GNU Autoconf 2.63
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1459,7 +1459,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Haskell OpenGL package $as_me 2.2.2.0, which was
+It was created by Haskell OpenGL package $as_me 2.2.3.0, which was
 generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
@@ -7841,6 +7841,155 @@
 $as_echo "not supported" >&6; }
 fi
 
+
+# cruel hack for ancient Windows headers
+{ $as_echo "$as_me:$LINENO: checking Haskell type for char" >&5
+$as_echo_n "checking Haskell type for char... " >&6; }
+if test "${fptools_cv_htype_char+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  fptools_cv_htype_sup_char=yes
+fp_check_htype_save_cppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+if test "$cross_compiling" = yes; then
+  fptools_cv_htype_char=NotReallyATypeCross; fptools_cv_htype_sup_char=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stddef.h>
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
+#if HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
+#if HAVE_TIME_H
+# include <time.h>
+#endif
+
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#if HAVE_STRING_H
+# include <string.h>
+#endif
+
+#if HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+#if defined(HAVE_GL_GL_H)
+# include <GL/gl.h>
+#elif defined(HAVE_OPENGL_GL_H)
+# include <OpenGL/gl.h>
+#endif
+
+#if defined(HAVE_AL_AL_H)
+# include <AL/al.h>
+#elif defined(HAVE_OPENAL_AL_H)
+# include <OpenAL/al.h>
+#endif
+
+#if defined(HAVE_AL_ALC_H)
+# include <AL/alc.h>
+#elif defined(HAVE_OPENAL_ALC_H)
+# include <OpenAL/alc.h>
+#endif
+
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+typedef char testing;
+
+main() {
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
+    fprintf(f, "%s%d\n",
+           ((testing)(-1) < (testing)0) ? "Int" : "Word",
+           sizeof(testing)*8);
+  } else {
+    fprintf(f,"%s\n",
+           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
+           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
+  }
+  fclose(f);
+  exit(0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  fptools_cv_htype_char=`cat conftestval`
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+fptools_cv_htype_char=NotReallyAType; fptools_cv_htype_sup_char=no
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+CPPFLAGS="$fp_check_htype_save_cppflags"
+fi
+ if test "$fptools_cv_htype_sup_char" = yes; then
+  { $as_echo "$as_me:$LINENO: result: $fptools_cv_htype_char" >&5
+$as_echo "$fptools_cv_htype_char" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define HTYPE_CHAR $fptools_cv_htype_char
+_ACEOF
+
+else
+  { $as_echo "$as_me:$LINENO: result: not supported" >&5
+$as_echo "not supported" >&6; }
+fi
+
 { $as_echo "$as_me:$LINENO: checking Haskell type for GLchar" >&5
 $as_echo_n "checking Haskell type for GLchar... " >&6; }
 if test "${fptools_cv_htype_GLchar+set}" = set; then
@@ -7966,7 +8115,7 @@
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-fptools_cv_htype_GLchar=NotReallyAType; fptools_cv_htype_sup_GLchar=no
+fptools_cv_htype_GLchar=$fptools_cv_htype_char
 fi
 rm -rf conftest.dSYM
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
@@ -7988,6 +8137,155 @@
 $as_echo "not supported" >&6; }
 fi
 
+
+# ... and a similar hack
+{ $as_echo "$as_me:$LINENO: checking Haskell type for ptrdiff_t" >&5
+$as_echo_n "checking Haskell type for ptrdiff_t... " >&6; }
+if test "${fptools_cv_htype_ptrdiff_t+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  fptools_cv_htype_sup_ptrdiff_t=yes
+fp_check_htype_save_cppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+if test "$cross_compiling" = yes; then
+  fptools_cv_htype_ptrdiff_t=NotReallyATypeCross; fptools_cv_htype_sup_ptrdiff_t=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stddef.h>
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
+#if HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
+#if HAVE_TIME_H
+# include <time.h>
+#endif
+
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#if HAVE_STRING_H
+# include <string.h>
+#endif
+
+#if HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+#if defined(HAVE_GL_GL_H)
+# include <GL/gl.h>
+#elif defined(HAVE_OPENGL_GL_H)
+# include <OpenGL/gl.h>
+#endif
+
+#if defined(HAVE_AL_AL_H)
+# include <AL/al.h>
+#elif defined(HAVE_OPENAL_AL_H)
+# include <OpenAL/al.h>
+#endif
+
+#if defined(HAVE_AL_ALC_H)
+# include <AL/alc.h>
+#elif defined(HAVE_OPENAL_ALC_H)
+# include <OpenAL/alc.h>
+#endif
+
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+typedef ptrdiff_t testing;
+
+main() {
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
+    fprintf(f, "%s%d\n",
+           ((testing)(-1) < (testing)0) ? "Int" : "Word",
+           sizeof(testing)*8);
+  } else {
+    fprintf(f,"%s\n",
+           (sizeof(testing) >  sizeof(double)) ? "LDouble" :
+           (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
+  }
+  fclose(f);
+  exit(0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  fptools_cv_htype_ptrdiff_t=`cat conftestval`
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+fptools_cv_htype_ptrdiff_t=NotReallyAType; fptools_cv_htype_sup_ptrdiff_t=no
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+CPPFLAGS="$fp_check_htype_save_cppflags"
+fi
+ if test "$fptools_cv_htype_sup_ptrdiff_t" = yes; then
+  { $as_echo "$as_me:$LINENO: result: $fptools_cv_htype_ptrdiff_t" >&5
+$as_echo "$fptools_cv_htype_ptrdiff_t" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define HTYPE_PTRDIFF_T $fptools_cv_htype_ptrdiff_t
+_ACEOF
+
+else
+  { $as_echo "$as_me:$LINENO: result: not supported" >&5
+$as_echo "not supported" >&6; }
+fi
+
 { $as_echo "$as_me:$LINENO: checking Haskell type for GLintptr" >&5
 $as_echo_n "checking Haskell type for GLintptr... " >&6; }
 if test "${fptools_cv_htype_GLintptr+set}" = set; then
@@ -8113,7 +8411,7 @@
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-fptools_cv_htype_GLintptr=NotReallyAType; fptools_cv_htype_sup_GLintptr=no
+fptools_cv_htype_GLintptr=$fptools_cv_htype_ptrdiff_t
 fi
 rm -rf conftest.dSYM
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
@@ -8260,7 +8558,7 @@
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-fptools_cv_htype_GLsizeiptr=NotReallyAType; fptools_cv_htype_sup_GLsizeiptr=no
+fptools_cv_htype_GLsizeiptr=$fptools_cv_htype_ptrdiff_t
 fi
 rm -rf conftest.dSYM
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
@@ -8737,7 +9035,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Haskell OpenGL package $as_me 2.2.2.0, which was
+This file was extended by Haskell OpenGL package $as_me 2.2.3.0, which was
 generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -8796,7 +9094,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-Haskell OpenGL package config.status 2.2.2.0
+Haskell OpenGL package config.status 2.2.3.0
 configured by $0, generated by GNU Autoconf 2.63,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([Haskell OpenGL package], [2.2.2.0], [sven.panne@aedion.de], [OpenGL])
+AC_INIT([Haskell OpenGL package], [2.2.3.0], [sven.panne@aedion.de], [OpenGL])
 
 # Safety check: Ensure that we are in the correct source directory.
 AC_CONFIG_SRCDIR([include/HsOpenGL.h.in])
@@ -56,9 +56,15 @@
 FPTOOLS_CHECK_HTYPE([GLclampf])
 FPTOOLS_CHECK_HTYPE([GLdouble])
 FPTOOLS_CHECK_HTYPE([GLclampd])
-FPTOOLS_CHECK_HTYPE([GLchar])
-FPTOOLS_CHECK_HTYPE([GLintptr])
-FPTOOLS_CHECK_HTYPE([GLsizeiptr])
+
+# cruel hack for ancient Windows headers
+FPTOOLS_CHECK_HTYPE([char])
+FPTOOLS_CHECK_HTYPE([GLchar], [$fptools_cv_htype_char])
+
+# ... and a similar hack
+FPTOOLS_CHECK_HTYPE([ptrdiff_t])
+FPTOOLS_CHECK_HTYPE([GLintptr], [$fptools_cv_htype_ptrdiff_t])
+FPTOOLS_CHECK_HTYPE([GLsizeiptr], [$fptools_cv_htype_ptrdiff_t])
 
 AC_DEFINE_UNQUOTED([GLU_CFLAGS],
   [`echo '' $GLU_CFLAGS | sed -e 's/-[[^ ]]*/,"&"/g' -e 's/^ *,//'`],
diff --git a/include/HsOpenGLConfig.h.in b/include/HsOpenGLConfig.h.in
--- a/include/HsOpenGLConfig.h.in
+++ b/include/HsOpenGLConfig.h.in
@@ -48,6 +48,9 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to Haskell type for char */
+#undef HTYPE_CHAR
+
 /* Define to Haskell type for GLbitfield */
 #undef HTYPE_GLBITFIELD
 
@@ -98,6 +101,9 @@
 
 /* Define to Haskell type for GLushort */
 #undef HTYPE_GLUSHORT
+
+/* Define to Haskell type for ptrdiff_t */
+#undef HTYPE_PTRDIFF_T
 
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
