danabr75-opengl 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +29 -0
  3. data/.gemtest +0 -0
  4. data/.gitignore +6 -0
  5. data/.travis.yml +19 -0
  6. data/Gemfile +8 -0
  7. data/History.md +101 -0
  8. data/MIT-LICENSE +18 -0
  9. data/Manifest.txt +142 -0
  10. data/README.rdoc +105 -0
  11. data/Rakefile +170 -0
  12. data/danabr75-opengl.gemspec +32 -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 +157 -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/GL/gl.h +2115 -0
  96. data/ext/opengl/GL/glext.h +11770 -0
  97. data/ext/opengl/common.h +372 -0
  98. data/ext/opengl/conv.h +247 -0
  99. data/ext/opengl/extconf.rb +19 -0
  100. data/ext/opengl/fptr_struct.h +912 -0
  101. data/ext/opengl/funcdef.h +279 -0
  102. data/ext/opengl/gl-1.0-1.1.c +3345 -0
  103. data/ext/opengl/gl-1.2.c +155 -0
  104. data/ext/opengl/gl-1.3.c +447 -0
  105. data/ext/opengl/gl-1.4.c +346 -0
  106. data/ext/opengl/gl-1.5.c +225 -0
  107. data/ext/opengl/gl-2.0.c +665 -0
  108. data/ext/opengl/gl-2.1.c +57 -0
  109. data/ext/opengl/gl-3.0.c +502 -0
  110. data/ext/opengl/gl-enums.c +4853 -0
  111. data/ext/opengl/gl-enums.h +14528 -0
  112. data/ext/opengl/gl-error.c +110 -0
  113. data/ext/opengl/gl-error.h +25 -0
  114. data/ext/opengl/gl-ext-3dfx.c +27 -0
  115. data/ext/opengl/gl-ext-arb.c +880 -0
  116. data/ext/opengl/gl-ext-ati.c +41 -0
  117. data/ext/opengl/gl-ext-ext.c +885 -0
  118. data/ext/opengl/gl-ext-gremedy.c +41 -0
  119. data/ext/opengl/gl-ext-nv.c +679 -0
  120. data/ext/opengl/gl.c +265 -0
  121. data/ext/opengl/gl_buffer.c +202 -0
  122. data/ext/opengl/glimpl.c +187 -0
  123. data/ext/opengl/glimpl.h +47 -0
  124. data/ext/opengl/opengl.c +9 -0
  125. data/lib/gl.rb +1 -0
  126. data/lib/opengl.rb +79 -0
  127. data/lib/opengl/bindings_version.rb +4 -0
  128. data/lib/opengl/implementation.rb +38 -0
  129. data/lib/opengl/test_case.rb +86 -0
  130. data/test/dummy.xorg.conf +140 -0
  131. data/test/test_gl.rb +45 -0
  132. data/test/test_gl_10_11.rb +1363 -0
  133. data/test/test_gl_12.rb +71 -0
  134. data/test/test_gl_13.rb +221 -0
  135. data/test/test_gl_14.rb +218 -0
  136. data/test/test_gl_15.rb +258 -0
  137. data/test/test_gl_20.rb +417 -0
  138. data/test/test_gl_21.rb +436 -0
  139. data/test/test_gl_ext_arb.rb +508 -0
  140. data/test/test_gl_ext_ati.rb +28 -0
  141. data/test/test_gl_ext_ext.rb +608 -0
  142. data/test/test_gl_ext_gremedy.rb +29 -0
  143. data/test/test_gl_ext_nv.rb +349 -0
  144. data/test/test_glimpl.rb +23 -0
  145. data/test/test_opengl_buffer.rb +122 -0
  146. data/utils/README +6 -0
  147. data/utils/enumgen.rb +108 -0
  148. data/utils/extlistgen.rb +90 -0
  149. metadata +326 -0
