ruby-opengl 0.33.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. data/Rakefile +42 -15
  2. data/doc/build_install.txt +70 -25
  3. data/doc/history.txt +4 -0
  4. data/doc/requirements_and_design.txt +2 -3
  5. data/doc/roadmap.txt +15 -2
  6. data/doc/screenshots.txt +23 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +3 -0
  9. data/doc/tutorial.txt +5 -3
  10. data/examples/README +57 -7
  11. data/examples/legacy/COPYRIGHT +8 -0
  12. data/examples/{aaindex.rb → legacy/aaindex.rb} +6 -5
  13. data/examples/legacy/aapoly.rb +153 -0
  14. data/examples/legacy/aargb.rb +139 -0
  15. data/examples/legacy/accanti.rb +159 -0
  16. data/examples/legacy/accpersp.rb +216 -0
  17. data/examples/legacy/alpha.rb +133 -0
  18. data/examples/legacy/alpha3D.rb +165 -0
  19. data/examples/legacy/bezcurve.rb +107 -0
  20. data/examples/legacy/bezmesh.rb +131 -0
  21. data/examples/legacy/checker.rb +121 -0
  22. data/examples/legacy/clip.rb +104 -0
  23. data/examples/legacy/colormat.rb +145 -0
  24. data/examples/legacy/cube.rb +73 -0
  25. data/examples/legacy/depthcue.rb +101 -0
  26. data/examples/legacy/dof.rb +212 -0
  27. data/examples/legacy/double.rb +104 -0
  28. data/examples/legacy/drawf.rb +98 -0
  29. data/examples/legacy/feedback.rb +152 -0
  30. data/examples/legacy/fog.rb +172 -0
  31. data/examples/legacy/font-glut.rb +41 -0
  32. data/examples/legacy/font.rb +158 -0
  33. data/examples/legacy/hello.rb +75 -0
  34. data/examples/legacy/image.rb +145 -0
  35. data/examples/legacy/jitter.rb +209 -0
  36. data/examples/legacy/lines.rb +135 -0
  37. data/examples/legacy/list.rb +120 -0
  38. data/examples/legacy/material.rb +290 -0
  39. data/examples/legacy/mipmap.rb +159 -0
  40. data/examples/legacy/model.rb +119 -0
  41. data/examples/legacy/movelight.rb +140 -0
  42. data/examples/legacy/pickdepth.rb +180 -0
  43. data/examples/legacy/planet.rb +112 -0
  44. data/examples/legacy/quadric.rb +180 -0
  45. data/examples/legacy/readpixel.rb +59 -0
  46. data/examples/legacy/robot.rb +120 -0
  47. data/examples/legacy/select.rb +207 -0
  48. data/examples/{smooth_prev.rb → legacy/smooth.rb} +3 -2
  49. data/examples/legacy/stencil.rb +154 -0
  50. data/examples/legacy/stroke.rb +170 -0
  51. data/examples/legacy/surface.rb +170 -0
  52. data/examples/legacy/teaambient.rb +132 -0
  53. data/examples/legacy/teapots.rb +188 -0
  54. data/examples/legacy/tess.rb +222 -0
  55. data/examples/legacy/texbind.rb +157 -0
  56. data/examples/legacy/texgen.rb +171 -0
  57. data/examples/legacy/texturesurf.rb +128 -0
  58. data/examples/legacy/varray.rb +167 -0
  59. data/examples/legacy/wrap.rb +158 -0
  60. data/examples/nehe_lesson02.rb +117 -0
  61. data/examples/nehe_lesson03.rb +122 -0
  62. data/examples/nehe_lesson04.rb +133 -0
  63. data/examples/nehe_lesson05.rb +186 -0
  64. data/examples/plane.rb +1 -1
  65. data/examples/smooth.rb +4 -2
  66. data/examples/test.rb +3 -2
  67. data/ext/common/{rbogl.c → common.h} +99 -32
  68. data/ext/common/gl-enums.h +39 -1
  69. data/ext/gl/gl-1.0-1.1.c +350 -305
  70. data/ext/gl/gl-1.2.c +933 -38
  71. data/ext/gl/gl-1.3.c +725 -0
  72. data/ext/gl/gl-1.4.c +647 -0
  73. data/ext/gl/gl-1.5.c +362 -0
  74. data/ext/gl/gl-2.0.c +1632 -0
  75. data/ext/gl/gl-2.1.c +154 -0
  76. data/ext/gl/gl-enums.c +1 -2
  77. data/ext/gl/gl.c +58 -2
  78. data/ext/gl/mkrf_conf.rb +4 -1
  79. data/ext/glu/glu.c +5 -4
  80. data/ext/glu/mkrf_conf.rb +4 -1
  81. data/ext/glut/glut.c +7 -1
  82. data/ext/glut/mkrf_conf.rb +5 -0
  83. data/lib/gl_prev.rb +4 -3
  84. data/lib/glu_prev.rb +4 -3
  85. data/lib/glut_prev.rb +3 -3
  86. data/{examples/all_tests.rb → lib/opengl.rb} +9 -12
  87. data/test/README +5 -18
  88. data/test/tc_common.rb +79 -0
  89. data/test/tc_func_10_11.rb +1255 -0
  90. data/test/tc_func_12.rb +186 -0
  91. data/test/tc_func_13.rb +203 -0
  92. data/test/tc_func_14.rb +197 -0
  93. data/test/tc_func_15.rb +82 -0
  94. data/test/tc_func_20.rb +320 -0
  95. data/test/tc_func_21.rb +67 -0
  96. data/test/tc_include_gl.rb +1 -1
  97. data/test/{tc_opengl_namespace.rb → tc_misc.rb} +20 -20
  98. data/test/tc_require_gl.rb +1 -1
  99. metadata +99 -27
  100. data/ext/common/Rakefile +0 -39
  101. data/ext/common/rbogl.h +0 -52
  102. data/test/runtests.sh +0 -7
  103. data/test/tc_gl_vertex.rb +0 -180
