diff --git a/GLUT.cabal b/GLUT.cabal
--- a/GLUT.cabal
+++ b/GLUT.cabal
@@ -1,5 +1,5 @@
 name: GLUT
-version: 2.5.1.0
+version: 2.5.1.1
 license: BSD3
 license-file: LICENSE
 maintainer: Sven Panne <svenpanne@gmail.com>, Jason Dagit <dagitj@gmail.com>
@@ -34,6 +34,10 @@
    examples/Makefile
    examples/Misc/00-README
    examples/Misc/ARBOcclude.hs
+   examples/Misc/ColorTriangle/ColorTriangle.hs
+   examples/Misc/ColorTriangle/Makefile
+   examples/Misc/ColorTriangle/color_triangles.frac
+   examples/Misc/ColorTriangle/color_triangles.vert
    examples/Misc/ExtractContours.hs
    examples/Misc/Gears.hs
    examples/Misc/Makefile
diff --git a/Graphics/UI/GLUT/Raw/Functions.hs b/Graphics/UI/GLUT/Raw/Functions.hs
--- a/Graphics/UI/GLUT/Raw/Functions.hs
+++ b/Graphics/UI/GLUT/Raw/Functions.hs
@@ -183,161 +183,161 @@
 
 #include "HsGLUTExt.h"
 
