opengl 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +29 -0
  5. data/.gemtest +0 -0
  6. data/.gitignore +6 -0
  7. data/.travis.yml +19 -0
  8. data/History.rdoc +77 -0
  9. data/MIT-LICENSE +18 -0
  10. data/Manifest.txt +138 -0
  11. data/README.rdoc +102 -0
  12. data/Rakefile +60 -0
  13. data/examples/NeHe/NeHe.png +0 -0
  14. data/examples/NeHe/crate.png +0 -0
  15. data/examples/NeHe/glass.png +0 -0
  16. data/examples/NeHe/nehe_lesson02.rb +117 -0
  17. data/examples/NeHe/nehe_lesson03.rb +123 -0
  18. data/examples/NeHe/nehe_lesson04.rb +132 -0
  19. data/examples/NeHe/nehe_lesson05.rb +182 -0
  20. data/examples/NeHe/nehe_lesson06.rb +186 -0
  21. data/examples/NeHe/nehe_lesson07.rb +240 -0
  22. data/examples/NeHe/nehe_lesson08.rb +255 -0
  23. data/examples/NeHe/nehe_lesson09.rb +203 -0
  24. data/examples/NeHe/nehe_lesson11.rb +176 -0
  25. data/examples/NeHe/nehe_lesson12.rb +203 -0
  26. data/examples/NeHe/nehe_lesson16.rb +211 -0
  27. data/examples/NeHe/nehe_lesson19.rb +209 -0
  28. data/examples/NeHe/nehe_lesson36.rb +308 -0
  29. data/examples/NeHe/particle.png +0 -0
  30. data/examples/NeHe/star.png +0 -0
  31. data/examples/NeHe/tim.png +0 -0
  32. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  33. data/examples/OrangeBook/brick.frag +36 -0
  34. data/examples/OrangeBook/brick.rb +378 -0
  35. data/examples/OrangeBook/brick.vert +41 -0
  36. data/examples/OrangeBook/particle.frag +17 -0
  37. data/examples/OrangeBook/particle.rb +408 -0
  38. data/examples/OrangeBook/particle.vert +38 -0
  39. data/examples/README +16 -0
  40. data/examples/RedBook/aapoly.rb +143 -0
  41. data/examples/RedBook/aargb.rb +121 -0
  42. data/examples/RedBook/accanti.rb +164 -0
  43. data/examples/RedBook/accpersp.rb +217 -0
  44. data/examples/RedBook/alpha.rb +125 -0
  45. data/examples/RedBook/alpha3D.rb +160 -0
  46. data/examples/RedBook/bezcurve.rb +107 -0
  47. data/examples/RedBook/bezmesh.rb +139 -0
  48. data/examples/RedBook/checker.rb +126 -0
  49. data/examples/RedBook/clip.rb +97 -0
  50. data/examples/RedBook/colormat.rb +137 -0
  51. data/examples/RedBook/cube.rb +71 -0
  52. data/examples/RedBook/depthcue.rb +101 -0
  53. data/examples/RedBook/dof.rb +206 -0
  54. data/examples/RedBook/double.rb +107 -0
  55. data/examples/RedBook/drawf.rb +93 -0
  56. data/examples/RedBook/feedback.rb +147 -0
  57. data/examples/RedBook/fog.rb +168 -0
  58. data/examples/RedBook/font.rb +153 -0
  59. data/examples/RedBook/hello.rb +81 -0
  60. data/examples/RedBook/image.rb +139 -0
  61. data/examples/RedBook/jitter.rb +207 -0
  62. data/examples/RedBook/light.rb +155 -0
  63. data/examples/RedBook/lines.rb +130 -0
  64. data/examples/RedBook/list.rb +113 -0
  65. data/examples/RedBook/material.rb +276 -0
  66. data/examples/RedBook/mipmap.rb +158 -0
  67. data/examples/RedBook/model.rb +115 -0
  68. data/examples/RedBook/movelight.rb +134 -0
  69. data/examples/RedBook/pickdepth.rb +181 -0
  70. data/examples/RedBook/planet.rb +110 -0
  71. data/examples/RedBook/quadric.rb +160 -0
  72. data/examples/RedBook/robot.rb +117 -0
  73. data/examples/RedBook/select.rb +198 -0
  74. data/examples/RedBook/smooth.rb +97 -0
  75. data/examples/RedBook/stencil.rb +165 -0
  76. data/examples/RedBook/stroke.rb +169 -0
  77. data/examples/RedBook/surface.rb +168 -0
  78. data/examples/RedBook/teaambient.rb +134 -0
  79. data/examples/RedBook/teapots.rb +184 -0
  80. data/examples/RedBook/tess.rb +185 -0
  81. data/examples/RedBook/texbind.rb +149 -0
  82. data/examples/RedBook/texgen.rb +171 -0
  83. data/examples/RedBook/texturesurf.rb +130 -0
  84. data/examples/RedBook/varray.rb +161 -0
  85. data/examples/RedBook/wrap.rb +150 -0
  86. data/examples/misc/OGLBench.rb +338 -0
  87. data/examples/misc/anisotropic.rb +196 -0
  88. data/examples/misc/fbo_test.rb +357 -0
  89. data/examples/misc/font-glut.rb +47 -0
  90. data/examples/misc/glfwtest.rb +30 -0
  91. data/examples/misc/plane.rb +161 -0
  92. data/examples/misc/readpixel.rb +66 -0
  93. data/examples/misc/sdltest.rb +36 -0
  94. data/examples/misc/trislam.rb +829 -0
  95. data/ext/opengl/common.h +428 -0
  96. data/ext/opengl/conv.h +244 -0
  97. data/ext/opengl/extconf.rb +47 -0
  98. data/ext/opengl/funcdef.h +313 -0
  99. data/ext/opengl/gl-1.0-1.1.c +3075 -0
  100. data/ext/opengl/gl-1.2.c +155 -0
  101. data/ext/opengl/gl-1.3.c +443 -0
  102. data/ext/opengl/gl-1.4.c +348 -0
  103. data/ext/opengl/gl-1.5.c +224 -0
  104. data/ext/opengl/gl-2.0.c +667 -0
  105. data/ext/opengl/gl-2.1.c +57 -0
  106. data/ext/opengl/gl-3.0.c +493 -0
  107. data/ext/opengl/gl-enums.c +4873 -0
  108. data/ext/opengl/gl-enums.h +14588 -0
  109. data/ext/opengl/gl-error.c +112 -0
  110. data/ext/opengl/gl-error.h +28 -0
  111. data/ext/opengl/gl-ext-3dfx.c +27 -0
  112. data/ext/opengl/gl-ext-arb.c +875 -0
  113. data/ext/opengl/gl-ext-ati.c +41 -0
  114. data/ext/opengl/gl-ext-ext.c +889 -0
  115. data/ext/opengl/gl-ext-gremedy.c +41 -0
  116. data/ext/opengl/gl-ext-nv.c +680 -0
  117. data/ext/opengl/gl-types.h +67 -0
  118. data/ext/opengl/gl.c +220 -0
  119. data/ext/opengl/gl_buffer.c +177 -0
  120. data/ext/opengl/opengl.c +7 -0
  121. data/lib/gl.rb +1 -0
  122. data/lib/opengl.rb +53 -0
  123. data/lib/opengl/2.0/opengl.so +0 -0
  124. data/lib/opengl/2.1/opengl.so +0 -0
  125. data/lib/opengl/test_case.rb +86 -0
  126. data/test/dummy.xorg.conf +140 -0
  127. data/test/test_gl.rb +38 -0
  128. data/test/test_gl_10_11.rb +1363 -0
  129. data/test/test_gl_12.rb +71 -0
  130. data/test/test_gl_13.rb +221 -0
  131. data/test/test_gl_14.rb +218 -0
  132. data/test/test_gl_15.rb +258 -0
  133. data/test/test_gl_20.rb +417 -0
  134. data/test/test_gl_21.rb +436 -0
  135. data/test/test_gl_ext_arb.rb +508 -0
  136. data/test/test_gl_ext_ati.rb +28 -0
  137. data/test/test_gl_ext_ext.rb +608 -0
  138. data/test/test_gl_ext_gremedy.rb +29 -0
  139. data/test/test_gl_ext_nv.rb +349 -0
  140. data/test/test_opengl_buffer.rb +120 -0
  141. data/utils/README +6 -0
  142. data/utils/enumgen.rb +108 -0
  143. data/utils/extlistgen.rb +90 -0
  144. metadata +319 -0
  145. metadata.gz.sig +1 -0
