Fix corner case
[llpp.git] / lablGL / ml_gl.h
blob8053cf4a6bc9e418e1137cd780cd6dc427ea8e4d
1 /* $Id: ml_gl.h,v 1.21 2003-10-03 04:27:19 garrigue Exp $ */
3 #ifndef _ml_gl_
4 #define _ml_gl_
6 #include "ml_raw.h"
8 void ml_raise_gl (const char *errmsg) Noreturn;
9 #define copy_string_check lablgl_copy_string_check
10 value copy_string_check (const char *str);
12 GLenum GLenum_val (value);
14 #define Float_val(dbl) ((GLfloat) Double_val(dbl))
15 #define Addr_val(addr) ((GLvoid *) addr)
16 #define Val_addr(addr) ((value) addr)
17 #define Type_raw(raw) (GLenum_val(Kind_raw(raw)))
18 #define Type_void_raw(raw) Type_raw(raw), Void_raw(raw)
20 #define ML_0(cname) \
21 CAMLprim value ml_##cname (value unit) \
22 { cname (); return Val_unit; }
23 #define ML_1(cname, conv1) \
24 CAMLprim value ml_##cname (value arg1) \
25 { cname (conv1(arg1)); return Val_unit; }
26 #define ML_2(cname, conv1, conv2) \
27 CAMLprim value ml_##cname (value arg1, value arg2) \
28 { cname (conv1(arg1), conv2(arg2)); return Val_unit; }
29 #define ML_3(cname, conv1, conv2, conv3) \
30 CAMLprim value ml_##cname (value arg1, value arg2, value arg3) \
31 { cname (conv1(arg1), conv2(arg2), conv3(arg3)); return Val_unit; }
32 #define ML_4(cname, conv1, conv2, conv3, conv4) \
33 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4) \
34 { cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4)); \
35 return Val_unit; }
36 #define ML_5(cname, conv1, conv2, conv3, conv4, conv5) \
37 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
38 value arg5) \
39 { cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), conv5(arg5)); \
40 return Val_unit; }
41 #define ML_6(cname, conv1, conv2, conv3, conv4, conv5, conv6) \
42 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
43 value arg5, value arg6) \
44 { cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), conv5(arg5), \
45 conv6(arg6)); \
46 return Val_unit; }
47 #define ML_7(cname, conv1, conv2, conv3, conv4, conv5, conv6, conv7) \
48 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
49 value arg5, value arg6, value arg7) \
50 { cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), conv5(arg5), \
51 conv6(arg6), conv7(arg7)); \
52 return Val_unit; }
53 #define ML_8(cname, conv1, conv2, conv3, conv4, conv5, conv6, conv7, conv8) \
54 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
55 value arg5, value arg6, value arg7, value arg8) \
56 { cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), conv5(arg5), \
57 conv6(arg6), conv7(arg7), conv8(arg8)); \
58 return Val_unit; }
60 #define ML_0_(cname, conv) \
61 CAMLprim value ml_##cname (value unit) \
62 { return conv (cname ()); }
63 #define ML_1_(cname, conv1, conv) \
64 CAMLprim value ml_##cname (value arg1) \
65 { return conv (cname (conv1(arg1))); }
66 #define ML_2_(cname, conv1, conv2, conv) \
67 CAMLprim value ml_##cname (value arg1, value arg2) \
68 { return conv (cname (conv1(arg1), conv2(arg2))); }
69 #define ML_3_(cname, conv1, conv2, conv3, conv) \
70 CAMLprim value ml_##cname (value arg1, value arg2, value arg3) \
71 { return conv (cname (conv1(arg1), conv2(arg2), conv3(arg3))); }
72 #define ML_4_(cname, conv1, conv2, conv3, conv4, conv) \
73 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4) \
74 { return conv (cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4))); }
75 #define ML_5_(cname, conv1, conv2, conv3, conv4, conv5, conv) \
76 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
77 value arg5) \
78 { return conv (cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), \
79 conv5(arg5))); }
80 #define ML_6_(cname, conv1, conv2, conv3, conv4, conv5, conv6, conv) \
81 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
82 value arg5, value arg6) \
83 { return conv (cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), \
84 conv5(arg5), conv6(arg6))); }
85 #define ML_7_(cname, conv1, conv2, conv3, conv4, conv5, conv6, conv7, conv) \
86 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
87 value arg5, value arg6, value arg7) \
88 { return conv (cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), \
89 conv5(arg5), conv6(arg6), conv7(arg7))); }
90 #define ML_8_(cname, conv1, conv2, conv3, conv4, conv5, conv6, conv7, conv8, \
91 conv) \
92 CAMLprim value ml_##cname (value arg1, value arg2, value arg3, value arg4, \
93 value arg5, value arg6, value arg7, value arg8) \
94 { return conv (cname (conv1(arg1), conv2(arg2), conv3(arg3), conv4(arg4), \
95 conv5(arg5), conv6(arg6), conv7(arg7), conv8(arg8))); }
97 /* Use with care: needs the argument index */
98 #define Ignore(x)
99 #define Split(x,f,g) f(x), g(x) Ignore
100 #define Split3(x,f,g,h) f(x), g(x), h(x) Ignore
101 #define Pair(x,f,g) f(Field(x,0)), g(Field(x,1)) Ignore
102 #define Triple(x,f,g,h) f(Field(x,0)), g(Field(x,1)), h(Field(x,2)) Ignore
104 /* For more than 5 arguments */
105 #define ML_bc6(cname) \
106 CAMLprim value cname##_bc (value *argv, int argn) \
107 { return cname(argv[0],argv[1],argv[2],argv[3],argv[4],argv[5]); }
109 #define ML_bc7(cname) \
110 CAMLprim value cname##_bc (value *argv, int argn) \
111 { return cname(argv[0],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6]); }
113 #define ML_bc8(cname) \
114 CAMLprim value cname##_bc (value *argv, int argn) \
115 { return cname(argv[0],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], \
116 argv[7]); }
119 /* subtleties of openGL 1.1 vs 1.2 */
120 #if !defined(GL_DOUBLE) && defined(GL_DOUBLE_EXT)
121 #define GL_DOUBLE GL_DOUBLE_EXT
122 #endif
123 #if !defined(GL_TEXTURE_PRIORITY) && defined(GL_TEXTURE_PRIORITY_EXT)
124 #define GL_TEXTURE_PRIORITY GL_TEXTURE_PRIORITY_EXT
125 #endif
126 #if !defined(GL_PROXY_TEXTURE_1D) && defined(GL_PROXY_TEXTURE_1D_EXT)
127 #define GL_PROXY_TEXTURE_1D GL_PROXY_TEXTURE_1D_EXT
128 #endif
129 #if !defined(GL_PROXY_TEXTURE_2D) && defined(GL_PROXY_TEXTURE_2D_EXT)
130 #define GL_PROXY_TEXTURE_2D GL_PROXY_TEXTURE_2D_EXT
131 #endif
133 #endif