-API_ENTRY(glutAddMenuEntry,Ptr CChar -> CInt -> IO ())
-API_ENTRY(glutAddSubMenu,Ptr CChar -> CInt -> IO ())
-API_ENTRY(glutAppStatusFunc,FunPtr AppStatusFunc -> IO ())
-API_ENTRY(glutAttachMenu,CInt -> IO ())
-API_ENTRY(glutBitmapCharacter,Ptr a -> CInt -> IO ())
-API_ENTRY(glutBitmapHeight,Ptr a -> IO CInt)
-API_ENTRY(glutBitmapLength,Ptr a -> Ptr CUChar -> IO CInt)
-API_ENTRY(glutBitmapString,Ptr a -> Ptr CUChar -> IO ())
-API_ENTRY(glutBitmapWidth,Ptr a -> CInt -> IO CInt)
-API_ENTRY(glutButtonBoxFunc,FunPtr ButtonBoxFunc -> IO ())
-API_ENTRY(glutChangeToMenuEntry,CInt -> Ptr CChar -> CInt -> IO ())
-API_ENTRY(glutChangeToSubMenu,CInt -> Ptr CChar -> CInt -> IO ())
-API_ENTRY(glutCloseFunc,FunPtr CloseFunc -> IO ())
-API_ENTRY(glutCopyColormap,CInt -> IO ())
-API_ENTRY(glutCreateMenu,FunPtr MenuFunc -> IO CInt)
-API_ENTRY(glutCreateSubWindow,CInt -> CInt -> CInt -> CInt -> CInt -> IO CInt)
-API_ENTRY(glutCreateWindow,Ptr CChar -> IO CInt)
-API_ENTRY(glutDestroyMenu,CInt -> IO ())
-API_ENTRY(glutDestroyWindow,CInt -> IO ())
-API_ENTRY(glutDetachMenu,CInt -> IO ())
-API_ENTRY(glutDeviceGet,GLenum -> IO CInt)
-API_ENTRY(glutDialsFunc,FunPtr DialsFunc -> IO ())
-API_ENTRY(glutDisplayFunc,FunPtr DisplayFunc -> IO ())
-API_ENTRY(glutEnterGameMode,IO CInt)
-API_ENTRY(glutEntryFunc,FunPtr EntryFunc -> IO ())
-API_ENTRY_SAFE(glutEstablishOverlay,IO ())
-API_ENTRY(glutExit,IO ())
-API_ENTRY(glutExtensionSupported,Ptr CChar -> IO CInt)
-API_ENTRY(glutForceJoystickFunc,IO ())
-API_ENTRY(glutFullScreen,IO ())
-API_ENTRY(glutFullScreenToggle,IO ())
-API_ENTRY(glutGameModeGet,GLenum -> IO CInt)
-API_ENTRY(glutGameModeString,Ptr CChar -> IO ())
-API_ENTRY(glutGet,GLenum -> IO CInt)
-API_ENTRY(glutGetColor,CInt -> CInt -> IO GLfloat)
-API_ENTRY(glutGetMenu,IO CInt)
-API_ENTRY(glutGetMenuData,IO (Ptr a))
-API_ENTRY(glutGetModeValues,GLenum -> Ptr CInt -> IO (Ptr CInt))
-API_ENTRY(glutGetModifiers,IO CInt)
-API_ENTRY(glutGetProcAddress,Ptr CChar -> IO (FunPtr a))
-API_ENTRY(glutGetWindow,IO CInt)
-API_ENTRY(glutGetWindowData,IO (Ptr a))
-API_ENTRY_SAFE(glutHideOverlay,IO ())
-API_ENTRY(glutHideWindow,IO ())
-API_ENTRY(glutIconifyWindow,IO ())
-API_ENTRY(glutIdleFunc,FunPtr IdleFunc -> IO ())
-API_ENTRY(glutIgnoreKeyRepeat,CInt -> IO ())
-API_ENTRY(glutInit,Ptr CInt -> Ptr (Ptr CChar) -> IO ())
-API_ENTRY(glutInitContextFlags,CInt -> IO ())
-API_ENTRY(glutInitContextFunc,FunPtr InitContextFunc -> IO ())
-API_ENTRY(glutInitContextProfile,CInt -> IO ())
-API_ENTRY(glutInitContextVersion,CInt -> CInt -> IO ())
-API_ENTRY(glutInitDisplayMode,CUInt -> IO ())
-API_ENTRY(glutInitDisplayString,Ptr CChar -> IO ())
-API_ENTRY(glutInitWindowPosition,CInt -> CInt -> IO ())
-API_ENTRY(glutInitWindowSize,CInt -> CInt -> IO ())
-API_ENTRY(glutJoystickFunc,FunPtr JoystickFunc -> CInt -> IO ())
-API_ENTRY(glutKeyboardFunc,FunPtr KeyboardFunc -> IO ())
-API_ENTRY(glutKeyboardUpFunc,FunPtr KeyboardUpFunc -> IO ())
-API_ENTRY(glutLayerGet,GLenum -> IO CInt)
-API_ENTRY(glutLeaveFullScreen,IO ())
-API_ENTRY(glutLeaveGameMode,IO ())
-API_ENTRY_SAFE(glutLeaveMainLoop,IO ())
-API_ENTRY_SAFE(glutMainLoop,IO ())
-API_ENTRY_SAFE(glutMainLoopEvent,IO ())
-API_ENTRY(glutMenuDestroyFunc,FunPtr MenuDestroyFunc -> IO ())
-API_ENTRY(glutMenuStateFunc,FunPtr MenuStateFunc -> IO ())
-API_ENTRY(glutMenuStatusFunc,FunPtr MenuStatusFunc -> IO ())
-API_ENTRY(glutMotionFunc,FunPtr MotionFunc -> IO ())
-API_ENTRY(glutMouseFunc,FunPtr MouseFunc -> IO ())
-API_ENTRY(glutMouseWheelFunc,FunPtr MouseWheelFunc -> IO ())
-API_ENTRY(glutMultiButtonFunc,FunPtr MultiButtonFunc -> IO ())
-API_ENTRY(glutMultiEntryFunc,FunPtr MultiEntryFunc -> IO ())
-API_ENTRY(glutMultiMotionFunc,FunPtr MultiMotionFunc -> IO ())
-API_ENTRY(glutMultiPassiveFunc,FunPtr MultiPassiveFunc -> IO ())
-API_ENTRY(glutOverlayDisplayFunc,FunPtr OverlayDisplayFunc -> IO ())
-API_ENTRY(glutPassiveMotionFunc,FunPtr PassiveMotionFunc -> IO ())
-API_ENTRY(glutPopWindow,IO ())
-API_ENTRY(glutPositionFunc,FunPtr PositionFunc -> IO ())
-API_ENTRY(glutPositionWindow,CInt -> CInt -> IO ())
-API_ENTRY_SAFE(glutPostOverlayRedisplay,IO ())
-API_ENTRY(glutPostRedisplay,IO ())
-API_ENTRY_SAFE(glutPostWindowOverlayRedisplay,CInt -> IO ())
-API_ENTRY(glutPostWindowRedisplay,CInt -> IO ())
-API_ENTRY(glutPushWindow,IO ())
-API_ENTRY(glutRemoveMenuItem,CInt -> IO ())
-API_ENTRY_SAFE(glutRemoveOverlay,IO ())
-API_ENTRY(glutReportErrors,IO ())
-API_ENTRY(glutReshapeFunc,FunPtr ReshapeFunc -> IO ())
-API_ENTRY(glutReshapeWindow,CInt -> CInt -> IO ())
-API_ENTRY(glutSetColor,CInt -> GLfloat -> GLfloat -> GLfloat -> IO ())
-API_ENTRY(glutSetCursor,CInt -> IO ())
-API_ENTRY(glutSetIconTitle,Ptr CChar -> IO ())
-API_ENTRY(glutSetKeyRepeat,CInt -> IO ())
-API_ENTRY(glutSetMenu,CInt -> IO ())
-API_ENTRY(glutSetMenuData,Ptr a -> IO ())
-API_ENTRY(glutSetMenuFont,GLint -> Ptr a -> IO ())
-API_ENTRY(glutSetOption,GLenum -> CInt -> IO ())
-API_ENTRY(glutSetVertexAttribCoord3,GLint -> IO ())
-API_ENTRY(glutSetVertexAttribNormal,GLint -> IO ())
-API_ENTRY(glutSetVertexAttribTexCoord2,GLint -> IO ())
-API_ENTRY(glutSetWindow,CInt -> IO ())
-API_ENTRY(glutSetWindowData,Ptr a -> IO ())
-API_ENTRY(glutSetWindowTitle,Ptr CChar -> IO ())
-API_ENTRY(glutSetupVideoResizing,IO ())
-API_ENTRY_SAFE(glutShowOverlay,IO ())
-API_ENTRY(glutShowWindow,IO ())
-API_ENTRY(glutSolidCone,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutSolidCube,GLdouble -> IO ())
-API_ENTRY(glutSolidCylinder,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutSolidDodecahedron,IO ())
-API_ENTRY(glutSolidIcosahedron,IO ())
-API_ENTRY(glutSolidOctahedron,IO ())
-API_ENTRY(glutSolidRhombicDodecahedron,IO ())
-API_ENTRY(glutSolidSierpinskiSponge,CInt -> Ptr GLdouble -> GLdouble -> IO ())
-API_ENTRY(glutSolidSphere,GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutSolidTeacup,GLdouble -> IO ())
-API_ENTRY(glutSolidTeapot,GLdouble -> IO ())
-API_ENTRY(glutSolidTeaspoon,GLdouble -> IO ())
-API_ENTRY(glutSolidTetrahedron,IO ())
-API_ENTRY(glutSolidTorus,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutSpaceballButtonFunc,FunPtr SpaceballButtonFunc -> IO ())
-API_ENTRY(glutSpaceballMotionFunc,FunPtr SpaceballMotionFunc -> IO ())
-API_ENTRY(glutSpaceballRotateFunc,FunPtr SpaceballRotateFunc -> IO ())
-API_ENTRY(glutSpecialFunc,FunPtr SpecialFunc -> IO ())
-API_ENTRY(glutSpecialUpFunc,FunPtr SpecialUpFunc -> IO ())
-API_ENTRY(glutStopVideoResizing,IO ())
-API_ENTRY(glutStrokeCharacter,Ptr a -> CInt -> IO ())
-API_ENTRY(glutStrokeHeight,Ptr a -> IO GLfloat)
-API_ENTRY(glutStrokeLength,Ptr a -> Ptr CUChar -> IO CInt)
-API_ENTRY(glutStrokeString,Ptr a -> Ptr CUChar -> IO ())
-API_ENTRY(glutStrokeWidth,Ptr a -> CInt -> IO CInt)
-API_ENTRY(glutSwapBuffers,IO ())
-API_ENTRY(glutTabletButtonFunc,FunPtr TabletButtonFunc -> IO ())
-API_ENTRY(glutTabletMotionFunc,FunPtr TabletMotionFunc -> IO ())
-API_ENTRY(glutTimerFunc,CUInt -> FunPtr TimerFunc -> CInt -> IO ())
-API_ENTRY_SAFE(glutUseLayer,GLenum -> IO ())
-API_ENTRY(glutVideoPan,CInt -> CInt -> CInt -> CInt -> IO ())
-API_ENTRY(glutVideoResize,CInt -> CInt -> CInt -> CInt -> IO ())
-API_ENTRY(glutVideoResizeGet,GLenum -> IO CInt)
-API_ENTRY(glutVisibilityFunc,FunPtr VisibilityFunc -> IO ())
-API_ENTRY(glutWMCloseFunc,FunPtr WMCloseFunc -> IO ())
-API_ENTRY(glutWarpPointer,CInt -> CInt -> IO ())
-API_ENTRY(glutWindowStatusFunc,FunPtr WindowStatusFunc -> IO ())
-API_ENTRY(glutWireCone,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutWireCube,GLdouble -> IO ())
-API_ENTRY(glutWireCylinder,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutWireDodecahedron,IO ())
-API_ENTRY(glutWireIcosahedron,IO ())
-API_ENTRY(glutWireOctahedron,IO ())
-API_ENTRY(glutWireRhombicDodecahedron,IO ())
-API_ENTRY(glutWireSierpinskiSponge,CInt -> Ptr GLdouble -> GLdouble -> IO ())
-API_ENTRY(glutWireSphere,GLdouble -> GLint -> GLint -> IO ())
-API_ENTRY(glutWireTeacup,GLdouble -> IO ())
-API_ENTRY(glutWireTeapot,GLdouble -> IO ())
-API_ENTRY(glutWireTeaspoon,GLdouble -> IO ())
-API_ENTRY(glutWireTetrahedron,IO ())
-API_ENTRY(glutWireTorus,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutAddMenuEntry,ptr_glutAddMenuEntry,"glutAddMenuEntry",glutAddMenuEntry,Ptr CChar -> CInt -> IO ())
+API_ENTRY(dyn_glutAddSubMenu,ptr_glutAddSubMenu,"glutAddSubMenu",glutAddSubMenu,Ptr CChar -> CInt -> IO ())
+API_ENTRY(dyn_glutAppStatusFunc,ptr_glutAppStatusFunc,"glutAppStatusFunc",glutAppStatusFunc,FunPtr AppStatusFunc -> IO ())
+API_ENTRY(dyn_glutAttachMenu,ptr_glutAttachMenu,"glutAttachMenu",glutAttachMenu,CInt -> IO ())
+API_ENTRY(dyn_glutBitmapCharacter,ptr_glutBitmapCharacter,"glutBitmapCharacter",glutBitmapCharacter,Ptr a -> CInt -> IO ())
+API_ENTRY(dyn_glutBitmapHeight,ptr_glutBitmapHeight,"glutBitmapHeight",glutBitmapHeight,Ptr a -> IO CInt)
+API_ENTRY(dyn_glutBitmapLength,ptr_glutBitmapLength,"glutBitmapLength",glutBitmapLength,Ptr a -> Ptr CUChar -> IO CInt)
+API_ENTRY(dyn_glutBitmapString,ptr_glutBitmapString,"glutBitmapString",glutBitmapString,Ptr a -> Ptr CUChar -> IO ())
+API_ENTRY(dyn_glutBitmapWidth,ptr_glutBitmapWidth,"glutBitmapWidth",glutBitmapWidth,Ptr a -> CInt -> IO CInt)
+API_ENTRY(dyn_glutButtonBoxFunc,ptr_glutButtonBoxFunc,"glutButtonBoxFunc",glutButtonBoxFunc,FunPtr ButtonBoxFunc -> IO ())
+API_ENTRY(dyn_glutChangeToMenuEntry,ptr_glutChangeToMenuEntry,"glutChangeToMenuEntry",glutChangeToMenuEntry,CInt -> Ptr CChar -> CInt -> IO ())
+API_ENTRY(dyn_glutChangeToSubMenu,ptr_glutChangeToSubMenu,"glutChangeToSubMenu",glutChangeToSubMenu,CInt -> Ptr CChar -> CInt -> IO ())
+API_ENTRY(dyn_glutCloseFunc,ptr_glutCloseFunc,"glutCloseFunc",glutCloseFunc,FunPtr CloseFunc -> IO ())
+API_ENTRY(dyn_glutCopyColormap,ptr_glutCopyColormap,"glutCopyColormap",glutCopyColormap,CInt -> IO ())
+API_ENTRY(dyn_glutCreateMenu,ptr_glutCreateMenu,"glutCreateMenu",glutCreateMenu,FunPtr MenuFunc -> IO CInt)
+API_ENTRY(dyn_glutCreateSubWindow,ptr_glutCreateSubWindow,"glutCreateSubWindow",glutCreateSubWindow,CInt -> CInt -> CInt -> CInt -> CInt -> IO CInt)
+API_ENTRY(dyn_glutCreateWindow,ptr_glutCreateWindow,"glutCreateWindow",glutCreateWindow,Ptr CChar -> IO CInt)
+API_ENTRY(dyn_glutDestroyMenu,ptr_glutDestroyMenu,"glutDestroyMenu",glutDestroyMenu,CInt -> IO ())
+API_ENTRY(dyn_glutDestroyWindow,ptr_glutDestroyWindow,"glutDestroyWindow",glutDestroyWindow,CInt -> IO ())
+API_ENTRY(dyn_glutDetachMenu,ptr_glutDetachMenu,"glutDetachMenu",glutDetachMenu,CInt -> IO ())
+API_ENTRY(dyn_glutDeviceGet,ptr_glutDeviceGet,"glutDeviceGet",glutDeviceGet,GLenum -> IO CInt)
+API_ENTRY(dyn_glutDialsFunc,ptr_glutDialsFunc,"glutDialsFunc",glutDialsFunc,FunPtr DialsFunc -> IO ())
+API_ENTRY(dyn_glutDisplayFunc,ptr_glutDisplayFunc,"glutDisplayFunc",glutDisplayFunc,FunPtr DisplayFunc -> IO ())
+API_ENTRY(dyn_glutEnterGameMode,ptr_glutEnterGameMode,"glutEnterGameMode",glutEnterGameMode,IO CInt)
+API_ENTRY(dyn_glutEntryFunc,ptr_glutEntryFunc,"glutEntryFunc",glutEntryFunc,FunPtr EntryFunc -> IO ())
+API_ENTRY_SAFE(dyn_glutEstablishOverlay,ptr_glutEstablishOverlay,"glutEstablishOverlay",glutEstablishOverlay,IO ())
+API_ENTRY(dyn_glutExit,ptr_glutExit,"glutExit",glutExit,IO ())
+API_ENTRY(dyn_glutExtensionSupported,ptr_glutExtensionSupported,"glutExtensionSupported",glutExtensionSupported,Ptr CChar -> IO CInt)
+API_ENTRY(dyn_glutForceJoystickFunc,ptr_glutForceJoystickFunc,"glutForceJoystickFunc",glutForceJoystickFunc,IO ())
+API_ENTRY(dyn_glutFullScreen,ptr_glutFullScreen,"glutFullScreen",glutFullScreen,IO ())
+API_ENTRY(dyn_glutFullScreenToggle,ptr_glutFullScreenToggle,"glutFullScreenToggle",glutFullScreenToggle,IO ())
+API_ENTRY(dyn_glutGameModeGet,ptr_glutGameModeGet,"glutGameModeGet",glutGameModeGet,GLenum -> IO CInt)
+API_ENTRY(dyn_glutGameModeString,ptr_glutGameModeString,"glutGameModeString",glutGameModeString,Ptr CChar -> IO ())
+API_ENTRY(dyn_glutGet,ptr_glutGet,"glutGet",glutGet,GLenum -> IO CInt)
+API_ENTRY(dyn_glutGetColor,ptr_glutGetColor,"glutGetColor",glutGetColor,CInt -> CInt -> IO GLfloat)
+API_ENTRY(dyn_glutGetMenu,ptr_glutGetMenu,"glutGetMenu",glutGetMenu,IO CInt)
+API_ENTRY(dyn_glutGetMenuData,ptr_glutGetMenuData,"glutGetMenuData",glutGetMenuData,IO (Ptr a))
+API_ENTRY(dyn_glutGetModeValues,ptr_glutGetModeValues,"glutGetModeValues",glutGetModeValues,GLenum -> Ptr CInt -> IO (Ptr CInt))
+API_ENTRY(dyn_glutGetModifiers,ptr_glutGetModifiers,"glutGetModifiers",glutGetModifiers,IO CInt)
+API_ENTRY(dyn_glutGetProcAddress,ptr_glutGetProcAddress,"glutGetProcAddress",glutGetProcAddress,Ptr CChar -> IO (FunPtr a))
+API_ENTRY(dyn_glutGetWindow,ptr_glutGetWindow,"glutGetWindow",glutGetWindow,IO CInt)
+API_ENTRY(dyn_glutGetWindowData,ptr_glutGetWindowData,"glutGetWindowData",glutGetWindowData,IO (Ptr a))
+API_ENTRY_SAFE(dyn_glutHideOverlay,ptr_glutHideOverlay,"glutHideOverlay",glutHideOverlay,IO ())
+API_ENTRY(dyn_glutHideWindow,ptr_glutHideWindow,"glutHideWindow",glutHideWindow,IO ())
+API_ENTRY(dyn_glutIconifyWindow,ptr_glutIconifyWindow,"glutIconifyWindow",glutIconifyWindow,IO ())
+API_ENTRY(dyn_glutIdleFunc,ptr_glutIdleFunc,"glutIdleFunc",glutIdleFunc,FunPtr IdleFunc -> IO ())
+API_ENTRY(dyn_glutIgnoreKeyRepeat,ptr_glutIgnoreKeyRepeat,"glutIgnoreKeyRepeat",glutIgnoreKeyRepeat,CInt -> IO ())
+API_ENTRY(dyn_glutInit,ptr_glutInit,"glutInit",glutInit,Ptr CInt -> Ptr (Ptr CChar) -> IO ())
+API_ENTRY(dyn_glutInitContextFlags,ptr_glutInitContextFlags,"glutInitContextFlags",glutInitContextFlags,CInt -> IO ())
+API_ENTRY(dyn_glutInitContextFunc,ptr_glutInitContextFunc,"glutInitContextFunc",glutInitContextFunc,FunPtr InitContextFunc -> IO ())
+API_ENTRY(dyn_glutInitContextProfile,ptr_glutInitContextProfile,"glutInitContextProfile",glutInitContextProfile,CInt -> IO ())
+API_ENTRY(dyn_glutInitContextVersion,ptr_glutInitContextVersion,"glutInitContextVersion",glutInitContextVersion,CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutInitDisplayMode,ptr_glutInitDisplayMode,"glutInitDisplayMode",glutInitDisplayMode,CUInt -> IO ())
+API_ENTRY(dyn_glutInitDisplayString,ptr_glutInitDisplayString,"glutInitDisplayString",glutInitDisplayString,Ptr CChar -> IO ())
+API_ENTRY(dyn_glutInitWindowPosition,ptr_glutInitWindowPosition,"glutInitWindowPosition",glutInitWindowPosition,CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutInitWindowSize,ptr_glutInitWindowSize,"glutInitWindowSize",glutInitWindowSize,CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutJoystickFunc,ptr_glutJoystickFunc,"glutJoystickFunc",glutJoystickFunc,FunPtr JoystickFunc -> CInt -> IO ())
+API_ENTRY(dyn_glutKeyboardFunc,ptr_glutKeyboardFunc,"glutKeyboardFunc",glutKeyboardFunc,FunPtr KeyboardFunc -> IO ())
+API_ENTRY(dyn_glutKeyboardUpFunc,ptr_glutKeyboardUpFunc,"glutKeyboardUpFunc",glutKeyboardUpFunc,FunPtr KeyboardUpFunc -> IO ())
+API_ENTRY(dyn_glutLayerGet,ptr_glutLayerGet,"glutLayerGet",glutLayerGet,GLenum -> IO CInt)
+API_ENTRY(dyn_glutLeaveFullScreen,ptr_glutLeaveFullScreen,"glutLeaveFullScreen",glutLeaveFullScreen,IO ())
+API_ENTRY(dyn_glutLeaveGameMode,ptr_glutLeaveGameMode,"glutLeaveGameMode",glutLeaveGameMode,IO ())
+API_ENTRY_SAFE(dyn_glutLeaveMainLoop,ptr_glutLeaveMainLoop,"glutLeaveMainLoop",glutLeaveMainLoop,IO ())
+API_ENTRY_SAFE(dyn_glutMainLoop,ptr_glutMainLoop,"glutMainLoop",glutMainLoop,IO ())
+API_ENTRY_SAFE(dyn_glutMainLoopEvent,ptr_glutMainLoopEvent,"glutMainLoopEvent",glutMainLoopEvent,IO ())
+API_ENTRY(dyn_glutMenuDestroyFunc,ptr_glutMenuDestroyFunc,"glutMenuDestroyFunc",glutMenuDestroyFunc,FunPtr MenuDestroyFunc -> IO ())
+API_ENTRY(dyn_glutMenuStateFunc,ptr_glutMenuStateFunc,"glutMenuStateFunc",glutMenuStateFunc,FunPtr MenuStateFunc -> IO ())
+API_ENTRY(dyn_glutMenuStatusFunc,ptr_glutMenuStatusFunc,"glutMenuStatusFunc",glutMenuStatusFunc,FunPtr MenuStatusFunc -> IO ())
+API_ENTRY(dyn_glutMotionFunc,ptr_glutMotionFunc,"glutMotionFunc",glutMotionFunc,FunPtr MotionFunc -> IO ())
+API_ENTRY(dyn_glutMouseFunc,ptr_glutMouseFunc,"glutMouseFunc",glutMouseFunc,FunPtr MouseFunc -> IO ())
+API_ENTRY(dyn_glutMouseWheelFunc,ptr_glutMouseWheelFunc,"glutMouseWheelFunc",glutMouseWheelFunc,FunPtr MouseWheelFunc -> IO ())
+API_ENTRY(dyn_glutMultiButtonFunc,ptr_glutMultiButtonFunc,"glutMultiButtonFunc",glutMultiButtonFunc,FunPtr MultiButtonFunc -> IO ())
+API_ENTRY(dyn_glutMultiEntryFunc,ptr_glutMultiEntryFunc,"glutMultiEntryFunc",glutMultiEntryFunc,FunPtr MultiEntryFunc -> IO ())
+API_ENTRY(dyn_glutMultiMotionFunc,ptr_glutMultiMotionFunc,"glutMultiMotionFunc",glutMultiMotionFunc,FunPtr MultiMotionFunc -> IO ())
+API_ENTRY(dyn_glutMultiPassiveFunc,ptr_glutMultiPassiveFunc,"glutMultiPassiveFunc",glutMultiPassiveFunc,FunPtr MultiPassiveFunc -> IO ())
+API_ENTRY(dyn_glutOverlayDisplayFunc,ptr_glutOverlayDisplayFunc,"glutOverlayDisplayFunc",glutOverlayDisplayFunc,FunPtr OverlayDisplayFunc -> IO ())
+API_ENTRY(dyn_glutPassiveMotionFunc,ptr_glutPassiveMotionFunc,"glutPassiveMotionFunc",glutPassiveMotionFunc,FunPtr PassiveMotionFunc -> IO ())
+API_ENTRY(dyn_glutPopWindow,ptr_glutPopWindow,"glutPopWindow",glutPopWindow,IO ())
+API_ENTRY(dyn_glutPositionFunc,ptr_glutPositionFunc,"glutPositionFunc",glutPositionFunc,FunPtr PositionFunc -> IO ())
+API_ENTRY(dyn_glutPositionWindow,ptr_glutPositionWindow,"glutPositionWindow",glutPositionWindow,CInt -> CInt -> IO ())
+API_ENTRY_SAFE(dyn_glutPostOverlayRedisplay,ptr_glutPostOverlayRedisplay,"glutPostOverlayRedisplay",glutPostOverlayRedisplay,IO ())
+API_ENTRY(dyn_glutPostRedisplay,ptr_glutPostRedisplay,"glutPostRedisplay",glutPostRedisplay,IO ())
+API_ENTRY_SAFE(dyn_glutPostWindowOverlayRedisplay,ptr_glutPostWindowOverlayRedisplay,"glutPostWindowOverlayRedisplay",glutPostWindowOverlayRedisplay,CInt -> IO ())
+API_ENTRY(dyn_glutPostWindowRedisplay,ptr_glutPostWindowRedisplay,"glutPostWindowRedisplay",glutPostWindowRedisplay,CInt -> IO ())
+API_ENTRY(dyn_glutPushWindow,ptr_glutPushWindow,"glutPushWindow",glutPushWindow,IO ())
+API_ENTRY(dyn_glutRemoveMenuItem,ptr_glutRemoveMenuItem,"glutRemoveMenuItem",glutRemoveMenuItem,CInt -> IO ())
+API_ENTRY_SAFE(dyn_glutRemoveOverlay,ptr_glutRemoveOverlay,"glutRemoveOverlay",glutRemoveOverlay,IO ())
+API_ENTRY(dyn_glutReportErrors,ptr_glutReportErrors,"glutReportErrors",glutReportErrors,IO ())
+API_ENTRY(dyn_glutReshapeFunc,ptr_glutReshapeFunc,"glutReshapeFunc",glutReshapeFunc,FunPtr ReshapeFunc -> IO ())
+API_ENTRY(dyn_glutReshapeWindow,ptr_glutReshapeWindow,"glutReshapeWindow",glutReshapeWindow,CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutSetColor,ptr_glutSetColor,"glutSetColor",glutSetColor,CInt -> GLfloat -> GLfloat -> GLfloat -> IO ())
+API_ENTRY(dyn_glutSetCursor,ptr_glutSetCursor,"glutSetCursor",glutSetCursor,CInt -> IO ())
+API_ENTRY(dyn_glutSetIconTitle,ptr_glutSetIconTitle,"glutSetIconTitle",glutSetIconTitle,Ptr CChar -> IO ())
+API_ENTRY(dyn_glutSetKeyRepeat,ptr_glutSetKeyRepeat,"glutSetKeyRepeat",glutSetKeyRepeat,CInt -> IO ())
+API_ENTRY(dyn_glutSetMenu,ptr_glutSetMenu,"glutSetMenu",glutSetMenu,CInt -> IO ())
+API_ENTRY(dyn_glutSetMenuData,ptr_glutSetMenuData,"glutSetMenuData",glutSetMenuData,Ptr a -> IO ())
+API_ENTRY(dyn_glutSetMenuFont,ptr_glutSetMenuFont,"glutSetMenuFont",glutSetMenuFont,GLint -> Ptr a -> IO ())
+API_ENTRY(dyn_glutSetOption,ptr_glutSetOption,"glutSetOption",glutSetOption,GLenum -> CInt -> IO ())
+API_ENTRY(dyn_glutSetVertexAttribCoord3,ptr_glutSetVertexAttribCoord3,"glutSetVertexAttribCoord3",glutSetVertexAttribCoord3,GLint -> IO ())
+API_ENTRY(dyn_glutSetVertexAttribNormal,ptr_glutSetVertexAttribNormal,"glutSetVertexAttribNormal",glutSetVertexAttribNormal,GLint -> IO ())
+API_ENTRY(dyn_glutSetVertexAttribTexCoord2,ptr_glutSetVertexAttribTexCoord2,"glutSetVertexAttribTexCoord2",glutSetVertexAttribTexCoord2,GLint -> IO ())
+API_ENTRY(dyn_glutSetWindow,ptr_glutSetWindow,"glutSetWindow",glutSetWindow,CInt -> IO ())
+API_ENTRY(dyn_glutSetWindowData,ptr_glutSetWindowData,"glutSetWindowData",glutSetWindowData,Ptr a -> IO ())
+API_ENTRY(dyn_glutSetWindowTitle,ptr_glutSetWindowTitle,"glutSetWindowTitle",glutSetWindowTitle,Ptr CChar -> IO ())
+API_ENTRY(dyn_glutSetupVideoResizing,ptr_glutSetupVideoResizing,"glutSetupVideoResizing",glutSetupVideoResizing,IO ())
+API_ENTRY_SAFE(dyn_glutShowOverlay,ptr_glutShowOverlay,"glutShowOverlay",glutShowOverlay,IO ())
+API_ENTRY(dyn_glutShowWindow,ptr_glutShowWindow,"glutShowWindow",glutShowWindow,IO ())
+API_ENTRY(dyn_glutSolidCone,ptr_glutSolidCone,"glutSolidCone",glutSolidCone,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutSolidCube,ptr_glutSolidCube,"glutSolidCube",glutSolidCube,GLdouble -> IO ())
+API_ENTRY(dyn_glutSolidCylinder,ptr_glutSolidCylinder,"glutSolidCylinder",glutSolidCylinder,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutSolidDodecahedron,ptr_glutSolidDodecahedron,"glutSolidDodecahedron",glutSolidDodecahedron,IO ())
+API_ENTRY(dyn_glutSolidIcosahedron,ptr_glutSolidIcosahedron,"glutSolidIcosahedron",glutSolidIcosahedron,IO ())
+API_ENTRY(dyn_glutSolidOctahedron,ptr_glutSolidOctahedron,"glutSolidOctahedron",glutSolidOctahedron,IO ())
+API_ENTRY(dyn_glutSolidRhombicDodecahedron,ptr_glutSolidRhombicDodecahedron,"glutSolidRhombicDodecahedron",glutSolidRhombicDodecahedron,IO ())
+API_ENTRY(dyn_glutSolidSierpinskiSponge,ptr_glutSolidSierpinskiSponge,"glutSolidSierpinskiSponge",glutSolidSierpinskiSponge,CInt -> Ptr GLdouble -> GLdouble -> IO ())
+API_ENTRY(dyn_glutSolidSphere,ptr_glutSolidSphere,"glutSolidSphere",glutSolidSphere,GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutSolidTeacup,ptr_glutSolidTeacup,"glutSolidTeacup",glutSolidTeacup,GLdouble -> IO ())
+API_ENTRY(dyn_glutSolidTeapot,ptr_glutSolidTeapot,"glutSolidTeapot",glutSolidTeapot,GLdouble -> IO ())
+API_ENTRY(dyn_glutSolidTeaspoon,ptr_glutSolidTeaspoon,"glutSolidTeaspoon",glutSolidTeaspoon,GLdouble -> IO ())
+API_ENTRY(dyn_glutSolidTetrahedron,ptr_glutSolidTetrahedron,"glutSolidTetrahedron",glutSolidTetrahedron,IO ())
+API_ENTRY(dyn_glutSolidTorus,ptr_glutSolidTorus,"glutSolidTorus",glutSolidTorus,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutSpaceballButtonFunc,ptr_glutSpaceballButtonFunc,"glutSpaceballButtonFunc",glutSpaceballButtonFunc,FunPtr SpaceballButtonFunc -> IO ())
+API_ENTRY(dyn_glutSpaceballMotionFunc,ptr_glutSpaceballMotionFunc,"glutSpaceballMotionFunc",glutSpaceballMotionFunc,FunPtr SpaceballMotionFunc -> IO ())
+API_ENTRY(dyn_glutSpaceballRotateFunc,ptr_glutSpaceballRotateFunc,"glutSpaceballRotateFunc",glutSpaceballRotateFunc,FunPtr SpaceballRotateFunc -> IO ())
+API_ENTRY(dyn_glutSpecialFunc,ptr_glutSpecialFunc,"glutSpecialFunc",glutSpecialFunc,FunPtr SpecialFunc -> IO ())
+API_ENTRY(dyn_glutSpecialUpFunc,ptr_glutSpecialUpFunc,"glutSpecialUpFunc",glutSpecialUpFunc,FunPtr SpecialUpFunc -> IO ())
+API_ENTRY(dyn_glutStopVideoResizing,ptr_glutStopVideoResizing,"glutStopVideoResizing",glutStopVideoResizing,IO ())
+API_ENTRY(dyn_glutStrokeCharacter,ptr_glutStrokeCharacter,"glutStrokeCharacter",glutStrokeCharacter,Ptr a -> CInt -> IO ())
+API_ENTRY(dyn_glutStrokeHeight,ptr_glutStrokeHeight,"glutStrokeHeight",glutStrokeHeight,Ptr a -> IO GLfloat)
+API_ENTRY(dyn_glutStrokeLength,ptr_glutStrokeLength,"glutStrokeLength",glutStrokeLength,Ptr a -> Ptr CUChar -> IO CInt)
+API_ENTRY(dyn_glutStrokeString,ptr_glutStrokeString,"glutStrokeString",glutStrokeString,Ptr a -> Ptr CUChar -> IO ())
+API_ENTRY(dyn_glutStrokeWidth,ptr_glutStrokeWidth,"glutStrokeWidth",glutStrokeWidth,Ptr a -> CInt -> IO CInt)
+API_ENTRY(dyn_glutSwapBuffers,ptr_glutSwapBuffers,"glutSwapBuffers",glutSwapBuffers,IO ())
+API_ENTRY(dyn_glutTabletButtonFunc,ptr_glutTabletButtonFunc,"glutTabletButtonFunc",glutTabletButtonFunc,FunPtr TabletButtonFunc -> IO ())
+API_ENTRY(dyn_glutTabletMotionFunc,ptr_glutTabletMotionFunc,"glutTabletMotionFunc",glutTabletMotionFunc,FunPtr TabletMotionFunc -> IO ())
+API_ENTRY(dyn_glutTimerFunc,ptr_glutTimerFunc,"glutTimerFunc",glutTimerFunc,CUInt -> FunPtr TimerFunc -> CInt -> IO ())
+API_ENTRY_SAFE(dyn_glutUseLayer,ptr_glutUseLayer,"glutUseLayer",glutUseLayer,GLenum -> IO ())
+API_ENTRY(dyn_glutVideoPan,ptr_glutVideoPan,"glutVideoPan",glutVideoPan,CInt -> CInt -> CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutVideoResize,ptr_glutVideoResize,"glutVideoResize",glutVideoResize,CInt -> CInt -> CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutVideoResizeGet,ptr_glutVideoResizeGet,"glutVideoResizeGet",glutVideoResizeGet,GLenum -> IO CInt)
+API_ENTRY(dyn_glutVisibilityFunc,ptr_glutVisibilityFunc,"glutVisibilityFunc",glutVisibilityFunc,FunPtr VisibilityFunc -> IO ())
+API_ENTRY(dyn_glutWMCloseFunc,ptr_glutWMCloseFunc,"glutWMCloseFunc",glutWMCloseFunc,FunPtr WMCloseFunc -> IO ())
+API_ENTRY(dyn_glutWarpPointer,ptr_glutWarpPointer,"glutWarpPointer",glutWarpPointer,CInt -> CInt -> IO ())
+API_ENTRY(dyn_glutWindowStatusFunc,ptr_glutWindowStatusFunc,"glutWindowStatusFunc",glutWindowStatusFunc,FunPtr WindowStatusFunc -> IO ())
+API_ENTRY(dyn_glutWireCone,ptr_glutWireCone,"glutWireCone",glutWireCone,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutWireCube,ptr_glutWireCube,"glutWireCube",glutWireCube,GLdouble -> IO ())
+API_ENTRY(dyn_glutWireCylinder,ptr_glutWireCylinder,"glutWireCylinder",glutWireCylinder,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutWireDodecahedron,ptr_glutWireDodecahedron,"glutWireDodecahedron",glutWireDodecahedron,IO ())
+API_ENTRY(dyn_glutWireIcosahedron,ptr_glutWireIcosahedron,"glutWireIcosahedron",glutWireIcosahedron,IO ())
+API_ENTRY(dyn_glutWireOctahedron,ptr_glutWireOctahedron,"glutWireOctahedron",glutWireOctahedron,IO ())
+API_ENTRY(dyn_glutWireRhombicDodecahedron,ptr_glutWireRhombicDodecahedron,"glutWireRhombicDodecahedron",glutWireRhombicDodecahedron,IO ())
+API_ENTRY(dyn_glutWireSierpinskiSponge,ptr_glutWireSierpinskiSponge,"glutWireSierpinskiSponge",glutWireSierpinskiSponge,CInt -> Ptr GLdouble -> GLdouble -> IO ())
+API_ENTRY(dyn_glutWireSphere,ptr_glutWireSphere,"glutWireSphere",glutWireSphere,GLdouble -> GLint -> GLint -> IO ())
+API_ENTRY(dyn_glutWireTeacup,ptr_glutWireTeacup,"glutWireTeacup",glutWireTeacup,GLdouble -> IO ())
+API_ENTRY(dyn_glutWireTeapot,ptr_glutWireTeapot,"glutWireTeapot",glutWireTeapot,GLdouble -> IO ())
+API_ENTRY(dyn_glutWireTeaspoon,ptr_glutWireTeaspoon,"glutWireTeaspoon",glutWireTeaspoon,GLdouble -> IO ())
+API_ENTRY(dyn_glutWireTetrahedron,ptr_glutWireTetrahedron,"glutWireTetrahedron",glutWireTetrahedron,IO ())
+API_ENTRY(dyn_glutWireTorus,ptr_glutWireTorus,"glutWireTorus",glutWireTorus,GLdouble -> GLdouble -> GLint -> GLint -> IO ())
diff --git a/examples/Misc/ColorTriangle/ColorTriangle.hs b/examples/Misc/ColorTriangle/ColorTriangle.hs
new file mode 100644
--- /dev/null
+++ b/examples/Misc/ColorTriangle/ColorTriangle.hs
@@ -0,0 +1,101 @@
+{-
+   ColorTriangle.hs (adapted from triangles.cpp which is (c) The Red Book
+   Authors.)
+   Copyright (c) Sven Panne 2014 <svenpanne@gmail.com>
+   This file is part of HOpenGL and distributed under a BSD-style license
+   See the file GLUT/LICENSE
+
+   A variation of Triangles.hs, adding colors to vertices via interleaved vertex
+   attributes.
+-}
+
+import Control.Monad
+import Foreign.Marshal.Array
+import Foreign.Ptr
+import Foreign.Storable
+import Graphics.UI.GLUT
+import Prelude hiding ( init )
+import LoadShaders
+
+bufferOffset :: Integral a => a -> Ptr b
+bufferOffset = plusPtr nullPtr . fromIntegral
+
+data Descriptor = Descriptor VertexArrayObject ArrayIndex NumArrayIndices
+
+data ColoredVertex = ColoredVertex (Vertex2 GLfloat) (Color3 GLfloat)
+
+instance Storable ColoredVertex where
+  sizeOf ~(ColoredVertex v c) = sizeOf v + sizeOf c
+  alignment ~(ColoredVertex v _) = alignment v
+  peek ptr = do v <- peek (castPtr ptr)
+                c <- peekByteOff (castPtr ptr) (sizeOf v)
+                return $ ColoredVertex v c
+  poke ptr (ColoredVertex v c) = do poke (castPtr ptr) v
+                                    pokeByteOff (castPtr ptr) (sizeOf v) c
+
+init :: IO Descriptor
+init = do
+  triangles <- genObjectName
+  bindVertexArrayObject $= Just triangles
+
+  let vertices = [
+        -- Triangle 1
+        ColoredVertex (Vertex2 (-0.90) (-0.90)) (Color3 1 0 0),
+        ColoredVertex (Vertex2   0.85  (-0.90)) (Color3 0 1 0),
+        ColoredVertex (Vertex2 (-0.90)   0.85 ) (Color3 0 0 1),
+        -- Triangle 2
+        ColoredVertex (Vertex2   0.90  (-0.85)) (Color3 0 1 1),
+        ColoredVertex (Vertex2   0.90    0.90 ) (Color3 1 0 1),
+        ColoredVertex (Vertex2 (-0.85)   0.90 ) (Color3 1 1 0)]
+      numVertices = length vertices
+      vertexSize = sizeOf (head vertices)
+
+  arrayBuffer <- genObjectName
+  bindBuffer ArrayBuffer $= Just arrayBuffer
+  withArray vertices $ \ptr -> do
+    let size = fromIntegral (numVertices * vertexSize)
+    bufferData ArrayBuffer $= (size, ptr, StaticDraw)
+
+  program <- loadShaders [
+     ShaderInfo VertexShader (FileSource "color_triangles.vert"),
+     ShaderInfo FragmentShader (FileSource "color_triangles.frac")]
+  currentProgram $= Just program
+
+  let firstIndex = 0
+      vPosition = AttribLocation 0
+      vColor = AttribLocation 1
+  vertexAttribPointer vPosition $=
+    (ToFloat,
+     VertexArrayDescriptor 2 Float (fromIntegral vertexSize)
+                           (bufferOffset (firstIndex * vertexSize)))
+  vertexAttribArray vPosition $= Enabled
+  let colorOffset = case head vertices of ~(ColoredVertex v _) -> sizeOf v
+  vertexAttribPointer vColor $=
+    (ToFloat,
+     VertexArrayDescriptor 3 Float (fromIntegral vertexSize)
+                           (bufferOffset ((firstIndex * vertexSize) +
+                                          fromIntegral colorOffset)))
+  vertexAttribArray vColor $= Enabled
+
+  return $
+    Descriptor triangles (fromIntegral firstIndex) (fromIntegral numVertices)
+
+display :: Descriptor -> DisplayCallback
+display (Descriptor triangles firstIndex numVertices) = do
+  clear [ ColorBuffer ]
+  bindVertexArrayObject $= Just triangles
+  drawArrays Triangles firstIndex numVertices
+  flush
+
+main :: IO ()
+main = do
+  (progName, _args) <- getArgsAndInitialize
+  initialDisplayMode $= [ RGBAMode ]
+  initialWindowSize $= Size 512 512
+  initialContextVersion $= (4, 3)
+  initialContextFlags $= [ DebugContext ]
+  initialContextProfile $= [ CoreProfile ]
+  _ <- createWindow progName
+  descriptor <- init
+  displayCallback $= display descriptor
+  mainLoop
diff --git a/examples/Misc/ColorTriangle/Makefile b/examples/Misc/ColorTriangle/Makefile
new file mode 100644
--- /dev/null
+++ b/examples/Misc/ColorTriangle/Makefile
@@ -0,0 +1,2 @@
+HC_SEARCH_PATHS := ../../RedBook8/common/
+include ../../examples.mk
diff --git a/examples/Misc/ColorTriangle/color_triangles.frac b/examples/Misc/ColorTriangle/color_triangles.frac
new file mode 100644
--- /dev/null
+++ b/examples/Misc/ColorTriangle/color_triangles.frac
@@ -0,0 +1,10 @@
+#version 430 core
+
+in vec4 color;	
+out vec4 fColor;
+
+void
+main()
+{
+   fColor = color;
+}
diff --git a/examples/Misc/ColorTriangle/color_triangles.vert b/examples/Misc/ColorTriangle/color_triangles.vert
new file mode 100644
--- /dev/null
+++ b/examples/Misc/ColorTriangle/color_triangles.vert
@@ -0,0 +1,12 @@
+#version 430 core
+
+layout(location = 0) in vec4 vPosition;
+layout(location = 1) in vec4 vColor;
+out vec4 color;
+
+void
+main()
+{
+   gl_Position = vPosition;
+   color = vColor;
+}
diff --git a/examples/Misc/Makefile b/examples/Misc/Makefile
--- a/examples/Misc/Makefile
+++ b/examples/Misc/Makefile
@@ -1,1 +1,2 @@
+SUBDIRS := ColorTriangle
 include ../examples.mk
