6 #include <caml/mlvalues.h>
7 #include <caml/memory.h>
8 #include <caml/alloc.h>
9 #include <caml/config.h>
11 #include <OpenGL/gl.h>
20 int ml_glSizeOfValue(value v
) {
22 case MLTAG_one
: return(1);
23 case MLTAG_two
: return(2);
24 case MLTAG_three
: return(3);
25 case MLTAG_four
: return(4);
26 default: ml_raise_gl("ml_glSizeOfValue: invalid size");
30 CAMLprim value
ml_glEdgeFlagPointer(value raw
)
32 glEdgeFlagPointer(0, (GLboolean
*)Addr_raw(raw
));
36 CAMLprim value
ml_glTexCoordPointer(value size
, value raw
)
38 glTexCoordPointer (ml_glSizeOfValue(size
),
39 GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
43 CAMLprim value
ml_glColorPointer(value size
, value raw
)
45 glColorPointer (ml_glSizeOfValue(size
),
46 GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
50 CAMLprim value
ml_glIndexPointer(value raw
)
52 glIndexPointer (GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
56 CAMLprim value
ml_glNormalPointer(value raw
)
58 glNormalPointer (GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
62 CAMLprim value
ml_glVertexPointer(value size
, value raw
)
64 glVertexPointer (ml_glSizeOfValue(size
),
65 GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
69 CAMLprim value
ml_glEnableClientState(value kl
)
74 case MLTAG_edge_flag
: a
= GL_EDGE_FLAG_ARRAY
; break;
75 case MLTAG_texture_coord
: a
= GL_TEXTURE_COORD_ARRAY
; break;
76 case MLTAG_color
: a
= GL_COLOR_ARRAY
; break;
77 case MLTAG_index
: a
= GL_INDEX_ARRAY
; break;
78 case MLTAG_normal
: a
= GL_NORMAL_ARRAY
; break;
79 case MLTAG_vertex
: a
= GL_VERTEX_ARRAY
; break;
80 default: ml_raise_gl("ml_glEnableClientState: invalid array");
82 glEnableClientState(a
);
86 CAMLprim value
ml_glDisableClientState(value kl
)
91 case MLTAG_edge_flag
: a
= GL_EDGE_FLAG_ARRAY
; break;
92 case MLTAG_texture_coord
: a
= GL_TEXTURE_COORD_ARRAY
; break;
93 case MLTAG_color
: a
= GL_COLOR_ARRAY
; break;
94 case MLTAG_index
: a
= GL_INDEX_ARRAY
; break;
95 case MLTAG_normal
: a
= GL_NORMAL_ARRAY
; break;
96 case MLTAG_vertex
: a
= GL_VERTEX_ARRAY
; break;
97 default: ml_raise_gl("ml_glDisableClientState: invalid array");
99 glDisableClientState(a
);
103 ML_1 (glArrayElement
, Int_val
);
104 ML_3 (glDrawArrays
, GLenum_val
, Int_val
, Int_val
);
106 CAMLprim value
ml_glDrawElements(value mode
, value count
, value raw
)
108 glDrawElements (GLenum_val(mode
), Int_val(count
),
109 GLenum_val(Kind_raw(raw
)), Void_raw(raw
));