type-specific wrapping and unwrapping of scheme values
[clinton/guile-figl.git] / figl / gl / types.scm
CommitLineData
37a0c0f3
DH
1;;; figl
2;;; Copyright (C) 2013 Daniel Hartwig <mandyke@gmail.com>
3;;;
4;;; Figl is free software: you can redistribute it and/or modify it
5;;; under the terms of the GNU Lesser General Public License as
6;;; published by the Free Software Foundation, either version 3 of the
7;;; License, or (at your option) any later version.
8;;;
9;;; Figl is distributed in the hope that it will be useful, but WITHOUT
10;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
12;;; Public License for more details.
13;;;
14;;; You should have received a copy of the GNU Lesser General Public
15;;; License along with this program. If not, see
16;;; <http://www.gnu.org/licenses/>.
17
18;;; Commentary:
19;;
20;; Mappings from OpenGL to FFI types.
21;;
22;;; Code:
23
7ec693ed 24(define-module (figl gl types)
93f72ad8
AW
25 #:use-module (figl runtime)
26 #:use-module ((system foreign) #:renamer (symbol-prefix-proc 'ffi:))
27 #:export (void
28 GLboolean
37a0c0f3
DH
29 GLbyte
30 GLubyte
31 GLchar
32 GLshort
33 GLushort
34 GLint
35 GLuint
36 GLsizei
37 GLenum
38 GLintptr
39 GLsizeiptr
40 GLbitfield
41 GLfloat
42 GLclampf
43 GLdouble
00239761
AW
44 GLclampd
45
46 GLboolean-*
47 GLchar-*
48 GLdouble-*
49 GLenum-*
50 GLfloat-*
51 GLint-*
52 GLsizei-*
53 GLubyte-*
54 GLuint-*
55 GLvoid-*
56 const-GLchar-*
57 const-GLchar-**
58 const-GLclampf-*
59 const-GLdouble-*
60 const-GLenum-*
61 const-GLfloat-*
62 const-GLint-*
63 const-GLsizei-*
64 const-GLubyte*
65 const-GLubyte-*
66 const-GLubyte-*
67 const-GLuint-*
68 const-GLvoid-*
69 const-GLvoid-**
70 void-*))
37a0c0f3
DH
71
72(define %ptr
93f72ad8
AW
73 (case (ffi:sizeof '*)
74 ((4) ffi:uint32)
75 ((8) ffi:uint64)
37a0c0f3
DH
76 (else (error "unknown pointer size"))))
77
93f72ad8
AW
78(define-simple-foreign-type void ffi:void)
79(define-simple-foreign-type GLboolean ffi:uint8)
80(define-simple-foreign-type GLbyte ffi:int8)
81(define-simple-foreign-type GLubyte ffi:uint8)
82(define-simple-foreign-type GLchar ffi:int8)
83(define-simple-foreign-type Glshort ffi:int16)
84(define-simple-foreign-type GLushort ffi:uint16)
85(define-simple-foreign-type GLint ffi:int32)
86(define-simple-foreign-type GLuint ffi:uint32)
87(define-simple-foreign-type GLsizei ffi:int32)
88(define-simple-foreign-type GLenum ffi:uint32)
89(define-simple-foreign-type GLintptr %ptr)
90(define-simple-foreign-type GLsizeiptr %ptr)
91(define-simple-foreign-type GLbitfield ffi:uint32)
92(define-simple-foreign-type GLfloat ffi:float)
93(define-simple-foreign-type GLclampf ffi:float)
94(define-simple-foreign-type GLdouble ffi:double)
95(define-simple-foreign-type GLclampd ffi:double)
00239761
AW
96
97;; All of these have different meanings and we should be able to do a
98;; basic job at teasing them out, but for now, just use the limited
99;; annotation from (system foreign).
93f72ad8
AW
100(define-simple-foreign-type GLboolean-* '*)
101(define-simple-foreign-type GLchar-* '*)
102(define-simple-foreign-type GLdouble-* '*)
103(define-simple-foreign-type GLenum-* '*)
104(define-simple-foreign-type GLfloat-* '*)
105(define-simple-foreign-type GLint-* '*)
106(define-simple-foreign-type GLsizei-* '*)
107(define-simple-foreign-type GLubyte-* '*)
108(define-simple-foreign-type GLuint-* '*)
109(define-simple-foreign-type GLvoid-* '*)
110(define-simple-foreign-type const-GLchar-* '*)
111(define-simple-foreign-type const-GLchar-** '*)
112(define-simple-foreign-type const-GLclampf-* '*)
113(define-simple-foreign-type const-GLdouble-* '*)
114(define-simple-foreign-type const-GLenum-* '*)
115(define-simple-foreign-type const-GLfloat-* '*)
116(define-simple-foreign-type const-GLint-* '*)
117(define-simple-foreign-type const-GLsizei-* '*)
118(define-simple-foreign-type const-GLubyte* '*)
119(define-simple-foreign-type const-GLubyte-* '*)
120(define-simple-foreign-type const-GLubyte-* '*)
121(define-simple-foreign-type const-GLuint-* '*)
122(define-simple-foreign-type const-GLvoid-* '*)
123(define-simple-foreign-type const-GLvoid-** '*)
124(define-simple-foreign-type void-* '*)