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,279 @@
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
+ #ifndef _FUNCDEF_H_
17
+ #define _FUNCDEF_H_
18
+
19
+ /*
20
+ These macros are for simplification of function definition, as passing
21
+ arguments from/to OpenGL usually follows the same few patterns. It would
22
+ be probably wise to adapt the whole bindings to C++ (templates, overloaded
23
+ functions, etc.), but for now supporting ruby extension for Windows means
24
+ MSVC6, and that in turn means unspeakable horrors and pains for everyone
25
+ attempting to merely write, much less debug or maintain any template-based
26
+ code.
27
+ */
28
+
29
+ /*
30
+ * Loads the function pointer for function _NAME_ on first call to the
31
+ * function, or raises a NotImplementedError if the OpenGL version is less
32
+ * then required or the required extension is not supported.
33
+ */
34
+ #define LOAD_GL_FUNC(_NAME_, _VEREXT_) \
35
+ do { \
36
+ fptr_##_NAME_ = GET_GLIMPL_VARIABLE(glfuncs._NAME_); \
37
+ if (fptr_##_NAME_==NULL){ \
38
+ if (_VEREXT_) EnsureVersionExtension(obj, (_VEREXT_)); \
39
+ fptr_##_NAME_ = GET_GLIMPL_VARIABLE(load_gl_function)(obj,#_NAME_, 1); \
40
+ SET_GLIMPL_VARIABLE(glfuncs._NAME_,fptr_##_NAME_); \
41
+ } \
42
+ } while (0)
43
+
44
+ #if defined(GLFUNC_MAGIC_START)
45
+ #define DECL_GL_FUNC_PTR(_returntype_,_name_,_args_) \
46
+ GLFUNC_MAGIC_START _returntype_ (GLFUNC_MAGIC_APIENTRY * _name_)_args_ GLFUNC_MAGIC_END
47
+ #else
48
+ #define DECL_GL_FUNC_PTR(_returntype_,_name_,_args_) \
49
+ _returntype_ (APIENTRY * fptr_##_name_)_args_ = NULL
50
+ #endif
51
+
52
+ /*
53
+ Macroset for defining simple functions, i.e. functions that take n arguments and
54
+ pass them to GL API function without any additional processing.
55
+
56
+ Some checking is implicit in _conversion_ argument - e.g. NUM2INT makes sure that
57
+ user is really passing type that can be converted to INT, otherwire raises.
58
+
59
+ *_LOAD version of macros are for defining functions where we load function pointer
60
+ instead of direct call - that means all functions above OpenGL 1.1 (including all extensions)
61
+ */
62
+
63
+ #define ARGLIST0
64
+ #define ARGLIST1 ,arg1
65
+ #define ARGLIST2 ,arg1,arg2
66
+ #define ARGLIST3 ,arg1,arg2,arg3
67
+ #define ARGLIST4 ,arg1,arg2,arg3,arg4
68
+ #define ARGLIST5 ,arg1,arg2,arg3,arg4,arg5
69
+ #define ARGLIST6 ,arg1,arg2,arg3,arg4,arg5,arg6
70
+ #define ARGLIST7 ,arg1,arg2,arg3,arg4,arg5,arg6,arg7
71
+ #define ARGLIST8 ,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8
72
+ #define ARGLIST9 ,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9
73
+ #define ARGLIST10 ,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10
74
+
75
+ #define CONV_GLenum (GLenum)RUBY2GLENUM
76
+ #define CONV_GLboolean (GLboolean)RUBYBOOL2GL
77
+ #define CONV_GLbitfield (GLbitfield)NUM2UINT
78
+ #define CONV_GLbyte (GLbyte)NUM2INT
79
+ #define CONV_GLshort (GLshort)NUM2INT
80
+ #define CONV_GLint (GLint)NUM2INT
81
+ #define CONV_GLubyte (GLubyte)NUM2UINT
82
+ #define CONV_GLushort (GLushort)NUM2UINT
83
+ #define CONV_GLuint (GLuint)NUM2UINT
84
+ #define CONV_GLsizei (GLsizei)NUM2INT
85
+ #define CONV_GLfloat (GLfloat)NUM2DBL
86
+ #define CONV_GLclampf (GLclampf)NUM2DBL
87
+ #define CONV_GLdouble (GLdouble)NUM2DBL
88
+ #define CONV_GLclampd (GLclampd)NUM2DBL
89
+
90
+ #define RETDECL_BASE(_t_) _t_ ret = (_t_) 0;
91
+ #define RETDECL_GLvoid
92
+ #define RETDECL_void
93
+ #define RETDECL_GLenum RETDECL_BASE(GLenum)
94
+ #define RETDECL_GLboolean RETDECL_BASE(GLboolean)
95
+ #define RETDECL_GLbitfield RETDECL_BASE(GLbitfield)
96
+ #define RETDECL_GLbyte RETDECL_BASE(GLbyte)
97
+ #define RETDECL_GLshort RETDECL_BASE(GLshort)
98
+ #define RETDECL_GLint RETDECL_BASE(GLint)
99
+ #define RETDECL_GLubyte RETDECL_BASE(GLubyte)
100
+ #define RETDECL_GLushort RETDECL_BASE(GLushort)
101
+ #define RETDECL_GLuint RETDECL_BASE(GLuint)
102
+ #define RETDECL_GLsizei RETDECL_BASE(GLsizei)
103
+ #define RETDECL_GLfloat RETDECL_BASE(GLfloat)
104
+ #define RETDECL_GLclampf RETDECL_BASE(GLclampf)
105
+ #define RETDECL_GLdouble RETDECL_BASE(GLdouble)
106
+ #define RETDECL_GLclampd RETDECL_BASE(GLclampd)
107
+
108
+ #define RETSTAT_GLvoid
109
+ #define RETSTAT_void
110
+ #define RETSTAT_GLenum ret=
111
+ #define RETSTAT_GLboolean ret=
112
+ #define RETSTAT_GLbitfield ret=
113
+ #define RETSTAT_GLbyte ret=
114
+ #define RETSTAT_GLshort ret=
115
+ #define RETSTAT_GLint ret=
116
+ #define RETSTAT_GLubyte ret=
117
+ #define RETSTAT_GLushort ret=
118
+ #define RETSTAT_GLuint ret=
119
+ #define RETSTAT_GLsizei ret=
120
+ #define RETSTAT_GLfloat ret=
121
+ #define RETSTAT_GLclampf ret=
122
+ #define RETSTAT_GLdouble ret=
123
+ #define RETSTAT_GLclampd ret=
124
+
125
+ #define RETCONV_GLvoid(x) Qnil
126
+ #define RETCONV_void(x) Qnil
127
+ #define RETCONV_GLenum(x) UINT2NUM(x)
128
+ #define RETCONV_GLboolean(x) GLBOOL2RUBY(x)
129
+ #define RETCONV_GLbitfield(x) UINT2NUM(x)
130
+ #define RETCONV_GLbyte(x) INT2NUM(x)
131
+ #define RETCONV_GLshort(x) INT2NUM(x)
132
+ #define RETCONV_GLsizeiptr(x) ULONG2NUM(x)
133
+ #define RETCONV_GLint(x) INT2NUM(x)
134
+ #define RETCONV_GLubyte(x) UINT2NUM(x)
135
+ #define RETCONV_GLushort(x) UINT2NUM(x)
136
+ #define RETCONV_GLuint(x) UINT2NUM(x)
137
+ #define RETCONV_GLsizei(x) INT2NUM(x)
138
+ #define RETCONV_GLfloat(x) rb_float_new(x)
139
+ #define RETCONV_GLclampf(x) rb_float_new(x)
140
+ #define RETCONV_GLdouble(x) rb_float_new(x)
141
+ #define RETCONV_GLclampd(x) rb_float_new(x)
142
+
143
+ #define PROTOPARAM0(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) void
144
+ #define PROTOPARAM1(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1
145
+ #define PROTOPARAM2(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2
146
+ #define PROTOPARAM3(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3
147
+ #define PROTOPARAM4(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4
148
+ #define PROTOPARAM5(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4,p5
149
+ #define PROTOPARAM6(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4,p5,p6
150
+ #define PROTOPARAM7(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4,p5,p6,p7
151
+ #define PROTOPARAM8(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4,p5,p6,p7,p8
152
+ #define PROTOPARAM9(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4,p5,p6,p7,p8,p9
153
+ #define PROTOPARAM10(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) p1,p2,p3,p4,p5,p6,p7,p8,p9,p10
154
+
155
+ #define CALLCONV0(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10)
156
+ #define CALLCONV1(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1)
157
+ #define CALLCONV2(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2)
158
+ #define CALLCONV3(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3)
159
+ #define CALLCONV4(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4)
160
+ #define CALLCONV5(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5)
161
+ #define CALLCONV6(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5),CONV_##cv6(arg6)
162
+ #define CALLCONV7(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5),CONV_##cv6(arg6),CONV_##cv7(arg7)
163
+ #define CALLCONV8(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5),CONV_##cv6(arg6),CONV_##cv7(arg7),CONV_##cv8(arg8)
164
+ #define CALLCONV9(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5),CONV_##cv6(arg6),CONV_##cv7(arg7),CONV_##cv8(arg8),CONV_##cv9(arg9)
165
+ #define CALLCONV10(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5),CONV_##cv6(arg6),CONV_##cv7(arg7),CONV_##cv8(arg8),CONV_##cv9(arg9),CONV_##cv10(arg10)
166
+
167
+ #define GL_FUNC_LOAD(_num_,_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_) \
168
+ static VALUE \
169
+ gl_##_name_(obj ARGLIST##_num_) \
170
+ VALUE obj ARGLIST##_num_; \
171
+ { \
172
+ RETDECL_##_returntype_ \
173
+ DECL_GL_FUNC_PTR(_returntype_,gl##_name_,(PROTOPARAM##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10))); \
174
+ LOAD_GL_FUNC(gl##_name_,_ver_); \
175
+ RETSTAT_##_returntype_ fptr_gl##_name_(CALLCONV##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
176
+ CHECK_GLERROR_FROM("gl" #_name_); \
177
+ return RETCONV_##_returntype_(ret) ; \
178
+ }
179
+
180
+ #define GL_FUNC_STATIC(_num_,_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10) \
181
+ GL_FUNC_LOAD(_num_,_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,NULL)
182
+
183
+ #define GL_FUNC_LOAD_0(_name_,_returntype_,_ver_) \
184
+ GL_FUNC_LOAD(0, _name_,_returntype_,0,0,0,0,0,0,0,0,0,0,_ver_)
185
+ #define GL_FUNC_LOAD_1(_name_,_returntype_,targ1,_ver_) \
186
+ GL_FUNC_LOAD(1, _name_,_returntype_,targ1,0,0,0,0,0,0,0,0,0,_ver_)
187
+ #define GL_FUNC_LOAD_2(_name_,_returntype_,targ1,targ2,_ver_) \
188
+ GL_FUNC_LOAD(2, _name_,_returntype_,targ1,targ2,0,0,0,0,0,0,0,0,_ver_)
189
+ #define GL_FUNC_LOAD_3(_name_,_returntype_,targ1,targ2,targ3,_ver_) \
190
+ GL_FUNC_LOAD(3, _name_,_returntype_,targ1,targ2,targ3,0,0,0,0,0,0,0,_ver_)
191
+ #define GL_FUNC_LOAD_4(_name_,_returntype_,targ1,targ2,targ3,targ4,_ver_) \
192
+ GL_FUNC_LOAD(4, _name_,_returntype_,targ1,targ2,targ3,targ4,0,0,0,0,0,0,_ver_)
193
+ #define GL_FUNC_LOAD_5(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,_ver_) \
194
+ GL_FUNC_LOAD(5, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,0,0,0,0,0,_ver_)
195
+ #define GL_FUNC_LOAD_6(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,_ver_) \
196
+ GL_FUNC_LOAD(6, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,0,0,0,0,_ver_)
197
+ #define GL_FUNC_LOAD_7(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,_ver_) \
198
+ GL_FUNC_LOAD(7, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,0,0,0,_ver_)
199
+ #define GL_FUNC_LOAD_8(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,_ver_) \
200
+ GL_FUNC_LOAD(8, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,0,0,_ver_)
201
+ #define GL_FUNC_LOAD_9(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,_ver_) \
202
+ GL_FUNC_LOAD(9, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,0,_ver_)
203
+ #define GL_FUNC_LOAD_10(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_) \
204
+ GL_FUNC_LOAD(10, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_)
205
+
206
+ #define GL_FUNC_STATIC_0(_name_,_returntype_) \
207
+ GL_FUNC_STATIC(0, _name_,_returntype_,0,0,0,0,0,0,0,0,0,0)
208
+ #define GL_FUNC_STATIC_1(_name_,_returntype_,targ1) \
209
+ GL_FUNC_STATIC(1, _name_,_returntype_,targ1,0,0,0,0,0,0,0,0,0)
210
+ #define GL_FUNC_STATIC_2(_name_,_returntype_,targ1,targ2) \
211
+ GL_FUNC_STATIC(2, _name_,_returntype_,targ1,targ2,0,0,0,0,0,0,0,0)
212
+ #define GL_FUNC_STATIC_3(_name_,_returntype_,targ1,targ2,targ3) \
213
+ GL_FUNC_STATIC(3, _name_,_returntype_,targ1,targ2,targ3,0,0,0,0,0,0,0)
214
+ #define GL_FUNC_STATIC_4(_name_,_returntype_,targ1,targ2,targ3,targ4) \
215
+ GL_FUNC_STATIC(4, _name_,_returntype_,targ1,targ2,targ3,targ4,0,0,0,0,0,0)
216
+ #define GL_FUNC_STATIC_5(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5) \
217
+ GL_FUNC_STATIC(5, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,0,0,0,0,0)
218
+ #define GL_FUNC_STATIC_6(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6) \
219
+ GL_FUNC_STATIC(6, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,0,0,0,0)
220
+ #define GL_FUNC_STATIC_7(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7) \
221
+ GL_FUNC_STATIC(7, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,0,0,0)
222
+ #define GL_FUNC_STATIC_8(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8) \
223
+ GL_FUNC_STATIC(8, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,0,0)
224
+ #define GL_FUNC_STATIC_9(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9) \
225
+ GL_FUNC_STATIC(9, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,0)
226
+ #define GL_FUNC_STATIC_10(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10_ver_) \
227
+ GL_FUNC_STATIC(10, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)
228
+
229
+ /* Templates for glGen* and glDelete* */
230
+
231
+ #define GL_FUNC_GENOBJECTS_LOAD(_name_,_ver_) \
232
+ static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
233
+ { \
234
+ GLsizei n; \
235
+ GLuint *objects; \
236
+ VALUE ret; \
237
+ GLsizei i; \
238
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLsizei,GLuint *)); \
239
+ LOAD_GL_FUNC(gl##_name_,_ver_); \
240
+ n = CONV_GLsizei(arg1); \
241
+ objects = ALLOC_N(GLuint, n); \
242
+ fptr_gl##_name_(n,objects); \
243
+ ret = rb_ary_new2(n); \
244
+ for (i = 0; i < n; i++) \
245
+ rb_ary_push(ret, RETCONV_GLuint(objects[i])); \
246
+ xfree(objects); \
247
+ CHECK_GLERROR_FROM("gl" #_name_); \
248
+ return ret; \
249
+ }
250
+
251
+ #define GL_FUNC_GENOBJECTS(_name_) \
252
+ GL_FUNC_GENOBJECTS_LOAD(_name_,"1.1")
253
+
254
+ #define GL_FUNC_DELETEOBJECTS_LOAD(_name_,_ver_) \
255
+ static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
256
+ { \
257
+ GLsizei n; \
258
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLsizei,const GLuint *)); \
259
+ LOAD_GL_FUNC(gl##_name_,_ver_); \
260
+ if (TYPE(arg1)==T_ARRAY) { \
261
+ GLuint *objects; \
262
+ n = (GLsizei)RARRAY_LENINT(arg1); \
263
+ objects = ALLOC_N(GLuint,n); \
264
+ ary2cuint(arg1,objects,n); \
265
+ fptr_gl##_name_(n,objects); \
266
+ xfree(objects); \
267
+ } else { \
268
+ GLuint object; \
269
+ object = CONV_GLsizei(arg1); \
270
+ fptr_gl##_name_(1,&object); \
271
+ } \
272
+ CHECK_GLERROR_FROM("gl" #_name_); \
273
+ return Qnil; \
274
+ }
275
+
276
+ #define GL_FUNC_DELETEOBJECTS(_name_) \
277
+ GL_FUNC_DELETEOBJECTS_LOAD(_name_,"1.1")
278
+
279
+ #endif
@@ -0,0 +1,3345 @@
1
+ /*
2
+ * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
3
+ * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
5
+ *
6
+ * This program is distributed under the terms of the MIT license.
7
+ * See the included MIT-LICENSE file for the terms of this license.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
12
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
13
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ */
17
+
18
+ #include "common.h"
19
+
20
+ #ifndef MAX
21
+ #define MAX(a, b) (((a) > (b)) ? (a) : (b))
22
+ #endif
23
+
24
+ /* OpenGL 1.0 + 1.1 functions */
25
+
26
+ GL_FUNC_STATIC_2(Accum,GLvoid, GLenum,GLfloat)
27
+ GL_FUNC_STATIC_2(AlphaFunc,GLvoid, GLenum,GLclampf)
28
+ GL_FUNC_STATIC_1(ArrayElement,GLvoid, GLint)
29
+ GL_FUNC_STATIC_2(BindTexture,GLvoid, GLenum,GLuint)
30
+ GL_FUNC_STATIC_2(BlendFunc,GLvoid, GLenum,GLenum)
31
+ GL_FUNC_STATIC_1(CallList,GLvoid, GLuint)
32
+ GL_FUNC_STATIC_1(Clear,GLvoid, GLbitfield)
33
+ GL_FUNC_STATIC_4(ClearAccum,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
34
+ GL_FUNC_STATIC_4(ClearColor,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
35
+ GL_FUNC_STATIC_1(ClearDepth,GLvoid, GLclampd)
36
+ GL_FUNC_STATIC_1(ClearIndex,GLvoid, GLfloat)
37
+ GL_FUNC_STATIC_1(ClearStencil,GLvoid, GLint)
38
+ GL_FUNC_STATIC_3(Color3b,GLvoid, GLbyte,GLbyte,GLbyte)
39
+ GL_FUNC_STATIC_3(Color3d,GLvoid, GLdouble,GLdouble,GLdouble)
40
+ GL_FUNC_STATIC_3(Color3f,GLvoid, GLfloat,GLfloat,GLfloat)
41
+ GL_FUNC_STATIC_3(Color3i,GLvoid, GLint,GLint,GLint)
42
+ GL_FUNC_STATIC_3(Color3s,GLvoid, GLshort,GLshort,GLshort)
43
+ GL_FUNC_STATIC_3(Color3ub,GLvoid, GLubyte,GLubyte,GLubyte)
44
+ GL_FUNC_STATIC_3(Color3ui,GLvoid, GLuint,GLuint,GLuint)
45
+ GL_FUNC_STATIC_3(Color3us,GLvoid, GLushort,GLushort,GLushort)
46
+ GL_FUNC_STATIC_4(Color4b,GLvoid, GLbyte,GLbyte,GLbyte,GLbyte)
47
+ GL_FUNC_STATIC_4(Color4d,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble)
48
+ GL_FUNC_STATIC_4(Color4f,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
49
+ GL_FUNC_STATIC_4(Color4i,GLvoid, GLint,GLint,GLint,GLint)
50
+ GL_FUNC_STATIC_4(Color4s,GLvoid, GLshort,GLshort,GLshort,GLshort)
51
+ GL_FUNC_STATIC_4(Color4ub,GLvoid, GLubyte,GLubyte,GLubyte,GLubyte)
52
+ GL_FUNC_STATIC_4(Color4ui,GLvoid, GLuint,GLuint,GLuint,GLuint)
53
+ GL_FUNC_STATIC_4(Color4us,GLvoid, GLushort,GLushort,GLushort,GLushort)
54
+ GL_FUNC_STATIC_4(ColorMask,GLvoid, GLboolean,GLboolean,GLboolean,GLboolean)
55
+ GL_FUNC_STATIC_2(ColorMaterial,GLvoid, GLenum,GLenum)
56
+ GL_FUNC_STATIC_5(CopyPixels,GLvoid, GLint,GLint,GLsizei,GLsizei,GLenum)
57
+ GL_FUNC_STATIC_7(CopyTexImage1D,GLvoid, GLenum,GLint,GLenum,GLint,GLint,GLsizei,GLint)
58
+ GL_FUNC_STATIC_8(CopyTexImage2D,GLvoid, GLenum,GLint,GLenum,GLint,GLint,GLsizei,GLsizei,GLint)
59
+ GL_FUNC_STATIC_6(CopyTexSubImage1D,GLvoid, GLenum,GLint,GLint,GLint,GLint,GLsizei)
60
+ GL_FUNC_STATIC_8(CopyTexSubImage2D,GLvoid, GLenum,GLint,GLint,GLint,GLint,GLint,GLsizei,GLsizei)
61
+ GL_FUNC_STATIC_1(CullFace,GLvoid, GLenum)
62
+ GL_FUNC_STATIC_2(DeleteLists,GLvoid, GLuint,GLuint)
63
+ GL_FUNC_STATIC_1(DepthFunc,GLvoid, GLenum)
64
+ GL_FUNC_STATIC_1(DepthMask,GLvoid, GLboolean)
65
+ GL_FUNC_STATIC_2(DepthRange,GLvoid, GLclampd,GLclampd)
66
+ GL_FUNC_STATIC_3(DrawArrays,GLvoid, GLenum,GLint,GLsizei)
67
+ GL_FUNC_STATIC_1(DrawBuffer,GLvoid, GLenum)
68
+ GL_FUNC_STATIC_1(EdgeFlag,GLvoid, GLboolean)
69
+ GL_FUNC_STATIC_1(EvalCoord1d,GLvoid, GLdouble)
70
+ GL_FUNC_STATIC_1(EvalCoord1f,GLvoid, GLfloat)
71
+ GL_FUNC_STATIC_2(EvalCoord2d,GLvoid, GLdouble,GLdouble)
72
+ GL_FUNC_STATIC_2(EvalCoord2f,GLvoid, GLfloat,GLfloat)
73
+ GL_FUNC_STATIC_3(EvalMesh1,GLvoid, GLenum,GLint,GLint)
74
+ GL_FUNC_STATIC_5(EvalMesh2,GLvoid, GLenum,GLint,GLint,GLint,GLint)
75
+ GL_FUNC_STATIC_1(EvalPoint1,GLvoid, GLint)
76
+ GL_FUNC_STATIC_2(EvalPoint2,GLvoid, GLint,GLint)
77
+ GL_FUNC_STATIC_0(Finish,GLvoid)
78
+ GL_FUNC_STATIC_0(Flush,GLvoid)
79
+ GL_FUNC_STATIC_2(Fogi,GLvoid, GLenum,GLint)
80
+ GL_FUNC_STATIC_2(Fogf,GLvoid, GLenum,GLfloat)
81
+ GL_FUNC_STATIC_1(FrontFace,GLvoid, GLenum)
82
+ GL_FUNC_STATIC_6(Frustum,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble)
83
+ GL_FUNC_STATIC_1(GenLists,GLuint, GLsizei)
84
+ GL_FUNC_STATIC_0(GetError,GLenum)
85
+ GL_FUNC_STATIC_2(Hint,GLvoid, GLenum,GLenum)
86
+ GL_FUNC_STATIC_1(Indexd,GLvoid, GLdouble)
87
+ GL_FUNC_STATIC_1(Indexf,GLvoid, GLfloat)
88
+ GL_FUNC_STATIC_1(Indexi,GLvoid, GLint)
89
+ GL_FUNC_STATIC_1(IndexMask,GLvoid, GLuint)
90
+ GL_FUNC_STATIC_1(Indexs,GLvoid, GLshort)
91
+ GL_FUNC_STATIC_1(Indexub,GLvoid, GLubyte)
92
+ GL_FUNC_STATIC_0(InitNames,GLvoid)
93
+ GL_FUNC_STATIC_1(IsEnabled,GLboolean, GLenum)
94
+ GL_FUNC_STATIC_1(IsList,GLboolean, GLuint)
95
+ GL_FUNC_STATIC_1(IsTexture,GLboolean, GLuint)
96
+ GL_FUNC_STATIC_2(LightModelf,GLvoid, GLenum,GLfloat)
97
+ GL_FUNC_STATIC_2(LightModeli,GLvoid, GLenum,GLint)
98
+ GL_FUNC_STATIC_3(Lightf,GLvoid, GLenum,GLenum,GLfloat)
99
+ GL_FUNC_STATIC_3(Lighti,GLvoid, GLenum,GLenum,GLint)
100
+ GL_FUNC_STATIC_2(LineStipple,GLvoid, GLint,GLushort)
101
+ GL_FUNC_STATIC_1(LineWidth,GLvoid, GLfloat)
102
+ GL_FUNC_STATIC_1(ListBase,GLvoid, GLuint)
103
+ GL_FUNC_STATIC_0(LoadIdentity,GLvoid)
104
+ GL_FUNC_STATIC_1(LoadName,GLvoid, GLuint)
105
+ GL_FUNC_STATIC_1(LogicOp,GLvoid, GLenum)
106
+ GL_FUNC_STATIC_3(MapGrid1d,GLvoid, GLint,GLdouble,GLdouble)
107
+ GL_FUNC_STATIC_3(MapGrid1f,GLvoid, GLint,GLfloat,GLfloat)
108
+ GL_FUNC_STATIC_6(MapGrid2d,GLvoid, GLint,GLdouble,GLdouble,GLint,GLdouble,GLdouble)
109
+ GL_FUNC_STATIC_6(MapGrid2f,GLvoid, GLint,GLfloat,GLfloat,GLint,GLfloat,GLfloat)
110
+ GL_FUNC_STATIC_3(Materialf,GLvoid, GLenum,GLenum,GLfloat)
111
+ GL_FUNC_STATIC_3(Materiali,GLvoid, GLenum,GLenum,GLint)
112
+ GL_FUNC_STATIC_1(MatrixMode,GLvoid, GLenum)
113
+ GL_FUNC_STATIC_3(Normal3b,GLvoid, GLbyte,GLbyte,GLbyte)
114
+ GL_FUNC_STATIC_3(Normal3d,GLvoid, GLdouble,GLdouble,GLdouble)
115
+ GL_FUNC_STATIC_3(Normal3f,GLvoid, GLfloat,GLfloat,GLfloat)
116
+ GL_FUNC_STATIC_3(Normal3i,GLvoid, GLint,GLint,GLint)
117
+ GL_FUNC_STATIC_3(Normal3s,GLvoid, GLshort,GLshort,GLshort)
118
+ GL_FUNC_STATIC_6(Ortho,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble)
119
+ GL_FUNC_STATIC_1(PassThrough,GLvoid, GLfloat)
120
+ GL_FUNC_STATIC_2(PixelStoref,GLvoid, GLenum,GLfloat)
121
+ GL_FUNC_STATIC_2(PixelStorei,GLvoid, GLenum,GLint)
122
+ GL_FUNC_STATIC_2(PixelTransferf,GLvoid, GLenum,GLfloat)
123
+ GL_FUNC_STATIC_2(PixelTransferi,GLvoid, GLenum,GLint)
124
+ GL_FUNC_STATIC_2(PixelZoom,GLvoid, GLfloat,GLfloat)
125
+ GL_FUNC_STATIC_1(PointSize,GLvoid, GLfloat)
126
+ GL_FUNC_STATIC_2(PolygonMode,GLvoid, GLenum,GLenum)
127
+ GL_FUNC_STATIC_2(PolygonOffset,GLvoid, GLfloat,GLfloat)
128
+ GL_FUNC_STATIC_0(PopAttrib,GLvoid)
129
+ GL_FUNC_STATIC_0(PopClientAttrib,GLvoid)
130
+ GL_FUNC_STATIC_0(PopName,GLvoid)
131
+ GL_FUNC_STATIC_1(PushAttrib,GLvoid, GLbitfield)
132
+ GL_FUNC_STATIC_1(PushClientAttrib,GLvoid, GLbitfield)
133
+ GL_FUNC_STATIC_1(PushName,GLvoid, GLuint)
134
+ GL_FUNC_STATIC_2(RasterPos2d,GLvoid, GLdouble,GLdouble)
135
+ GL_FUNC_STATIC_2(RasterPos2f,GLvoid, GLfloat,GLfloat)
136
+ GL_FUNC_STATIC_2(RasterPos2i,GLvoid, GLint,GLint)
137
+ GL_FUNC_STATIC_2(RasterPos2s,GLvoid, GLshort,GLshort)
138
+ GL_FUNC_STATIC_3(RasterPos3d,GLvoid, GLdouble,GLdouble,GLdouble)
139
+ GL_FUNC_STATIC_3(RasterPos3f,GLvoid, GLfloat,GLfloat,GLfloat)
140
+ GL_FUNC_STATIC_3(RasterPos3i,GLvoid, GLint,GLint,GLint)
141
+ GL_FUNC_STATIC_3(RasterPos3s,GLvoid, GLshort,GLshort,GLshort)
142
+ GL_FUNC_STATIC_4(RasterPos4d,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble)
143
+ GL_FUNC_STATIC_4(RasterPos4f,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
144
+ GL_FUNC_STATIC_4(RasterPos4i,GLvoid, GLint,GLint,GLint,GLint)
145
+ GL_FUNC_STATIC_4(RasterPos4s,GLvoid, GLshort,GLshort,GLshort,GLshort)
146
+ GL_FUNC_STATIC_1(ReadBuffer,GLvoid, GLenum)
147
+ GL_FUNC_STATIC_4(Rectd,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble)
148
+ GL_FUNC_STATIC_4(Rectf,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
149
+ GL_FUNC_STATIC_4(Recti,GLvoid, GLint,GLint,GLint,GLint)
150
+ GL_FUNC_STATIC_4(Rects,GLvoid, GLshort,GLshort,GLshort,GLshort)
151
+ GL_FUNC_STATIC_1(RenderMode,GLint, GLenum)
152
+ GL_FUNC_STATIC_4(Rotated,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble)
153
+ GL_FUNC_STATIC_4(Rotatef,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
154
+ GL_FUNC_STATIC_3(Scaled,GLvoid, GLdouble,GLdouble,GLdouble)
155
+ GL_FUNC_STATIC_3(Scalef,GLvoid, GLfloat,GLfloat,GLfloat)
156
+ GL_FUNC_STATIC_4(Scissor,GLvoid, GLint,GLint,GLint,GLint)
157
+ GL_FUNC_STATIC_1(ShadeModel,GLvoid, GLenum)
158
+ GL_FUNC_STATIC_3(StencilFunc,GLvoid, GLenum,GLint,GLuint)
159
+ GL_FUNC_STATIC_1(StencilMask,GLvoid, GLuint)
160
+ GL_FUNC_STATIC_3(StencilOp,GLvoid, GLenum,GLenum,GLenum)
161
+ GL_FUNC_STATIC_1(TexCoord1d,GLvoid, GLdouble)
162
+ GL_FUNC_STATIC_1(TexCoord1f,GLvoid, GLfloat)
163
+ GL_FUNC_STATIC_1(TexCoord1i,GLvoid, GLint)
164
+ GL_FUNC_STATIC_1(TexCoord1s,GLvoid, GLshort)
165
+ GL_FUNC_STATIC_2(TexCoord2d,GLvoid, GLdouble,GLdouble)
166
+ GL_FUNC_STATIC_2(TexCoord2f,GLvoid, GLfloat,GLfloat)
167
+ GL_FUNC_STATIC_2(TexCoord2i,GLvoid, GLint,GLint)
168
+ GL_FUNC_STATIC_2(TexCoord2s,GLvoid, GLshort,GLshort)
169
+ GL_FUNC_STATIC_3(TexCoord3d,GLvoid, GLdouble,GLdouble,GLdouble)
170
+ GL_FUNC_STATIC_3(TexCoord3f,GLvoid, GLfloat,GLfloat,GLfloat)
171
+ GL_FUNC_STATIC_3(TexCoord3i,GLvoid, GLint,GLint,GLint)
172
+ GL_FUNC_STATIC_3(TexCoord3s,GLvoid, GLshort,GLshort,GLshort)
173
+ GL_FUNC_STATIC_4(TexCoord4d,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble)
174
+ GL_FUNC_STATIC_4(TexCoord4f,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
175
+ GL_FUNC_STATIC_4(TexCoord4i,GLvoid, GLint,GLint,GLint,GLint)
176
+ GL_FUNC_STATIC_4(TexCoord4s,GLvoid, GLshort,GLshort,GLshort,GLshort)
177
+ GL_FUNC_STATIC_3(TexEnvf,GLvoid, GLenum,GLenum,GLfloat)
178
+ GL_FUNC_STATIC_3(TexEnvi,GLvoid, GLenum,GLenum,GLint)
179
+ GL_FUNC_STATIC_3(TexGend,GLvoid, GLenum,GLenum,GLdouble)
180
+ GL_FUNC_STATIC_3(TexGenf,GLvoid, GLenum,GLenum,GLfloat)
181
+ GL_FUNC_STATIC_3(TexGeni,GLvoid, GLenum,GLenum,GLint)
182
+ GL_FUNC_STATIC_3(TexParameterf,GLvoid, GLenum,GLenum,GLfloat)
183
+ GL_FUNC_STATIC_3(TexParameteri,GLvoid, GLenum,GLenum,GLint)
184
+ GL_FUNC_STATIC_3(Translated,GLvoid, GLdouble,GLdouble,GLdouble)
185
+ GL_FUNC_STATIC_3(Translatef,GLvoid, GLfloat,GLfloat,GLfloat)
186
+ GL_FUNC_STATIC_2(Vertex2d,GLvoid, GLdouble,GLdouble)
187
+ GL_FUNC_STATIC_2(Vertex2f,GLvoid, GLfloat,GLfloat)
188
+ GL_FUNC_STATIC_2(Vertex2i,GLvoid, GLint,GLint)
189
+ GL_FUNC_STATIC_2(Vertex2s,GLvoid, GLshort,GLshort)
190
+ GL_FUNC_STATIC_3(Vertex3d,GLvoid, GLdouble,GLdouble,GLdouble)
191
+ GL_FUNC_STATIC_3(Vertex3f,GLvoid, GLfloat,GLfloat,GLfloat)
192
+ GL_FUNC_STATIC_3(Vertex3i,GLvoid, GLint,GLint,GLint)
193
+ GL_FUNC_STATIC_3(Vertex3s,GLvoid, GLshort,GLshort,GLshort)
194
+ GL_FUNC_STATIC_4(Vertex4d,GLvoid, GLdouble,GLdouble,GLdouble,GLdouble)
195
+ GL_FUNC_STATIC_4(Vertex4f,GLvoid, GLfloat,GLfloat,GLfloat,GLfloat)
196
+ GL_FUNC_STATIC_4(Vertex4i,GLvoid, GLint,GLint,GLint,GLint)
197
+ GL_FUNC_STATIC_4(Vertex4s,GLvoid, GLshort,GLshort,GLshort,GLshort)
198
+ GL_FUNC_STATIC_4(Viewport,GLvoid, GLuint,GLuint,GLuint,GLuint)
199
+
200
+ struct gl_endisable_args {
201
+ VALUE obj;
202
+ VALUE caps;
203
+ };
204
+
205
+ static VALUE
206
+ gl_Enable1(struct gl_endisable_args *args)
207
+ {
208
+ long i;
209
+ VALUE obj = args->obj;
210
+ DECL_GL_FUNC_PTR(void,glEnable,(GLenum cap));
211
+
212
+ LOAD_GL_FUNC(glEnable, NULL);
213
+ for (i = 0; i < RARRAY_LEN(args->caps); i++) {
214
+ fptr_glEnable(CONV_GLenum(rb_ary_entry(args->caps, i)));
215
+
216
+ CHECK_GLERROR_FROM("glEnable");
217
+ }
218
+
219
+ return Qnil;
220
+ }
221
+
222
+ static VALUE
223
+ gl_Enable0(struct gl_endisable_args *args)
224
+ {
225
+ gl_Enable1(args);
226
+
227
+ if (rb_block_given_p())
228
+ rb_yield(Qundef);
229
+
230
+ return Qnil;
231
+ }
232
+
233
+ static VALUE
234
+ gl_Disable1(struct gl_endisable_args *args)
235
+ {
236
+ long i;
237
+ VALUE obj = args->obj;
238
+ DECL_GL_FUNC_PTR(void,glDisable,(GLenum cap));
239
+
240
+ LOAD_GL_FUNC(glDisable, NULL);
241
+ for (i = 0; i < RARRAY_LEN(args->caps); i++) {
242
+ fptr_glDisable(CONV_GLenum(rb_ary_entry(args->caps, i)));
243
+
244
+ CHECK_GLERROR_FROM("glDisable");
245
+ }
246
+
247
+ return Qnil;
248
+ }
249
+
250
+ static VALUE
251
+ gl_Disable0(struct gl_endisable_args *args)
252
+ {
253
+ gl_Disable1(args);
254
+
255
+ if (rb_block_given_p())
256
+ rb_yield(Qundef);
257
+
258
+ return Qnil;
259
+ }
260
+
261
+ static VALUE
262
+ gl_Enable(int argc, VALUE *argv, VALUE obj)
263
+ {
264
+ int i;
265
+ VALUE caps, rev;
266
+
267
+ rb_scan_args(argc, argv, "1*", NULL, NULL);
268
+
269
+ caps = rb_ary_new2(argc);
270
+
271
+ for (i = 0; i < argc; i++)
272
+ rb_ary_push(caps, argv[i]);
273
+
274
+ rev = rb_ary_reverse(caps);
275
+
276
+ if (rb_block_given_p()){
277
+ struct gl_endisable_args enargs = { obj, caps };
278
+ struct gl_endisable_args disargs = { obj, rev };
279
+ return rb_ensure(gl_Enable0, (VALUE)&enargs, gl_Disable1, (VALUE)&disargs);
280
+ } else {
281
+ struct gl_endisable_args args = { obj, caps };
282
+ gl_Enable0(&args);
283
+ }
284
+
285
+ return Qnil;
286
+ }
287
+
288
+ static VALUE
289
+ gl_Disable(int argc, VALUE *argv, VALUE obj)
290
+ {
291
+ int i;
292
+ VALUE caps, rev;
293
+
294
+ rb_scan_args(argc, argv, "1*", NULL, NULL);
295
+
296
+ caps = rb_ary_new2(argc);
297
+
298
+ for (i = 0; i < argc; i++)
299
+ rb_ary_push(caps, argv[i]);
300
+
301
+ rev = rb_ary_reverse(caps);
302
+
303
+ if (rb_block_given_p()){
304
+ struct gl_endisable_args disargs = { obj, caps };
305
+ struct gl_endisable_args enargs = { obj, rev };
306
+ return rb_ensure(gl_Disable0, (VALUE)&disargs, gl_Enable1, (VALUE)&enargs);
307
+ } else {
308
+ struct gl_endisable_args args = { obj, caps };
309
+ gl_Disable0(&args);
310
+ }
311
+
312
+ return Qnil;
313
+ }
314
+
315
+ struct gl_client_state_args {
316
+ VALUE obj;
317
+ VALUE ary;
318
+ };
319
+
320
+ static VALUE
321
+ gl_EnableClientState1(struct gl_client_state_args *args)
322
+ {
323
+ long i;
324
+ VALUE obj = args->obj;
325
+ DECL_GL_FUNC_PTR(void,glEnableClientState,(GLenum cap));
326
+
327
+ LOAD_GL_FUNC(glEnableClientState, NULL);
328
+ for (i = 0; i < RARRAY_LEN(args->ary); i++) {
329
+ fptr_glEnableClientState(CONV_GLenum(rb_ary_entry(args->ary, i)));
330
+
331
+ CHECK_GLERROR_FROM("glEnableClientState");
332
+ }
333
+
334
+ return Qnil;
335
+ }
336
+
337
+ static VALUE
338
+ gl_EnableClientState0(struct gl_client_state_args *args)
339
+ {
340
+ gl_EnableClientState1(args);
341
+
342
+ if (rb_block_given_p())
343
+ rb_yield(Qundef);
344
+
345
+ return Qnil;
346
+ }
347
+
348
+ static VALUE
349
+ gl_DisableClientState1(struct gl_client_state_args *args)
350
+ {
351
+ long i;
352
+ VALUE obj = args->obj;
353
+ DECL_GL_FUNC_PTR(void,glDisableClientState,(GLenum cap));
354
+
355
+ LOAD_GL_FUNC(glDisableClientState, NULL);
356
+ for (i = 0; i < RARRAY_LEN(args->ary); i++) {
357
+ fptr_glDisableClientState(CONV_GLenum(rb_ary_entry(args->ary, i)));
358
+
359
+ CHECK_GLERROR_FROM("glDisableClientState");
360
+ }
361
+
362
+ return Qnil;
363
+ }
364
+
365
+ static VALUE
366
+ gl_DisableClientState0(struct gl_client_state_args *args)
367
+ {
368
+ gl_DisableClientState1(args);
369
+
370
+ if (rb_block_given_p())
371
+ rb_yield(Qundef);
372
+
373
+ return Qnil;
374
+ }
375
+
376
+ static VALUE
377
+ gl_EnableClientState(int argc, VALUE *argv, VALUE obj)
378
+ {
379
+ int i;
380
+ VALUE ary, rev;
381
+
382
+ rb_scan_args(argc, argv, "1*", NULL, NULL);
383
+
384
+ ary = rb_ary_new2(argc);
385
+
386
+ for (i = 0; i < argc; i++)
387
+ rb_ary_push(ary, argv[i]);
388
+
389
+ rev = rb_ary_reverse(ary);
390
+
391
+ if (rb_block_given_p()){
392
+ struct gl_client_state_args enargs = { obj, ary };
393
+ struct gl_client_state_args disargs = { obj, rev };
394
+ return rb_ensure(gl_EnableClientState0, (VALUE)&enargs, gl_DisableClientState1, (VALUE)&disargs);
395
+ } else {
396
+ struct gl_client_state_args args = { obj, ary };
397
+ gl_EnableClientState0(&args);
398
+ }
399
+
400
+ return Qnil;
401
+ }
402
+
403
+ static VALUE
404
+ gl_DisableClientState(int argc, VALUE *argv, VALUE obj)
405
+ {
406
+ int i;
407
+ VALUE ary, rev;
408
+
409
+ rb_scan_args(argc, argv, "1*", NULL, NULL);
410
+
411
+ ary = rb_ary_new2(argc);
412
+
413
+ for (i = 0; i < argc; i++)
414
+ rb_ary_push(ary, argv[i]);
415
+
416
+ rev = rb_ary_reverse(ary);
417
+
418
+ if (rb_block_given_p()){
419
+ struct gl_client_state_args disargs = { obj, ary };
420
+ struct gl_client_state_args enargs = { obj, rev };
421
+ return rb_ensure(gl_DisableClientState0, (VALUE)&disargs, gl_EnableClientState1, (VALUE)&enargs);
422
+ } else {
423
+ struct gl_client_state_args args = { obj, ary };
424
+ gl_DisableClientState0(&args);
425
+ }
426
+
427
+ return Qnil;
428
+ }
429
+
430
+ struct gl_begin0_args {
431
+ VALUE obj;
432
+ GLenum mode;
433
+ };
434
+
435
+ static VALUE
436
+ gl_Begin0(struct gl_begin0_args *args)
437
+ {
438
+ VALUE obj = args->obj;
439
+ DECL_GL_FUNC_PTR(void,glBegin,(GLenum mode));
440
+
441
+ LOAD_GL_FUNC(glBegin, NULL);
442
+ fptr_glBegin(args->mode);
443
+
444
+ if (rb_block_given_p())
445
+ rb_yield(Qundef);
446
+
447
+ return Qnil;
448
+ }
449
+
450
+ static VALUE
451
+ gl_End(VALUE obj)
452
+ {
453
+ DECL_GL_FUNC_PTR(void,glEnd,(void));
454
+
455
+ LOAD_GL_FUNC(glEnd, NULL);
456
+ SET_GLIMPL_VARIABLE(inside_begin_end, Qfalse);
457
+
458
+ fptr_glEnd();
459
+
460
+ CHECK_GLERROR_FROM("glEnd");
461
+
462
+ return Qnil;
463
+ }
464
+
465
+ static VALUE
466
+ gl_Begin(VALUE obj, VALUE mode)
467
+ {
468
+ struct gl_begin0_args args = { obj, CONV_GLenum(mode) };
469
+
470
+ SET_GLIMPL_VARIABLE(inside_begin_end, Qtrue);
471
+
472
+ if (rb_block_given_p())
473
+ return rb_ensure(gl_Begin0, (VALUE)&args, gl_End, obj);
474
+ else
475
+ gl_Begin0(&args);
476
+
477
+ return Qnil;
478
+ }
479
+
480
+ static VALUE
481
+ gl_PopMatrix(VALUE obj)
482
+ {
483
+ DECL_GL_FUNC_PTR(void,glPopMatrix,(void));
484
+
485
+ LOAD_GL_FUNC(glPopMatrix, NULL);
486
+ fptr_glPopMatrix();
487
+
488
+ CHECK_GLERROR_FROM("glPopMatrix");
489
+
490
+ return Qnil;
491
+ }
492
+
493
+ static VALUE
494
+ gl_PushMatrix0(VALUE obj)
495
+ {
496
+ DECL_GL_FUNC_PTR(void,glPushMatrix,(void));
497
+
498
+ LOAD_GL_FUNC(glPushMatrix, NULL);
499
+ fptr_glPushMatrix();
500
+
501
+ if (rb_block_given_p())
502
+ rb_yield(Qnil);
503
+
504
+ return Qnil;
505
+ }
506
+
507
+ static VALUE
508
+ gl_PushMatrix(VALUE obj)
509
+ {
510
+ if (rb_block_given_p())
511
+ return rb_ensure(gl_PushMatrix0, obj, gl_PopMatrix, obj);
512
+ else {
513
+ DECL_GL_FUNC_PTR(void,glPushMatrix,(void));
514
+ LOAD_GL_FUNC(glPushMatrix, NULL);
515
+ fptr_glPushMatrix();
516
+ }
517
+
518
+ return Qnil;
519
+ }
520
+
521
+ struct gl_list_args {
522
+ VALUE obj;
523
+ VALUE list;
524
+ VALUE mode;
525
+ };
526
+
527
+ static VALUE
528
+ gl_NewList0(struct gl_list_args *args)
529
+ {
530
+ GLuint list;
531
+ GLenum mode;
532
+ VALUE obj = args->obj;
533
+ DECL_GL_FUNC_PTR(void,glNewList,(GLuint list, GLenum mode));
534
+
535
+ LOAD_GL_FUNC(glNewList, NULL);
536
+ list = (GLuint)NUM2UINT(args->list);
537
+ mode = RUBY2GLENUM(args->mode);
538
+
539
+ fptr_glNewList(list, mode);
540
+
541
+ if (rb_block_given_p())
542
+ rb_yield(Qundef);
543
+
544
+ return Qnil;
545
+ }
546
+
547
+ static VALUE
548
+ gl_EndList(VALUE obj)
549
+ {
550
+ DECL_GL_FUNC_PTR(void,glEndList,(void));
551
+
552
+ LOAD_GL_FUNC(glEndList, NULL);
553
+ fptr_glEndList();
554
+
555
+ return Qnil;
556
+ }
557
+
558
+ static VALUE
559
+ gl_NewList(VALUE obj, VALUE list, VALUE mode)
560
+ {
561
+ struct gl_list_args args = { obj, list, mode };
562
+
563
+ if (rb_block_given_p())
564
+ return rb_ensure(gl_NewList0, (VALUE)&args, gl_EndList, obj);
565
+ else
566
+ gl_NewList0(&args);
567
+
568
+ return Qnil;
569
+ }
570
+
571
+ static VALUE
572
+ gl_CallLists(obj,arg1,arg2)
573
+ VALUE obj,arg1,arg2;
574
+ {
575
+ GLsizei n;
576
+ GLenum type;
577
+ VALUE lists;
578
+ DECL_GL_FUNC_PTR(GLvoid,glCallLists,(GLsizei n, GLenum type, const GLvoid *lists));
579
+
580
+ LOAD_GL_FUNC(glCallLists, NULL);
581
+ type = CONV_GLenum(arg1);
582
+ lists = pack_array_or_pass_string(type,arg2);
583
+ n = (GLsizei)RSTRING_LENINT(lists) / gltype_glformat_unit_size(type,1);
584
+ fptr_glCallLists(n, type, RSTRING_PTR(lists));
585
+ CHECK_GLERROR_FROM("glCallLists");
586
+ return Qnil;
587
+ }
588
+
589
+ static VALUE
590
+ gl_Bitmap(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
591
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7;
592
+ {
593
+ GLsizei width;
594
+ GLsizei height;
595
+ GLfloat xorig;
596
+ GLfloat yorig;
597
+ GLfloat xmove;
598
+ GLfloat ymove;
599
+ DECL_GL_FUNC_PTR(void,glBitmap,(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap));
600
+
601
+ LOAD_GL_FUNC(glBitmap, NULL);
602
+ width = (GLsizei)NUM2UINT(arg1);
603
+ height = (GLsizei)NUM2UINT(arg2);
604
+ xorig = (GLfloat)NUM2DBL(arg3);
605
+ yorig = (GLfloat)NUM2DBL(arg4);
606
+ xmove = (GLfloat)NUM2DBL(arg5);
607
+ ymove = (GLfloat)NUM2DBL(arg6);
608
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
609
+ fptr_glBitmap(width, height, xorig, yorig, xmove, ymove, (GLubyte *)NUM2SIZET(arg7));
610
+ } else {
611
+ VALUE data;
612
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg7);
613
+
614
+ if ((RSTRING_LEN(data)*8) < (width * height))
615
+ rb_raise(rb_eArgError, "string length:%li", RSTRING_LEN(data));
616
+
617
+ fptr_glBitmap(width, height, xorig, yorig, xmove, ymove, (const GLubyte *)RSTRING_PTR(data));
618
+ }
619
+ CHECK_GLERROR_FROM("glBitmap");
620
+ return Qnil;
621
+ }
622
+
623
+ static VALUE
624
+ gl_EdgeFlagv(obj,arg1)
625
+ VALUE obj,arg1;
626
+ {
627
+ GLboolean flag[1] = { GL_FALSE };
628
+ DECL_GL_FUNC_PTR(void,glEdgeFlagv,(const GLboolean *flag));
629
+
630
+ LOAD_GL_FUNC(glEdgeFlagv, NULL);
631
+ Check_Type(arg1,T_ARRAY);
632
+ ary2cboolean(arg1,flag,1);
633
+ fptr_glEdgeFlagv(flag);
634
+ CHECK_GLERROR_FROM("glEdgeFlagv");
635
+ return Qnil;
636
+ }
637
+
638
+ static VALUE
639
+ gl_Indexdv(obj,arg1)
640
+ VALUE obj,arg1;
641
+ {
642
+ GLdouble c[1] = {0.0};
643
+ DECL_GL_FUNC_PTR(void,glIndexdv,(const GLdouble *c));
644
+
645
+ LOAD_GL_FUNC(glIndexdv, NULL);
646
+ Check_Type(arg1,T_ARRAY);
647
+ ary2cdbl(arg1,c,1);
648
+ fptr_glIndexdv(c);
649
+ CHECK_GLERROR_FROM("glIndexdv");
650
+ return Qnil;
651
+ }
652
+
653
+ static VALUE
654
+ gl_Indexfv(obj,arg1)
655
+ VALUE obj,arg1;
656
+ {
657
+ GLfloat c[1] = { (GLfloat)0.0 };
658
+ DECL_GL_FUNC_PTR(void,glIndexfv,(const GLfloat *c));
659
+
660
+ LOAD_GL_FUNC(glIndexfv, NULL);
661
+ Check_Type(arg1,T_ARRAY);
662
+ ary2cflt(arg1,c,1);
663
+ fptr_glIndexfv(c);
664
+ CHECK_GLERROR_FROM("glIndexfv");
665
+ return Qnil;
666
+ }
667
+
668
+ static VALUE
669
+ gl_Indexiv(obj,arg1)
670
+ VALUE obj,arg1;
671
+ {
672
+ GLint c[1] = {0};
673
+ DECL_GL_FUNC_PTR(void,glIndexiv,(const GLint *c));
674
+
675
+ LOAD_GL_FUNC(glIndexiv, NULL);
676
+ Check_Type(arg1,T_ARRAY);
677
+ ary2cint(arg1,c,1);
678
+ fptr_glIndexiv(c);
679
+ CHECK_GLERROR_FROM("glIndexiv");
680
+ return Qnil;
681
+ }
682
+
683
+ static VALUE
684
+ gl_Indexsv(obj,arg1)
685
+ VALUE obj,arg1;
686
+ {
687
+ GLshort c[1] = {0};
688
+ DECL_GL_FUNC_PTR(void,glIndexsv,(const GLshort *c));
689
+
690
+ LOAD_GL_FUNC(glIndexsv, NULL);
691
+ Check_Type(arg1,T_ARRAY);
692
+ ary2cshort(arg1,c,1);
693
+ fptr_glIndexsv(c);
694
+ CHECK_GLERROR_FROM("glIndexsv");
695
+ return Qnil;
696
+ }
697
+
698
+ static VALUE
699
+ gl_ClipPlane(obj,arg1,arg2)
700
+ VALUE obj,arg1,arg2;
701
+ {
702
+ GLenum plane;
703
+ GLdouble equation[4];
704
+ DECL_GL_FUNC_PTR(void,glClipPlane,(GLenum plane, const GLdouble *equation));
705
+
706
+ LOAD_GL_FUNC(glClipPlane, NULL);
707
+ plane = (GLenum)NUM2INT(arg1);
708
+ Check_Type(arg2,T_ARRAY);
709
+ ary2cdbl(arg2, equation, 4);
710
+ fptr_glClipPlane(plane,equation);
711
+ CHECK_GLERROR_FROM("glClipPlane");
712
+ return Qnil;
713
+ }
714
+
715
+ static VALUE
716
+ gl_Fogfv(obj,arg1,arg2)
717
+ VALUE obj,arg1,arg2;
718
+ {
719
+ GLenum pname;
720
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
721
+ DECL_GL_FUNC_PTR(void,glFogfv,(GLenum pname, const GLfloat *params));
722
+
723
+ LOAD_GL_FUNC(glFogfv, NULL);
724
+ pname = (GLenum)NUM2INT(arg1);
725
+ Check_Type(arg2,T_ARRAY);
726
+ ary2cflt(arg2,params,4);
727
+ fptr_glFogfv(pname,params);
728
+ CHECK_GLERROR_FROM("glFogfv");
729
+ return Qnil;
730
+ }
731
+
732
+ static VALUE
733
+ gl_Fogiv(obj,arg1,arg2)
734
+ VALUE obj,arg1,arg2;
735
+ {
736
+ GLenum pname;
737
+ GLint params[4] = {0,0,0,0};
738
+ DECL_GL_FUNC_PTR(void,glFogiv,(GLenum pname, const GLint *params));
739
+
740
+ LOAD_GL_FUNC(glFogiv, NULL);
741
+ pname = (GLenum)NUM2INT(arg1);
742
+ Check_Type(arg2,T_ARRAY);
743
+ ary2cint(arg2,params,4);
744
+ fptr_glFogiv(pname,params);
745
+ CHECK_GLERROR_FROM("glFogiv");
746
+ return Qnil;
747
+ }
748
+
749
+ static VALUE
750
+ gl_Lightfv(obj,arg1,arg2,arg3)
751
+ VALUE obj,arg1,arg2,arg3;
752
+ {
753
+ GLenum light;
754
+ GLenum pname;
755
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
756
+ DECL_GL_FUNC_PTR(void,glLightfv,(GLenum light, GLenum pname, const GLfloat *params));
757
+
758
+ LOAD_GL_FUNC(glLightfv, NULL);
759
+ light = (GLenum)NUM2INT(arg1);
760
+ pname = (GLenum)NUM2INT(arg2);
761
+ Check_Type(arg3,T_ARRAY);
762
+ ary2cflt(arg3,params,4);
763
+ fptr_glLightfv(light,pname,params);
764
+ CHECK_GLERROR_FROM("glLightfv");
765
+ return Qnil;
766
+ }
767
+
768
+ static VALUE
769
+ gl_Lightiv(obj,arg1,arg2,arg3)
770
+ VALUE obj,arg1,arg2,arg3;
771
+ {
772
+ GLenum light;
773
+ GLenum pname;
774
+ GLint params[4]={0,0,0,0};
775
+ DECL_GL_FUNC_PTR(void,glLightiv,(GLenum light, GLenum pname, const GLint *params));
776
+
777
+ LOAD_GL_FUNC(glLightiv, NULL);
778
+ light = (GLenum)NUM2INT(arg1);
779
+ pname = (GLenum)NUM2INT(arg2);
780
+ Check_Type(arg3,T_ARRAY);
781
+ ary2cint(arg3,params,4);
782
+ fptr_glLightiv(light,pname,params);
783
+ CHECK_GLERROR_FROM("glLightiv");
784
+ return Qnil;
785
+ }
786
+
787
+ static VALUE
788
+ gl_LightModelfv(obj,arg1,arg2)
789
+ VALUE obj,arg1,arg2;
790
+ {
791
+ GLenum pname;
792
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
793
+ DECL_GL_FUNC_PTR(void,glLightModelfv,(GLenum pname, const GLfloat *params));
794
+
795
+ LOAD_GL_FUNC(glLightModelfv, NULL);
796
+ pname = (GLenum)NUM2INT(arg1);
797
+ Check_Type(arg2,T_ARRAY);
798
+ ary2cflt(arg2,params,4);
799
+ fptr_glLightModelfv(pname,params);
800
+ CHECK_GLERROR_FROM("glLightModelfv");
801
+ return Qnil;
802
+ }
803
+
804
+ static VALUE
805
+ gl_LightModeliv(obj,arg1,arg2)
806
+ VALUE obj,arg1,arg2;
807
+ {
808
+ GLenum pname;
809
+ GLint params[4] = {0,0,0,0};
810
+ DECL_GL_FUNC_PTR(void,glLightModeliv,(GLenum pname, const GLint *params));
811
+
812
+ LOAD_GL_FUNC(glLightModeliv, NULL);
813
+ pname = (GLenum)NUM2INT(arg1);
814
+ Check_Type(arg2,T_ARRAY);
815
+ ary2cint(arg2,params,4);
816
+ fptr_glLightModeliv(pname,params);
817
+ CHECK_GLERROR_FROM("glLightModeliv");
818
+ return Qnil;
819
+ }
820
+
821
+
822
+ static VALUE
823
+ gl_Materialfv(obj,arg1,arg2,arg3)
824
+ VALUE obj,arg1,arg2,arg3;
825
+ {
826
+ GLenum face;
827
+ GLenum pname;
828
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
829
+ DECL_GL_FUNC_PTR(void,glMaterialfv,(GLenum face, GLenum pname, const GLfloat *params));
830
+
831
+ LOAD_GL_FUNC(glMaterialfv, NULL);
832
+ face = (GLenum)NUM2INT(arg1);
833
+ pname = (GLenum)NUM2INT(arg2);
834
+ Check_Type(arg3,T_ARRAY);
835
+ ary2cflt(arg3,params,4);
836
+ fptr_glMaterialfv(face,pname,params);
837
+ CHECK_GLERROR_FROM("glMaterialfv");
838
+ return Qnil;
839
+ }
840
+
841
+ static VALUE
842
+ gl_Materialiv(obj,arg1,arg2,arg3)
843
+ VALUE obj,arg1,arg2,arg3;
844
+ {
845
+ GLenum face;
846
+ GLenum pname;
847
+ GLint params[4] = {0,0,0,0};
848
+ DECL_GL_FUNC_PTR(void,glMaterialiv,(GLenum face, GLenum pname, const GLint *params));
849
+
850
+ LOAD_GL_FUNC(glMaterialiv, NULL);
851
+ face = (GLenum)NUM2INT(arg1);
852
+ pname = (GLenum)NUM2INT(arg2);
853
+ Check_Type(arg3,T_ARRAY);
854
+ ary2cint(arg3,params,4);
855
+ fptr_glMaterialiv(face,pname,params);
856
+ CHECK_GLERROR_FROM("glMaterialiv");
857
+ return Qnil;
858
+ }
859
+
860
+ static VALUE
861
+ gl_PolygonStipple(obj,arg1)
862
+ VALUE obj,arg1;
863
+ {
864
+ DECL_GL_FUNC_PTR(void,glPolygonStipple,(const GLubyte *mask));
865
+
866
+ LOAD_GL_FUNC(glPolygonStipple, NULL);
867
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
868
+ fptr_glPolygonStipple((GLubyte *)NUM2SIZET(arg1));
869
+ } else {
870
+ VALUE data;
871
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg1);
872
+ if (RSTRING_LEN(data) < 128)
873
+ rb_raise(rb_eArgError, "string length:%li", RSTRING_LEN(data));
874
+
875
+ fptr_glPolygonStipple((GLubyte *)RSTRING_PTR(data));
876
+ }
877
+ CHECK_GLERROR_FROM("glPolygonStipple");
878
+ return Qnil;
879
+ }
880
+
881
+
882
+ static VALUE
883
+ gl_TexParameterfv(obj,arg1,arg2,arg3)
884
+ VALUE obj,arg1,arg2,arg3;
885
+ {
886
+ GLenum target;
887
+ GLenum pname;
888
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
889
+ DECL_GL_FUNC_PTR(void,glTexParameterfv,(GLenum target, GLenum pname, const GLfloat *params));
890
+
891
+ LOAD_GL_FUNC(glTexParameterfv, NULL);
892
+ target = (GLenum)NUM2INT(arg1);
893
+ pname = (GLenum)NUM2INT(arg2);
894
+ Check_Type(arg3,T_ARRAY);
895
+ ary2cflt(arg3,params,4);
896
+ fptr_glTexParameterfv(target,pname,params);
897
+ CHECK_GLERROR_FROM("glTexParameterfv");
898
+ return Qnil;
899
+ }
900
+
901
+ static VALUE
902
+ gl_TexParameteriv(obj,arg1,arg2,arg3)
903
+ VALUE obj,arg1,arg2,arg3;
904
+ {
905
+ GLenum target;
906
+ GLenum pname;
907
+ GLint params[4] = {0,0,0,0};
908
+ DECL_GL_FUNC_PTR(void,glTexParameteriv,(GLenum target, GLenum pname, const GLint *params));
909
+
910
+ LOAD_GL_FUNC(glTexParameteriv, NULL);
911
+ target = (GLenum)NUM2INT(arg1);
912
+ pname = (GLenum)NUM2INT(arg2);
913
+ Check_Type(arg3,T_ARRAY);
914
+ ary2cint(arg3,params,4);
915
+ fptr_glTexParameteriv(target,pname,params);
916
+ CHECK_GLERROR_FROM("glTexParameteriv");
917
+ return Qnil;
918
+ }
919
+
920
+ static VALUE
921
+ gl_TexImage1D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)
922
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8;
923
+ {
924
+ GLenum target;
925
+ GLint level;
926
+ GLint components;
927
+ GLsizei width;
928
+ GLint border;
929
+ GLenum format;
930
+ GLenum type;
931
+ const char *pixels;
932
+ DECL_GL_FUNC_PTR(void,glTexImage1D,(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels));
933
+
934
+ LOAD_GL_FUNC(glTexImage1D, NULL);
935
+ target = (GLenum)NUM2INT(arg1);
936
+ level = (GLint)NUM2INT(arg2);
937
+ components = (GLint)NUM2INT(arg3);
938
+ width = (GLsizei)NUM2UINT(arg4);
939
+ border = (GLint)NUM2INT(arg5);
940
+ format = (GLenum)NUM2INT(arg6);
941
+ type = (GLenum)NUM2INT(arg7);
942
+
943
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
944
+ fptr_glTexImage1D(target,level,components,width,border,format,type,(GLvoid *)NUM2SIZET(arg8));
945
+ CHECK_GLERROR_FROM("glTexImage1D");
946
+ return Qnil;
947
+ }
948
+
949
+ if (target == GL_PROXY_TEXTURE_1D || NIL_P(arg8)) { /* proxy texture, no data read */
950
+ pixels = NULL;
951
+ } else {
952
+ VALUE data;
953
+ data = pack_array_or_pass_string(type,arg8);
954
+ CheckDataSize(type,format,width,data);
955
+ pixels = RSTRING_PTR(data);
956
+ }
957
+ fptr_glTexImage1D(target,level,components,width,border,format,type,pixels);
958
+ CHECK_GLERROR_FROM("glTexImage1D");
959
+ return Qnil;
960
+ }
961
+
962
+ static VALUE
963
+ gl_TexImage2D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
964
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
965
+ {
966
+ GLenum target;
967
+ GLint level;
968
+ GLint components;
969
+ GLsizei width;
970
+ GLsizei height;
971
+ GLint border;
972
+ GLenum format;
973
+ GLenum type;
974
+ const char *pixels;
975
+ DECL_GL_FUNC_PTR(void,glTexImage2D,(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels));
976
+
977
+ LOAD_GL_FUNC(glTexImage2D, NULL);
978
+ target = (GLenum)NUM2INT(arg1);
979
+ level = (GLint)NUM2INT(arg2);
980
+ components = (GLint)NUM2INT(arg3);
981
+ width = (GLsizei)NUM2UINT(arg4);
982
+ height = (GLsizei)NUM2UINT(arg5);
983
+ border = (GLint)NUM2INT(arg6);
984
+ format = (GLenum)NUM2INT(arg7);
985
+ type = (GLenum)NUM2INT(arg8);
986
+
987
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
988
+ fptr_glTexImage2D(target,level,components,width,height,border,format,type,(GLvoid *)NUM2SIZET(arg9));
989
+ CHECK_GLERROR_FROM("glTexImage2D");
990
+ return Qnil;
991
+ }
992
+
993
+ if (target == GL_PROXY_TEXTURE_2D || target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || target == GL_PROXY_TEXTURE_CUBE_MAP || NIL_P(arg9)) { /* proxy texture, no data read */
994
+ pixels = NULL;
995
+ } else {
996
+ VALUE data;
997
+ data = pack_array_or_pass_string(type,arg9);
998
+ CheckDataSize(type,format,width*height,data);
999
+ pixels = RSTRING_PTR(data);
1000
+ }
1001
+ fptr_glTexImage2D(target,level,components,width,height,border,format,type,pixels);
1002
+ CHECK_GLERROR_FROM("glTexImage2D");
1003
+ return Qnil;
1004
+ }
1005
+
1006
+ static VALUE
1007
+ gl_TexEnvfv(obj,arg1,arg2,arg3)
1008
+ VALUE obj,arg1,arg2,arg3;
1009
+ {
1010
+ GLenum target;
1011
+ GLenum pname;
1012
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
1013
+ DECL_GL_FUNC_PTR(void,glTexEnvfv,(GLenum target, GLenum pname, const GLfloat *params));
1014
+
1015
+ LOAD_GL_FUNC(glTexEnvfv, NULL);
1016
+ target = (GLenum)NUM2INT(arg1);
1017
+ pname = (GLenum)NUM2INT(arg2);
1018
+ Check_Type(arg3,T_ARRAY);
1019
+ ary2cflt(arg3,params,4);
1020
+ fptr_glTexEnvfv(target,pname,params);
1021
+ CHECK_GLERROR_FROM("glTexEnvfv");
1022
+ return Qnil;
1023
+ }
1024
+
1025
+ static VALUE
1026
+ gl_TexEnviv(obj,arg1,arg2,arg3)
1027
+ VALUE obj,arg1,arg2,arg3;
1028
+ {
1029
+ GLenum target;
1030
+ GLenum pname;
1031
+ GLint params[4] = {0,0,0,0};
1032
+ DECL_GL_FUNC_PTR(void,glTexEnviv,(GLenum target, GLenum pname, const GLint *params));
1033
+
1034
+ LOAD_GL_FUNC(glTexEnviv, NULL);
1035
+ target = (GLenum)NUM2INT(arg1);
1036
+ pname = (GLenum)NUM2INT(arg2);
1037
+ Check_Type(arg3,T_ARRAY);
1038
+ ary2cint(arg3,params,4);
1039
+ fptr_glTexEnviv(target,pname,params);
1040
+ CHECK_GLERROR_FROM("glTexEnviv");
1041
+ return Qnil;
1042
+ }
1043
+
1044
+
1045
+ static VALUE
1046
+ gl_TexGendv(obj,arg1,arg2,arg3)
1047
+ VALUE obj,arg1,arg2,arg3;
1048
+ {
1049
+ GLenum coord;
1050
+ GLenum pname;
1051
+ GLdouble params[4] = {0.0,0.0,0.0,0.0};
1052
+ DECL_GL_FUNC_PTR(void,glTexGendv,(GLenum coord, GLenum pname, const GLdouble *params));
1053
+
1054
+ LOAD_GL_FUNC(glTexGendv, NULL);
1055
+ coord = (GLenum)NUM2INT(arg1);
1056
+ pname = (GLenum)NUM2INT(arg2);
1057
+ Check_Type(arg3,T_ARRAY);
1058
+ ary2cdbl(arg3,params,4);
1059
+ fptr_glTexGendv(coord,pname,params);
1060
+ CHECK_GLERROR_FROM("glTexGendv");
1061
+ return Qnil;
1062
+ }
1063
+
1064
+
1065
+ static VALUE
1066
+ gl_TexGenfv(obj,arg1,arg2,arg3)
1067
+ VALUE obj,arg1,arg2,arg3;
1068
+ {
1069
+ GLenum coord;
1070
+ GLenum pname;
1071
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
1072
+ DECL_GL_FUNC_PTR(void,glTexGenfv,(GLenum coord, GLenum pname, const GLfloat *params));
1073
+
1074
+ LOAD_GL_FUNC(glTexGenfv, NULL);
1075
+ coord = (GLenum)NUM2INT(arg1);
1076
+ pname = (GLenum)NUM2INT(arg2);
1077
+ Check_Type(arg3,T_ARRAY);
1078
+ ary2cflt(arg3,params,4);
1079
+ fptr_glTexGenfv(coord,pname,params);
1080
+ CHECK_GLERROR_FROM("glTexGenfv");
1081
+ return Qnil;
1082
+ }
1083
+
1084
+
1085
+ static VALUE
1086
+ gl_TexGeniv(obj,arg1,arg2,arg3)
1087
+ VALUE obj,arg1,arg2,arg3;
1088
+ {
1089
+ GLenum coord;
1090
+ GLenum pname;
1091
+ GLint params[4] = {0,0,0,0};
1092
+ DECL_GL_FUNC_PTR(void,glTexGeniv,(GLenum coord, GLenum pname, const GLint *params));
1093
+
1094
+ LOAD_GL_FUNC(glTexGeniv, NULL);
1095
+ coord = (GLenum)NUM2INT(arg1);
1096
+ pname = (GLenum)NUM2INT(arg2);
1097
+ Check_Type(arg3,T_ARRAY);
1098
+ ary2cint(arg3,params,4);
1099
+ fptr_glTexGeniv(coord,pname,params);
1100
+ CHECK_GLERROR_FROM("glTexGeniv");
1101
+ return Qnil;
1102
+ }
1103
+ static VALUE
1104
+ gl_FeedbackBuffer(obj,arg1,arg2)
1105
+ VALUE obj,arg1,arg2;
1106
+ {
1107
+ GLsizei size;
1108
+ GLenum type;
1109
+ VALUE current_feed_buffer;
1110
+ DECL_GL_FUNC_PTR(void,glFeedbackBuffer,(GLsizei size, GLenum type, GLfloat *buffer));
1111
+
1112
+ LOAD_GL_FUNC(glFeedbackBuffer, NULL);
1113
+ size = (GLsizei)NUM2UINT(arg1);
1114
+ type = (GLenum)NUM2INT(arg2);
1115
+ current_feed_buffer = allocate_buffer_with_string(sizeof(GLfloat)*size);
1116
+ rb_str_freeze(current_feed_buffer);
1117
+ fptr_glFeedbackBuffer(size, type, (GLfloat*)RSTRING_PTR(current_feed_buffer));
1118
+ CHECK_GLERROR_FROM("glFeedbackBuffer");
1119
+ SET_GLIMPL_VARIABLE(current_feed_buffer, current_feed_buffer);
1120
+ return current_feed_buffer;
1121
+ }
1122
+
1123
+ static VALUE
1124
+ gl_SelectBuffer(obj,arg1)
1125
+ VALUE obj,arg1;
1126
+ {
1127
+ GLsizei size;
1128
+ VALUE current_sel_buffer;
1129
+ DECL_GL_FUNC_PTR(void,glSelectBuffer,(GLsizei size, GLuint *buffer));
1130
+
1131
+ LOAD_GL_FUNC(glSelectBuffer, NULL);
1132
+ size = (GLsizei)NUM2UINT(arg1);
1133
+ current_sel_buffer = allocate_buffer_with_string(sizeof(GLuint)*size);
1134
+ rb_str_freeze(current_sel_buffer);
1135
+ fptr_glSelectBuffer(size, (GLuint*)RSTRING_PTR(current_sel_buffer));
1136
+ CHECK_GLERROR_FROM("glSelectBuffer");
1137
+ SET_GLIMPL_VARIABLE(current_sel_buffer, current_sel_buffer);
1138
+ return current_sel_buffer;
1139
+ }
1140
+
1141
+
1142
+ static VALUE
1143
+ gl_Map1d(obj,arg1,arg2,arg3,arg4,arg5,arg6)
1144
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
1145
+ {
1146
+ GLenum target;
1147
+ GLdouble u1;
1148
+ GLdouble u2;
1149
+ GLint stride;
1150
+ GLint order;
1151
+ GLdouble *points;
1152
+
1153
+ VALUE work_ary;
1154
+ DECL_GL_FUNC_PTR(void,glMap1d,(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points));
1155
+
1156
+ LOAD_GL_FUNC(glMap1d, NULL);
1157
+ target = (GLenum)NUM2INT(arg1);
1158
+ u1 = (GLdouble)NUM2DBL(arg2);
1159
+ u2 = (GLdouble)NUM2DBL(arg3);
1160
+ stride = (GLint)NUM2INT(arg4);
1161
+ order = (GLint)NUM2INT(arg5);
1162
+ points = ALLOC_N(GLdouble, order*stride);
1163
+ work_ary = rb_funcall(arg6,rb_intern("flatten"),0);
1164
+ ary2cdbl(work_ary, points, order*stride);
1165
+ fptr_glMap1d(target, u1, u2, stride, order, points);
1166
+ xfree(points);
1167
+ CHECK_GLERROR_FROM("glMap1d");
1168
+ return Qnil;
1169
+ }
1170
+
1171
+ static VALUE
1172
+ gl_Map1f(obj,arg1,arg2,arg3,arg4,arg5,arg6)
1173
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
1174
+ {
1175
+ GLenum target;
1176
+ GLfloat u1;
1177
+ GLfloat u2;
1178
+ GLint stride;
1179
+ GLint order;
1180
+ GLfloat *points;
1181
+
1182
+ VALUE work_ary;
1183
+ DECL_GL_FUNC_PTR(void,glMap1f,(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points));
1184
+
1185
+ LOAD_GL_FUNC(glMap1f, NULL);
1186
+ target = (GLenum)NUM2INT(arg1);
1187
+ u1 = (GLfloat)NUM2DBL(arg2);
1188
+ u2 = (GLfloat)NUM2DBL(arg3);
1189
+ stride = (GLint)NUM2INT(arg4);
1190
+ order = (GLint)NUM2INT(arg5);
1191
+ points = ALLOC_N(GLfloat, order*stride);
1192
+ work_ary = rb_funcall(arg6,rb_intern("flatten"),0);
1193
+ ary2cflt(work_ary, points, order*stride);
1194
+ fptr_glMap1f(target, u1, u2, stride, order, points);
1195
+ xfree(points);
1196
+ CHECK_GLERROR_FROM("glMap1f");
1197
+ return Qnil;
1198
+ }
1199
+
1200
+ static VALUE
1201
+ gl_Map2d(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
1202
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10;
1203
+ {
1204
+ GLenum target;
1205
+ GLdouble u1;
1206
+ GLdouble u2;
1207
+ GLint ustride;
1208
+ GLint uorder;
1209
+ GLdouble v1;
1210
+ GLdouble v2;
1211
+ GLint vstride;
1212
+ GLint vorder;
1213
+ GLdouble *points;
1214
+
1215
+ VALUE work_ary;
1216
+ DECL_GL_FUNC_PTR(void,glMap2d,(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points));
1217
+
1218
+ LOAD_GL_FUNC(glMap2d, NULL);
1219
+ target = (GLenum)NUM2INT(arg1);
1220
+ u1 = (GLdouble)NUM2INT(arg2);
1221
+ u2 = (GLdouble)NUM2INT(arg3);
1222
+ ustride = (GLint)NUM2INT(arg4);
1223
+ uorder = (GLint)NUM2INT(arg5);
1224
+ v1 = (GLdouble)NUM2INT(arg6);
1225
+ v2 = (GLdouble)NUM2INT(arg7);
1226
+ vstride = (GLint)NUM2INT(arg8);
1227
+ vorder = (GLint)NUM2INT(arg9);
1228
+ points = ALLOC_N(GLdouble, MAX(ustride*uorder, vstride*vorder));
1229
+ work_ary = rb_funcall(arg10,rb_intern("flatten"),0);
1230
+ ary2cdbl(work_ary, points, MAX(ustride*uorder, vstride*vorder));
1231
+ fptr_glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
1232
+ xfree(points);
1233
+ CHECK_GLERROR_FROM("glMap2d");
1234
+ return Qnil;
1235
+ }
1236
+
1237
+ static VALUE
1238
+ gl_Map2f(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
1239
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10;
1240
+ {
1241
+ GLenum target;
1242
+ GLfloat u1;
1243
+ GLfloat u2;
1244
+ GLint ustride;
1245
+ GLint uorder;
1246
+ GLfloat v1;
1247
+ GLfloat v2;
1248
+ GLint vstride;
1249
+ GLint vorder;
1250
+ GLfloat *points;
1251
+
1252
+ VALUE work_ary;
1253
+ DECL_GL_FUNC_PTR(void,glMap2f,(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points));
1254
+
1255
+ LOAD_GL_FUNC(glMap2f, NULL);
1256
+ target = (GLenum)NUM2INT(arg1);
1257
+ u1 = (GLfloat)NUM2INT(arg2);
1258
+ u2 = (GLfloat)NUM2INT(arg3);
1259
+ ustride = (GLint)NUM2INT(arg4);
1260
+ uorder = (GLint)NUM2INT(arg5);
1261
+ v1 = (GLfloat)NUM2INT(arg6);
1262
+ v2 = (GLfloat)NUM2INT(arg7);
1263
+ vstride = (GLint)NUM2INT(arg8);
1264
+ vorder = (GLint)NUM2INT(arg9);
1265
+ points = ALLOC_N(GLfloat, MAX(ustride*uorder, vstride*vorder));
1266
+ work_ary = rb_funcall(arg10,rb_intern("flatten"),0);
1267
+ ary2cflt(work_ary, points, MAX(ustride*uorder, vstride*vorder));
1268
+ fptr_glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
1269
+ xfree(points);
1270
+ CHECK_GLERROR_FROM("glMap2f");
1271
+ return Qnil;
1272
+ }
1273
+
1274
+ static VALUE
1275
+ gl_EvalCoord1dv(obj,arg1)
1276
+ VALUE obj,arg1;
1277
+ {
1278
+ GLdouble params[1] = {0.0};
1279
+ DECL_GL_FUNC_PTR(void,glEvalCoord1dv,(const GLdouble *u));
1280
+
1281
+ LOAD_GL_FUNC(glEvalCoord1dv, NULL);
1282
+ Check_Type(arg1,T_ARRAY);
1283
+ ary2cdbl(arg1,params,1);
1284
+ fptr_glEvalCoord1dv(params);
1285
+ CHECK_GLERROR_FROM("glEvalCoord1dv");
1286
+ return Qnil;
1287
+ }
1288
+
1289
+ static VALUE
1290
+ gl_EvalCoord1fv(obj,arg1)
1291
+ VALUE obj,arg1;
1292
+ {
1293
+ GLfloat params[1] = {(GLfloat)0.0};
1294
+ DECL_GL_FUNC_PTR(void,glEvalCoord1fv,(const GLfloat *u));
1295
+
1296
+ LOAD_GL_FUNC(glEvalCoord1fv, NULL);
1297
+ Check_Type(arg1,T_ARRAY);
1298
+ ary2cflt(arg1,params,1);
1299
+ fptr_glEvalCoord1fv(params);
1300
+ CHECK_GLERROR_FROM("glEvalCoord1fv");
1301
+ return Qnil;
1302
+ }
1303
+
1304
+ static VALUE
1305
+ gl_EvalCoord2dv(obj,arg1)
1306
+ VALUE obj,arg1;
1307
+ {
1308
+ GLdouble params[2] = {0.0,0.0};
1309
+ DECL_GL_FUNC_PTR(void,glEvalCoord2dv,(const GLdouble *u));
1310
+
1311
+ LOAD_GL_FUNC(glEvalCoord2dv, NULL);
1312
+ Check_Type(arg1,T_ARRAY);
1313
+ ary2cdbl(arg1,params,2);
1314
+ fptr_glEvalCoord2dv(params);
1315
+ CHECK_GLERROR_FROM("glEvalCoord2fv");
1316
+ return Qnil;
1317
+ }
1318
+
1319
+ static VALUE
1320
+ gl_EvalCoord2fv(obj,arg1)
1321
+ VALUE obj,arg1;
1322
+ {
1323
+ GLfloat params[2] = {(GLfloat)0.0,(GLfloat)0.0};
1324
+ DECL_GL_FUNC_PTR(void,glEvalCoord2fv,(const GLfloat *u));
1325
+
1326
+ LOAD_GL_FUNC(glEvalCoord2fv, NULL);
1327
+ Check_Type(arg1,T_ARRAY);
1328
+ ary2cflt(arg1,params,2);
1329
+ fptr_glEvalCoord2fv(params);
1330
+ CHECK_GLERROR_FROM("glEvalCoord2fv");
1331
+ return Qnil;
1332
+ }
1333
+
1334
+
1335
+ #define GLPIXELMAP_FUNC(_type_,_vartype_,_convert_) \
1336
+ static VALUE \
1337
+ gl_PixelMap##_type_##v(argc,argv,obj) \
1338
+ int argc; \
1339
+ VALUE *argv; \
1340
+ VALUE obj; \
1341
+ { \
1342
+ GLenum map; \
1343
+ _vartype_ *values; \
1344
+ GLsizei size; \
1345
+ VALUE args[4]; \
1346
+ DECL_GL_FUNC_PTR(void,glPixelMap##_type_##v,(GLenum map, GLsizei mapsize, const _vartype_ *values)); \
1347
+ LOAD_GL_FUNC(glPixelMap##_type_##v, NULL); \
1348
+ switch(rb_scan_args(argc, argv, "21", &args[0], &args[1], &args[2])) { \
1349
+ default: \
1350
+ case 2: \
1351
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) \
1352
+ rb_raise(rb_eArgError, "Pixel unpack buffer bound, but offset argument missing"); \
1353
+ map = (GLenum)NUM2INT(args[0]); \
1354
+ Check_Type(args[1],T_ARRAY); \
1355
+ size = (int)RARRAY_LENINT(args[1]); \
1356
+ values = ALLOC_N(_vartype_,size); \
1357
+ _convert_(args[1],values,size); \
1358
+ fptr_glPixelMap##_type_##v(map,size,values); \
1359
+ xfree(values); \
1360
+ break; \
1361
+ case 3: \
1362
+ if (!CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) \
1363
+ rb_raise(rb_eArgError, "Pixel unpack buffer not bound"); \
1364
+ map = (GLenum)NUM2INT(args[0]); \
1365
+ size = (GLsizei)NUM2INT(args[1]); \
1366
+ fptr_glPixelMap##_type_##v(map,size,(GLvoid *)NUM2SIZET(args[2])); \
1367
+ break; \
1368
+ } \
1369
+ CHECK_GLERROR_FROM("glPixelMap" #_type_ "v"); \
1370
+ return Qnil; \
1371
+ }
1372
+
1373
+ GLPIXELMAP_FUNC(f,GLfloat,ary2cflt)
1374
+ GLPIXELMAP_FUNC(ui,GLuint,ary2cuint)
1375
+ GLPIXELMAP_FUNC(us,GLushort,ary2cushort)
1376
+ #undef GLPIXELMAP_FUNC
1377
+
1378
+
1379
+ static VALUE
1380
+ gl_ReadPixels(argc,argv,obj)
1381
+ int argc;
1382
+ VALUE *argv;
1383
+ VALUE obj;
1384
+ {
1385
+ GLint x;
1386
+ GLint y;
1387
+ GLsizei width;
1388
+ GLsizei height;
1389
+ int format;
1390
+ int type;
1391
+ VALUE pixels;
1392
+ VALUE args[7];
1393
+ int numargs;
1394
+ DECL_GL_FUNC_PTR(void,glReadPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels));
1395
+
1396
+ LOAD_GL_FUNC(glReadPixels, NULL);
1397
+ numargs = rb_scan_args(argc, argv, "61", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6]);
1398
+ x = (GLint)NUM2INT(args[0]);
1399
+ y = (GLint)NUM2INT(args[1]);
1400
+ width = (GLsizei)NUM2UINT(args[2]);
1401
+ height = (GLsizei)NUM2UINT(args[3]);
1402
+ format = NUM2INT(args[4]);
1403
+ type = NUM2INT(args[5]);
1404
+
1405
+ switch(numargs) {
1406
+ default:
1407
+ case 6:
1408
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING))
1409
+ rb_raise(rb_eArgError, "Pixel pack buffer bound, but offset argument missing");
1410
+ pixels = allocate_buffer_with_string(GetDataSize(type,format,width*height));
1411
+ FORCE_PIXEL_STORE_MODE
1412
+ fptr_glReadPixels(x,y,width,height,format,type,(GLvoid*)RSTRING_PTR(pixels));
1413
+ RESTORE_PIXEL_STORE_MODE
1414
+ CHECK_GLERROR_FROM("glReadPixels");
1415
+ return pixels;
1416
+ break;
1417
+ case 7:
1418
+ if (!CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING))
1419
+ rb_raise(rb_eArgError, "Pixel pack buffer not bound");
1420
+ FORCE_PIXEL_STORE_MODE
1421
+ fptr_glReadPixels(x,y,width,height,format,type,(GLvoid*)NUM2SIZET(args[6]));
1422
+ RESTORE_PIXEL_STORE_MODE
1423
+ CHECK_GLERROR_FROM("glReadPixels");
1424
+ return Qnil;
1425
+ break;
1426
+ }
1427
+ }
1428
+
1429
+ static VALUE
1430
+ gl_DrawPixels(obj,arg1,arg2,arg3,arg4,arg5)
1431
+ VALUE obj,arg1,arg2,arg3,arg4,arg5;
1432
+ {
1433
+ GLsizei width;
1434
+ GLsizei height;
1435
+ GLenum format;
1436
+ GLenum type;
1437
+ const char *pixels;
1438
+ DECL_GL_FUNC_PTR(void,glDrawPixels,(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels));
1439
+
1440
+ LOAD_GL_FUNC(glDrawPixels, NULL);
1441
+ width = (GLsizei)NUM2UINT(arg1);
1442
+ height = (GLsizei)NUM2UINT(arg2);
1443
+ format = (GLenum)NUM2INT(arg3);
1444
+ type = (GLenum)NUM2INT(arg4);
1445
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
1446
+ fptr_glDrawPixels(width,height,format,type,(GLvoid *)NUM2SIZET(arg5));
1447
+ } else {
1448
+ VALUE data;
1449
+ data = pack_array_or_pass_string(type,arg5);
1450
+ CheckDataSize(type,format,width*height,data);
1451
+ pixels = RSTRING_PTR(data);
1452
+ fptr_glDrawPixels(width,height,format,type,pixels);
1453
+ }
1454
+ CHECK_GLERROR_FROM("glDrawPixels");
1455
+ return Qnil;
1456
+ }
1457
+
1458
+ static VALUE
1459
+ gl_GetClipPlane(obj,arg1)
1460
+ VALUE obj,arg1;
1461
+ {
1462
+ GLenum plane;
1463
+ GLdouble equation[4] = {0.0,0.0,0.0,0.0};
1464
+ VALUE retary;
1465
+ int i;
1466
+ DECL_GL_FUNC_PTR(void,glGetClipPlane,(GLenum plane, GLdouble *equation));
1467
+
1468
+ LOAD_GL_FUNC(glGetClipPlane, NULL);
1469
+ plane = (GLenum)NUM2INT(arg1);
1470
+ fptr_glGetClipPlane(plane,equation);
1471
+ retary = rb_ary_new2(4);
1472
+ for(i=0;i<4;i++)
1473
+ rb_ary_push(retary, rb_float_new(equation[i]));
1474
+ CHECK_GLERROR_FROM("glGetClipPlane");
1475
+ return retary;
1476
+ }
1477
+
1478
+ #define GLGET_FUNC(_name_,_type_,_conv_) \
1479
+ static VALUE \
1480
+ gl_Get##_name_##v(obj,arg1) \
1481
+ VALUE obj,arg1; \
1482
+ { \
1483
+ GLenum pname; \
1484
+ int nitems; \
1485
+ VALUE ary, ary2; \
1486
+ int i,j; \
1487
+ _type_ items[64]; \
1488
+ DECL_GL_FUNC_PTR(void,glGet##_name_##v,(GLenum pname, _type_ *params)); \
1489
+ LOAD_GL_FUNC(glGet##_name_##v, NULL); \
1490
+ pname = NUM2INT(arg1); \
1491
+ switch(pname) { \
1492
+ case GL_ACCUM_CLEAR_VALUE: \
1493
+ case GL_BLEND_COLOR: \
1494
+ case GL_COLOR_CLEAR_VALUE: \
1495
+ case GL_COLOR_WRITEMASK: \
1496
+ case GL_CURRENT_COLOR: \
1497
+ case GL_CURRENT_RASTER_COLOR: \
1498
+ case GL_CURRENT_RASTER_POSITION: \
1499
+ case GL_CURRENT_RASTER_SECONDARY_COLOR: \
1500
+ case GL_CURRENT_RASTER_TEXTURE_COORDS: \
1501
+ case GL_CURRENT_TEXTURE_COORDS: \
1502
+ case GL_FOG_COLOR: \
1503
+ case GL_LIGHT_MODEL_AMBIENT: \
1504
+ case GL_MAP2_GRID_DOMAIN: \
1505
+ case GL_CURRENT_SECONDARY_COLOR: \
1506
+ case GL_SCISSOR_BOX: \
1507
+ case GL_TEXTURE_ENV_COLOR: \
1508
+ case GL_VIEWPORT: \
1509
+ case GL_REFERENCE_PLANE_EQUATION_SGIX: \
1510
+ case GL_FOG_OFFSET_VALUE_SGIX: \
1511
+ case GL_TEXTURE_ENV_BIAS_SGIX: \
1512
+ case GL_CULL_VERTEX_OBJECT_POSITION_EXT: \
1513
+ case GL_CULL_VERTEX_EYE_POSITION_EXT: \
1514
+ case GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX: \
1515
+ case GL_CONSTANT_COLOR0_NV: \
1516
+ case GL_CONSTANT_COLOR1_NV: \
1517
+ case GL_TEXTURE_COLOR_WRITEMASK_SGIS: \
1518
+ case GL_FLOAT_CLEAR_COLOR_VALUE_NV: \
1519
+ case GL_RGBA_SIGNED_COMPONENTS_EXT: \
1520
+ nitems = 4; \
1521
+ break; \
1522
+ case GL_CURRENT_NORMAL: \
1523
+ case GL_POINT_DISTANCE_ATTENUATION: \
1524
+ case GL_SPRITE_AXIS_SGIX: \
1525
+ case GL_SPRITE_TRANSLATION_SGIX: \
1526
+ case GL_CURRENT_RASTER_NORMAL_SGIX: \
1527
+ case GL_CURRENT_TANGENT_EXT: \
1528
+ case GL_CURRENT_BINORMAL_EXT: \
1529
+ nitems = 3; \
1530
+ break; \
1531
+ case GL_DEPTH_RANGE: \
1532
+ case GL_LINE_WIDTH_RANGE: \
1533
+ case GL_MAP1_GRID_DOMAIN: \
1534
+ case GL_MAP2_GRID_SEGMENTS: \
1535
+ case GL_MAX_VIEWPORT_DIMS: \
1536
+ case GL_POINT_SIZE_RANGE: \
1537
+ case GL_POLYGON_MODE: \
1538
+ case GL_ALIASED_LINE_WIDTH_RANGE: \
1539
+ case GL_ALIASED_POINT_SIZE_RANGE: \
1540
+ case GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX: \
1541
+ case GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX: \
1542
+ case GL_FOG_FUNC_SGIS: \
1543
+ case GL_DEPTH_BOUNDS_EXT: \
1544
+ nitems = 2; \
1545
+ break; \
1546
+ case GL_MODELVIEW_MATRIX: \
1547
+ case GL_PROJECTION_MATRIX: \
1548
+ case GL_TEXTURE_MATRIX: \
1549
+ case GL_COLOR_MATRIX: \
1550
+ case GL_TRANSPOSE_MODELVIEW_MATRIX: \
1551
+ case GL_TRANSPOSE_PROJECTION_MATRIX: \
1552
+ case GL_TRANSPOSE_TEXTURE_MATRIX: \
1553
+ case GL_TRANSPOSE_COLOR_MATRIX: \
1554
+ case GL_TRANSPOSE_CURRENT_MATRIX_ARB: \
1555
+ case GL_MODELVIEW0_ARB: \
1556
+ case GL_MODELVIEW1_ARB: \
1557
+ case GL_MODELVIEW2_ARB: \
1558
+ case GL_MODELVIEW3_ARB: \
1559
+ case GL_MODELVIEW4_ARB: \
1560
+ case GL_MODELVIEW5_ARB: \
1561
+ case GL_MODELVIEW6_ARB: \
1562
+ case GL_MODELVIEW7_ARB: \
1563
+ case GL_MODELVIEW8_ARB: \
1564
+ case GL_MODELVIEW9_ARB: \
1565
+ case GL_MODELVIEW10_ARB: \
1566
+ case GL_MODELVIEW11_ARB: \
1567
+ case GL_MODELVIEW12_ARB: \
1568
+ case GL_MODELVIEW13_ARB: \
1569
+ case GL_MODELVIEW14_ARB: \
1570
+ case GL_MODELVIEW15_ARB: \
1571
+ case GL_MODELVIEW16_ARB: \
1572
+ case GL_MODELVIEW17_ARB: \
1573
+ case GL_MODELVIEW18_ARB: \
1574
+ case GL_MODELVIEW19_ARB: \
1575
+ case GL_MODELVIEW20_ARB: \
1576
+ case GL_MODELVIEW21_ARB: \
1577
+ case GL_MODELVIEW22_ARB: \
1578
+ case GL_MODELVIEW23_ARB: \
1579
+ case GL_MODELVIEW24_ARB: \
1580
+ case GL_MODELVIEW25_ARB: \
1581
+ case GL_MODELVIEW26_ARB: \
1582
+ case GL_MODELVIEW27_ARB: \
1583
+ case GL_MODELVIEW28_ARB: \
1584
+ case GL_MODELVIEW29_ARB: \
1585
+ case GL_MODELVIEW30_ARB: \
1586
+ case GL_MODELVIEW31_ARB: \
1587
+ case GL_MATRIX_PALETTE_ARB: \
1588
+ case GL_PIXEL_TRANSFORM_2D_MATRIX_EXT: \
1589
+ case GL_MODELVIEW1_MATRIX_EXT: \
1590
+ case GL_CURRENT_MATRIX_NV: \
1591
+ fptr_glGet##_name_##v(pname, items); \
1592
+ ary = rb_ary_new2(4); \
1593
+ for (i = 0; i < 4; i++) { \
1594
+ ary2 = rb_ary_new2(4); \
1595
+ rb_ary_push(ary, ary2); \
1596
+ for (j = 0; j < 4; j++) \
1597
+ rb_ary_push(ary2, _conv_(items[i*4+j])); \
1598
+ } \
1599
+ CHECK_GLERROR_FROM("glGet" #_name_ "v"); \
1600
+ return ary; \
1601
+ case GL_POLYGON_STIPPLE: \
1602
+ fptr_glGet##_name_##v(pname, items); \
1603
+ CHECK_GLERROR_FROM("glGet" #_name_ "v"); \
1604
+ return rb_str_new((const char*)items, 32); \
1605
+ case GL_COMPRESSED_TEXTURE_FORMATS: \
1606
+ { \
1607
+ DECL_GL_FUNC_PTR(void,glGetIntegerv,(GLenum pname, GLint *params)); \
1608
+ LOAD_GL_FUNC(glGetIntegerv, NULL); \
1609
+ fptr_glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nitems); \
1610
+ CHECK_GLERROR_FROM("glGetIntegerv"); \
1611
+ if (nitems<=0||nitems>64) \
1612
+ return INT2NUM(0); \
1613
+ } \
1614
+ break; \
1615
+ default: /* size=1 */ \
1616
+ fptr_glGet##_name_##v(pname, items); \
1617
+ CHECK_GLERROR_FROM("glGet" #_name_ "v"); \
1618
+ return _conv_(items[0]); \
1619
+ } \
1620
+ fptr_glGet##_name_##v(pname, items); \
1621
+ ary = rb_ary_new2(nitems); \
1622
+ for (i = 0; i < nitems; i++) \
1623
+ rb_ary_push(ary, _conv_(items[i])); \
1624
+ CHECK_GLERROR_FROM("glGet" #_name_ "v"); \
1625
+ return ary; \
1626
+ }
1627
+
1628
+ GLGET_FUNC(Double,GLdouble,rb_float_new)
1629
+ GLGET_FUNC(Float,GLfloat,rb_float_new)
1630
+ GLGET_FUNC(Integer,GLint,INT2NUM)
1631
+ GLGET_FUNC(Boolean,GLboolean,GLBOOL2RUBY)
1632
+
1633
+ #undef GLGET_FUNC
1634
+
1635
+
1636
+ static VALUE
1637
+ gl_GetLightfv(obj,arg1,arg2)
1638
+ VALUE obj,arg1,arg2;
1639
+ {
1640
+ GLenum light;
1641
+ GLenum pname;
1642
+ GLsizei size;
1643
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
1644
+ DECL_GL_FUNC_PTR(void,glGetLightfv,(GLenum light, GLenum pname, GLfloat *params));
1645
+
1646
+ LOAD_GL_FUNC(glGetLightfv, NULL);
1647
+ light = (GLenum)NUM2INT(arg1);
1648
+ pname = (GLenum)NUM2INT(arg2);
1649
+ switch(pname) {
1650
+ case GL_AMBIENT:
1651
+ case GL_DIFFUSE:
1652
+ case GL_SPECULAR:
1653
+ case GL_POSITION:
1654
+ size = 4;
1655
+ break;
1656
+ case GL_SPOT_DIRECTION:
1657
+ size = 3;
1658
+ break;
1659
+ case GL_CONSTANT_ATTENUATION:
1660
+ case GL_LINEAR_ATTENUATION:
1661
+ case GL_QUADRATIC_ATTENUATION:
1662
+ case GL_SPOT_EXPONENT:
1663
+ case GL_SPOT_CUTOFF:
1664
+ size = 1;
1665
+ break;
1666
+ default:
1667
+ rb_raise(rb_eArgError, "unknown pname:%d",pname);
1668
+ break; /* not reached */
1669
+ }
1670
+ fptr_glGetLightfv(light,pname,params);
1671
+ RET_ARRAY_OR_SINGLE("glGetLightfv", size, rb_float_new, params);
1672
+ }
1673
+
1674
+ static VALUE
1675
+ gl_GetLightiv(obj,arg1,arg2)
1676
+ VALUE obj,arg1,arg2;
1677
+ {
1678
+ GLenum light;
1679
+ GLenum pname;
1680
+ GLsizei size;
1681
+ GLint params[4] = {0,0,0,0};
1682
+ DECL_GL_FUNC_PTR(void,glGetLightiv,(GLenum light, GLenum pname, GLint *params));
1683
+
1684
+ LOAD_GL_FUNC(glGetLightiv, NULL);
1685
+ light = (GLenum)NUM2INT(arg1);
1686
+ pname = (GLenum)NUM2INT(arg2);
1687
+ switch(pname) {
1688
+ case GL_AMBIENT:
1689
+ case GL_DIFFUSE:
1690
+ case GL_SPECULAR:
1691
+ case GL_POSITION:
1692
+ size = 4;
1693
+ break;
1694
+ case GL_SPOT_DIRECTION:
1695
+ size = 3;
1696
+ break;
1697
+ case GL_CONSTANT_ATTENUATION:
1698
+ case GL_LINEAR_ATTENUATION:
1699
+ case GL_QUADRATIC_ATTENUATION:
1700
+ case GL_SPOT_EXPONENT:
1701
+ case GL_SPOT_CUTOFF:
1702
+ size = 1;
1703
+ break;
1704
+ default:
1705
+ rb_raise(rb_eArgError, "unknown pname:%d",pname);
1706
+ break; /* not reached */
1707
+ }
1708
+ fptr_glGetLightiv(light,pname,params);
1709
+ RET_ARRAY_OR_SINGLE("glGetLightiv", size, INT2NUM, params);
1710
+ }
1711
+
1712
+ #define GETMAP_FUNC(_name_,_type_) \
1713
+ static VALUE \
1714
+ gl_##_name_(obj,arg1,arg2) \
1715
+ VALUE obj,arg1,arg2; \
1716
+ { \
1717
+ GLenum target; \
1718
+ GLenum query; \
1719
+ int dims; \
1720
+ int pointsize; \
1721
+ int size=0; \
1722
+ _type_ *points; \
1723
+ GLint order[2] = {0,0}; /* for GL_COEFF, [order] or [uorder,vorder] (MAP1/MAP2) */ \
1724
+ DECL_GL_FUNC_PTR(void,gl##_name_,(GLenum target, GLenum query, _type_ *v)); \
1725
+ LOAD_GL_FUNC(gl##_name_, NULL); \
1726
+ target = (GLenum)NUM2INT(arg1); \
1727
+ query = (GLenum)NUM2INT(arg2); \
1728
+ switch(target) { \
1729
+ case GL_MAP1_INDEX: \
1730
+ case GL_MAP1_TEXTURE_COORD_1: dims=1; pointsize=1; break; \
1731
+ case GL_MAP1_TEXTURE_COORD_2: dims=1; pointsize=2; break; \
1732
+ case GL_MAP1_VERTEX_3: \
1733
+ case GL_MAP1_NORMAL: \
1734
+ case GL_MAP1_TEXTURE_COORD_3: dims=1; pointsize=3; break; \
1735
+ case GL_MAP1_COLOR_4: \
1736
+ case GL_MAP1_TEXTURE_COORD_4: \
1737
+ case GL_MAP1_VERTEX_4: dims=1; pointsize=4; break; \
1738
+ case GL_MAP2_INDEX: \
1739
+ case GL_MAP2_TEXTURE_COORD_1: dims=2; pointsize=1; break; \
1740
+ case GL_MAP2_TEXTURE_COORD_2: dims=2; pointsize=2; break; \
1741
+ case GL_MAP2_VERTEX_3: \
1742
+ case GL_MAP2_NORMAL: \
1743
+ case GL_MAP2_TEXTURE_COORD_3: dims=2; pointsize=3; break; \
1744
+ case GL_MAP2_COLOR_4: \
1745
+ case GL_MAP2_TEXTURE_COORD_4: \
1746
+ case GL_MAP2_VERTEX_4: dims=2; pointsize=4; break; \
1747
+ default: \
1748
+ rb_raise(rb_eArgError, "unknown target:%d",target); \
1749
+ break; /* not reached */ \
1750
+ } \
1751
+ switch(query) { \
1752
+ case GL_ORDER: size = dims; break; \
1753
+ case GL_DOMAIN: size = dims*2; break; \
1754
+ case GL_COEFF: \
1755
+ { \
1756
+ DECL_GL_FUNC_PTR(void,glGetMapiv,(GLenum target, GLenum query, GLint *v)); \
1757
+ LOAD_GL_FUNC(glGetMapiv, NULL); \
1758
+ fptr_glGetMapiv(target,GL_ORDER,order); \
1759
+ CHECK_GLERROR_FROM("glGetMapiv"); \
1760
+ if (dims==1) \
1761
+ size = order[0] * pointsize; \
1762
+ else \
1763
+ size = (order[0]*order[1]) * pointsize; \
1764
+ } \
1765
+ break; \
1766
+ default: \
1767
+ rb_raise(rb_eArgError, "unknown target:%d",target); \
1768
+ break; /* not reached */ \
1769
+ } \
1770
+ points = ALLOC_N(_type_,size); \
1771
+ fptr_gl##_name_(target,query,points); \
1772
+ \
1773
+ RET_ARRAY_OR_SINGLE_FREE("gl" #_name_, size, RETCONV_##_type_, points); \
1774
+ }
1775
+
1776
+ GETMAP_FUNC(GetMapdv,GLdouble)
1777
+ GETMAP_FUNC(GetMapfv,GLfloat)
1778
+ GETMAP_FUNC(GetMapiv,GLint)
1779
+ #undef GETMAP_FUNC
1780
+
1781
+ static VALUE
1782
+ gl_GetMaterialfv(obj,arg1,arg2)
1783
+ VALUE obj,arg1,arg2;
1784
+ {
1785
+ GLenum face;
1786
+ GLenum pname;
1787
+ GLfloat params[4] = {(GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)0.0};
1788
+ int size;
1789
+ DECL_GL_FUNC_PTR(void,glGetMaterialfv,(GLenum face, GLenum pname, GLfloat *params));
1790
+
1791
+ LOAD_GL_FUNC(glGetMaterialfv, NULL);
1792
+ face = (GLenum)NUM2INT(arg1);
1793
+ pname = (GLenum)NUM2INT(arg2);
1794
+ switch(pname) {
1795
+ case GL_AMBIENT:
1796
+ case GL_DIFFUSE:
1797
+ case GL_SPECULAR:
1798
+ case GL_EMISSION:
1799
+ size = 4;
1800
+ break;
1801
+ case GL_COLOR_INDEXES:
1802
+ size = 3;
1803
+ break;
1804
+ case GL_SHININESS:
1805
+ size = 1;
1806
+ break;
1807
+ default:
1808
+ rb_raise(rb_eArgError, "unknown pname:%d",pname);
1809
+ break; /* not reached */
1810
+ }
1811
+ fptr_glGetMaterialfv(face,pname,params);
1812
+ RET_ARRAY_OR_SINGLE("glGetMaterialfv", size, rb_float_new, params);
1813
+ }
1814
+
1815
+ static VALUE
1816
+ gl_GetMaterialiv(obj,arg1,arg2)
1817
+ VALUE obj,arg1,arg2;
1818
+ {
1819
+ GLenum face;
1820
+ GLenum pname;
1821
+ GLint params[4] = {0,0,0,0};
1822
+ int size;
1823
+ DECL_GL_FUNC_PTR(void,glGetMaterialiv,(GLenum face, GLenum pname, GLint *params));
1824
+
1825
+ LOAD_GL_FUNC(glGetMaterialiv, NULL);
1826
+ face = (GLenum)NUM2INT(arg1);
1827
+ pname = (GLenum)NUM2INT(arg2);
1828
+ switch(pname) {
1829
+ case GL_AMBIENT:
1830
+ case GL_DIFFUSE:
1831
+ case GL_SPECULAR:
1832
+ case GL_EMISSION:
1833
+ size = 4;
1834
+ break;
1835
+ case GL_COLOR_INDEXES:
1836
+ size = 3;
1837
+ break;
1838
+ case GL_SHININESS:
1839
+ size = 1;
1840
+ break;
1841
+ default:
1842
+ rb_raise(rb_eArgError, "unknown pname:%d",pname);
1843
+ break; /* not reached */
1844
+ }
1845
+ fptr_glGetMaterialiv(face,pname,params);
1846
+ RET_ARRAY_OR_SINGLE("glGetMaterialiv", size, INT2NUM, params);
1847
+ }
1848
+
1849
+ #define GLGETPIXELMAP_FUNC(_type_,_vartype_,_convert_) \
1850
+ static VALUE \
1851
+ gl_GetPixelMap##_type_##v(argc,argv,obj) \
1852
+ int argc; \
1853
+ VALUE *argv; \
1854
+ VALUE obj; \
1855
+ { \
1856
+ GLenum map; \
1857
+ GLenum map_size; \
1858
+ GLint size = 0; \
1859
+ _vartype_ *values; \
1860
+ VALUE args[2]; \
1861
+ DECL_GL_FUNC_PTR(void,glGetPixelMap##_type_##v,(GLenum map, _vartype_ *values)); \
1862
+ LOAD_GL_FUNC(glGetPixelMap##_type_##v, NULL); \
1863
+ switch (rb_scan_args(argc, argv, "11", &args[0], &args[1])) { \
1864
+ default: \
1865
+ case 1: \
1866
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING)) \
1867
+ rb_raise(rb_eArgError, \
1868
+ "Pixel pack buffer bound, but offset argument missing"); \
1869
+ \
1870
+ map = (GLenum)NUM2INT(args[0]); \
1871
+ switch(map) { \
1872
+ case GL_PIXEL_MAP_I_TO_I: map_size=GL_PIXEL_MAP_I_TO_I_SIZE; break; \
1873
+ case GL_PIXEL_MAP_S_TO_S: map_size=GL_PIXEL_MAP_S_TO_S_SIZE; break; \
1874
+ case GL_PIXEL_MAP_I_TO_R: map_size=GL_PIXEL_MAP_I_TO_R_SIZE; break; \
1875
+ case GL_PIXEL_MAP_I_TO_G: map_size=GL_PIXEL_MAP_I_TO_G_SIZE; break; \
1876
+ case GL_PIXEL_MAP_I_TO_B: map_size=GL_PIXEL_MAP_I_TO_B_SIZE; break; \
1877
+ case GL_PIXEL_MAP_I_TO_A: map_size=GL_PIXEL_MAP_I_TO_A_SIZE; break; \
1878
+ case GL_PIXEL_MAP_R_TO_R: map_size=GL_PIXEL_MAP_R_TO_R_SIZE; break; \
1879
+ case GL_PIXEL_MAP_G_TO_G: map_size=GL_PIXEL_MAP_G_TO_G_SIZE; break; \
1880
+ case GL_PIXEL_MAP_B_TO_B: map_size=GL_PIXEL_MAP_B_TO_B_SIZE; break; \
1881
+ case GL_PIXEL_MAP_A_TO_A: map_size=GL_PIXEL_MAP_A_TO_A_SIZE; break; \
1882
+ default: \
1883
+ rb_raise(rb_eArgError, "unknown map:%d",map); \
1884
+ break; \
1885
+ } \
1886
+ { \
1887
+ DECL_GL_FUNC_PTR(void,glGetIntegerv,(GLenum pname, GLint *params)); \
1888
+ LOAD_GL_FUNC(glGetIntegerv, NULL); \
1889
+ fptr_glGetIntegerv(map_size,&size); \
1890
+ } \
1891
+ CHECK_GLERROR_FROM("glGetIntegerv"); \
1892
+ values = ALLOC_N(_vartype_,size); \
1893
+ fptr_glGetPixelMap##_type_##v(map,values); \
1894
+ RET_ARRAY_OR_SINGLE_FREE("glGetPixelMap" #_type_ "v", size, _convert_, \
1895
+ values); \
1896
+ break; \
1897
+ case 2: \
1898
+ if (!CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING)) \
1899
+ rb_raise(rb_eArgError, "Pixel pack buffer not bound"); \
1900
+ \
1901
+ map = (GLenum)NUM2INT(args[0]); \
1902
+ fptr_glGetPixelMap##_type_##v(map,(GLvoid*)NUM2SIZET(args[1])); \
1903
+ CHECK_GLERROR_FROM("glGetPixelMap" #_type_ "v"); \
1904
+ return Qnil; \
1905
+ } \
1906
+ }
1907
+
1908
+ GLGETPIXELMAP_FUNC(f,GLfloat,rb_float_new)
1909
+ GLGETPIXELMAP_FUNC(ui,GLuint,INT2NUM)
1910
+ GLGETPIXELMAP_FUNC(us,GLushort,INT2NUM)
1911
+ #undef GLGETPIXELMAP_FUNC
1912
+
1913
+ static VALUE
1914
+ gl_GetPolygonStipple(argc,argv,obj)
1915
+ int argc;
1916
+ VALUE *argv;
1917
+ VALUE obj;
1918
+ {
1919
+ VALUE args[1];
1920
+ GLubyte mask[128];
1921
+ DECL_GL_FUNC_PTR(void,glGetPolygonStipple,(GLubyte *mask));
1922
+
1923
+ LOAD_GL_FUNC(glGetPolygonStipple, NULL);
1924
+ switch(rb_scan_args(argc, argv, "01", &args[0])) {
1925
+ default:
1926
+ case 0:
1927
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING))
1928
+ rb_raise(rb_eArgError, "Pixel pack buffer bound, but offset argument missing");
1929
+ memset(mask, 0x0, sizeof(GLubyte)*128);
1930
+ FORCE_PIXEL_STORE_MODE
1931
+ fptr_glGetPolygonStipple(mask);
1932
+ RESTORE_PIXEL_STORE_MODE
1933
+ CHECK_GLERROR_FROM("glGetPolygonStipple");
1934
+ return rb_str_new((const char*)mask, 128);
1935
+ case 1:
1936
+ if (!CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING))
1937
+ rb_raise(rb_eArgError, "Pixel pack buffer not bound");
1938
+ fptr_glGetPolygonStipple((GLvoid *)NUM2SIZET(args[0]));
1939
+ CHECK_GLERROR_FROM("glGetPolygonStipple");
1940
+ return Qnil;
1941
+ }
1942
+ }
1943
+
1944
+ static VALUE
1945
+ gl_GetString(obj,arg1)
1946
+ VALUE obj,arg1;
1947
+ {
1948
+ GLenum name;
1949
+ const GLubyte *ret;
1950
+ DECL_GL_FUNC_PTR(const GLubyte *,glGetString,(GLenum name));
1951
+
1952
+ LOAD_GL_FUNC(glGetString, NULL);
1953
+ name = (GLenum)NUM2INT(arg1);
1954
+ ret = fptr_glGetString(name);
1955
+ CHECK_GLERROR_FROM("glGetString");