diff --git a/examples/RedBook8/Chapter01/Triangles.hs b/examples/RedBook8/Chapter01/Triangles.hs
--- a/examples/RedBook8/Chapter01/Triangles.hs
+++ b/examples/RedBook8/Chapter01/Triangles.hs
@@ -1,8 +1,8 @@
 {-
    Triangles.hs (adapted from triangles.cpp which is (c) The Red Book Authors.)
-   Copyright (c) Sven Panne 2013 <svenpanne@gmail.com>
+   Copyright (c) Sven Panne 2014 <svenpanne@gmail.com>
    This file is part of HOpenGL and distributed under a BSD-style license
-   See the file libraries/GLUT/LICENSE
+   See the file GLUT/LICENSE
 
    Our first OpenGL program.
 -}
@@ -13,17 +13,8 @@
 import Foreign.Storable
 import Graphics.UI.GLUT
 import Prelude hiding ( init )
-import System.IO
 import LoadShaders
 
--- TODO: Just for debugging, remove me later.
-checkError :: String -> IO ()
-checkError functionName = get errors >>= mapM_ reportError
-  where reportError e =
-          hPutStrLn stderr (showError e ++ " detected in " ++ functionName)
-        showError (Error category message) =
-          "GL error " ++ show category ++ " (" ++ message ++ ")"
-
 bufferOffset :: Integral a => a -> Ptr b
 bufferOffset = plusPtr nullPtr . fromIntegral
 