@@ -0,0 +1,348 @@
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
+ #include "common.h"
17
+
18
+ /* OpenGL 1.4 functions */
19
+
20
+ GL_FUNC_LOAD_4(BlendFuncSeparate,GLvoid, GLenum,GLenum,GLenum,GLenum, "1.4")
21
+ GL_FUNC_LOAD_1(FogCoordf,GLvoid, GLfloat, "1.4")
22
+ GL_FUNC_LOAD_1(FogCoordd,GLvoid, GLdouble, "1.4")
23
+ GL_FUNC_LOAD_2(PointParameteri,GLvoid, GLenum,GLint, "1.4")
24
+ GL_FUNC_LOAD_2(PointParameterf,GLvoid, GLenum,GLfloat, "1.4")
25
+ GL_FUNC_LOAD_3(SecondaryColor3b,GLvoid, GLbyte,GLbyte,GLbyte, "1.4")
26
+ GL_FUNC_LOAD_3(SecondaryColor3d,GLvoid, GLdouble,GLdouble,GLdouble, "1.4")
27
+ GL_FUNC_LOAD_3(SecondaryColor3f,GLvoid, GLfloat,GLfloat,GLfloat, "1.4")
28
+ GL_FUNC_LOAD_3(SecondaryColor3i,GLvoid, GLint,GLint,GLint, "1.4")
29
+ GL_FUNC_LOAD_3(SecondaryColor3s,GLvoid, GLshort,GLshort,GLshort, "1.4")
30
+ GL_FUNC_LOAD_3(SecondaryColor3ub,GLvoid, GLubyte,GLubyte,GLubyte, "1.4")
31
+ GL_FUNC_LOAD_3(SecondaryColor3ui,GLvoid, GLuint,GLuint,GLuint, "1.4")
32
+ GL_FUNC_LOAD_3(SecondaryColor3us,GLvoid, GLushort,GLushort,GLushort, "1.4")
33
+ GL_FUNC_LOAD_2(WindowPos2d,GLvoid, GLdouble,GLdouble, "1.4")
34
+ GL_FUNC_LOAD_2(WindowPos2f,GLvoid, GLfloat,GLfloat, "1.4")
35
+ GL_FUNC_LOAD_2(WindowPos2i,GLvoid, GLint,GLint, "1.4")
36
+ GL_FUNC_LOAD_2(WindowPos2s,GLvoid, GLshort,GLshort, "1.4")
37
+ GL_FUNC_LOAD_3(WindowPos3d,GLvoid, GLdouble,GLdouble,GLdouble, "1.4")
38
+ GL_FUNC_LOAD_3(WindowPos3f,GLvoid, GLfloat,GLfloat,GLfloat, "1.4")
39
+ GL_FUNC_LOAD_3(WindowPos3i,GLvoid, GLint,GLint,GLint, "1.4")
40
+ GL_FUNC_LOAD_3(WindowPos3s,GLvoid, GLshort,GLshort,GLshort, "1.4")
41
+
42
+ static void (APIENTRY * fptr_glFogCoordfv)(GLfloat *);
43
+ static VALUE
44
+ gl_FogCoordfv(obj,arg1)
45
+ VALUE obj,arg1;
46
+ {
47
+ GLfloat coord;
48
+ LOAD_GL_FUNC(glFogCoordfv, "1.4");
49
+ Check_Type(arg1,T_ARRAY);
50
+ ary2cflt(arg1,&coord,1);
51
+ fptr_glFogCoordfv(&coord);
52
+ CHECK_GLERROR_FROM("glFogCoordfv");
53
+ return Qnil;
54
+ }
55
+
56
+ static void (APIENTRY * fptr_glFogCoorddv)(GLdouble *);
57
+ static VALUE
58
+ gl_FogCoorddv(obj,arg1)
59
+ VALUE obj,arg1;
60
+ {
61
+ GLdouble coord;
62
+ LOAD_GL_FUNC(glFogCoorddv, "1.4");
63
+ Check_Type(arg1,T_ARRAY);
64
+ ary2cdbl(arg1,&coord,1);
65
+ fptr_glFogCoorddv(&coord);
66
+ CHECK_GLERROR_FROM("glFogCoorddv");
67
+ return Qnil;
68
+ }
69
+
70
+ extern VALUE g_FogCoord_ptr;
71
+ static void (APIENTRY * fptr_glFogCoordPointer)(GLenum,GLsizei,const GLvoid *);
72
+ static VALUE
73
+ gl_FogCoordPointer(obj,arg1,arg2,arg3)
74
+ VALUE obj,arg1,arg2,arg3;
75
+ {
76
+ GLenum type;
77
+ GLsizei stride;
78
+ LOAD_GL_FUNC(glFogCoordPointer, "1.4");
79
+ type = (GLenum)NUM2INT(arg1);
80
+ stride = (GLsizei)NUM2UINT(arg2);
81
+ if (CheckBufferBinding(GL_ARRAY_BUFFER_BINDING)) {
82
+ g_FogCoord_ptr = arg3;
83
+ fptr_glFogCoordPointer(type, stride, (const GLvoid*)NUM2SIZET(arg3));
84
+ } else {
85
+ VALUE data;
86
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg3);
87
+ rb_str_freeze(data);
88
+ g_FogCoord_ptr = data;
89
+ fptr_glFogCoordPointer(type, stride, (const GLvoid*)RSTRING_PTR(data));
90
+ }
91
+ CHECK_GLERROR_FROM("glFogCoordPointer");
92
+ return Qnil;
93
+ }
94
+
95
+ static void (APIENTRY * fptr_glMultiDrawArrays)(GLenum,GLint*,GLsizei*,GLsizei);
96
+ static VALUE
97
+ gl_MultiDrawArrays(obj,arg1,arg2,arg3)
98
+ VALUE obj,arg1,arg2,arg3;
99
+ {
100
+ GLenum mode;
101
+ GLint *ary1;
102
+ GLsizei *ary2;
103
+ int len1,len2;
104
+ LOAD_GL_FUNC(glMultiDrawArrays, "1.4");
105
+ len1 = (int)RARRAY_LENINT(arg2);
106
+ len2 = (int)RARRAY_LENINT(arg3);
107
+ if (len1!=len2)
108
+ rb_raise(rb_eArgError, "Passed arrays must have same length");
109
+ mode = (GLenum)NUM2INT(arg1);
110
+ ary1 = ALLOC_N(GLint,len1);
111
+ ary2 = ALLOC_N(GLsizei,len2);
112
+ ary2cint(arg2,ary1,len1);
113
+ ary2cint(arg3,ary2,len2);
114
+ fptr_glMultiDrawArrays(mode,ary1,ary2,len1);
115
+ xfree(ary1);
116
+ xfree(ary2);
117
+ CHECK_GLERROR_FROM("glMultiDrawArrays");
118
+ return Qnil;
119
+ }
120
+
121
+ static void (APIENTRY * fptr_glMultiDrawElements)(GLenum,const GLsizei *,GLenum,GLvoid **,GLsizei);
122
+ static VALUE
123
+ gl_MultiDrawElements(argc,argv,obj)
124
+ int argc;
125
+ VALUE *argv;
126
+ VALUE obj;
127
+ {
128
+ GLenum mode;
129
+ GLenum type;
130
+ GLsizei *counts;
131
+ GLvoid **indices;
132
+ GLint size;
133
+ int i;
134
+ VALUE ary, args[4];
135
+ LOAD_GL_FUNC(glMultiDrawElements, "1.4");
136
+ switch (rb_scan_args(argc, argv, "31", &args[0], &args[1], &args[2],&args[3])) {
137
+ default:
138
+ case 3:
139
+ if (CheckBufferBinding(GL_ELEMENT_ARRAY_BUFFER_BINDING))
140
+ rb_raise(rb_eArgError, "Element array buffer bound, but offsets array missing");
141
+ mode = (GLenum)NUM2INT(args[0]);
142
+ type = (GLenum)NUM2INT(args[1]);
143
+ Check_Type(args[2],T_ARRAY);
144
+ ary = args[2];
145
+ size = (GLint)RARRAY_LENINT(ary);
146
+ counts = ALLOC_N(GLsizei,size);
147
+ indices = ALLOC_N(GLvoid*,size);
148
+ for (i=0;i<size;i++) {
149
+ VALUE data;
150
+ data = pack_array_or_pass_string(type,RARRAY_PTR(ary)[i]);
151
+ indices[i] = RSTRING_PTR(data);
152
+ counts[i] = (GLsizei)RSTRING_LENINT(data);
153
+ }
154
+ fptr_glMultiDrawElements(mode,counts,type,indices,size);
155
+ xfree(counts);
156
+ xfree(indices);
157
+ break;
158
+ case 4:
159
+ if (!CheckBufferBinding(GL_ELEMENT_ARRAY_BUFFER_BINDING))
160
+ rb_raise(rb_eArgError, "Element array buffer not bound");
161
+ mode = (GLenum)NUM2INT(args[0]);
162
+ type = (GLenum)NUM2INT(args[1]);
163
+ Check_Type(args[2],T_ARRAY);
164
+ Check_Type(args[3],T_ARRAY);
165
+ if (RARRAY_LEN(args[2]) != RARRAY_LEN(args[3]))
166
+ rb_raise(rb_eArgError, "Count and indices offset array must have same length");
167
+
168
+ size = (GLint)RARRAY_LENINT(args[2]);
169
+
170
+ counts = ALLOC_N(GLsizei,size);
171
+ indices = ALLOC_N(GLvoid*,size);
172
+ for (i=0;i<size;i++) {
173
+ counts[i] = (GLsizei)NUM2INT(rb_ary_entry(args[2],i));
174
+ indices[i] = (GLvoid *)NUM2SIZET(rb_ary_entry(args[3],i));
175
+ }
176
+ fptr_glMultiDrawElements(mode,counts,type,indices,size);
177
+ xfree(counts);
178
+ xfree(indices);
179
+ break;
180
+ }
181
+ CHECK_GLERROR_FROM("glMultiDrawElements");
182
+ return Qnil;
183
+ }
184
+
185
+ static void (APIENTRY * fptr_glPointParameterfv)(GLenum,GLfloat *);
186
+ static VALUE
187
+ gl_PointParameterfv(obj,arg1,arg2)
188
+ VALUE obj,arg1,arg2;
189
+ {
190
+ GLenum pname;
191
+ GLfloat params[3] = {(GLfloat)0.0,(GLfloat)0.0,(GLfloat)0.0};
192
+ GLint size;
193
+ LOAD_GL_FUNC(glPointParameterfv, "1.4");
194
+ pname = (GLenum)NUM2INT(arg1);
195
+ Check_Type(arg2,T_ARRAY);
196
+ if (pname==GL_POINT_DISTANCE_ATTENUATION)
197
+ size = 3;
198
+ else
199
+ size = 1;
200
+ ary2cflt(arg2,params,size);
201
+ fptr_glPointParameterfv(pname,params);
202
+ CHECK_GLERROR_FROM("glPointParameterfv");
203
+ return Qnil;
204
+ }
205
+
206
+ static void (APIENTRY * fptr_glPointParameteriv)(GLenum,GLint *);
207
+ static VALUE
208
+ gl_PointParameteriv(obj,arg1,arg2)
209
+ VALUE obj,arg1,arg2;
210
+ {
211
+ GLenum pname;
212
+ GLint params[3] = {0,0,0};
213
+ GLint size;
214
+ LOAD_GL_FUNC(glPointParameteriv, "1.4");
215
+ pname = (GLenum)NUM2INT(arg1);
216
+ Check_Type(arg2,T_ARRAY);
217
+ if (pname==GL_POINT_DISTANCE_ATTENUATION)
218
+ size = 3;
219
+ else
220
+ size = 1;
221
+ ary2cint(arg2,params,size);
222
+ fptr_glPointParameteriv(pname,params);
223
+ CHECK_GLERROR_FROM("glPointParameteriv");
224
+ return Qnil;
225
+ }
226
+
227
+ #define GLSECONDARYCOLOR_VFUNC(_name_,_type_,_conv_) \
228
+ static void (APIENTRY * fptr_gl##_name_)(_type_ *); \
229
+ VALUE gl_##_name_(VALUE obj,VALUE arg1) \
230
+ { \
231
+ _type_ cary[3] = {0,0,0}; \
232
+ LOAD_GL_FUNC(gl##_name_, "1.4"); \
233
+ Check_Type(arg1,T_ARRAY); \
234
+ _conv_(arg1,cary,3); \
235
+ fptr_gl##_name_(cary); \
236
+ CHECK_GLERROR_FROM("gl" #_name_); \
237
+ return Qnil; \
238
+ }
239
+
240
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3bv,GLbyte,ary2cbyte)
241
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3dv,GLdouble,ary2cdbl)
242
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3fv,GLfloat,ary2cflt)
243
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3iv,GLint,ary2cint)
244
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3sv,GLshort,ary2cshort)
245
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3uiv,GLuint,ary2cuint)
246
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3ubv,GLubyte,ary2cubyte)
247
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3usv,GLushort,ary2cushort)
248
+ #undef GLSECONDARYCOLOR_VFUNC
249
+
250
+ extern VALUE g_SecondaryColor_ptr;
251
+ static void (APIENTRY * fptr_glSecondaryColorPointer)(GLint,GLenum,GLsizei,const GLvoid *);
252
+ static VALUE
253
+ gl_SecondaryColorPointer(obj,arg1,arg2,arg3,arg4)
254
+ VALUE obj,arg1,arg2,arg3,arg4;
255
+ {
256
+ GLint size;
257
+ GLenum type;
258
+ GLsizei stride;
259
+ LOAD_GL_FUNC(glSecondaryColorPointer, "1.4");
260
+ size = (GLint)NUM2INT(arg1);
261
+ type = (GLenum)NUM2INT(arg2);
262
+ stride = (GLsizei)NUM2UINT(arg3);
263
+ if (CheckBufferBinding(GL_ARRAY_BUFFER_BINDING)) {
264
+ g_SecondaryColor_ptr = arg4;
265
+ fptr_glSecondaryColorPointer(size,type, stride, (const GLvoid*)NUM2SIZET(arg4));
266
+ } else {
267
+ VALUE data;
268
+ data = pack_array_or_pass_string(type,arg4);
269
+ rb_str_freeze(data);
270
+ g_SecondaryColor_ptr = data;
271
+ fptr_glSecondaryColorPointer(size,type, stride, (const GLvoid*)RSTRING_PTR(data));
272
+ }
273
+ CHECK_GLERROR_FROM("glSecondaryColorPointer");
274
+ return Qnil;
275
+ }
276
+
277
+ #define GLWINDOWPOS_VFUNC(_name_,_type_,_size_,_conv_) \
278
+ static void (APIENTRY * fptr_gl##_name_)(_type_ *); \
279
+ VALUE gl_##_name_(VALUE obj,VALUE arg1) \
280
+ { \
281
+ _type_ cary[3] = {0,0,0}; \
282
+ LOAD_GL_FUNC(gl##_name_, "1.4"); \
283
+ Check_Type(arg1,T_ARRAY); \
284
+ _conv_(arg1,cary,_size_); \
285
+ fptr_gl##_name_(cary); \
286
+ CHECK_GLERROR_FROM("gl" #_name_); \
287
+ return Qnil; \
288
+ }
289
+
290
+ GLWINDOWPOS_VFUNC(WindowPos2dv,GLdouble,2,ary2cdbl)
291
+ GLWINDOWPOS_VFUNC(WindowPos2fv,GLfloat,2,ary2cflt)
292
+ GLWINDOWPOS_VFUNC(WindowPos2iv,GLint,2,ary2cint)
293
+ GLWINDOWPOS_VFUNC(WindowPos2sv,GLshort,2,ary2cshort)
294
+ GLWINDOWPOS_VFUNC(WindowPos3dv,GLdouble,3,ary2cdbl)
295
+ GLWINDOWPOS_VFUNC(WindowPos3fv,GLfloat,3,ary2cflt)
296
+ GLWINDOWPOS_VFUNC(WindowPos3iv,GLint,3,ary2cint)
297
+ GLWINDOWPOS_VFUNC(WindowPos3sv,GLshort,3,ary2cshort)
298
+ #undef GLWINDOWPOS_VFUNC
299
+
300
+
301
+ void gl_init_functions_1_4(VALUE module)
302
+ {
303
+ rb_define_module_function(module, "glBlendFuncSeparate", gl_BlendFuncSeparate, 4);
304
+ rb_define_module_function(module, "glFogCoordf", gl_FogCoordf, 1);
305
+ rb_define_module_function(module, "glFogCoordfv", gl_FogCoordfv, 1);
306
+ rb_define_module_function(module, "glFogCoordd", gl_FogCoordd, 1);
307
+ rb_define_module_function(module, "glFogCoorddv", gl_FogCoorddv, 1);
308
+ rb_define_module_function(module, "glFogCoordPointer", gl_FogCoordPointer, 3);
309
+ rb_define_module_function(module, "glMultiDrawArrays", gl_MultiDrawArrays, 3);
310
+ rb_define_module_function(module, "glMultiDrawElements", gl_MultiDrawElements, -1);
311
+ rb_define_module_function(module, "glPointParameterf", gl_PointParameterf, 2);
312
+ rb_define_module_function(module, "glPointParameterfv", gl_PointParameterfv, 2);
313
+ rb_define_module_function(module, "glPointParameteri", gl_PointParameteri, 2);
314
+ rb_define_module_function(module, "glPointParameteriv", gl_PointParameteriv, 2);
315
+ rb_define_module_function(module, "glSecondaryColor3b", gl_SecondaryColor3b, 3);
316
+ rb_define_module_function(module, "glSecondaryColor3d", gl_SecondaryColor3d, 3);
317
+ rb_define_module_function(module, "glSecondaryColor3f", gl_SecondaryColor3f, 3);
318
+ rb_define_module_function(module, "glSecondaryColor3i", gl_SecondaryColor3i, 3);
319
+ rb_define_module_function(module, "glSecondaryColor3s", gl_SecondaryColor3s, 3);
320
+ rb_define_module_function(module, "glSecondaryColor3ub", gl_SecondaryColor3ub, 3);
321
+ rb_define_module_function(module, "glSecondaryColor3ui", gl_SecondaryColor3ui, 3);
322
+ rb_define_module_function(module, "glSecondaryColor3us", gl_SecondaryColor3us, 3);
323
+ rb_define_module_function(module, "glSecondaryColor3bv", gl_SecondaryColor3bv, 1);
324
+ rb_define_module_function(module, "glSecondaryColor3dv", gl_SecondaryColor3dv, 1);
325
+ rb_define_module_function(module, "glSecondaryColor3fv", gl_SecondaryColor3fv, 1);
326
+ rb_define_module_function(module, "glSecondaryColor3iv", gl_SecondaryColor3iv, 1);
327
+ rb_define_module_function(module, "glSecondaryColor3sv", gl_SecondaryColor3sv, 1);
328
+ rb_define_module_function(module, "glSecondaryColor3ubv", gl_SecondaryColor3ubv, 1);
329
+ rb_define_module_function(module, "glSecondaryColor3uiv", gl_SecondaryColor3uiv, 1);
330
+ rb_define_module_function(module, "glSecondaryColor3usv", gl_SecondaryColor3usv, 1);
331
+ rb_define_module_function(module, "glSecondaryColorPointer", gl_SecondaryColorPointer, 4);
332
+ rb_define_module_function(module, "glWindowPos2d", gl_WindowPos2d, 2);
333
+ rb_define_module_function(module, "glWindowPos2f", gl_WindowPos2f, 2);
334
+ rb_define_module_function(module, "glWindowPos2i", gl_WindowPos2i, 2);
335
+ rb_define_module_function(module, "glWindowPos2s", gl_WindowPos2s, 2);
336
+ rb_define_module_function(module, "glWindowPos3d", gl_WindowPos3d, 3);
337
+ rb_define_module_function(module, "glWindowPos3f", gl_WindowPos3f, 3);
338
+ rb_define_module_function(module, "glWindowPos3i", gl_WindowPos3i, 3);
339
+ rb_define_module_function(module, "glWindowPos3s", gl_WindowPos3s, 3);
340
+ rb_define_module_function(module, "glWindowPos2dv", gl_WindowPos2dv, 1);
341
+ rb_define_module_function(module, "glWindowPos2fv", gl_WindowPos2fv, 1);
342
+ rb_define_module_function(module, "glWindowPos2iv", gl_WindowPos2iv, 1);
343
+ rb_define_module_function(module, "glWindowPos2sv", gl_WindowPos2sv, 1);
344
+ rb_define_module_function(module, "glWindowPos3dv", gl_WindowPos3dv, 1);
345
+ rb_define_module_function(module, "glWindowPos3fv", gl_WindowPos3fv, 1);
346
+ rb_define_module_function(module, "glWindowPos3iv", gl_WindowPos3iv, 1);
347
+ rb_define_module_function(module, "glWindowPos3sv", gl_WindowPos3sv, 1);
348
+ }
@@ -0,0 +1,224 @@
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
+ #include "common.h"
17
+
18
+ /* OpenGL 1.5 functions */
19
+
20
+ GL_FUNC_LOAD_1(EndQuery,GLvoid, GLenum, "1.5");
21
+ GL_FUNC_LOAD_1(IsQuery,GLboolean, GLuint, "1.5");
22
+ GL_FUNC_LOAD_2(BeginQuery,GLvoid, GLenum,GLuint, "1.5");
23
+ GL_FUNC_LOAD_2(BindBuffer,GLvoid, GLenum,GLuint, "1.5");
24
+ GL_FUNC_LOAD_1(IsBuffer,GLboolean, GLuint, "1.5");
25
+ GL_FUNC_GENOBJECTS_LOAD(GenQueries, "1.5");
26
+ GL_FUNC_DELETEOBJECTS_LOAD(DeleteQueries, "1.5");
27
+ GL_FUNC_GENOBJECTS_LOAD(GenBuffers, "1.5");
28
+ GL_FUNC_DELETEOBJECTS_LOAD(DeleteBuffers, "1.5");
29
+
30
+ static void (APIENTRY * fptr_glGetQueryiv)(GLenum,GLenum,GLint *);
31
+ static VALUE
32
+ gl_GetQueryiv(obj,arg1,arg2)
33
+ VALUE obj,arg1,arg2;
34
+ {
35
+ GLenum target;
36
+ GLenum pname;
37
+ GLint params = 0;
38
+ LOAD_GL_FUNC(glGetQueryiv, "1.5");
39
+ target = (GLenum)NUM2INT(arg1);
40
+ pname = (GLenum)NUM2INT(arg2);
41
+ fptr_glGetQueryiv(target,pname,&params);
42
+ CHECK_GLERROR_FROM("glGetQueryiv");
43
+ return RETCONV_GLint(params);
44
+ }
45
+
46
+ static void (APIENTRY * fptr_glGetQueryObjectiv)(GLuint,GLenum,GLint *);
47
+ static VALUE
48
+ gl_GetQueryObjectiv(obj,arg1,arg2)
49
+ VALUE obj,arg1,arg2;
50
+ {
51
+ GLuint id;
52
+ GLenum pname;
53
+ GLint params = 0;
54
+ LOAD_GL_FUNC(glGetQueryObjectiv, "1.5");
55
+ id = (GLuint)NUM2UINT(arg1);
56
+ pname = (GLenum)NUM2INT(arg2);
57
+ fptr_glGetQueryObjectiv(id,pname,&params);
58
+ CHECK_GLERROR_FROM("glGetQueryObjectiv");
59
+ return cond_GLBOOL2RUBY(pname,params);
60
+ }
61
+
62
+ static void (APIENTRY * fptr_glGetQueryObjectuiv)(GLuint,GLenum,GLuint *);
63
+ static VALUE
64
+ gl_GetQueryObjectuiv(obj,arg1,arg2)
65
+ VALUE obj,arg1,arg2;
66
+ {
67
+ GLuint id;
68
+ GLenum pname;
69
+ GLuint params = 0;
70
+ LOAD_GL_FUNC(glGetQueryObjectuiv, "1.5");
71
+ id = (GLuint)NUM2UINT(arg1);
72
+ pname = (GLenum)NUM2INT(arg2);
73
+ fptr_glGetQueryObjectuiv(id,pname,&params);
74
+ CHECK_GLERROR_FROM("glGetQueryObjectuiv");
75
+ return cond_GLBOOL2RUBY_U(pname,params);
76
+ }
77
+
78
+ static void (APIENTRY * fptr_glBufferData)(GLenum,GLsizeiptr,GLvoid *,GLenum);
79
+ static VALUE
80
+ gl_BufferData(obj,arg1,arg2,arg3,arg4)
81
+ VALUE obj,arg1,arg2,arg3,arg4;
82
+ {
83
+ GLenum target;
84
+ GLsizeiptr size;
85
+ GLenum usage;
86
+ LOAD_GL_FUNC(glBufferData, "1.5");
87
+ target = (GLenum)NUM2INT(arg1);
88
+ size = (GLsizeiptr)NUM2INT(arg2);
89
+ usage = (GLenum)NUM2INT(arg4);
90
+ if (TYPE(arg3) == T_STRING) {
91
+ fptr_glBufferData(target,size,(GLvoid *)RSTRING_PTR(arg3),usage);
92
+ } else if (NIL_P(arg3)) {
93
+ fptr_glBufferData(target,size,NULL,usage);
94
+ } else {
95
+ Check_Type(arg3,T_STRING); /* force exception - HACK do it right */
96
+ }
97
+ CHECK_GLERROR_FROM("glBufferData");
98
+ return Qnil;
99
+ }
100
+
101
+ static void (APIENTRY * fptr_glBufferSubData)(GLenum,GLintptr,GLsizeiptr,GLvoid *);
102
+ static VALUE
103
+ gl_BufferSubData(obj,arg1,arg2,arg3,arg4)
104
+ VALUE obj,arg1,arg2,arg3,arg4;
105
+ {
106
+ GLenum target;
107
+ GLintptr offset;
108
+ GLsizeiptr size;
109
+ LOAD_GL_FUNC(glBufferSubData, "1.5");
110
+ target = (GLenum)NUM2INT(arg1);
111
+ offset = (GLintptr)NUM2INT(arg2);
112
+ size = (GLsizeiptr)NUM2INT(arg3);
113
+ Check_Type(arg4,T_STRING);
114
+ fptr_glBufferSubData(target,offset,size,(GLvoid *)RSTRING_PTR(arg4));
115
+ CHECK_GLERROR_FROM("glBufferSubData");
116
+ return Qnil;
117
+ }
118
+
119
+ static void (APIENTRY * fptr_glGetBufferSubData)(GLenum,GLintptr,GLsizeiptr,GLvoid *);
120
+ static VALUE
121
+ gl_GetBufferSubData(obj,arg1,arg2,arg3)
122
+ VALUE obj,arg1,arg2,arg3;
123
+ {
124
+ GLenum target;
125
+ GLintptr offset;
126
+ GLsizeiptr size;
127
+ VALUE data;
128
+ LOAD_GL_FUNC(glGetBufferSubData, "1.5");
129
+ target = (GLenum)NUM2INT(arg1);
130
+ offset = (GLintptr)NUM2INT(arg2);
131
+ size = (GLsizeiptr)NUM2INT(arg3);
132
+ data = allocate_buffer_with_string((long)size);
133
+ fptr_glGetBufferSubData(target,offset,size,(GLvoid *)RSTRING_PTR(data));
134
+ CHECK_GLERROR_FROM("glGetBufferSubData");
135
+ return data;
136
+ }
137
+
138
+ static void (APIENTRY * fptr_glGetBufferParameteriv)(GLenum,GLenum,GLint *);
139
+ static VALUE
140
+ gl_GetBufferParameteriv(obj,arg1,arg2)
141
+ VALUE obj,arg1,arg2;
142
+ {
143
+ GLenum target;
144
+ GLenum value;
145
+ GLint data = 0;
146
+ LOAD_GL_FUNC(glGetBufferParameteriv, "1.5");
147
+ target = (GLenum)NUM2INT(arg1);
148
+ value = (GLenum)NUM2INT(arg2);
149
+ fptr_glGetBufferParameteriv(target,value,&data);
150
+ CHECK_GLERROR_FROM("glGetBufferParameteriv");
151
+ return cond_GLBOOL2RUBY(value,data);
152
+ }
153
+
154
+ static GLvoid * (APIENTRY * fptr_glMapBuffer)(GLenum,GLenum);
155
+ static VALUE
156
+ gl_MapBuffer(VALUE self, VALUE _target, VALUE _access) {
157
+ GLenum target = CONV_GLenum(_target);
158
+ GLenum access = CONV_GLenum(_access);
159
+ GLint size = 0;
160
+ GLvoid *buffer_ptr = NULL;
161
+
162
+ LOAD_GL_FUNC(glMapBuffer, "1.5");
163
+ LOAD_GL_FUNC(glGetBufferParameteriv, "1.5");
164
+
165
+ fptr_glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size);
166
+ CHECK_GLERROR_FROM("glGetBufferParameteriv");
167
+
168
+ buffer_ptr = fptr_glMapBuffer(target, access);
169
+ CHECK_GLERROR_FROM("glMapBuffer");
170
+
171
+ /* fail late to avoid GL_INVALID_OPERATION from glUnampBuffer */
172
+ if (buffer_ptr == NULL || size <= 0)
173
+ return Qnil;
174
+
175
+ return rb_str_new(buffer_ptr, size);
176
+ }
177
+
178
+ static GLboolean (APIENTRY * fptr_glUnmapBuffer)(GLenum);
179
+ static VALUE
180
+ gl_UnmapBuffer(obj,arg1)
181
+ VALUE obj,arg1;
182
+ {
183
+ GLenum target;
184
+ GLboolean ret;
185
+ LOAD_GL_FUNC(glUnmapBuffer, "1.5");
186
+ target = (GLenum)NUM2INT(arg1);
187
+ ret = fptr_glUnmapBuffer(target);
188
+ CHECK_GLERROR_FROM("glUnmapBuffer");
189
+ return GLBOOL2RUBY(ret);
190
+ }
191
+
192
+ static void (APIENTRY * fptr_glGetBufferPointerv)(GLenum,GLenum,GLvoid **);
193
+ static VALUE
194
+ gl_GetBufferPointerv(obj,arg1,arg2,arg3)
195
+ VALUE obj,arg1,arg2,arg3;
196
+ {
197
+ LOAD_GL_FUNC(glGetBufferPointerv, "1.5");
198
+ rb_raise(rb_eArgError, "glGetBufferPointerv not implemented");
199
+ CHECK_GLERROR_FROM("glGetBufferPointerv");
200
+ return Qnil;
201
+ }
202
+
203
+ void gl_init_functions_1_5(VALUE module)
204
+ {
205
+ rb_define_module_function(module, "glGenQueries", gl_GenQueries, 1);
206
+ rb_define_module_function(module, "glDeleteQueries", gl_DeleteQueries, 1);
207
+ rb_define_module_function(module, "glIsQuery", gl_IsQuery, 1);
208
+ rb_define_module_function(module, "glBeginQuery", gl_BeginQuery, 2);
209
+ rb_define_module_function(module, "glEndQuery", gl_EndQuery, 1);
210
+ rb_define_module_function(module, "glGetQueryiv", gl_GetQueryiv, 2);
211
+ rb_define_module_function(module, "glGetQueryObjectiv", gl_GetQueryObjectiv, 2);
212
+ rb_define_module_function(module, "glGetQueryObjectuiv", gl_GetQueryObjectuiv, 2);
213
+ rb_define_module_function(module, "glBindBuffer", gl_BindBuffer, 2);
214
+ rb_define_module_function(module, "glDeleteBuffers", gl_DeleteBuffers, 1);
215
+ rb_define_module_function(module, "glGenBuffers", gl_GenBuffers, 1);
216
+ rb_define_module_function(module, "glIsBuffer", gl_IsBuffer, 1);
217
+ rb_define_module_function(module, "glBufferData", gl_BufferData, 4);
218
+ rb_define_module_function(module, "glBufferSubData", gl_BufferSubData, 4);
219
+ rb_define_module_function(module, "glGetBufferSubData", gl_GetBufferSubData, 3);
220
+ rb_define_module_function(module, "glMapBuffer", gl_MapBuffer, 2);
221
+ rb_define_module_function(module, "glUnmapBuffer", gl_UnmapBuffer, 1);
222
+ rb_define_module_function(module, "glGetBufferParameteriv", gl_GetBufferParameteriv, 2);
223
+ rb_define_module_function(module, "glGetBufferPointerv", gl_GetBufferPointerv, 3);
224
+ }