+
+(define (array->pointer x)
+ (lambda (x)
+ (if x
+ (ffi:bytevector->pointer x)
+ ffi:%null-pointer)))
+
+(define-syntax define-array-foreign-type
+ (syntax-rules ()
+ ((_ name element-type)
+ (define-foreign-type name '*
+ array->pointer
+ (lambda (x) x)))))
+
+(define-array-foreign-type GLboolean-* GLboolean)
+(define-array-foreign-type GLbyte-* GLbyte)
+(define-array-foreign-type GLubyte-* GLubyte)
+(define-array-foreign-type GLchar-* GLchar)
+(define-array-foreign-type GLshort-* GLshort)
+(define-array-foreign-type GLushort-* GLushort)
+(define-array-foreign-type GLint-* GLint)
+(define-array-foreign-type GLuint-* GLuint)
+(define-array-foreign-type GLsizei-* GLsizei)
+(define-array-foreign-type GLenum-* GLenum)
+(define-array-foreign-type GLfloat-* GLfloat)
+(define-array-foreign-type GLclampf-* GLclampf)
+(define-array-foreign-type GLdouble-* GLdouble)
+(define-array-foreign-type GLclampd-* GLclampd)
+
+(define-array-foreign-type const-GLboolean-* GLboolean)
+(define-array-foreign-type const-GLbyte-* GLbyte)
+(define-array-foreign-type const-GLubyte-* GLubyte)
+(define-array-foreign-type const-GLshort-* GLshort)
+(define-array-foreign-type const-GLushort-* GLushort)
+(define-array-foreign-type const-GLint-* GLint)
+(define-array-foreign-type const-GLuint-* GLuint)
+(define-array-foreign-type const-GLsizei-* GLsizei)
+(define-array-foreign-type const-GLenum-* GLenum)
+(define-array-foreign-type const-GLfloat-* GLfloat)
+(define-array-foreign-type const-GLclampf-* GLclampf)
+(define-array-foreign-type const-GLdouble-* GLdouble)
+(define-array-foreign-type const-GLclampd-* GLclampd)
+(define-array-foreign-type const-GLvoid-* GLvoid)
+
+(define-foreign-type const-GLchar-* '*
+ ffi:string->pointer
+ ffi:pointer->string)
+
+;; Functions with these types will need special help.
+(define-simple-foreign-type GLvoid-** '*)
+(define-simple-foreign-type const-GLchar-** '*)