@@ -0,0 +1,346 @@
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 VALUE
43
+ gl_FogCoordfv(obj,arg1)
44
+ VALUE obj,arg1;
45
+ {
46
+ GLfloat coord;
47
+ DECL_GL_FUNC_PTR(GLvoid,glFogCoordfv,(GLfloat *));
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 VALUE
57
+ gl_FogCoorddv(obj,arg1)
58
+ VALUE obj,arg1;
59
+ {
60
+ GLdouble coord;
61
+ DECL_GL_FUNC_PTR(GLvoid,glFogCoorddv,(GLdouble *));
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
+ static VALUE
71
+ gl_FogCoordPointer(obj,arg1,arg2,arg3)
72
+ VALUE obj,arg1,arg2,arg3;
73
+ {
74
+ GLenum type;
75
+ GLsizei stride;
76
+ DECL_GL_FUNC_PTR(GLvoid,glFogCoordPointer,(GLenum,GLsizei,const GLvoid *));
77
+ LOAD_GL_FUNC(glFogCoordPointer, "1.4");
78
+ type = (GLenum)NUM2INT(arg1);
79
+ stride = (GLsizei)NUM2UINT(arg2);
80
+ if (CHECK_BUFFER_BINDING(GL_ARRAY_BUFFER_BINDING)) {
81
+ SET_GLIMPL_VARIABLE(FogCoord_ptr, arg3);
82
+ fptr_glFogCoordPointer(type, stride, (const GLvoid*)NUM2SIZET(arg3));
83
+ } else {
84
+ VALUE data;
85
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg3);
86
+ rb_str_freeze(data);
87
+ SET_GLIMPL_VARIABLE(FogCoord_ptr, data);
88
+ fptr_glFogCoordPointer(type, stride, (const GLvoid*)RSTRING_PTR(data));
89
+ }
90
+ CHECK_GLERROR_FROM("glFogCoordPointer");
91
+ return Qnil;
92
+ }
93
+
94
+ static VALUE
95
+ gl_MultiDrawArrays(obj,arg1,arg2,arg3)
96
+ VALUE obj,arg1,arg2,arg3;
97
+ {
98
+ GLenum mode;
99
+ GLint *ary1;
100
+ GLsizei *ary2;
101
+ int len1,len2;
102
+ DECL_GL_FUNC_PTR(GLvoid,glMultiDrawArrays,(GLenum,GLint*,GLsizei*,GLsizei));
103
+ LOAD_GL_FUNC(glMultiDrawArrays, "1.4");
104
+ len1 = (int)RARRAY_LENINT(arg2);
105
+ len2 = (int)RARRAY_LENINT(arg3);
106
+ if (len1!=len2)
107
+ rb_raise(rb_eArgError, "Passed arrays must have same length");
108
+ mode = (GLenum)NUM2INT(arg1);
109
+ ary1 = ALLOC_N(GLint,len1);
110
+ ary2 = ALLOC_N(GLsizei,len2);
111
+ ary2cint(arg2,ary1,len1);
112
+ ary2cint(arg3,ary2,len2);
113
+ fptr_glMultiDrawArrays(mode,ary1,ary2,len1);
114
+ xfree(ary1);
115
+ xfree(ary2);
116
+ CHECK_GLERROR_FROM("glMultiDrawArrays");
117
+ return Qnil;
118
+ }
119
+
120
+ static VALUE
121
+ gl_MultiDrawElements(argc,argv,obj)
122
+ int argc;
123
+ VALUE *argv;
124
+ VALUE obj;
125
+ {
126
+ GLenum mode;
127
+ GLenum type;
128
+ GLsizei *counts;
129
+ GLvoid **indices;
130
+ GLint size;
131
+ int i;
132
+ VALUE ary, args[4];
133
+ DECL_GL_FUNC_PTR(GLvoid,glMultiDrawElements,(GLenum,const GLsizei *,GLenum,GLvoid **,GLsizei));
134
+ LOAD_GL_FUNC(glMultiDrawElements, "1.4");
135
+ switch (rb_scan_args(argc, argv, "31", &args[0], &args[1], &args[2],&args[3])) {
136
+ default:
137
+ case 3:
138
+ if (CHECK_BUFFER_BINDING(GL_ELEMENT_ARRAY_BUFFER_BINDING))
139
+ rb_raise(rb_eArgError, "Element array buffer bound, but offsets array missing");
140
+ mode = (GLenum)NUM2INT(args[0]);
141
+ type = (GLenum)NUM2INT(args[1]);
142
+ Check_Type(args[2],T_ARRAY);
143
+ ary = args[2];
144
+ size = (GLint)RARRAY_LENINT(ary);
145
+ counts = ALLOC_N(GLsizei,size);
146
+ indices = ALLOC_N(GLvoid*,size);
147
+ for (i=0;i<size;i++) {
148
+ VALUE data;
149
+ data = pack_array_or_pass_string(type,RARRAY_PTR(ary)[i]);
150
+ indices[i] = RSTRING_PTR(data);
151
+ counts[i] = (GLsizei)RSTRING_LENINT(data);
152
+ }
153
+ fptr_glMultiDrawElements(mode,counts,type,indices,size);
154
+ xfree(counts);
155
+ xfree(indices);
156
+ break;
157
+ case 4:
158
+ if (!CHECK_BUFFER_BINDING(GL_ELEMENT_ARRAY_BUFFER_BINDING))
159
+ rb_raise(rb_eArgError, "Element array buffer not bound");
160
+ mode = (GLenum)NUM2INT(args[0]);
161
+ type = (GLenum)NUM2INT(args[1]);
162
+ Check_Type(args[2],T_ARRAY);
163
+ Check_Type(args[3],T_ARRAY);
164
+ if (RARRAY_LEN(args[2]) != RARRAY_LEN(args[3]))
165
+ rb_raise(rb_eArgError, "Count and indices offset array must have same length");
166
+
167
+ size = (GLint)RARRAY_LENINT(args[2]);
168
+
169
+ counts = ALLOC_N(GLsizei,size);
170
+ indices = ALLOC_N(GLvoid*,size);
171
+ for (i=0;i<size;i++) {
172
+ counts[i] = (GLsizei)NUM2INT(rb_ary_entry(args[2],i));
173
+ indices[i] = (GLvoid *)NUM2SIZET(rb_ary_entry(args[3],i));
174
+ }
175
+ fptr_glMultiDrawElements(mode,counts,type,indices,size);
176
+ xfree(counts);
177
+ xfree(indices);
178
+ break;
179
+ }
180
+ CHECK_GLERROR_FROM("glMultiDrawElements");
181
+ return Qnil;
182
+ }
183
+
184
+ static VALUE
185
+ gl_PointParameterfv(obj,arg1,arg2)
186
+ VALUE obj,arg1,arg2;
187
+ {
188
+ GLenum pname;
189
+ GLfloat params[3] = {(GLfloat)0.0,(GLfloat)0.0,(GLfloat)0.0};
190
+ GLint size;
191
+ DECL_GL_FUNC_PTR(GLvoid,glPointParameterfv,(GLenum,GLfloat *));
192
+ LOAD_GL_FUNC(glPointParameterfv, "1.4");
193
+ pname = (GLenum)NUM2INT(arg1);
194
+ Check_Type(arg2,T_ARRAY);
195
+ if (pname==GL_POINT_DISTANCE_ATTENUATION)
196
+ size = 3;
197
+ else
198
+ size = 1;
199
+ ary2cflt(arg2,params,size);
200
+ fptr_glPointParameterfv(pname,params);
201
+ CHECK_GLERROR_FROM("glPointParameterfv");
202
+ return Qnil;
203
+ }
204
+
205
+ static VALUE
206
+ gl_PointParameteriv(obj,arg1,arg2)
207
+ VALUE obj,arg1,arg2;
208
+ {
209
+ GLenum pname;
210
+ GLint params[3] = {0,0,0};
211
+ GLint size;
212
+ DECL_GL_FUNC_PTR(GLvoid,glPointParameteriv,(GLenum,GLint *));
213
+ LOAD_GL_FUNC(glPointParameteriv, "1.4");
214
+ pname = (GLenum)NUM2INT(arg1);
215
+ Check_Type(arg2,T_ARRAY);
216
+ if (pname==GL_POINT_DISTANCE_ATTENUATION)
217
+ size = 3;
218
+ else
219
+ size = 1;
220
+ ary2cint(arg2,params,size);
221
+ fptr_glPointParameteriv(pname,params);
222
+ CHECK_GLERROR_FROM("glPointParameteriv");
223
+ return Qnil;
224
+ }
225
+
226
+ #define GLSECONDARYCOLOR_VFUNC(_name_,_type_,_conv_) \
227
+ VALUE gl_##_name_(VALUE obj,VALUE arg1) \
228
+ { \
229
+ _type_ cary[3] = {0,0,0}; \
230
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(_type_ *)); \
231
+ LOAD_GL_FUNC(gl##_name_, "1.4"); \
232
+ Check_Type(arg1,T_ARRAY); \
233
+ _conv_(arg1,cary,3); \
234
+ fptr_gl##_name_(cary); \
235
+ CHECK_GLERROR_FROM("gl" #_name_); \
236
+ return Qnil; \
237
+ }
238
+
239
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3bv,GLbyte,ary2cbyte)
240
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3dv,GLdouble,ary2cdbl)
241
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3fv,GLfloat,ary2cflt)
242
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3iv,GLint,ary2cint)
243
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3sv,GLshort,ary2cshort)
244
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3uiv,GLuint,ary2cuint)
245
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3ubv,GLubyte,ary2cubyte)
246
+ GLSECONDARYCOLOR_VFUNC(SecondaryColor3usv,GLushort,ary2cushort)
247
+ #undef GLSECONDARYCOLOR_VFUNC
248
+
249
+ static VALUE
250
+ gl_SecondaryColorPointer(obj,arg1,arg2,arg3,arg4)
251
+ VALUE obj,arg1,arg2,arg3,arg4;
252
+ {
253
+ GLint size;
254
+ GLenum type;
255
+ GLsizei stride;
256
+ DECL_GL_FUNC_PTR(GLvoid,glSecondaryColorPointer,(GLint,GLenum,GLsizei,const GLvoid *));
257
+ LOAD_GL_FUNC(glSecondaryColorPointer, "1.4");
258
+ size = (GLint)NUM2INT(arg1);
259
+ type = (GLenum)NUM2INT(arg2);
260
+ stride = (GLsizei)NUM2UINT(arg3);
261
+ if (CHECK_BUFFER_BINDING(GL_ARRAY_BUFFER_BINDING)) {
262
+ SET_GLIMPL_VARIABLE(SecondaryColor_ptr, arg4);
263
+ fptr_glSecondaryColorPointer(size,type, stride, (const GLvoid*)NUM2SIZET(arg4));
264
+ } else {
265
+ VALUE data;
266
+ data = pack_array_or_pass_string(type,arg4);
267
+ rb_str_freeze(data);
268
+ SET_GLIMPL_VARIABLE(SecondaryColor_ptr, data);
269
+ fptr_glSecondaryColorPointer(size,type, stride, (const GLvoid*)RSTRING_PTR(data));
270
+ }
271
+ CHECK_GLERROR_FROM("glSecondaryColorPointer");
272
+ return Qnil;
273
+ }
274
+
275
+ #define GLWINDOWPOS_VFUNC(_name_,_type_,_size_,_conv_) \
276
+ VALUE gl_##_name_(VALUE obj,VALUE arg1) \
277
+ { \
278
+ _type_ cary[3] = {0,0,0}; \
279
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(_type_ *)); \
280
+ LOAD_GL_FUNC(gl##_name_, "1.4"); \
281
+ Check_Type(arg1,T_ARRAY); \
282
+ _conv_(arg1,cary,_size_); \
283
+ fptr_gl##_name_(cary); \
284
+ CHECK_GLERROR_FROM("gl" #_name_); \
285
+ return Qnil; \
286
+ }
287
+
288
+ GLWINDOWPOS_VFUNC(WindowPos2dv,GLdouble,2,ary2cdbl)
289
+ GLWINDOWPOS_VFUNC(WindowPos2fv,GLfloat,2,ary2cflt)
290
+ GLWINDOWPOS_VFUNC(WindowPos2iv,GLint,2,ary2cint)
291
+ GLWINDOWPOS_VFUNC(WindowPos2sv,GLshort,2,ary2cshort)
292
+ GLWINDOWPOS_VFUNC(WindowPos3dv,GLdouble,3,ary2cdbl)
293
+ GLWINDOWPOS_VFUNC(WindowPos3fv,GLfloat,3,ary2cflt)
294
+ GLWINDOWPOS_VFUNC(WindowPos3iv,GLint,3,ary2cint)
295
+ GLWINDOWPOS_VFUNC(WindowPos3sv,GLshort,3,ary2cshort)
296
+ #undef GLWINDOWPOS_VFUNC
297
+
298
+
299
+ void gl_init_functions_1_4(VALUE klass)
300
+ {
301
+ rb_define_method(klass, "glBlendFuncSeparate", gl_BlendFuncSeparate, 4);
302
+ rb_define_method(klass, "glFogCoordf", gl_FogCoordf, 1);
303
+ rb_define_method(klass, "glFogCoordfv", gl_FogCoordfv, 1);
304
+ rb_define_method(klass, "glFogCoordd", gl_FogCoordd, 1);
305
+ rb_define_method(klass, "glFogCoorddv", gl_FogCoorddv, 1);
306
+ rb_define_method(klass, "glFogCoordPointer", gl_FogCoordPointer, 3);
307
+ rb_define_method(klass, "glMultiDrawArrays", gl_MultiDrawArrays, 3);
308
+ rb_define_method(klass, "glMultiDrawElements", gl_MultiDrawElements, -1);
309
+ rb_define_method(klass, "glPointParameterf", gl_PointParameterf, 2);
310
+ rb_define_method(klass, "glPointParameterfv", gl_PointParameterfv, 2);
311
+ rb_define_method(klass, "glPointParameteri", gl_PointParameteri, 2);
312
+ rb_define_method(klass, "glPointParameteriv", gl_PointParameteriv, 2);
313
+ rb_define_method(klass, "glSecondaryColor3b", gl_SecondaryColor3b, 3);
314
+ rb_define_method(klass, "glSecondaryColor3d", gl_SecondaryColor3d, 3);
315
+ rb_define_method(klass, "glSecondaryColor3f", gl_SecondaryColor3f, 3);
316
+ rb_define_method(klass, "glSecondaryColor3i", gl_SecondaryColor3i, 3);
317
+ rb_define_method(klass, "glSecondaryColor3s", gl_SecondaryColor3s, 3);
318
+ rb_define_method(klass, "glSecondaryColor3ub", gl_SecondaryColor3ub, 3);
319
+ rb_define_method(klass, "glSecondaryColor3ui", gl_SecondaryColor3ui, 3);
320
+ rb_define_method(klass, "glSecondaryColor3us", gl_SecondaryColor3us, 3);
321
+ rb_define_method(klass, "glSecondaryColor3bv", gl_SecondaryColor3bv, 1);
322
+ rb_define_method(klass, "glSecondaryColor3dv", gl_SecondaryColor3dv, 1);
323
+ rb_define_method(klass, "glSecondaryColor3fv", gl_SecondaryColor3fv, 1);
324
+ rb_define_method(klass, "glSecondaryColor3iv", gl_SecondaryColor3iv, 1);
325
+ rb_define_method(klass, "glSecondaryColor3sv", gl_SecondaryColor3sv, 1);
326
+ rb_define_method(klass, "glSecondaryColor3ubv", gl_SecondaryColor3ubv, 1);
327
+ rb_define_method(klass, "glSecondaryColor3uiv", gl_SecondaryColor3uiv, 1);
328
+ rb_define_method(klass, "glSecondaryColor3usv", gl_SecondaryColor3usv, 1);
329
+ rb_define_method(klass, "glSecondaryColorPointer", gl_SecondaryColorPointer, 4);
330
+ rb_define_method(klass, "glWindowPos2d", gl_WindowPos2d, 2);
331
+ rb_define_method(klass, "glWindowPos2f", gl_WindowPos2f, 2);
332
+ rb_define_method(klass, "glWindowPos2i", gl_WindowPos2i, 2);
333
+ rb_define_method(klass, "glWindowPos2s", gl_WindowPos2s, 2);
334
+ rb_define_method(klass, "glWindowPos3d", gl_WindowPos3d, 3);
335
+ rb_define_method(klass, "glWindowPos3f", gl_WindowPos3f, 3);
336
+ rb_define_method(klass, "glWindowPos3i", gl_WindowPos3i, 3);
337
+ rb_define_method(klass, "glWindowPos3s", gl_WindowPos3s, 3);
338
+ rb_define_method(klass, "glWindowPos2dv", gl_WindowPos2dv, 1);
339
+ rb_define_method(klass, "glWindowPos2fv", gl_WindowPos2fv, 1);
340
+ rb_define_method(klass, "glWindowPos2iv", gl_WindowPos2iv, 1);
341
+ rb_define_method(klass, "glWindowPos2sv", gl_WindowPos2sv, 1);
342
+ rb_define_method(klass, "glWindowPos3dv", gl_WindowPos3dv, 1);
343
+ rb_define_method(klass, "glWindowPos3fv", gl_WindowPos3fv, 1);
344
+ rb_define_method(klass, "glWindowPos3iv", gl_WindowPos3iv, 1);
345
+ rb_define_method(klass, "glWindowPos3sv", gl_WindowPos3sv, 1);
346
+ }
@@ -0,0 +1,225 @@
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 VALUE
31
+ gl_GetQueryiv(obj,arg1,arg2)
32
+ VALUE obj,arg1,arg2;
33
+ {
34
+ GLenum target;
35
+ GLenum pname;
36
+ GLint params = 0;
37
+ DECL_GL_FUNC_PTR(GLvoid,glGetQueryiv,(GLenum,GLenum,GLint *));
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 VALUE
47
+ gl_GetQueryObjectiv(obj,arg1,arg2)
48
+ VALUE obj,arg1,arg2;
49
+ {
50
+ GLuint id;
51
+ GLenum pname;
52
+ GLint params = 0;
53
+ DECL_GL_FUNC_PTR(GLvoid,glGetQueryObjectiv,(GLuint,GLenum,GLint *));
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 VALUE
63
+ gl_GetQueryObjectuiv(obj,arg1,arg2)
64
+ VALUE obj,arg1,arg2;
65
+ {
66
+ GLuint id;
67
+ GLenum pname;
68
+ GLuint params = 0;
69
+ DECL_GL_FUNC_PTR(GLvoid,glGetQueryObjectuiv,(GLuint,GLenum,GLuint *));
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 VALUE
79
+ gl_BufferData(obj,arg1,arg2,arg3,arg4)
80
+ VALUE obj,arg1,arg2,arg3,arg4;
81
+ {
82
+ GLenum target;
83
+ GLsizeiptr size;
84
+ GLenum usage;
85
+ DECL_GL_FUNC_PTR(GLvoid,glBufferData,(GLenum,GLsizeiptr,GLvoid *,GLenum));
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 VALUE
102
+ gl_BufferSubData(obj,arg1,arg2,arg3,arg4)
103
+ VALUE obj,arg1,arg2,arg3,arg4;
104
+ {
105
+ GLenum target;
106
+ GLintptr offset;
107
+ GLsizeiptr size;
108
+ DECL_GL_FUNC_PTR(GLvoid,glBufferSubData,(GLenum,GLintptr,GLsizeiptr,GLvoid *));
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 VALUE
120
+ gl_GetBufferSubData(obj,arg1,arg2,arg3)
121
+ VALUE obj,arg1,arg2,arg3;
122
+ {
123
+ GLenum target;
124
+ GLintptr offset;
125
+ GLsizeiptr size;
126
+ VALUE data;
127
+ DECL_GL_FUNC_PTR(GLvoid,glGetBufferSubData,(GLenum,GLintptr,GLsizeiptr,GLvoid *));
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 VALUE
139
+ gl_GetBufferParameteriv(obj,arg1,arg2)
140
+ VALUE obj,arg1,arg2;
141
+ {
142
+ GLenum target;
143
+ GLenum value;
144
+ GLint data = 0;
145
+ DECL_GL_FUNC_PTR(GLvoid,glGetBufferParameteriv,(GLenum,GLenum,GLint *));
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 VALUE
155
+ gl_MapBuffer(VALUE obj, VALUE _target, VALUE _access) {
156
+ GLenum target = CONV_GLenum(_target);
157
+ GLenum access = CONV_GLenum(_access);
158
+ GLint size = 0;
159
+ GLvoid *buffer_ptr = NULL;
160
+
161
+ DECL_GL_FUNC_PTR(GLvoid *,glMapBuffer,(GLenum,GLenum));
162
+ DECL_GL_FUNC_PTR(GLvoid,glGetBufferParameteriv,(GLenum,GLenum,GLint *));
163
+ LOAD_GL_FUNC(glMapBuffer, "1.5");
164
+ LOAD_GL_FUNC(glGetBufferParameteriv, "1.5");
165
+
166
+ fptr_glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size);
167
+ CHECK_GLERROR_FROM("glGetBufferParameteriv");
168
+
169
+ buffer_ptr = fptr_glMapBuffer(target, access);
170
+ CHECK_GLERROR_FROM("glMapBuffer");
171
+
172
+ /* fail late to avoid GL_INVALID_OPERATION from glUnampBuffer */
173
+ if (buffer_ptr == NULL || size <= 0)
174
+ return Qnil;
175
+
176
+ return rb_str_new(buffer_ptr, size);
177
+ }
178
+
179
+ static VALUE
180
+ gl_UnmapBuffer(obj,arg1)
181
+ VALUE obj,arg1;
182
+ {
183
+ GLenum target;
184
+ GLboolean ret;
185
+ DECL_GL_FUNC_PTR(GLboolean,glUnmapBuffer,(GLenum));
186
+ LOAD_GL_FUNC(glUnmapBuffer, "1.5");
187
+ target = (GLenum)NUM2INT(arg1);
188
+ ret = fptr_glUnmapBuffer(target);
189
+ CHECK_GLERROR_FROM("glUnmapBuffer");
190
+ return GLBOOL2RUBY(ret);
191
+ }
192
+
193
+ static VALUE
194
+ gl_GetBufferPointerv(obj,arg1,arg2,arg3)
195
+ VALUE obj,arg1,arg2,arg3;
196
+ {
197
+ DECL_GL_FUNC_PTR(GLvoid,glGetBufferPointerv,(GLenum,GLenum,GLvoid **));
198
+ LOAD_GL_FUNC(glGetBufferPointerv, "1.5");
199
+ rb_raise(rb_eArgError, "glGetBufferPointerv not implemented");
200
+ CHECK_GLERROR_FROM("glGetBufferPointerv");
201
+ return Qnil;
202
+ }
203
+
204
+ void gl_init_functions_1_5(VALUE klass)
205
+ {
206
+ rb_define_method(klass, "glGenQueries", gl_GenQueries, 1);
207
+ rb_define_method(klass, "glDeleteQueries", gl_DeleteQueries, 1);
208
+ rb_define_method(klass, "glIsQuery", gl_IsQuery, 1);
209
+ rb_define_method(klass, "glBeginQuery", gl_BeginQuery, 2);
210
+ rb_define_method(klass, "glEndQuery", gl_EndQuery, 1);
211
+ rb_define_method(klass, "glGetQueryiv", gl_GetQueryiv, 2);
212
+ rb_define_method(klass, "glGetQueryObjectiv", gl_GetQueryObjectiv, 2);
213
+ rb_define_method(klass, "glGetQueryObjectuiv", gl_GetQueryObjectuiv, 2);
214
+ rb_define_method(klass, "glBindBuffer", gl_BindBuffer, 2);
215
+ rb_define_method(klass, "glDeleteBuffers", gl_DeleteBuffers, 1);
216
+ rb_define_method(klass, "glGenBuffers", gl_GenBuffers, 1);
217
+ rb_define_method(klass, "glIsBuffer", gl_IsBuffer, 1);
218
+ rb_define_method(klass, "glBufferData", gl_BufferData, 4);
219
+ rb_define_method(klass, "glBufferSubData", gl_BufferSubData, 4);
220
+ rb_define_method(klass, "glGetBufferSubData", gl_GetBufferSubData, 3);
221
+ rb_define_method(klass, "glMapBuffer", gl_MapBuffer, 2);
222
+ rb_define_method(klass, "glUnmapBuffer", gl_UnmapBuffer, 1);
223
+ rb_define_method(klass, "glGetBufferParameteriv", gl_GetBufferParameteriv, 2);
224
+ rb_define_method(klass, "glGetBufferPointerv", gl_GetBufferPointerv, 3);
225
+ }