7 #include <caml/mlvalues.h>
8 #include <caml/memory.h>
9 #include <caml/alloc.h>
10 #include <caml/config.h>
12 #include <OpenGL/gl.h>
21 int ml_glSizeOfValue(value v
) {
23 case MLTAG_one
: return(1);
24 case MLTAG_two
: return(2);
25 case MLTAG_three
: return(3);
26 case MLTAG_four
: return(4);
27 default: ml_raise_gl("ml_glSizeOfValue: invalid size");
32 CAMLprim value
ml_glEdgeFlagPointer(value raw
)
34 glEdgeFlagPointer(0, (GLboolean
*)Addr_raw(raw
));
38 CAMLprim value
ml_glTexCoordPointer(value size
, value raw
)
40 glTexCoordPointer (ml_glSizeOfValue(size
),
41 GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
45 CAMLprim value
ml_glColorPointer(value size
, value raw
)
47 glColorPointer (ml_glSizeOfValue(size
),
48 GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
52 CAMLprim value
ml_glIndexPointer(value raw
)
54 glIndexPointer (GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
58 CAMLprim value
ml_glNormalPointer(value raw
)
60 glNormalPointer (GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
64 CAMLprim value
ml_glVertexPointer(value size
, value raw
)
66 glVertexPointer (ml_glSizeOfValue(size
),
67 GLenum_val(Kind_raw(raw
)), 0, Void_raw(raw
));
71 CAMLprim value
ml_glEnableClientState(value kl
)
76 case MLTAG_edge_flag
: a
= GL_EDGE_FLAG_ARRAY
; break;
77 case MLTAG_texture_coord
: a
= GL_TEXTURE_COORD_ARRAY
; break;
78 case MLTAG_color
: a
= GL_COLOR_ARRAY
; break;
79 case MLTAG_index
: a
= GL_INDEX_ARRAY
; break;
80 case MLTAG_normal
: a
= GL_NORMAL_ARRAY
; break;
81 case MLTAG_vertex
: a
= GL_VERTEX_ARRAY
; break;
82 default: ml_raise_gl("ml_glEnableClientState: invalid array");
84 glEnableClientState(a
);
88 CAMLprim value
ml_glDisableClientState(value kl
)
93 case MLTAG_edge_flag
: a
= GL_EDGE_FLAG_ARRAY
; break;
94 case MLTAG_texture_coord
: a
= GL_TEXTURE_COORD_ARRAY
; break;
95 case MLTAG_color
: a
= GL_COLOR_ARRAY
; break;
96 case MLTAG_index
: a
= GL_INDEX_ARRAY
; break;
97 case MLTAG_normal
: a
= GL_NORMAL_ARRAY
; break;
98 case MLTAG_vertex
: a
= GL_VERTEX_ARRAY
; break;
99 default: ml_raise_gl("ml_glDisableClientState: invalid array");
101 glDisableClientState(a
);
105 ML_1 (glArrayElement
, Int_val
);
106 ML_3 (glDrawArrays
, GLenum_val
, Int_val
, Int_val
);
108 CAMLprim value
ml_glDrawElements(value mode
, value count
, value raw
)
110 glDrawElements (GLenum_val(mode
), Int_val(count
),
111 GLenum_val(Kind_raw(raw
)), Void_raw(raw
));