Remove stray spaces
[llpp.git] / lablGL / ml_glarray.c
blobf22cb509bc213db6c55aec171b76cfc93b283acc
1 #ifdef _WIN32
2 #include <wtypes.h>
3 #endif
4 #include <string.h>
5 #include <caml/misc.h>
6 #include <caml/mlvalues.h>
7 #include <caml/memory.h>
8 #include <caml/alloc.h>
9 #include <caml/config.h>
10 #ifdef __APPLE__
11 #include <OpenGL/gl.h>
12 #else
13 #include <GL/gl.h>
14 #endif
15 #include "ml_gl.h"
16 #include "gl_tags.h"
17 #include "raw_tags.h"
18 #include "ml_raw.h"
20 int ml_glSizeOfValue(value v) {
21 switch(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));
33 return Val_unit;
36 CAMLprim value ml_glTexCoordPointer(value size, value raw)
38 glTexCoordPointer (ml_glSizeOfValue(size),
39 GLenum_val(Kind_raw(raw)), 0, Void_raw(raw));
40 return Val_unit;
43 CAMLprim value ml_glColorPointer(value size, value raw)
45 glColorPointer (ml_glSizeOfValue(size),
46 GLenum_val(Kind_raw(raw)), 0, Void_raw(raw));
47 return Val_unit;
50 CAMLprim value ml_glIndexPointer(value raw)
52 glIndexPointer (GLenum_val(Kind_raw(raw)), 0, Void_raw(raw));
53 return Val_unit;
56 CAMLprim value ml_glNormalPointer(value raw)
58 glNormalPointer (GLenum_val(Kind_raw(raw)), 0, Void_raw(raw));
59 return Val_unit;
62 CAMLprim value ml_glVertexPointer(value size, value raw)
64 glVertexPointer (ml_glSizeOfValue(size),
65 GLenum_val(Kind_raw(raw)), 0, Void_raw(raw));
66 return Val_unit;
69 CAMLprim value ml_glEnableClientState(value kl)
71 GLenum a;
73 switch(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);
83 return Val_unit;
86 CAMLprim value ml_glDisableClientState(value kl)
88 GLenum a;
90 switch(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);
100 return Val_unit;
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));
110 return Val_unit;