data/ext/gl/gl-1.5.c ADDED
@@ -0,0 +1,362 @@
1
+ /*
2
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
+ *
4
+ * This program is distributed under the terms of the MIT license.
5
+ * See the included MIT-LICENSE file for the terms of this license.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+
16
+ #ifdef __APPLE__
17
+ #include <OpenGL/gl.h>
18
+ #elif defined WIN32
19
+ #include <windows.h>
20
+ #include <GL/gl.h>
21
+ #else
22
+ #include <GL/gl.h>
23
+ #endif
24
+ #include "../common/common.h"
25
+
26
+ /* OpenGL 1.5 functions */
27
+
28
+ static void (APIENTRY * fptr_glGenQueries)(GLsizei,GLuint *);
29
+ static VALUE
30
+ gl_GenQueries(obj,arg1)
31
+ VALUE obj,arg1;
32
+ {
33
+ GLsizei n;
34
+ GLuint *queries;
35
+ RArray *ret;
36
+ int i;
37
+ LOAD_GL_FUNC(glGenQueries)
38
+ n = (GLsizei)NUM2UINT(arg1);
39
+ queries = ALLOC_N(GLuint, n);
40
+ fptr_glGenQueries(n, queries);
41
+ ret = RARRAY(rb_ary_new2(n));
42
+ for (i = 0; i < n; i++)
43
+ rb_ary_push((VALUE)ret, INT2NUM(queries[i]));
44
+ xfree(queries);
45
+ return (VALUE)ret;
46
+ }
47
+
48
+ static void (APIENTRY * fptr_glDeleteQueries)(GLsizei,GLuint *);
49
+ static VALUE
50
+ gl_DeleteQueries(obj,arg1)
51
+ VALUE obj,arg1;
52
+ {
53
+ GLsizei n;
54
+ GLuint *queries;
55
+ LOAD_GL_FUNC(glDeleteQueries)
56
+ Check_Type(arg1,T_ARRAY);
57
+ n = RARRAY(arg1)->len;
58
+ queries = ALLOC_N(GLuint,n);
59
+ ary2cuint(arg1,queries,n);
60
+ fptr_glDeleteQueries( n, queries);
61
+ xfree(queries);
62
+ return Qnil;
63
+ }
64
+
65
+ static GLboolean (APIENTRY * fptr_glIsQuery)(GLuint);
66
+ static VALUE
67
+ gl_IsQuery(obj,arg1)
68
+ VALUE obj,arg1;
69
+ {
70
+ GLuint query;
71
+ GLboolean ret;
72
+ LOAD_GL_FUNC(glIsQuery)
73
+ query = (GLuint)NUM2UINT(arg1);
74
+ ret = fptr_glIsQuery(query);
75
+ return INT2NUM(ret);
76
+ }
77
+
78
+ static void (APIENTRY * fptr_glBeginQuery)(GLenum,GLuint);
79
+ static VALUE
80
+ gl_BeginQuery(obj,arg1,arg2)
81
+ VALUE obj,arg1,arg2;
82
+ {
83
+ GLenum target;
84
+ GLuint id;
85
+ LOAD_GL_FUNC(glBeginQuery)
86
+ target = (GLenum)NUM2INT(arg1);
87
+ id = (GLuint)NUM2UINT(arg2);
88
+ fptr_glBeginQuery(target,id);
89
+ return Qnil;
90
+ }
91
+
92
+ static void (APIENTRY * fptr_glEndQuery)(GLenum);
93
+ static VALUE
94
+ gl_EndQuery(obj,arg1)
95
+ VALUE obj,arg1;
96
+ {
97
+ GLenum target;
98
+ LOAD_GL_FUNC(glEndQuery)
99
+ target = (GLenum)NUM2INT(arg1);
100
+ fptr_glEndQuery(target);
101
+ return Qnil;
102
+ }
103
+
104
+ static void (APIENTRY * fptr_glGetQueryiv)(GLenum,GLenum,GLint *);
105
+ static VALUE
106
+ gl_GetQueryiv(obj,arg1,arg2)
107
+ VALUE obj,arg1,arg2;
108
+ {
109
+ GLenum target;
110
+ GLenum pname;
111
+ GLint params = 0;
112
+ VALUE retary;
113
+ LOAD_GL_FUNC(glGetQueryiv)
114
+ target = (GLenum)NUM2INT(arg1);
115
+ pname = (GLenum)NUM2INT(arg2);
116
+ fptr_glGetQueryiv(target,pname,&params);
117
+ retary = rb_ary_new2(1);
118
+ rb_ary_push(retary, INT2NUM(params));
119
+ return retary;
120
+ }
121
+
122
+ static void (APIENTRY * fptr_glGetQueryObjectiv)(GLuint,GLenum,GLint *);
123
+ static VALUE
124
+ gl_GetQueryObjectiv(obj,arg1,arg2)
125
+ VALUE obj,arg1,arg2;
126
+ {
127
+ GLuint id;
128
+ GLenum pname;
129
+ GLint params = 0;
130
+ VALUE retary;
131
+ LOAD_GL_FUNC(glGetQueryObjectiv)
132
+ id = (GLuint)NUM2UINT(arg1);
133
+ pname = (GLenum)NUM2INT(arg2);
134
+ fptr_glGetQueryObjectiv(id,pname,&params);
135
+ retary = rb_ary_new2(1);
136
+ rb_ary_push(retary,INT2NUM(params));
137
+ return retary;
138
+ }
139
+
140
+ static void (APIENTRY * fptr_glGetQueryObjectuiv)(GLuint,GLenum,GLuint *);
141
+ static VALUE
142
+ gl_GetQueryObjectuiv(obj,arg1,arg2,arg3)
143
+ VALUE obj,arg1,arg2,arg3;
144
+ {
145
+ GLuint id;
146
+ GLenum pname;
147
+ GLuint params = 0;
148
+ VALUE retary;
149
+ LOAD_GL_FUNC(glGetQueryObjectuiv)
150
+ id = (GLuint)NUM2UINT(arg1);
151
+ pname = (GLenum)NUM2INT(arg2);
152
+ fptr_glGetQueryObjectuiv(id,pname,&params);
153
+ retary = rb_ary_new2(1);
154
+ rb_ary_push(retary,INT2NUM(params));
155
+ return retary;
156
+ }
157
+
158
+ static void (APIENTRY * fptr_glBindBuffer)(GLenum,GLuint);
159
+ static VALUE
160
+ gl_BindBuffer(obj,arg1,arg2)
161
+ VALUE obj,arg1,arg2;
162
+ {
163
+ GLenum target;
164
+ GLuint buffer;
165
+ LOAD_GL_FUNC(glBindBuffer)
166
+ target = (GLenum)NUM2INT(arg1);
167
+ buffer = (GLenum)NUM2INT(arg2);
168
+ fptr_glBindBuffer(target,buffer);
169
+ return Qnil;
170
+ }
171
+
172
+ static void (APIENTRY * fptr_glDeleteBuffers)(GLsizei,GLuint *);
173
+ static VALUE
174
+ gl_DeleteBuffers(obj,arg1)
175
+ VALUE obj,arg1;
176
+ {
177
+ GLsizei n;
178
+ GLuint *buffers;
179
+ LOAD_GL_FUNC(glDeleteBuffers)
180
+ Check_Type(arg1,T_ARRAY);
181
+ n = RARRAY(arg1)->len;
182
+ buffers = ALLOC_N(GLuint,n);
183
+ ary2cuint(arg1,buffers,n);
184
+ fptr_glDeleteBuffers(n, buffers);
185
+ xfree(buffers);
186
+ return Qnil;
187
+ }
188
+
189
+ static void (APIENTRY * fptr_glGenBuffers)(GLsizei,GLuint *);
190
+ static VALUE
191
+ gl_GenBuffers(obj,arg1)
192
+ VALUE obj,arg1;
193
+ {
194
+ GLsizei n;
195
+ GLuint *buffers;
196
+ RArray *ret;
197
+ int i;
198
+ LOAD_GL_FUNC(glGenBuffers)
199
+ n = (GLsizei)NUM2UINT(arg1);
200
+ buffers = ALLOC_N(GLuint, n);
201
+ fptr_glGenBuffers(n, buffers);
202
+ ret = RARRAY(rb_ary_new2(n));
203
+ for (i = 0; i < n; i++)
204
+ rb_ary_push((VALUE)ret, INT2NUM(buffers[i]));
205
+ xfree(buffers);
206
+ return (VALUE)ret;
207
+ }
208
+
209
+ static GLboolean (APIENTRY * fptr_glIsBuffer)(GLuint);
210
+ static VALUE
211
+ gl_IsBuffer(obj,arg1)
212
+ VALUE obj,arg1;
213
+ {
214
+ GLuint buffer;
215
+ GLboolean ret;
216
+ LOAD_GL_FUNC(glIsBuffer)
217
+ buffer = (GLuint)NUM2UINT(arg1);
218
+ ret = fptr_glIsBuffer(buffer);
219
+ return INT2NUM(ret);
220
+ }
221
+
222
+ static void (APIENTRY * fptr_glBufferData)(GLenum,GLsizeiptr,GLvoid *,GLenum);
223
+ static VALUE
224
+ gl_BufferData(obj,arg1,arg2,arg3,arg4)
225
+ VALUE obj,arg1,arg2,arg3,arg4;
226
+ {
227
+ GLenum target;
228
+ GLsizeiptr size;
229
+ GLenum usage;
230
+ LOAD_GL_FUNC(glBufferData)
231
+ target = (GLenum)NUM2INT(arg1);
232
+ size = (GLsizeiptr)NUM2INT(arg2);
233
+ usage = (GLenum)NUM2INT(arg4);
234
+ if (TYPE(arg3) == T_STRING) {
235
+ fptr_glBufferData(target,size,(GLvoid *)RSTRING(arg3)->ptr,usage);
236
+ } else if (NIL_P(arg3)) {
237
+ fptr_glBufferData(target,size,NULL,usage);
238
+ } else {
239
+ Check_Type(arg3,T_STRING); /* force exception */
240
+ }
241
+ return Qnil;
242
+ }
243
+
244
+ static void (APIENTRY * fptr_glBufferSubData)(GLenum,GLintptr,GLsizeiptr,GLvoid *);
245
+ static VALUE
246
+ gl_BufferSubData(obj,arg1,arg2,arg3,arg4)
247
+ VALUE obj,arg1,arg2,arg3,arg4;
248
+ {
249
+ GLenum target;
250
+ GLintptr offset;
251
+ GLsizeiptr size;
252
+ LOAD_GL_FUNC(glBufferSubData)
253
+ target = (GLenum)NUM2INT(arg1);
254
+ offset = (GLintptr)NUM2INT(arg2);
255
+ size = (GLsizeiptr)NUM2INT(arg3);
256
+ Check_Type(arg4,T_STRING);
257
+ fptr_glBufferSubData(target,offset,size,(GLvoid *)RSTRING(arg4)->ptr);
258
+ return Qnil;
259
+ }
260
+
261
+ static void (APIENTRY * fptr_glGetBufferSubData)(GLenum,GLintptr,GLsizeiptr,GLvoid *);
262
+ static VALUE
263
+ gl_GetBufferSubData(obj,arg1,arg2,arg3)
264
+ VALUE obj,arg1,arg2,arg3;
265
+ {
266
+ GLenum target;
267
+ GLintptr offset;
268
+ GLsizeiptr size;
269
+ VALUE data;
270
+ LOAD_GL_FUNC(glGetBufferSubData)
271
+ target = (GLenum)NUM2INT(arg1);
272
+ offset = (GLintptr)NUM2INT(arg2);
273
+ size = (GLsizeiptr)NUM2INT(arg3);
274
+ data = allocate_buffer_with_string(size);
275
+ fptr_glGetBufferSubData(target,offset,size,(GLvoid *)RSTRING(data)->ptr);
276
+ return data;
277
+ }
278
+
279
+ static void (APIENTRY * fptr_glGetBufferParameteriv)(GLenum,GLenum,GLint *);
280
+ static VALUE
281
+ gl_GetBufferParameteriv(obj,arg1,arg2)
282
+ VALUE obj,arg1,arg2;
283
+ {
284
+ GLenum target;
285
+ GLenum value;
286
+ GLint data = 0;
287
+ VALUE retary;
288
+ LOAD_GL_FUNC(glGetBufferParameteriv)
289
+ target = (GLenum)NUM2INT(arg1);
290
+ value = (GLenum)NUM2INT(arg2);
291
+ fptr_glGetBufferParameteriv(target,value,&data);
292
+ retary = rb_ary_new2(1);
293
+ rb_ary_push(retary,INT2NUM(data));
294
+ return retary;
295
+ }
296
+
297
+ static GLvoid * (APIENTRY * fptr_glMapBuffer)(GLenum,GLenum);
298
+ static VALUE
299
+ gl_MapBuffer(obj,arg1,arg2)
300
+ VALUE obj,arg1,arg2;
301
+ {
302
+ GLenum target;
303
+ GLenum access;
304
+ GLint size = 0;
305
+ VALUE data;
306
+ GLvoid *buffer_ptr;
307
+ LOAD_GL_FUNC(glMapBuffer)
308
+ LOAD_GL_FUNC(glGetBufferParameteriv)
309
+ target = (GLenum)NUM2INT(arg1);
310
+ access = (GLenum)NUM2INT(arg2);
311
+ fptr_glGetBufferParameteriv(target,GL_BUFFER_SIZE,&size);
312
+ buffer_ptr = fptr_glMapBuffer(target,access);
313
+ data = allocate_buffer_with_string(size);
314
+ memcpy(RSTRING(data)->ptr, buffer_ptr, size);
315
+ return data;
316
+ }
317
+
318
+ static GLboolean (APIENTRY * fptr_glUnmapBuffer)(GLenum);
319
+ static VALUE
320
+ gl_UnmapBuffer(obj,arg1)
321
+ VALUE obj,arg1;
322
+ {
323
+ GLenum target;
324
+ GLboolean ret;
325
+ LOAD_GL_FUNC(glUnmapBuffer)
326
+ target = (GLenum)NUM2INT(arg1);
327
+ ret = fptr_glUnmapBuffer(target);
328
+ return INT2NUM(ret);
329
+ }
330
+
331
+ static void (APIENTRY * fptr_glGetBufferPointerv)(GLenum,GLenum,GLvoid **);
332
+ static VALUE
333
+ gl_GetBufferPointerv(obj,arg1,arg2,arg3)
334
+ VALUE obj,arg1,arg2,arg3;
335
+ {
336
+ LOAD_GL_FUNC(glGetBufferPointerv)
337
+ /* not implemented */
338
+ return Qnil;
339
+ }
340
+
341
+ void gl_init_functions_1_5(VALUE module)
342
+ {
343
+ rb_define_module_function(module, "glGenQueries", gl_GenQueries, 1);
344
+ rb_define_module_function(module, "glDeleteQueries", gl_DeleteQueries, 1);
345
+ rb_define_module_function(module, "glIsQuery", gl_IsQuery, 1);
346
+ rb_define_module_function(module, "glBeginQuery", gl_BeginQuery, 2);
347
+ rb_define_module_function(module, "glEndQuery", gl_EndQuery, 1);
348
+ rb_define_module_function(module, "glGetQueryiv", gl_GetQueryiv, 2);
349
+ rb_define_module_function(module, "glGetQueryObjectiv", gl_GetQueryObjectiv, 2);
350
+ rb_define_module_function(module, "glGetQueryObjectuiv", gl_GetQueryObjectuiv, 2);
351
+ rb_define_module_function(module, "glBindBuffer", gl_BindBuffer, 2);
352
+ rb_define_module_function(module, "glDeleteBuffers", gl_DeleteBuffers, 1);
353
+ rb_define_module_function(module, "glGenBuffers", gl_GenBuffers, 1);
354
+ rb_define_module_function(module, "glIsBuffer", gl_IsBuffer, 1);
355
+ rb_define_module_function(module, "glBufferData", gl_BufferData, 4);
356
+ rb_define_module_function(module, "glBufferSubData", gl_BufferSubData, 4);
357
+ rb_define_module_function(module, "glGetBufferSubData", gl_GetBufferSubData, 3);
358
+ rb_define_module_function(module, "glMapBuffer", gl_MapBuffer, 2);
359
+ rb_define_module_function(module, "glUnmapBuffer", gl_UnmapBuffer, 1);
360
+ rb_define_module_function(module, "glGetBufferParameteriv", gl_GetBufferParameteriv, 2);
361
+ rb_define_module_function(module, "glGetBufferPointerv", gl_GetBufferPointerv, 3);
362
+ }
data/ext/gl/gl-2.0.c ADDED
@@ -0,0 +1,1632 @@
1
+ /*
2
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
+ *
4
+ * This program is distributed under the terms of the MIT license.
5
+ * See the included MIT-LICENSE file for the terms of this license.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+
16
+ #ifdef __APPLE__
17
+ #include <OpenGL/gl.h>
18
+ #elif defined WIN32
19
+ #include <windows.h>
20
+ #include <GL/gl.h>
21
+ #else
22
+ #include <GL/gl.h>
23
+ #endif
24
+ #include "../common/common.h"
25
+
26
+ static void (APIENTRY * fptr_glBlendEquationSeparate)(GLenum,GLenum);
27
+ static VALUE
28
+ gl_BlendEquationSeparate(obj,arg1,arg2)
29
+ VALUE obj,arg1,arg2;
30
+ {
31
+ GLenum modeRGB;
32
+ GLenum modeAlpha;
33
+ LOAD_GL_FUNC(glBlendEquationSeparate)
34
+ modeRGB = (GLenum)NUM2INT(arg1);
35
+ modeAlpha = (GLenum)NUM2INT(arg2);
36
+ fptr_glBlendEquationSeparate(modeRGB,modeAlpha);
37
+ return Qnil;
38
+ }
39
+
40
+ static void (APIENTRY * fptr_glDrawBuffers)(GLsizei,GLenum *);
41
+ static VALUE
42
+ gl_DrawBuffers(obj,arg1)
43
+ VALUE obj,arg1;
44
+ {
45
+ GLsizei size;
46
+ GLenum *buffers;
47
+ LOAD_GL_FUNC(glDrawBuffers)
48
+ Check_Type(arg1,T_ARRAY);
49
+ size = RARRAY(arg1)->len;
50
+ buffers = ALLOC_N(GLenum,size);
51
+ ary2cuint(arg1,buffers,size);
52
+ fptr_glDrawBuffers(size,buffers);
53
+ xfree(buffers);
54
+ return Qnil;
55
+ }
56
+
57
+ static void (APIENTRY * fptr_glStencilOpSeparate)(GLenum,GLenum,GLenum,GLenum);
58
+ static VALUE
59
+ gl_StencilOpSeparate(obj,arg1,arg2,arg3,arg4)
60
+ VALUE obj,arg1,arg2,arg3,arg4;
61
+ {
62
+ GLenum face;
63
+ GLenum sfail;
64
+ GLenum dpfail;
65
+ GLenum dppass;
66
+ LOAD_GL_FUNC(glStencilOpSeparate)
67
+ face = (GLenum)NUM2INT(arg1);
68
+ sfail = (GLenum)NUM2INT(arg2);
69
+ dpfail = (GLenum)NUM2INT(arg3);
70
+ dppass = (GLenum)NUM2INT(arg4);
71
+ fptr_glStencilOpSeparate(face,sfail,dpfail,dppass);
72
+ return Qnil;
73
+ }
74
+
75
+ static void (APIENTRY * fptr_glStencilFuncSeparate)(GLenum,GLenum,GLint,GLuint);
76
+ static VALUE
77
+ gl_StencilFuncSeparate(obj,arg1,arg2,arg3,arg4)
78
+ VALUE obj,arg1,arg2,arg3,arg4;
79
+ {
80
+ GLenum face;
81
+ GLenum func;
82
+ GLint ref;
83
+ GLuint mask;
84
+ LOAD_GL_FUNC(glStencilFuncSeparate)
85
+ face = (GLenum)NUM2INT(arg1);
86
+ func = (GLenum)NUM2INT(arg2);
87
+ ref = (GLint)NUM2INT(arg3);
88
+ mask = (GLuint)NUM2UINT(arg4);
89
+ fptr_glStencilFuncSeparate(face,func,ref,mask);
90
+ return Qnil;
91
+ }
92
+
93
+ static void (APIENTRY * fptr_glStencilMaskSeparate)(GLenum face,GLuint mask);
94
+ static VALUE
95
+ gl_StencilMaskSeparate(obj,arg1,arg2)
96
+ VALUE obj,arg1,arg2;
97
+ {
98
+ GLenum face;
99
+ GLuint mask;
100
+ LOAD_GL_FUNC(glStencilMaskSeparate)
101
+ face = (GLenum)NUM2INT(arg1);
102
+ mask = (GLenum)NUM2INT(arg2);
103
+ fptr_glStencilMaskSeparate(face,mask);
104
+ return Qnil;
105
+ }
106
+
107
+ static void (APIENTRY * fptr_glAttachShader)(GLuint,GLuint);
108
+ static VALUE
109
+ gl_AttachShader(obj,arg1,arg2)
110
+ VALUE obj,arg1,arg2;
111
+ {
112
+ GLuint program;
113
+ GLuint shader;
114
+ LOAD_GL_FUNC(glAttachShader)
115
+ program = (GLuint)NUM2UINT(arg1);
116
+ shader = (GLuint)NUM2UINT(arg2);
117
+ fptr_glAttachShader(program,shader);
118
+ return Qnil;
119
+ }
120
+
121
+ static void (APIENTRY * fptr_glBindAttribLocation)(GLuint,GLuint,GLchar *);
122
+ static VALUE
123
+ gl_BindAttribLocation(obj,arg1,arg2,arg3)
124
+ VALUE obj,arg1,arg2,arg3;
125
+ {
126
+ GLuint program;
127
+ GLuint index;
128
+ LOAD_GL_FUNC(glBindAttribLocation)
129
+ program = (GLuint)NUM2UINT(arg1);
130
+ index = (GLuint)NUM2UINT(arg2);
131
+ Check_Type(arg3, T_STRING);
132
+ fptr_glBindAttribLocation(program,index,RSTRING(arg3)->ptr);
133
+ return Qnil;
134
+ }
135
+
136
+ static void (APIENTRY * fptr_glCompileShader)(GLuint);
137
+ static VALUE
138
+ gl_CompileShader(obj,arg1)
139
+ VALUE obj,arg1;
140
+ {
141
+ GLuint shader;
142
+ LOAD_GL_FUNC(glCompileShader)
143
+ shader = (GLuint)NUM2UINT(arg1);
144
+ fptr_glCompileShader(shader);
145
+ return Qnil;
146
+ }
147
+
148
+ static GLuint (APIENTRY * fptr_glCreateProgram)(void);
149
+ static VALUE
150
+ gl_CreateProgram(obj)
151
+ VALUE obj;
152
+ {
153
+ GLuint ret;
154
+ LOAD_GL_FUNC(glCreateProgram)
155
+ ret = fptr_glCreateProgram();
156
+ return INT2NUM(ret);
157
+ }
158
+
159
+ static GLuint (APIENTRY * fptr_glCreateShader)(GLenum);
160
+ static VALUE
161
+ gl_CreateShader(obj,arg1)
162
+ VALUE obj,arg1;
163
+ {
164
+ GLenum shaderType;
165
+ GLuint ret;
166
+ LOAD_GL_FUNC(glCreateShader)
167
+ shaderType = (GLenum)NUM2INT(arg1);
168
+ ret = fptr_glCreateShader(shaderType);
169
+ return INT2NUM(ret);
170
+ }
171
+
172
+ static void (APIENTRY * fptr_glDeleteProgram)(GLuint);
173
+ static VALUE
174
+ gl_DeleteProgram(obj,arg1)
175
+ VALUE obj,arg1;
176
+ {
177
+ GLuint program;
178
+ LOAD_GL_FUNC(glDeleteProgram)
179
+ program = (GLuint)NUM2UINT(arg1);
180
+ fptr_glDeleteProgram(program);
181
+ return Qnil;
182
+ }
183
+
184
+ static void (APIENTRY * fptr_glDeleteShader)(GLuint);
185
+ static VALUE
186
+ gl_DeleteShader(obj,arg1)
187
+ VALUE obj,arg1;
188
+ {
189
+ GLuint shader;
190
+ LOAD_GL_FUNC(glDeleteShader)
191
+ shader = (GLuint)NUM2UINT(arg1);
192
+ fptr_glDeleteShader(shader);
193
+ return Qnil;
194
+ }
195
+
196
+ static void (APIENTRY * fptr_glDetachShader)(GLuint,GLuint);
197
+ static VALUE
198
+ gl_DetachShader(obj,arg1,arg2)
199
+ VALUE obj,arg1,arg2;
200
+ {
201
+ GLuint program;
202
+ GLuint shader;
203
+ LOAD_GL_FUNC(glDetachShader)
204
+ program=(GLuint)NUM2UINT(arg1);
205
+ shader=(GLuint)NUM2UINT(arg2);
206
+ fptr_glDetachShader(program,shader);
207
+ return Qnil;
208
+ }
209
+
210
+ static void (APIENTRY * fptr_glDisableVertexAttribArray)(GLuint);
211
+ static VALUE
212
+ gl_DisableVertexAttribArray(obj,arg1)
213
+ VALUE obj,arg1;
214
+ {
215
+ GLuint index;
216
+ LOAD_GL_FUNC(glDisableVertexAttribArray)
217
+ index=(GLuint)NUM2UINT(arg1);
218
+ fptr_glDisableVertexAttribArray(index);
219
+ return Qnil;
220
+ }
221
+
222
+ static void (APIENTRY * fptr_glEnableVertexAttribArray)(GLuint);
223
+ static VALUE
224
+ gl_EnableVertexAttribArray(obj,arg1)
225
+ VALUE obj,arg1;
226
+ {
227
+ GLuint index;
228
+ LOAD_GL_FUNC(glEnableVertexAttribArray)
229
+ index=(GLuint)NUM2UINT(arg1);
230
+ fptr_glEnableVertexAttribArray(index);
231
+ return Qnil;
232
+ }
233
+
234
+ static void (APIENTRY * fptr_glGetProgramiv)(GLuint,GLenum,GLint *);
235
+ static VALUE
236
+ gl_GetProgramiv(obj,arg1,arg2)
237
+ VALUE obj,arg1,arg2;
238
+ {
239
+ GLuint program;
240
+ GLenum pname;
241
+ GLint params = 0;
242
+ LOAD_GL_FUNC(glGetProgramiv)
243
+ program = (GLuint)NUM2UINT(arg1);
244
+ pname = (GLenum)NUM2INT(arg2);
245
+ fptr_glGetProgramiv(program,pname,&params);
246
+ return INT2NUM(params);
247
+ }
248
+
249
+ static void (APIENTRY * fptr_glGetActiveAttrib)(GLuint,GLuint,GLsizei,GLsizei *,GLint *,GLenum *,GLchar *);
250
+ static VALUE
251
+ gl_GetActiveAttrib(obj,arg1,arg2)
252
+ VALUE obj,arg1,arg2;
253
+ {
254
+ GLuint program;
255
+ GLuint index;
256
+ GLsizei max_size = 0;
257
+ GLsizei written = 0;
258
+ GLint attrib_size = 0;
259
+ GLenum attrib_type = 0;
260
+ VALUE buffer;
261
+ VALUE retary;
262
+ LOAD_GL_FUNC(glGetActiveAttrib)
263
+ LOAD_GL_FUNC(glGetProgramiv)
264
+ program = (GLuint)NUM2UINT(arg1);
265
+ index = (GLuint)NUM2UINT(arg2);
266
+ fptr_glGetProgramiv(program,GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,&max_size);
267
+ if (max_size==0)
268
+ rb_raise(rb_eTypeError, "Can't determine maximum attribute name length");
269
+ buffer = allocate_buffer_with_string(max_size-1);
270
+ fptr_glGetActiveAttrib(program,index,max_size,&written,&attrib_size,&attrib_type,RSTRING(buffer)->ptr);
271
+ retary = rb_ary_new2(3);
272
+ rb_ary_push(retary, INT2NUM(attrib_size));
273
+ rb_ary_push(retary, INT2NUM(attrib_type));
274
+ rb_ary_push(retary, buffer);
275
+ return retary;
276
+ }
277
+
278
+ static void (APIENTRY * fptr_glGetActiveUniform)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*);
279
+ static VALUE
280
+ gl_GetActiveUniform(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
281
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7;
282
+ {
283
+ GLuint program;
284
+ GLuint index;
285
+ GLsizei max_size = 0;
286
+ GLsizei written = 0;
287
+ GLint uniform_size = 0;
288
+ GLenum uniform_type = 0;
289
+ VALUE buffer;
290
+ VALUE retary;
291
+ LOAD_GL_FUNC(glGetActiveUniform)
292
+ LOAD_GL_FUNC(glGetProgramiv)
293
+ program = (GLuint)NUM2UINT(arg1);
294
+ index = (GLuint)NUM2UINT(arg2);
295
+ fptr_glGetProgramiv(program,GL_ACTIVE_UNIFORM_MAX_LENGTH,&max_size);
296
+ if (max_size==0)
297
+ rb_raise(rb_eTypeError, "Can't determine maximum uniform name length");
298
+ buffer = allocate_buffer_with_string(max_size-1);
299
+ fptr_glGetActiveUniform(program,index,max_size,&written,&uniform_size,&uniform_type,RSTRING(buffer)->ptr);
300
+ retary = rb_ary_new2(3);
301
+ rb_ary_push(retary, INT2NUM(uniform_size));
302
+ rb_ary_push(retary, INT2NUM(uniform_type));
303
+ rb_ary_push(retary, buffer);
304
+ return retary;
305
+ }
306
+
307
+ static void (APIENTRY * fptr_glGetAttachedShaders)(GLuint,GLsizei,GLsizei *,GLuint *);
308
+ static VALUE
309
+ gl_GetAttachedShaders(obj,arg1)
310
+ VALUE obj,arg1;
311
+ {
312
+ GLuint program;
313
+ GLint shaders_num = 0;
314
+ GLuint *shaders;
315
+ VALUE retary;
316
+ GLsizei count = 0;
317
+ GLint i;
318
+ LOAD_GL_FUNC(glGetAttachedShaders)
319
+ LOAD_GL_FUNC(glGetProgramiv)
320
+ program = (GLuint)NUM2UINT(arg1);
321
+ fptr_glGetProgramiv(program,GL_ATTACHED_SHADERS,&shaders_num);
322
+ if (shaders_num<=0)
323
+ return Qnil;
324
+ shaders = ALLOC_N(GLuint,shaders_num);
325
+ fptr_glGetAttachedShaders(program,shaders_num,&count,shaders);
326
+ retary = rb_ary_new2(shaders_num);
327
+ for(i=0;i<shaders_num;i++)
328
+ rb_ary_push(retary, INT2NUM(shaders[i]));
329
+ xfree(shaders);
330
+ return retary;
331
+ }
332
+
333
+ static GLint (APIENTRY * fptr_glGetAttribLocation)(GLuint, GLchar *);
334
+ static VALUE
335
+ gl_GetAttribLocation(obj,arg1,arg2)
336
+ VALUE obj,arg1,arg2;
337
+ {
338
+ GLuint program;
339
+ GLint ret;
340
+ LOAD_GL_FUNC(glGetAttribLocation)
341
+ program=(GLuint)NUM2UINT(arg1);
342
+ Check_Type(arg2,T_STRING);
343
+ ret = fptr_glGetAttribLocation(program,RSTRING(arg2)->ptr);
344
+ return INT2NUM(ret);
345
+ }
346
+
347
+ static void (APIENTRY * fptr_glGetProgramInfoLog)(GLuint,GLsizei,GLsizei *,GLchar *);
348
+ static VALUE
349
+ gl_GetProgramInfoLog(obj,arg1)
350
+ VALUE obj,arg1;
351
+ {
352
+ GLuint program;
353
+ GLint max_size = 0;
354
+ GLsizei ret_length = 0;
355
+ VALUE buffer;
356
+ LOAD_GL_FUNC(glGetProgramInfoLog)
357
+ LOAD_GL_FUNC(glGetProgramiv)
358
+ program = (GLuint)NUM2UINT(arg1);
359
+ fptr_glGetProgramiv(program,GL_INFO_LOG_LENGTH,&max_size);
360
+ if (max_size<=0)
361
+ return rb_str_new2("");
362
+ buffer = allocate_buffer_with_string(max_size);
363
+ fptr_glGetProgramInfoLog(program,max_size,&ret_length,RSTRING(buffer)->ptr);
364
+ RSTRING(buffer)->len = ret_length;
365
+ return buffer;
366
+ }
367
+
368
+ static void (APIENTRY * fptr_glGetShaderiv)(GLuint,GLenum,GLint *);
369
+ static VALUE
370
+ gl_GetShaderiv(obj,arg1,arg2)
371
+ VALUE obj,arg1,arg2;
372
+ {
373
+ GLuint program;
374
+ GLenum pname;
375
+ GLint params = 0;
376
+ LOAD_GL_FUNC(glGetShaderiv)
377
+ program = (GLuint)NUM2UINT(arg1);
378
+ pname = (GLenum)NUM2INT(arg2);
379
+ fptr_glGetShaderiv(program,pname,&params);
380
+ return INT2NUM(params);
381
+ }
382
+
383
+ static void (APIENTRY * fptr_glGetShaderInfoLog)(GLuint,GLsizei,GLsizei *,GLchar *);
384
+ static VALUE
385
+ gl_GetShaderInfoLog(obj,arg1)
386
+ VALUE obj,arg1;
387
+ {
388
+ GLuint program;
389
+ GLint max_size = 0;
390
+ GLsizei ret_length = 0;
391
+ VALUE ret_buffer;
392
+ GLchar *buffer;
393
+ LOAD_GL_FUNC(glGetShaderInfoLog)
394
+ LOAD_GL_FUNC(glGetShaderiv)
395
+ program = (GLuint)NUM2UINT(arg1);
396
+ fptr_glGetShaderiv(program,GL_INFO_LOG_LENGTH,&max_size);
397
+ if (max_size<=0)
398
+ return rb_str_new2("");
399
+ buffer = ALLOC_N(GLchar,max_size+1);
400
+ memset(buffer,0,sizeof(GLchar) * (max_size+1));
401
+ fptr_glGetShaderInfoLog(program,max_size,&ret_length,buffer);
402
+ ret_buffer = rb_str_new(buffer, ret_length);
403
+ xfree(buffer);
404
+ return ret_buffer;
405
+ }
406
+
407
+ static void (APIENTRY * fptr_glGetShaderSource)(GLuint,GLsizei,GLsizei *,GLchar *);
408
+ static VALUE
409
+ gl_GetShaderSource(obj,arg1)
410
+ VALUE obj,arg1;
411
+ {
412
+ GLuint shader;
413
+ GLint max_size = 0;
414
+ GLsizei ret_length = 0;
415
+ VALUE buffer;
416
+ LOAD_GL_FUNC(glGetShaderSource)
417
+ LOAD_GL_FUNC(glGetShaderiv)
418
+ shader = (GLuint)NUM2UINT(arg1);
419
+ fptr_glGetShaderiv(shader,GL_SHADER_SOURCE_LENGTH,&max_size);
420
+ if (max_size==0)
421
+ rb_raise(rb_eTypeError, "Can't determine maximum shader source length");
422
+ buffer = allocate_buffer_with_string(max_size-1);
423
+ fptr_glGetShaderSource(shader,max_size,&ret_length,RSTRING(buffer)->ptr);
424
+ return buffer;
425
+ }
426
+
427
+ static GLint (APIENTRY * fptr_glGetUniformLocation)(GLuint,const GLchar*);
428
+ static VALUE
429
+ gl_GetUniformLocation(obj,arg1,arg2)
430
+ VALUE obj,arg1,arg2;
431
+ {
432
+ GLuint program;
433
+ GLint ret;
434
+ LOAD_GL_FUNC(glGetUniformLocation)
435
+ program=(GLuint)NUM2UINT(arg1);
436
+ Check_Type(arg2,T_STRING);
437
+ ret = fptr_glGetUniformLocation(program,RSTRING(arg2)->ptr);
438
+ return INT2NUM(ret);
439
+ }
440
+
441
+
442
+ #define GET_UNIFORM_SIZE \
443
+ switch (uniform_type) { \
444
+ case GL_FLOAT: \
445
+ case GL_INT: \
446
+ case GL_BOOL: \
447
+ case GL_SAMPLER_1D: \
448
+ case GL_SAMPLER_2D: \
449
+ case GL_SAMPLER_3D: \
450
+ case GL_SAMPLER_CUBE: \
451
+ case GL_SAMPLER_1D_SHADOW: \
452
+ case GL_SAMPLER_2D_SHADOW: \
453
+ uniform_size = 1; \
454
+ break; \
455
+ case GL_FLOAT_VEC2: \
456
+ case GL_INT_VEC2: \
457
+ case GL_BOOL_VEC2: \
458
+ uniform_size = 2; \
459
+ break; \
460
+ case GL_FLOAT_VEC3: \
461
+ case GL_INT_VEC3: \
462
+ case GL_BOOL_VEC3: \
463
+ uniform_size = 3; \
464
+ break; \
465
+ case GL_FLOAT_VEC4: \
466
+ case GL_INT_VEC4: \
467
+ case GL_BOOL_VEC4: \
468
+ case GL_FLOAT_MAT2: \
469
+ uniform_size = 4; \
470
+ break; \
471
+ case GL_FLOAT_MAT2x3: \
472
+ case GL_FLOAT_MAT3x2: \
473
+ uniform_size = 6; \
474
+ break; \
475
+ case GL_FLOAT_MAT2x4: \
476
+ case GL_FLOAT_MAT4x2: \
477
+ uniform_size = 8; \
478
+ break; \
479
+ case GL_FLOAT_MAT3: \
480
+ uniform_size = 9; \
481
+ break; \
482
+ case GL_FLOAT_MAT4x3: \
483
+ case GL_FLOAT_MAT3x4: \
484
+ uniform_size = 12; \
485
+ break; \
486
+ case GL_FLOAT_MAT4: \
487
+ uniform_size = 16; \
488
+ break; \
489
+ default: \
490
+ rb_raise(rb_eTypeError, "Unsupported type '%i'",uniform_type); \
491
+ }
492
+
493
+ static void (APIENTRY * fptr_glGetUniformfv)(GLuint,GLint,GLfloat *);
494
+ static VALUE
495
+ gl_GetUniformfv(obj,arg1,arg2)
496
+ VALUE obj,arg1,arg2;
497
+ {
498
+ GLuint program;
499
+ GLint location;
500
+ GLfloat params[16];
501
+ VALUE retary;
502
+ GLint i;
503
+ GLint unused = 0;
504
+ GLenum uniform_type = 0;
505
+ GLint uniform_size = 0;
506
+
507
+ LOAD_GL_FUNC(glGetUniformfv)
508
+ LOAD_GL_FUNC(glGetActiveUniform)
509
+ program = (GLuint)NUM2UINT(arg1);
510
+ location = (GLint)NUM2INT(arg2);
511
+
512
+ fptr_glGetActiveUniform(program,location,0,NULL,&unused,&uniform_type,NULL);
513
+ if (uniform_type==0)
514
+ rb_raise(rb_eTypeError, "Can't determine the uniform's type");
515
+
516
+ GET_UNIFORM_SIZE
517
+
518
+ memset(params,0,16*sizeof(GLfloat));
519
+ fptr_glGetUniformfv(program,location,params);
520
+ retary = rb_ary_new2(uniform_size);
521
+ for(i=0;i<uniform_size;i++)
522
+ rb_ary_push(retary, rb_float_new(params[i]));
523
+ return retary;
524
+ }
525
+
526
+ static void (APIENTRY * fptr_glGetUniformiv)(GLuint,GLint,GLint *);
527
+ static VALUE
528
+ gl_GetUniformiv(obj,arg1,arg2)
529
+ VALUE obj,arg1,arg2;
530
+ {
531
+ GLuint program;
532
+ GLint location;
533
+ GLint params[16];
534
+ VALUE retary;
535
+ GLint i;
536
+ GLint unused = 0;
537
+ GLenum uniform_type = 0;
538
+ GLint uniform_size = 0;
539
+ LOAD_GL_FUNC(glGetUniformiv)
540
+ LOAD_GL_FUNC(glGetActiveUniform)
541
+ program = (GLuint)NUM2UINT(arg1);
542
+ location = (GLint)NUM2INT(arg2);
543
+
544
+ fptr_glGetActiveUniform(program,location,0,NULL,&unused,&uniform_type,NULL);
545
+ if (uniform_type==0)
546
+ rb_raise(rb_eTypeError, "Can't determine the uniform's type");
547
+
548
+ GET_UNIFORM_SIZE
549
+
550
+ memset(params,0,16*sizeof(GLint));
551
+ fptr_glGetUniformiv(program,location,params);
552
+ retary = rb_ary_new2(uniform_size);
553
+ for(i=0;i<uniform_size;i++)
554
+ rb_ary_push(retary, INT2NUM(params[i]));
555
+ return retary;
556
+ }
557
+
558
+ static void (APIENTRY * fptr_glGetVertexAttribdv)(GLuint,GLenum,GLdouble *);
559
+ static VALUE
560
+ gl_GetVertexAttribdv(obj,arg1,arg2)
561
+ VALUE obj,arg1,arg2;
562
+ {
563
+ GLuint index;
564
+ GLenum pname;
565
+ GLdouble params[4] = {0.0,0.0,0.0,0.0};
566
+ GLint size;
567
+ GLint i;
568
+ VALUE retary;
569
+ LOAD_GL_FUNC(glGetVertexAttribdv)
570
+ index = (GLuint)NUM2UINT(arg1);
571
+ pname = (GLenum)NUM2INT(arg2);
572
+ if (pname==GL_CURRENT_VERTEX_ATTRIB)
573
+ size = 4;
574
+ else
575
+ size = 1;
576
+ fptr_glGetVertexAttribdv(index,pname,params);
577
+ retary = rb_ary_new2(size);
578
+ for(i=0;i<size;i++)
579
+ rb_ary_push(retary, rb_float_new(params[i]));
580
+ return retary;
581
+ }
582
+
583
+ static void (APIENTRY * fptr_glGetVertexAttribfv)(GLuint,GLenum,GLfloat *);
584
+ static VALUE
585
+ gl_GetVertexAttribfv(obj,arg1,arg2)
586
+ VALUE obj,arg1,arg2;
587
+ {
588
+ GLuint index;
589
+ GLenum pname;
590
+ GLfloat params[4] = {0.0,0.0,0.0,0.0};
591
+ GLint size;
592
+ GLint i;
593
+ VALUE retary;
594
+ LOAD_GL_FUNC(glGetVertexAttribfv)
595
+ index = (GLuint)NUM2UINT(arg1);
596
+ pname = (GLenum)NUM2INT(arg2);
597
+ if (pname==GL_CURRENT_VERTEX_ATTRIB)
598
+ size = 4;
599
+ else
600
+ size = 1;
601
+ fptr_glGetVertexAttribfv(index,pname,params);
602
+ retary = rb_ary_new2(size);
603
+ for(i=0;i<size;i++)
604
+ rb_ary_push(retary, rb_float_new(params[i]));
605
+ return retary;
606
+ }
607
+
608
+ static void (APIENTRY * fptr_glGetVertexAttribiv)(GLuint,GLenum,GLint *);
609
+ static VALUE
610
+ gl_GetVertexAttribiv(obj,arg1,arg2)
611
+ VALUE obj,arg1,arg2;
612
+ {
613
+ GLuint index;
614
+ GLenum pname;
615
+ GLint params[4] = {0,0,0,0};
616
+ GLint size;
617
+ GLint i;
618
+ VALUE retary;
619
+ LOAD_GL_FUNC(glGetVertexAttribiv)
620
+ index = (GLuint)NUM2UINT(arg1);
621
+ pname = (GLenum)NUM2INT(arg2);
622
+ if (pname==GL_CURRENT_VERTEX_ATTRIB)
623
+ size = 4;
624
+ else
625
+ size = 1;
626
+ fptr_glGetVertexAttribiv(index,pname,params);
627
+ retary = rb_ary_new2(size);
628
+ for(i=0;i<size;i++)
629
+ rb_ary_push(retary, INT2NUM(params[i]));
630
+ return retary;
631
+ }
632
+
633
+ #define _MAX_VERTEX_ATTRIBS 64 /* at least GL_MAX_VERTEX_ATTRIBS - usually 16 or 32 on today's high-end cards */
634
+ static VALUE g_VertexAttrib_ptr[_MAX_VERTEX_ATTRIBS];
635
+
636
+ static void (APIENTRY * fptr_glGetVertexAttribPointerv)(GLuint,GLenum,GLvoid **);
637
+ static VALUE
638
+ gl_GetVertexAttribPointerv(obj,arg1)
639
+ VALUE obj,arg1;
640
+ {
641
+ GLuint index;
642
+ LOAD_GL_FUNC(glGetVertexAttribPointerv)
643
+ index =(GLuint) NUM2INT(arg1);
644
+ if (index>_MAX_VERTEX_ATTRIBS)
645
+ rb_raise(rb_eArgError, "Index too large, maximum allowed value '%i'",_MAX_VERTEX_ATTRIBS);
646
+
647
+ return g_VertexAttrib_ptr[index];
648
+ }
649
+
650
+ static GLboolean (APIENTRY * fptr_glIsProgram)(GLuint);
651
+ static VALUE
652
+ gl_IsProgram(obj,arg1)
653
+ VALUE obj,arg1;
654
+ {
655
+ GLuint program;
656
+ GLboolean ret;
657
+ LOAD_GL_FUNC(glIsProgram)
658
+ program = (GLuint)NUM2UINT(arg1);
659
+ ret = fptr_glIsProgram(program);
660
+ return INT2NUM(ret);
661
+ }
662
+
663
+ static GLboolean (APIENTRY * fptr_glIsShader)(GLuint);
664
+ static VALUE
665
+ gl_IsShader(obj,arg1)
666
+ VALUE obj,arg1;
667
+ {
668
+ GLuint program;
669
+ GLboolean ret;
670
+ LOAD_GL_FUNC(glIsShader)
671
+ program = (GLuint)NUM2UINT(arg1);
672
+ ret = fptr_glIsShader(program);
673
+ return INT2NUM(ret);
674
+ }
675
+
676
+ static void (APIENTRY * fptr_glLinkProgram)(GLuint);
677
+ static VALUE
678
+ gl_LinkProgram(obj,arg1)
679
+ VALUE obj,arg1;
680
+ {
681
+ GLuint program;
682
+ LOAD_GL_FUNC(glLinkProgram)
683
+ program = (GLuint)NUM2UINT(arg1);
684
+ fptr_glLinkProgram(program);
685
+ return Qnil;
686
+ }
687
+
688
+ static void (APIENTRY * fptr_glShaderSource)(GLuint,GLsizei,GLchar**,GLint *);
689
+ static VALUE
690
+ gl_ShaderSource(obj,arg1,arg2)
691
+ VALUE obj,arg1,arg2;
692
+ {
693
+ GLuint shader;
694
+ GLint length;
695
+ GLchar *str;
696
+ LOAD_GL_FUNC(glShaderSource)
697
+ shader = (GLuint)NUM2UINT(arg1);
698
+ Check_Type(arg2,T_STRING);
699
+ str = RSTRING(arg2)->ptr;
700
+ length = RSTRING(arg2)->len;
701
+ fptr_glShaderSource(shader,1,&str,&length);
702
+ return Qnil;
703
+ }
704
+
705
+ static void (APIENTRY * fptr_glUseProgram)(GLuint);
706
+ static VALUE
707
+ gl_UseProgram(obj,arg1)
708
+ VALUE obj,arg1;
709
+ {
710
+ GLuint program;
711
+ LOAD_GL_FUNC(glUseProgram)
712
+ program = (GLuint)NUM2UINT(arg1);
713
+ fptr_glUseProgram(program);
714
+ return Qnil;
715
+ }
716
+
717
+ static void (APIENTRY * fptr_glUniform1f)(GLint,GLfloat);
718
+ static VALUE
719
+ gl_Uniform1f(obj,arg1,arg2)
720
+ VALUE obj,arg1,arg2;
721
+ {
722
+ GLint location;
723
+ GLfloat v0;
724
+ LOAD_GL_FUNC(glUniform1f)
725
+ location = (GLint)NUM2INT(arg1);
726
+ v0 = (GLfloat)NUM2DBL(arg2);
727
+ fptr_glUniform1f(location,v0);
728
+ return Qnil;
729
+ }
730
+
731
+ static void (APIENTRY * fptr_glUniform2f)(GLint,GLfloat,GLfloat);
732
+ static VALUE
733
+ gl_Uniform2f(obj,arg1,arg2,arg3)
734
+ VALUE obj,arg1,arg2,arg3;
735
+ {
736
+ GLint location;
737
+ GLfloat v0;
738
+ GLfloat v1;
739
+ LOAD_GL_FUNC(glUniform2f)
740
+ location = (GLint)NUM2INT(arg1);
741
+ v0 = (GLfloat)NUM2DBL(arg2);
742
+ v1 = (GLfloat)NUM2DBL(arg3);
743
+ fptr_glUniform2f(location,v0,v1);
744
+ return Qnil;
745
+ }
746
+
747
+ static void (APIENTRY * fptr_glUniform3f)(GLint,GLfloat,GLfloat,GLfloat);
748
+ static VALUE
749
+ gl_Uniform3f(obj,arg1,arg2,arg3,arg4)
750
+ VALUE obj,arg1,arg2,arg3,arg4;
751
+ {
752
+ GLint location;
753
+ GLfloat v0;
754
+ GLfloat v1;
755
+ GLfloat v2;
756
+ LOAD_GL_FUNC(glUniform3f)
757
+ location = (GLint)NUM2INT(arg1);
758
+ v0 = (GLfloat)NUM2DBL(arg2);
759
+ v1 = (GLfloat)NUM2DBL(arg3);
760
+ v2 = (GLfloat)NUM2DBL(arg4);
761
+ fptr_glUniform3f(location,v0,v1,v2);
762
+ return Qnil;
763
+ }
764
+
765
+ static void (APIENTRY * fptr_glUniform4f)(GLint,GLfloat,GLfloat,GLfloat,GLfloat);
766
+ static VALUE
767
+ gl_Uniform4f(obj,arg1,arg2,arg3,arg4,arg5)
768
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
769
+ {
770
+ GLint location;
771
+ GLfloat v0;
772
+ GLfloat v1;
773
+ GLfloat v2;
774
+ GLfloat v3;
775
+ LOAD_GL_FUNC(glUniform4f)
776
+ location = (GLint)NUM2INT(arg1);
777
+ v0 = (GLfloat)NUM2DBL(arg2);
778
+ v1 = (GLfloat)NUM2DBL(arg3);
779
+ v2 = (GLfloat)NUM2DBL(arg4);
780
+ v3 = (GLfloat)NUM2DBL(arg5);
781
+ fptr_glUniform4f(location,v0,v1,v2,v3);
782
+ return Qnil;
783
+ }
784
+
785
+ static void (APIENTRY * fptr_glUniform1i)(GLint,GLint);
786
+ static VALUE
787
+ gl_Uniform1i(obj,arg1,arg2)
788
+ VALUE obj,arg1,arg2;
789
+ {
790
+ GLint location;
791
+ GLint v0;
792
+ LOAD_GL_FUNC(glUniform1i)
793
+ location = (GLint)NUM2INT(arg1);
794
+ v0 = (GLint)NUM2INT(arg2);
795
+ fptr_glUniform1i(location,v0);
796
+ return Qnil;
797
+ }
798
+
799
+ static void (APIENTRY * fptr_glUniform2i)(GLint,GLint,GLint);
800
+ static VALUE
801
+ gl_Uniform2i(obj,arg1,arg2,arg3)
802
+ VALUE obj,arg1,arg2,arg3;
803
+ {
804
+ GLint location;
805
+ GLint v0;
806
+ GLint v1;
807
+ LOAD_GL_FUNC(glUniform2i)
808
+ location = (GLint)NUM2INT(arg1);
809
+ v0 = (GLint)NUM2INT(arg2);
810
+ v1 = (GLint)NUM2INT(arg3);
811
+ fptr_glUniform2i(location,v0,v1);
812
+ return Qnil;
813
+ }
814
+
815
+ static void (APIENTRY * fptr_glUniform3i)(GLint,GLint,GLint,GLint);
816
+ static VALUE
817
+ gl_Uniform3i(obj,arg1,arg2,arg3,arg4)
818
+ VALUE obj,arg1,arg2,arg3,arg4;
819
+ {
820
+ GLint location;
821
+ GLint v0;
822
+ GLint v1;
823
+ GLint v2;
824
+ LOAD_GL_FUNC(glUniform3i)
825
+ location = (GLint)NUM2INT(arg1);
826
+ v0 = (GLint)NUM2INT(arg2);
827
+ v1 = (GLint)NUM2INT(arg3);
828
+ v2 = (GLint)NUM2INT(arg4);
829
+ fptr_glUniform3i(location,v0,v1,v2);
830
+ return Qnil;
831
+ }
832
+
833
+ static void (APIENTRY * fptr_glUniform4i)(GLint,GLint,GLint,GLint,GLint);
834
+ static VALUE
835
+ gl_Uniform4i(obj,arg1,arg2,arg3,arg4,arg5)
836
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
837
+ {
838
+ GLint location;
839
+ GLint v0;
840
+ GLint v1;
841
+ GLint v2;
842
+ GLint v3;
843
+ LOAD_GL_FUNC(glUniform4i)
844
+ location = (GLint)NUM2INT(arg1);
845
+ v0 = (GLint)NUM2INT(arg2);
846
+ v1 = (GLint)NUM2INT(arg3);
847
+ v2 = (GLint)NUM2INT(arg4);
848
+ v3 = (GLint)NUM2INT(arg5);
849
+ fptr_glUniform4i(location,v0,v1,v2,v3);
850
+ return Qnil;
851
+ }
852
+
853
+ static void (APIENTRY * fptr_glUniform1fv)(GLint,GLsizei,GLfloat *);
854
+ static VALUE
855
+ gl_Uniform1fv(obj,arg1,arg2,arg3)
856
+ VALUE obj,arg1,arg2,arg3;
857
+ {
858
+ GLint location;
859
+ GLsizei count;
860
+ GLfloat *value;
861
+ LOAD_GL_FUNC(glUniform1fv)
862
+ location = (GLint)NUM2INT(arg1);
863
+ count = (GLsizei)NUM2UINT(arg2);
864
+ value = ALLOC_N(GLfloat,1*count);
865
+ ary2cflt(arg3,value,1*count);
866
+ fptr_glUniform1fv(location,count,value);
867
+ xfree(value);
868
+ return Qnil;
869
+ }
870
+
871
+ static void (APIENTRY * fptr_glUniform2fv)(GLint,GLsizei,GLfloat *);
872
+ static VALUE
873
+ gl_Uniform2fv(obj,arg1,arg2,arg3)
874
+ VALUE obj,arg1,arg2,arg3;
875
+ {
876
+ GLint location;
877
+ GLsizei count;
878
+ GLfloat *value;
879
+ LOAD_GL_FUNC(glUniform2fv)
880
+ location = (GLint)NUM2INT(arg1);
881
+ count = (GLsizei)NUM2UINT(arg2);
882
+ value = ALLOC_N(GLfloat,2*count);
883
+ ary2cflt(arg3,value,2*count);
884
+ fptr_glUniform2fv(location,count,value);
885
+ xfree(value);
886
+ return Qnil;
887
+ }
888
+
889
+ static void (APIENTRY * fptr_glUniform3fv)(GLint,GLsizei,GLfloat *);
890
+ static VALUE
891
+ gl_Uniform3fv(obj,arg1,arg2,arg3)
892
+ VALUE obj,arg1,arg2,arg3;
893
+ {
894
+ GLint location;
895
+ GLsizei count;
896
+ GLfloat *value;
897
+ LOAD_GL_FUNC(glUniform3fv)
898
+ location = (GLint)NUM2INT(arg1);
899
+ count = (GLsizei)NUM2UINT(arg2);
900
+ value = ALLOC_N(GLfloat,3*count);
901
+ ary2cflt(arg3,value,3*count);
902
+ fptr_glUniform3fv(location,count,value);
903
+ xfree(value);
904
+ return Qnil;
905
+ }
906
+
907
+ static void (APIENTRY * fptr_glUniform4fv)(GLint,GLsizei,GLfloat *);
908
+ static VALUE
909
+ gl_Uniform4fv(obj,arg1,arg2,arg3)
910
+ VALUE obj,arg1,arg2,arg3;
911
+ {
912
+ GLint location;
913
+ GLsizei count;
914
+ GLfloat *value;
915
+ LOAD_GL_FUNC(glUniform4fv)
916
+ location = (GLint)NUM2INT(arg1);
917
+ count = (GLsizei)NUM2UINT(arg2);
918
+ value = ALLOC_N(GLfloat,4*count);
919
+ ary2cflt(arg3,value,4*count);
920
+ fptr_glUniform4fv(location,count,value);
921
+ xfree(value);
922
+ return Qnil;
923
+ }
924
+
925
+ static void (APIENTRY * fptr_glUniform1iv)(GLint,GLsizei,GLint *);
926
+ static VALUE
927
+ gl_Uniform1iv(obj,arg1,arg2,arg3)
928
+ VALUE obj,arg1,arg2,arg3;
929
+ {
930
+ GLint location;
931
+ GLsizei count;
932
+ GLint *value;
933
+ LOAD_GL_FUNC(glUniform1iv)
934
+ location = (GLint)NUM2INT(arg1);
935
+ count = (GLsizei)NUM2UINT(arg2);
936
+ value = ALLOC_N(GLint,1*count);
937
+ ary2cint(arg3,value,1*count);
938
+ fptr_glUniform1iv(location,count,value);
939
+ xfree(value);
940
+ return Qnil;
941
+ }
942
+
943
+ static void (APIENTRY * fptr_glUniform2iv)(GLint,GLsizei,GLint *);
944
+ static VALUE
945
+ gl_Uniform2iv(obj,arg1,arg2,arg3)
946
+ VALUE obj,arg1,arg2,arg3;
947
+ {
948
+ GLint location;
949
+ GLsizei count;
950
+ GLint *value;
951
+ LOAD_GL_FUNC(glUniform2iv)
952
+ location = (GLint)NUM2INT(arg1);
953
+ count = (GLsizei)NUM2UINT(arg2);
954
+ value = ALLOC_N(GLint,2*count);
955
+ ary2cint(arg3,value,2*count);
956
+ fptr_glUniform2iv(location,count,value);
957
+ xfree(value);
958
+ return Qnil;
959
+ }
960
+
961
+ static void (APIENTRY * fptr_glUniform3iv)(GLint,GLsizei,GLint *);
962
+ static VALUE
963
+ gl_Uniform3iv(obj,arg1,arg2,arg3)
964
+ VALUE obj,arg1,arg2,arg3;
965
+ {
966
+ GLint location;
967
+ GLsizei count;
968
+ GLint *value;
969
+ LOAD_GL_FUNC(glUniform3iv)
970
+ location = (GLint)NUM2INT(arg1);
971
+ count = (GLsizei)NUM2UINT(arg2);
972
+ value = ALLOC_N(GLint,3*count);
973
+ ary2cint(arg3,value,3*count);
974
+ fptr_glUniform3iv(location,count,value);
975
+ xfree(value);
976
+ return Qnil;
977
+ }
978
+
979
+ static void (APIENTRY * fptr_glUniform4iv)(GLint,GLsizei,GLint *);
980
+ static VALUE
981
+ gl_Uniform4iv(obj,arg1,arg2,arg3)
982
+ VALUE obj,arg1,arg2,arg3;
983
+ {
984
+ GLint location;
985
+ GLsizei count;
986
+ GLint *value;
987
+ LOAD_GL_FUNC(glUniform4iv)
988
+ location = (GLint)NUM2INT(arg1);
989
+ count = (GLsizei)NUM2UINT(arg2);
990
+ value = ALLOC_N(GLint,4*count);
991
+ ary2cint(arg3,value,4*count);
992
+ fptr_glUniform4iv(location,count,value);
993
+ xfree(value);
994
+ return Qnil;
995
+ }
996
+
997
+ static void (APIENTRY * fptr_glUniformMatrix2fv)(GLint,GLsizei,GLboolean,GLfloat *);
998
+ static VALUE
999
+ gl_UniformMatrix2fv(obj,arg1,arg2,arg3,arg4)
1000
+ VALUE obj,arg1,arg2,arg3,arg4;
1001
+ {
1002
+ GLint location;
1003
+ GLsizei count;
1004
+ GLboolean transpose;
1005
+ GLfloat *value;
1006
+ LOAD_GL_FUNC(glUniformMatrix2fv)
1007
+ location = (GLint)NUM2INT(arg1);
1008
+ count = (GLint)NUM2INT(arg2);
1009
+ transpose = (GLboolean)NUM2INT(arg3);
1010
+ value = ALLOC_N(GLfloat, 2*2*count);
1011
+ ary2cflt(arg4,value,2*2*count);
1012
+ fptr_glUniformMatrix2fv(location,count,transpose,value);
1013
+ xfree(value);
1014
+ return Qnil;
1015
+ }
1016
+
1017
+ static void (APIENTRY * fptr_glUniformMatrix3fv)(GLint,GLsizei,GLboolean,GLfloat *);
1018
+ static VALUE
1019
+ gl_UniformMatrix3fv(obj,arg1,arg2,arg3,arg4)
1020
+ VALUE obj,arg1,arg2,arg3,arg4;
1021
+ {
1022
+ GLint location;
1023
+ GLsizei count;
1024
+ GLboolean transpose;
1025
+ GLfloat *value;
1026
+ LOAD_GL_FUNC(glUniformMatrix3fv)
1027
+ location = (GLint)NUM2INT(arg1);
1028
+ count = (GLint)NUM2INT(arg2);
1029
+ transpose = (GLboolean)NUM2INT(arg3);
1030
+ value = ALLOC_N(GLfloat, 3*3*count);
1031
+ ary2cflt(arg4,value,3*3*count);
1032
+ fptr_glUniformMatrix3fv(location,count,transpose,value);
1033
+ xfree(value);
1034
+ return Qnil;
1035
+ }
1036
+
1037
+ static void (APIENTRY * fptr_glUniformMatrix4fv)(GLint,GLsizei,GLboolean,GLfloat *);
1038
+ static VALUE
1039
+ gl_UniformMatrix4fv(obj,arg1,arg2,arg3,arg4)
1040
+ VALUE obj,arg1,arg2,arg3,arg4;
1041
+ {
1042
+ GLint location;
1043
+ GLsizei count;
1044
+ GLboolean transpose;
1045
+ GLfloat *value;
1046
+ LOAD_GL_FUNC(glUniformMatrix4fv)
1047
+ location = (GLint)NUM2INT(arg1);
1048
+ count = (GLint)NUM2INT(arg2);
1049
+ transpose = (GLboolean)NUM2INT(arg3);
1050
+ value = ALLOC_N(GLfloat, 4*4*count);
1051
+ ary2cflt(arg4,value,4*4*count);
1052
+ fptr_glUniformMatrix4fv(location,count,transpose,value);
1053
+ xfree(value);
1054
+ return Qnil;
1055
+ }
1056
+
1057
+ static void (APIENTRY * fptr_glValidateProgram)(GLuint);
1058
+ static VALUE
1059
+ gl_ValidateProgram(obj,arg1)
1060
+ VALUE obj,arg1;
1061
+ {
1062
+ GLuint program;
1063
+ LOAD_GL_FUNC(glValidateProgram)
1064
+ program = (GLuint)NUM2UINT(arg1);
1065
+ fptr_glValidateProgram(program);
1066
+ return Qnil;
1067
+ }
1068
+
1069
+ static void (APIENTRY * fptr_glVertexAttrib1d)(GLuint,GLdouble);
1070
+ static VALUE
1071
+ gl_VertexAttrib1d(obj,arg1,arg2)
1072
+ VALUE obj,arg1,arg2;
1073
+ {
1074
+ GLuint index;
1075
+ GLdouble v0;
1076
+ LOAD_GL_FUNC(glVertexAttrib1d)
1077
+ index = (GLuint)NUM2UINT(arg1);
1078
+ v0 = (GLdouble)NUM2DBL(arg2);
1079
+ fptr_glVertexAttrib1d(index,v0);
1080
+ return Qnil;
1081
+ }
1082
+
1083
+ static void (APIENTRY * fptr_glVertexAttrib1f)(GLuint,GLfloat);
1084
+ static VALUE
1085
+ gl_VertexAttrib1f(obj,arg1,arg2)
1086
+ VALUE obj,arg1,arg2;
1087
+ {
1088
+ GLuint index;
1089
+ GLfloat v0;
1090
+ LOAD_GL_FUNC(glVertexAttrib1f)
1091
+ index = (GLuint)NUM2UINT(arg1);
1092
+ v0 = (GLfloat)NUM2DBL(arg2);
1093
+ fptr_glVertexAttrib1f(index,v0);
1094
+ return Qnil;
1095
+ }
1096
+
1097
+ static void (APIENTRY * fptr_glVertexAttrib1s)(GLuint,GLshort);
1098
+ static VALUE
1099
+ gl_VertexAttrib1s(obj,arg1,arg2)
1100
+ VALUE obj,arg1,arg2;
1101
+ {
1102
+ GLuint index;
1103
+ GLshort v0;
1104
+ LOAD_GL_FUNC(glVertexAttrib1s)
1105
+ index = (GLuint)NUM2UINT(arg1);
1106
+ v0 = (GLshort)NUM2INT(arg2);
1107
+ fptr_glVertexAttrib1s(index,v0);
1108
+ return Qnil;
1109
+ }
1110
+
1111
+ static void (APIENTRY * fptr_glVertexAttrib2d)(GLuint,GLdouble,GLdouble);
1112
+ static VALUE
1113
+ gl_VertexAttrib2d(obj,arg1,arg2,arg3)
1114
+ VALUE obj,arg1,arg2,arg3;
1115
+ {
1116
+ GLuint index;
1117
+ GLdouble v0;
1118
+ GLdouble v1;
1119
+ LOAD_GL_FUNC(glVertexAttrib2d)
1120
+ index = (GLuint)NUM2UINT(arg1);
1121
+ v0 = (GLdouble)NUM2DBL(arg2);
1122
+ v1 = (GLdouble)NUM2DBL(arg3);
1123
+ fptr_glVertexAttrib2d(index,v0,v1);
1124
+ return Qnil;
1125
+ }
1126
+
1127
+ static void (APIENTRY * fptr_glVertexAttrib2f)(GLuint,GLfloat,GLfloat);
1128
+ static VALUE
1129
+ gl_VertexAttrib2f(obj,arg1,arg2,arg3)
1130
+ VALUE obj,arg1,arg2,arg3;
1131
+ {
1132
+ GLuint index;
1133
+ GLfloat v0;
1134
+ GLfloat v1;
1135
+ LOAD_GL_FUNC(glVertexAttrib2f)
1136
+ index = (GLuint)NUM2UINT(arg1);
1137
+ v0 = (GLfloat)NUM2DBL(arg2);
1138
+ v1 = (GLfloat)NUM2DBL(arg3);
1139
+ fptr_glVertexAttrib2f(index,v0,v1);
1140
+ return Qnil;
1141
+ }
1142
+
1143
+ static void (APIENTRY * fptr_glVertexAttrib2s)(GLuint,GLshort,GLshort);
1144
+ static VALUE
1145
+ gl_VertexAttrib2s(obj,arg1,arg2,arg3)
1146
+ VALUE obj,arg1,arg2,arg3;
1147
+ {
1148
+ GLuint index;
1149
+ GLshort v0;
1150
+ GLshort v1;
1151
+ LOAD_GL_FUNC(glVertexAttrib2s)
1152
+ index = (GLuint)NUM2UINT(arg1);
1153
+ v0 = (GLshort)NUM2INT(arg2);
1154
+ v1 = (GLshort)NUM2INT(arg3);
1155
+ fptr_glVertexAttrib2s(index,v0,v1);
1156
+ return Qnil;
1157
+ }
1158
+
1159
+ static void (APIENTRY * fptr_glVertexAttrib3d)(GLuint,GLdouble,GLdouble,GLdouble);
1160
+ static VALUE
1161
+ gl_VertexAttrib3d(obj,arg1,arg2,arg3,arg4)
1162
+ VALUE obj,arg1,arg2,arg3,arg4;
1163
+ {
1164
+ GLuint index;
1165
+ GLdouble v0;
1166
+ GLdouble v1;
1167
+ GLdouble v2;
1168
+ LOAD_GL_FUNC(glVertexAttrib3d)
1169
+ index = (GLuint)NUM2UINT(arg1);
1170
+ v0 = (GLdouble)NUM2DBL(arg2);
1171
+ v1 = (GLdouble)NUM2DBL(arg3);
1172
+ v2 = (GLdouble)NUM2DBL(arg4);
1173
+ fptr_glVertexAttrib3d(index,v0,v1,v2);
1174
+ return Qnil;
1175
+ }
1176
+
1177
+ static void (APIENTRY * fptr_glVertexAttrib3f)(GLuint,GLfloat,GLfloat,GLfloat);
1178
+ static VALUE
1179
+ gl_VertexAttrib3f(obj,arg1,arg2,arg3,arg4)
1180
+ VALUE obj,arg1,arg2,arg3,arg4;
1181
+ {
1182
+ GLuint index;
1183
+ GLfloat v0;
1184
+ GLfloat v1;
1185
+ GLfloat v2;
1186
+ LOAD_GL_FUNC(glVertexAttrib3f)
1187
+ index = (GLuint)NUM2UINT(arg1);
1188
+ v0 = (GLfloat)NUM2DBL(arg2);
1189
+ v1 = (GLfloat)NUM2DBL(arg3);
1190
+ v2 = (GLfloat)NUM2DBL(arg4);
1191
+ fptr_glVertexAttrib3f(index,v0,v1,v2);
1192
+ return Qnil;
1193
+ }
1194
+
1195
+ static void (APIENTRY * fptr_glVertexAttrib3s)(GLuint,GLshort,GLshort,GLshort);
1196
+ static VALUE
1197
+ gl_VertexAttrib3s(obj,arg1,arg2,arg3,arg4)
1198
+ VALUE obj,arg1,arg2,arg3,arg4;
1199
+ {
1200
+ GLuint index;
1201
+ GLshort v0;
1202
+ GLshort v1;
1203
+ GLshort v2;
1204
+ LOAD_GL_FUNC(glVertexAttrib3s)
1205
+ index = (GLuint)NUM2UINT(arg1);
1206
+ v0 = (GLshort)NUM2INT(arg2);
1207
+ v1 = (GLshort)NUM2INT(arg3);
1208
+ v2 = (GLshort)NUM2INT(arg4);
1209
+ fptr_glVertexAttrib3s(index,v0,v1,v2);
1210
+ return Qnil;
1211
+ }
1212
+
1213
+ static void (APIENTRY * fptr_glVertexAttrib4Nbv)(GLuint,GLbyte *);
1214
+ static VALUE
1215
+ gl_VertexAttrib4Nbv(obj,arg1,arg2)
1216
+ VALUE obj,arg1,arg2;
1217
+ {
1218
+ GLuint index;
1219
+ GLbyte v[4];
1220
+ LOAD_GL_FUNC(glVertexAttrib4Nbv)
1221
+ index = (GLuint)NUM2UINT(arg1);
1222
+ ary2cbyte(arg2,v,4);
1223
+ fptr_glVertexAttrib4Nbv(index,v);
1224
+ return Qnil;
1225
+ }
1226
+
1227
+ static void (APIENTRY * fptr_glVertexAttrib4Niv)(GLuint,GLint *);
1228
+ static VALUE
1229
+ gl_VertexAttrib4Niv(obj,arg1,arg2)
1230
+ VALUE obj,arg1,arg2;
1231
+ {
1232
+ GLuint index;
1233
+ GLint v[4];
1234
+ LOAD_GL_FUNC(glVertexAttrib4Niv)
1235
+ index = (GLuint)NUM2UINT(arg1);
1236
+ ary2cint(arg2,v,4);
1237
+ fptr_glVertexAttrib4Niv(index,v);
1238
+ return Qnil;
1239
+ }
1240
+
1241
+ static void (APIENTRY * fptr_glVertexAttrib4Nsv)(GLuint,GLshort *);
1242
+ static VALUE
1243
+ gl_VertexAttrib4Nsv(obj,arg1,arg2)
1244
+ VALUE obj,arg1,arg2;
1245
+ {
1246
+ GLuint index;
1247
+ GLshort v[4];
1248
+ LOAD_GL_FUNC(glVertexAttrib4Nsv)
1249
+ index = (GLuint)NUM2UINT(arg1);
1250
+ ary2cshort(arg2,v,4);
1251
+ fptr_glVertexAttrib4Nsv(index,v);
1252
+ return Qnil;
1253
+ }
1254
+
1255
+ static void (APIENTRY * fptr_glVertexAttrib4Nub)(GLuint,GLubyte,GLubyte,GLubyte,GLubyte);
1256
+ static VALUE
1257
+ gl_VertexAttrib4Nub(obj,arg1,arg2,arg3,arg4,arg5)
1258
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
1259
+ {
1260
+ GLuint index;
1261
+ GLubyte v0;
1262
+ GLubyte v1;
1263
+ GLubyte v2;
1264
+ GLubyte v3;
1265
+ LOAD_GL_FUNC(glVertexAttrib4Nub)
1266
+ index = (GLuint)NUM2UINT(arg1);
1267
+ v0 = (GLubyte)NUM2INT(arg2);
1268
+ v1 = (GLubyte)NUM2INT(arg3);
1269
+ v2 = (GLubyte)NUM2INT(arg4);
1270
+ v3 = (GLubyte)NUM2INT(arg5);
1271
+ fptr_glVertexAttrib4Nub(index,v0,v1,v2,v3);
1272
+ return Qnil;
1273
+ }
1274
+
1275
+ static void (APIENTRY * fptr_glVertexAttrib4Nubv)(GLuint,GLubyte *);
1276
+ static VALUE
1277
+ gl_VertexAttrib4Nubv(obj,arg1,arg2)
1278
+ VALUE obj,arg1,arg2;
1279
+ {
1280
+ GLuint index;
1281
+ GLubyte v[4];
1282
+ LOAD_GL_FUNC(glVertexAttrib4Nubv)
1283
+ index = (GLuint)NUM2UINT(arg1);
1284
+ ary2cubyte(arg2,v,4);
1285
+ fptr_glVertexAttrib4Nubv(index,v);
1286
+ return Qnil;
1287
+ }
1288
+
1289
+ static void (APIENTRY * fptr_glVertexAttrib4Nuiv)(GLuint,GLuint *);
1290
+ static VALUE
1291
+ gl_VertexAttrib4Nuiv(obj,arg1,arg2)
1292
+ VALUE obj,arg1,arg2;
1293
+ {
1294
+ GLuint index;
1295
+ GLuint v[4];
1296
+ LOAD_GL_FUNC(glVertexAttrib4Nuiv)
1297
+ index = (GLuint)NUM2UINT(arg1);
1298
+ ary2cuint(arg2,v,4);
1299
+ fptr_glVertexAttrib4Nuiv(index,v);
1300
+ return Qnil;
1301
+ }
1302
+
1303
+ static void (APIENTRY * fptr_glVertexAttrib4Nusv)(GLuint,GLushort *);
1304
+ static VALUE
1305
+ gl_VertexAttrib4Nusv(obj,arg1,arg2)
1306
+ VALUE obj,arg1,arg2;
1307
+ {
1308
+ GLuint index;
1309
+ GLushort v[4];
1310
+ LOAD_GL_FUNC(glVertexAttrib4Nusv)
1311
+ index = (GLuint)NUM2UINT(arg1);
1312
+ ary2cushort(arg2,v,4);
1313
+ fptr_glVertexAttrib4Nusv(index,v);
1314
+ return Qnil;
1315
+ }
1316
+
1317
+ static void (APIENTRY * fptr_glVertexAttrib4bv)(GLuint,GLbyte *);
1318
+ static VALUE
1319
+ gl_VertexAttrib4bv(obj,arg1,arg2)
1320
+ VALUE obj,arg1,arg2;
1321
+ {
1322
+ GLuint index;
1323
+ GLbyte v[4];
1324
+ LOAD_GL_FUNC(glVertexAttrib4bv)
1325
+ index = (GLuint)NUM2UINT(arg1);
1326
+ ary2cbyte(arg2,v,4);
1327
+ fptr_glVertexAttrib4bv(index,v);
1328
+ return Qnil;
1329
+ }
1330
+
1331
+ static void (APIENTRY * fptr_glVertexAttrib4d)(GLuint,GLdouble,GLdouble,GLdouble,GLdouble);
1332
+ static VALUE
1333
+ gl_VertexAttrib4d(obj,arg1,arg2,arg3,arg4,arg5)
1334
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
1335
+ {
1336
+ GLuint index;
1337
+ GLdouble v0;
1338
+ GLdouble v1;
1339
+ GLdouble v2;
1340
+ GLdouble v3;
1341
+ LOAD_GL_FUNC(glVertexAttrib4d)
1342
+ index = (GLuint)NUM2UINT(arg1);
1343
+ v0 = (GLdouble)NUM2DBL(arg2);
1344
+ v1 = (GLdouble)NUM2DBL(arg3);
1345
+ v2 = (GLdouble)NUM2DBL(arg4);
1346
+ v3 = (GLdouble)NUM2DBL(arg5);
1347
+ fptr_glVertexAttrib4d(index,v0,v1,v2,v3);
1348
+ return Qnil;
1349
+ }
1350
+
1351
+ static void (APIENTRY * fptr_glVertexAttrib4f)(GLuint,GLfloat,GLfloat,GLfloat,GLfloat);
1352
+ static VALUE
1353
+ gl_VertexAttrib4f(obj,arg1,arg2,arg3,arg4,arg5)
1354
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
1355
+ {
1356
+ GLuint index;
1357
+ GLfloat v0;
1358
+ GLfloat v1;
1359
+ GLfloat v2;
1360
+ GLfloat v3;
1361
+ LOAD_GL_FUNC(glVertexAttrib4f)
1362
+ index = (GLuint)NUM2UINT(arg1);
1363
+ v0 = (GLfloat)NUM2DBL(arg2);
1364
+ v1 = (GLfloat)NUM2DBL(arg3);
1365
+ v2 = (GLfloat)NUM2DBL(arg4);
1366
+ v3 = (GLfloat)NUM2DBL(arg5);
1367
+ fptr_glVertexAttrib4f(index,v0,v1,v2,v3);
1368
+ return Qnil;
1369
+ }
1370
+
1371
+ static void (APIENTRY * fptr_glVertexAttrib4iv)(GLuint,GLint *);
1372
+ static VALUE
1373
+ gl_VertexAttrib4iv(obj,arg1,arg2)
1374
+ VALUE obj,arg1,arg2;
1375
+ {
1376
+ GLuint index;
1377
+ GLint v[4];
1378
+ LOAD_GL_FUNC(glVertexAttrib4iv)
1379
+ index = (GLuint)NUM2UINT(arg1);
1380
+ ary2cint(arg2,v,4);
1381
+ fptr_glVertexAttrib4iv(index,v);
1382
+ return Qnil;
1383
+ }
1384
+
1385
+ static void (APIENTRY * fptr_glVertexAttrib4s)(GLuint,GLshort,GLshort,GLshort,GLshort);
1386
+ static VALUE
1387
+ gl_VertexAttrib4s(obj,arg1,arg2,arg3,arg4,arg5)
1388
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
1389
+ {
1390
+ GLuint index;
1391
+ GLshort v0;
1392
+ GLshort v1;
1393
+ GLshort v2;
1394
+ GLshort v3;
1395
+ LOAD_GL_FUNC(glVertexAttrib4s)
1396
+ index = (GLuint)NUM2UINT(arg1);
1397
+ v0 = (GLshort)NUM2INT(arg2);
1398
+ v1 = (GLshort)NUM2INT(arg3);
1399
+ v2 = (GLshort)NUM2INT(arg4);
1400
+ v3 = (GLshort)NUM2INT(arg5);
1401
+ fptr_glVertexAttrib4s(index,v0,v1,v2,v3);
1402
+ return Qnil;
1403
+ }
1404
+
1405
+ static void (APIENTRY * fptr_glVertexAttrib4ubv)(GLuint,GLubyte *);
1406
+ static VALUE
1407
+ gl_VertexAttrib4ubv(obj,arg1,arg2)
1408
+ VALUE obj,arg1,arg2;
1409
+ {
1410
+ GLuint index;
1411
+ GLubyte v[4];
1412
+ LOAD_GL_FUNC(glVertexAttrib4ubv)
1413
+ index = (GLuint)NUM2UINT(arg1);
1414
+ ary2cubyte(arg2,v,4);
1415
+ fptr_glVertexAttrib4ubv(index,v);
1416
+ return Qnil;
1417
+ }
1418
+
1419
+ static void (APIENTRY * fptr_glVertexAttrib4uiv)(GLuint,GLuint *);
1420
+ static VALUE
1421
+ gl_VertexAttrib4uiv(obj,arg1,arg2)
1422
+ VALUE obj,arg1,arg2;
1423
+ {
1424
+ GLuint index;
1425
+ GLuint v[4];
1426
+ LOAD_GL_FUNC(glVertexAttrib4uiv)
1427
+ index = (GLuint)NUM2UINT(arg1);
1428
+ ary2cuint(arg2,v,4);
1429
+ fptr_glVertexAttrib4uiv(index,v);
1430
+ return Qnil;
1431
+ }
1432
+
1433
+ static void (APIENTRY * fptr_glVertexAttrib4usv)(GLuint,GLushort *);
1434
+ static VALUE
1435
+ gl_VertexAttrib4usv(obj,arg1,arg2)
1436
+ VALUE obj,arg1,arg2;
1437
+ {
1438
+ GLuint index;
1439
+ GLushort v[4];
1440
+ LOAD_GL_FUNC(glVertexAttrib4usv)
1441
+ index = (GLuint)NUM2UINT(arg1);
1442
+ ary2cushort(arg2,v,4);
1443
+ fptr_glVertexAttrib4usv(index,v);
1444
+ return Qnil;
1445
+ }
1446
+
1447
+ #define GLVERTEXATTRIB_VFUNC(_type_) \
1448
+ static VALUE \
1449
+ gl_VertexAttrib##_type_##v(argc,argv,obj) \
1450
+ int argc; \
1451
+ VALUE *argv; \
1452
+ VALUE obj; \
1453
+ { \
1454
+ VALUE args[5]; \
1455
+ RArray *ary; \
1456
+ switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) { \
1457
+ case 2: \
1458
+ if (TYPE(args[1]) == T_ARRAY) { \
1459
+ ary = RARRAY(args[1]); \
1460
+ switch (ary->len) { \
1461
+ case 1: \
1462
+ gl_VertexAttrib1##_type_(obj,args[0],ary->ptr[0]); \
1463
+ break; \
1464
+ case 2: \
1465
+ gl_VertexAttrib2##_type_(obj,args[0],ary->ptr[0],ary->ptr[1]); \
1466
+ break; \
1467
+ case 3: \
1468
+ gl_VertexAttrib3##_type_(obj,args[0],ary->ptr[0],ary->ptr[1],ary->ptr[2]); \
1469
+ break; \
1470
+ case 4: \
1471
+ gl_VertexAttrib4##_type_(obj,args[0],ary->ptr[0],ary->ptr[1],ary->ptr[2],ary->ptr[3]); \
1472
+ break; \
1473
+ default: \
1474
+ rb_raise(rb_eRuntimeError, "glVertex vertex num error!:%d", ary->len); \
1475
+ } \
1476
+ } \
1477
+ else { \
1478
+ gl_VertexAttrib1##_type_(obj,args[0], args[1]); \
1479
+ break; \
1480
+ } \
1481
+ break; \
1482
+ case 3: \
1483
+ gl_VertexAttrib2##_type_(obj,args[0], args[1], args[2]); \
1484
+ break; \
1485
+ case 4: \
1486
+ gl_VertexAttrib3##_type_(obj,args[0], args[1], args[2], args[3]); \
1487
+ break; \
1488
+ case 5: \
1489
+ gl_VertexAttrib4##_type_(obj,args[0], args[1], args[2], args[3], args[4]); \
1490
+ break; \
1491
+ default: \
1492
+ rb_raise(rb_eArgError, "Argument number error!"); \
1493
+ break; \
1494
+ } \
1495
+ return Qnil; \
1496
+ }
1497
+
1498
+ GLVERTEXATTRIB_VFUNC(d)
1499
+ GLVERTEXATTRIB_VFUNC(f)
1500
+ GLVERTEXATTRIB_VFUNC(s)
1501
+
1502
+ #undef GLVERTEXATTRIB_VFUNC
1503
+
1504
+ static void (APIENTRY * fptr_glVertexAttribPointer)(GLuint,GLint,GLenum,GLboolean,GLsizei,GLvoid *);
1505
+ static VALUE
1506
+ gl_VertexAttribPointer(obj,arg1,arg2,arg3,arg4,arg5,arg6)
1507
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
1508
+ {
1509
+ GLuint index;
1510
+ GLuint size;
1511
+ GLenum type;
1512
+ GLboolean normalized;
1513
+ GLsizei stride;
1514
+ LOAD_GL_FUNC(glVertexAttribPointer)
1515
+ index = (GLuint)NUM2UINT(arg1);
1516
+ size = (GLuint)NUM2UINT(arg2);
1517
+ type = (GLenum)NUM2INT(arg3);
1518
+ normalized = (GLboolean)NUM2INT(arg4);
1519
+ stride = (GLsizei)NUM2UINT(arg5);
1520
+ if (index>_MAX_VERTEX_ATTRIBS)
1521
+ rb_raise(rb_eArgError, "Index too large, maximum allowed value '%i'",_MAX_VERTEX_ATTRIBS);
1522
+ Check_Type(arg6, T_STRING);
1523
+ rb_str_freeze(arg6);
1524
+ g_VertexAttrib_ptr[index] = arg6;
1525
+ fptr_glVertexAttribPointer(index,size,type,normalized,stride,(GLvoid *)RSTRING(arg6)->ptr);
1526
+ return Qnil;
1527
+ }
1528
+
1529
+ void gl_init_functions_2_0(VALUE module)
1530
+ {
1531
+ rb_define_module_function(module, "glBlendEquationSeparate", gl_BlendEquationSeparate, 2);
1532
+ rb_define_module_function(module, "glDrawBuffers", gl_DrawBuffers, 1);
1533
+ rb_define_module_function(module, "glStencilOpSeparate", gl_StencilOpSeparate, 4);
1534
+ rb_define_module_function(module, "glStencilFuncSeparate", gl_StencilFuncSeparate, 4);
1535
+ rb_define_module_function(module, "glStencilMaskSeparate", gl_StencilMaskSeparate, 2);
1536
+ rb_define_module_function(module, "glAttachShader", gl_AttachShader, 2);
1537
+ rb_define_module_function(module, "glBindAttribLocation", gl_BindAttribLocation, 3);
1538
+ rb_define_module_function(module, "glCompileShader", gl_CompileShader, 1);
1539
+ rb_define_module_function(module, "glCreateProgram", gl_CreateProgram, 0);
1540
+ rb_define_module_function(module, "glCreateShader", gl_CreateShader, 1);
1541
+ rb_define_module_function(module, "glDeleteProgram", gl_DeleteProgram, 1);
1542
+ rb_define_module_function(module, "glDeleteShader", gl_DeleteShader, 1);
1543
+ rb_define_module_function(module, "glDetachShader", gl_DetachShader, 2);
1544
+ rb_define_module_function(module, "glDisableVertexAttribArray", gl_DisableVertexAttribArray, 1);
1545
+ rb_define_module_function(module, "glEnableVertexAttribArray", gl_EnableVertexAttribArray, 1);
1546
+ rb_define_module_function(module, "glGetActiveAttrib", gl_GetActiveAttrib, 2);
1547
+ rb_define_module_function(module, "glGetActiveUniform", gl_GetActiveUniform, 2);
1548
+ rb_define_module_function(module, "glGetAttachedShaders", gl_GetAttachedShaders, 1);
1549
+ rb_define_module_function(module, "glGetAttribLocation", gl_GetAttribLocation, 2);
1550
+ rb_define_module_function(module, "glGetProgramiv", gl_GetProgramiv, 2);
1551
+ rb_define_module_function(module, "glGetProgramInfoLog", gl_GetProgramInfoLog, 1);
1552
+ rb_define_module_function(module, "glGetShaderiv", gl_GetShaderiv, 2);
1553
+ rb_define_module_function(module, "glGetShaderInfoLog", gl_GetShaderInfoLog, 1);
1554
+ rb_define_module_function(module, "glGetShaderSource", gl_GetShaderSource, 1);
1555
+ rb_define_module_function(module, "glGetUniformLocation", gl_GetUniformLocation, 2);
1556
+ rb_define_module_function(module, "glGetUniformfv", gl_GetUniformfv, 2);
1557
+ rb_define_module_function(module, "glGetUniformiv", gl_GetUniformiv, 2);
1558
+ rb_define_module_function(module, "glGetVertexAttribdv", gl_GetVertexAttribdv, 2);
1559
+ rb_define_module_function(module, "glGetVertexAttribfv", gl_GetVertexAttribfv, 2);
1560
+ rb_define_module_function(module, "glGetVertexAttribiv", gl_GetVertexAttribiv, 2);
1561
+ rb_define_module_function(module, "glGetVertexAttribPointerv", gl_GetVertexAttribPointerv, 1);
1562
+ rb_define_module_function(module, "glIsProgram", gl_IsProgram, 1);
1563
+ rb_define_module_function(module, "glIsShader", gl_IsShader, 1);
1564
+ rb_define_module_function(module, "glLinkProgram", gl_LinkProgram, 1);
1565
+ rb_define_module_function(module, "glShaderSource", gl_ShaderSource, 2);
1566
+ rb_define_module_function(module, "glUseProgram", gl_UseProgram, 1);
1567
+ rb_define_module_function(module, "glUniform1f", gl_Uniform1f, 2);
1568
+ rb_define_module_function(module, "glUniform2f", gl_Uniform2f, 3);
1569
+ rb_define_module_function(module, "glUniform3f", gl_Uniform3f, 4);
1570
+ rb_define_module_function(module, "glUniform4f", gl_Uniform4f, 5);
1571
+ rb_define_module_function(module, "glUniform1i", gl_Uniform1i, 2);
1572
+ rb_define_module_function(module, "glUniform2i", gl_Uniform2i, 3);
1573
+ rb_define_module_function(module, "glUniform3i", gl_Uniform3i, 4);
1574
+ rb_define_module_function(module, "glUniform4i", gl_Uniform4i, 5);
1575
+ rb_define_module_function(module, "glUniform1fv", gl_Uniform1fv, 3);
1576
+ rb_define_module_function(module, "glUniform2fv", gl_Uniform2fv, 3);
1577
+ rb_define_module_function(module, "glUniform3fv", gl_Uniform3fv, 3);
1578
+ rb_define_module_function(module, "glUniform4fv", gl_Uniform4fv, 3);
1579
+ rb_define_module_function(module, "glUniform1iv", gl_Uniform1iv, 3);
1580
+ rb_define_module_function(module, "glUniform2iv", gl_Uniform2iv, 3);
1581
+ rb_define_module_function(module, "glUniform3iv", gl_Uniform3iv, 3);
1582
+ rb_define_module_function(module, "glUniform4iv", gl_Uniform4iv, 3);
1583
+ rb_define_module_function(module, "glUniformMatrix2fv", gl_UniformMatrix2fv, 4);
1584
+ rb_define_module_function(module, "glUniformMatrix3fv", gl_UniformMatrix3fv, 4);
1585
+ rb_define_module_function(module, "glUniformMatrix4fv", gl_UniformMatrix4fv, 4);
1586
+ rb_define_module_function(module, "glValidateProgram", gl_ValidateProgram, 1);
1587
+ rb_define_module_function(module, "glVertexAttrib1d", gl_VertexAttrib1d, 2);
1588
+ rb_define_module_function(module, "glVertexAttrib1f", gl_VertexAttrib1f, 2);
1589
+ rb_define_module_function(module, "glVertexAttrib1s", gl_VertexAttrib1s, 2);
1590
+ rb_define_module_function(module, "glVertexAttrib2d", gl_VertexAttrib2d, 3);
1591
+ rb_define_module_function(module, "glVertexAttrib2f", gl_VertexAttrib2f, 3);
1592
+ rb_define_module_function(module, "glVertexAttrib2s", gl_VertexAttrib2s, 3);
1593
+ rb_define_module_function(module, "glVertexAttrib3d", gl_VertexAttrib3d, 4);
1594
+ rb_define_module_function(module, "glVertexAttrib3f", gl_VertexAttrib3f, 4);
1595
+ rb_define_module_function(module, "glVertexAttrib3s", gl_VertexAttrib3s, 4);
1596
+ rb_define_module_function(module, "glVertexAttrib4Nbv", gl_VertexAttrib4Nbv, 2);
1597
+ rb_define_module_function(module, "glVertexAttrib4Niv", gl_VertexAttrib4Niv, 2);
1598
+ rb_define_module_function(module, "glVertexAttrib4Nsv", gl_VertexAttrib4Nsv, 2);
1599
+ rb_define_module_function(module, "glVertexAttrib4Nub", gl_VertexAttrib4Nub, 5);
1600
+ rb_define_module_function(module, "glVertexAttrib4Nubv", gl_VertexAttrib4Nubv, 2);
1601
+ rb_define_module_function(module, "glVertexAttrib4Nuiv", gl_VertexAttrib4Nuiv, 2);
1602
+ rb_define_module_function(module, "glVertexAttrib4Nusv", gl_VertexAttrib4Nusv, 2);
1603
+ rb_define_module_function(module, "glVertexAttrib4bv", gl_VertexAttrib4bv, 2);
1604
+ rb_define_module_function(module, "glVertexAttrib4d", gl_VertexAttrib4d, 5);
1605
+ rb_define_module_function(module, "glVertexAttrib4f", gl_VertexAttrib4f, 5);
1606
+ rb_define_module_function(module, "glVertexAttrib4iv", gl_VertexAttrib4iv, 2);
1607
+ rb_define_module_function(module, "glVertexAttrib4s", gl_VertexAttrib4s, 5);
1608
+ rb_define_module_function(module, "glVertexAttrib4ubv", gl_VertexAttrib4ubv, 2);
1609
+ rb_define_module_function(module, "glVertexAttrib4uiv", gl_VertexAttrib4uiv, 2);
1610
+ rb_define_module_function(module, "glVertexAttrib4usv", gl_VertexAttrib4usv, 2);
1611
+ rb_define_module_function(module, "glVertexAttribPointer", gl_VertexAttribPointer, 6);
1612
+
1613
+ /* Additional functions */
1614
+ rb_define_module_function(module, "glVertexAttrib1dv", gl_VertexAttribdv, -1);
1615
+ rb_define_module_function(module, "glVertexAttrib1fv", gl_VertexAttribfv, -1);
1616
+ rb_define_module_function(module, "glVertexAttrib1sv", gl_VertexAttribsv, -1);
1617
+ rb_define_module_function(module, "glVertexAttrib2dv", gl_VertexAttribdv, -1);
1618
+ rb_define_module_function(module, "glVertexAttrib2fv", gl_VertexAttribfv, -1);
1619
+ rb_define_module_function(module, "glVertexAttrib2sv", gl_VertexAttribsv, -1);
1620
+ rb_define_module_function(module, "glVertexAttrib3dv", gl_VertexAttribdv, -1);
1621
+ rb_define_module_function(module, "glVertexAttrib3fv", gl_VertexAttribfv, -1);
1622
+ rb_define_module_function(module, "glVertexAttrib3sv", gl_VertexAttribsv, -1);
1623
+ rb_define_module_function(module, "glVertexAttrib4dv", gl_VertexAttribdv, -1);
1624
+ rb_define_module_function(module, "glVertexAttrib4fv", gl_VertexAttribfv, -1);
1625
+ rb_define_module_function(module, "glVertexAttrib4sv", gl_VertexAttribsv, -1);
1626
+
1627
+ {
1628
+ int i;
1629
+ for (i=0;i<_MAX_VERTEX_ATTRIBS;i++)
1630
+ rb_global_variable(&g_VertexAttrib_ptr[i]);
1631
+ }
1632
+ }