@@ -42,11 +33,12 @@
         Vertex2   0.90    0.90 ,
         Vertex2 (-0.85)   0.90 ] :: [Vertex2 GLfloat]
       numVertices = length vertices
+      vertexSize = sizeOf (head vertices)
 
   arrayBuffer <- genObjectName
   bindBuffer ArrayBuffer $= Just arrayBuffer
   withArray vertices $ \ptr -> do
-    let size = fromIntegral (numVertices * sizeOf (head vertices))
+    let size = fromIntegral (numVertices * vertexSize)
     bufferData ArrayBuffer $= (size, ptr, StaticDraw)
 
   program <- loadShaders [
@@ -57,11 +49,12 @@
   let firstIndex = 0
       vPosition = AttribLocation 0
   vertexAttribPointer vPosition $=
-    (ToFloat, VertexArrayDescriptor 2 Float 0 (bufferOffset firstIndex))
+    (ToFloat,
+     VertexArrayDescriptor 2 Float 0 (bufferOffset (firstIndex * vertexSize)))
   vertexAttribArray vPosition $= Enabled
 
-  checkError "init"
-  return $ Descriptor triangles firstIndex (fromIntegral numVertices)
+  return $
+    Descriptor triangles (fromIntegral firstIndex) (fromIntegral numVertices)
 
 display :: Descriptor -> DisplayCallback
 display (Descriptor triangles firstIndex numVertices) = do
@@ -69,7 +62,6 @@
   bindVertexArrayObject $= Just triangles
   drawArrays Triangles firstIndex numVertices
   flush
-  checkError "display"
 
 main :: IO ()
 main = do
@@ -77,10 +69,6 @@
   initialDisplayMode $= [ RGBAMode ]
   initialWindowSize $= Size 512 512
   initialContextVersion $= (4, 3)
-
-  -- TODO: Just for debugging, remove me later.
-  initialContextFlags $= [ DebugContext ]
-
   initialContextProfile $= [ CoreProfile ]
   _ <- createWindow progName
   descriptor <- init
diff --git a/include/HsGLUTExt.h b/include/HsGLUTExt.h
--- a/include/HsGLUTExt.h
+++ b/include/HsGLUTExt.h
@@ -15,19 +15,21 @@
 #ifndef HSGLUTEXT_H
 #define HSGLUTEXT_H
 
+#define HASH #
+
 /* NOTE: The macro must immediately start with the foreign declaration,
    otherwise the magic mangler (hack_foreign) in the Hugs build system
    doesn't recognize it. */
-#define API_ENTRY_INTERNAL(_entry,_ty,_safety) \
-foreign import CALLCONV _safety "dynamic" dyn_/**/_entry :: Graphics.UI.GLUT.Raw.APIEntry.Invoker (_ty) ; \
+#define API_ENTRY_INTERNAL(_dyn_entry,_ptr_entry,_str_entry,_entry,_ty,_safety) \
+foreign import CALLCONV _safety "dynamic" _dyn_entry :: Graphics.UI.GLUT.Raw.APIEntry.Invoker (_ty) ; \
 _entry :: (_ty) ; \
-_entry = dyn_/**/_entry ptr_/**/_entry ; \
-ptr_/**/_entry :: FunPtr a ; \
-ptr_/**/_entry = unsafePerformIO (Graphics.UI.GLUT.Raw.APIEntry.getAPIEntry "_entry") ; \
-{-# NOINLINE ptr_/**/_entry #-}
+_entry = _dyn_entry _ptr_entry ; \
+_ptr_entry :: FunPtr a ; \
+_ptr_entry = unsafePerformIO (Graphics.UI.GLUT.Raw.APIEntry.getAPIEntry _str_entry) ; \
+{-HASH NOINLINE _ptr_entry HASH-}
 
-#define API_ENTRY(_entry,_ty) API_ENTRY_INTERNAL(_entry,_ty,unsafe)
+#define API_ENTRY(_dyn_entry,_ptr_entry,_str_entry,_entry,_ty) API_ENTRY_INTERNAL(_dyn_entry,_ptr_entry,_str_entry,_entry,_ty,unsafe)
 
-#define API_ENTRY_SAFE(_entry,_ty) API_ENTRY_INTERNAL(_entry,_ty,safe)
+#define API_ENTRY_SAFE(_dyn_entry,_ptr_entry,_str_entry,_entry,_ty) API_ENTRY_INTERNAL(_dyn_entry,_ptr_entry,_str_entry,_entry,_ty,safe)
 
 #endif
