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,57 @@
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
+ #define UNIFORMMATRIX_FUNC(_x_,_y_) \
19
+ static VALUE \
20
+ gl_UniformMatrix##_x_##x##_y_##fv(obj,arg1,arg2,arg3) \
21
+ VALUE obj,arg1,arg2,arg3; \
22
+ { \
23
+ GLint location; \
24
+ GLsizei count; \
25
+ GLboolean transpose; \
26
+ GLfloat *value; \
27
+ DECL_GL_FUNC_PTR(GLvoid,glUniformMatrix##_x_##x##_y_##fv,(GLint,GLsizei,GLboolean,GLfloat *)); \
28
+ LOAD_GL_FUNC(glUniformMatrix##_x_##x##_y_##fv,"2.1"); \
29
+ location = (GLint)NUM2INT(arg1); \
30
+ count = (GLsizei)RARRAY_LENINT(rb_funcall(rb_Array(arg3),rb_intern("flatten"),0)); \
31
+ transpose = (GLboolean)RUBYBOOL2GL(arg2); \
32
+ value = ALLOC_N(GLfloat, count); \
33
+ ary2cmatfloatcount(arg3,value, _x_, _y_); \
34
+ fptr_glUniformMatrix##_x_##x##_y_##fv(location,count /(_x_ * _y_),transpose,value); \
35
+ xfree(value); \
36
+ CHECK_GLERROR_FROM("glUniformMatrix" #_x_ "x" #_y_ "fv"); \
37
+ return Qnil; \
38
+ }
39
+
40
+ UNIFORMMATRIX_FUNC(2,3)
41
+ UNIFORMMATRIX_FUNC(3,2)
42
+ UNIFORMMATRIX_FUNC(2,4)
43
+ UNIFORMMATRIX_FUNC(4,2)
44
+ UNIFORMMATRIX_FUNC(3,4)
45
+ UNIFORMMATRIX_FUNC(4,3)
46
+
47
+ #undef UNIFORMMATRIX_FUNC
48
+
49
+ void gl_init_functions_2_1(VALUE klass)
50
+ {
51
+ rb_define_method(klass, "glUniformMatrix2x3fv", gl_UniformMatrix2x3fv, 3);
52
+ rb_define_method(klass, "glUniformMatrix3x2fv", gl_UniformMatrix3x2fv, 3);
53
+ rb_define_method(klass, "glUniformMatrix2x4fv", gl_UniformMatrix2x4fv, 3);
54
+ rb_define_method(klass, "glUniformMatrix4x2fv", gl_UniformMatrix4x2fv, 3);
55
+ rb_define_method(klass, "glUniformMatrix3x4fv", gl_UniformMatrix3x4fv, 3);
56
+ rb_define_method(klass, "glUniformMatrix4x3fv", gl_UniformMatrix4x3fv, 3);
57
+ }
@@ -0,0 +1,502 @@
1
+ /*
2
+ * Copyright (C) 2013 Blaž Hrastnik <speed.the.bboy@gmail.com>
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
+ /*
19
+ GL_APPLE_flush_buffer_range -> actually ARB_map_buffer_range
20
+
21
+ GL_EXT_framebuffer_object -> GL_ARB_framebuffer_object
22
+
23
+ GL_NV_half_float
24
+
25
+ GL_EXT_transform_feedback
26
+
27
+ -- New commands in OpenGL 3.0:
28
+
29
+ ClearBufferiv(buffer, drawbuffer, value)
30
+ return void
31
+ param buffer GLenum in value
32
+ param drawbuffer DrawBufferName in value
33
+ param value Int32 in array [COMPSIZE(buffer)]
34
+
35
+ ClearBufferuiv(buffer, drawbuffer, value)
36
+ return void
37
+ param buffer GLenum in value
38
+ param drawbuffer DrawBufferName in value
39
+ param value UInt32 in array [COMPSIZE(buffer)]
40
+
41
+ ClearBufferfv(buffer, drawbuffer, value)
42
+ return void
43
+ param buffer GLenum in value
44
+ param drawbuffer DrawBufferName in value
45
+ param value Float32 in array [COMPSIZE(buffer)]
46
+
47
+ ClearBufferfi(buffer, drawbuffer, depth, stencil)
48
+ return void
49
+ param buffer GLenum in value
50
+ param drawbuffer DrawBufferName in value
51
+ param depth Float32 in value
52
+ param stencil Int32 in value
53
+
54
+ GetStringi(name, index)
55
+ return String
56
+ param name GLenum in value
57
+ param index UInt32 in value
58
+
59
+ */
60
+
61
+ /* GL_NV_conditional_render */
62
+ GL_FUNC_LOAD_2(BeginConditionalRender,GLvoid, GLuint, GLenum, "3.0")
63
+ GL_FUNC_LOAD_0(EndConditionalRender,GLvoid, "3.0")
64
+
65
+ /* #326 - GL_EXT_gpu_shader4 */
66
+ GL_FUNC_LOAD_2(VertexAttribI1i,GLvoid, GLuint,GLint, "3.0")
67
+ GL_FUNC_LOAD_3(VertexAttribI2i,GLvoid, GLuint,GLint,GLint, "3.0")
68
+ GL_FUNC_LOAD_4(VertexAttribI3i,GLvoid, GLuint,GLint,GLint,GLint, "3.0")
69
+ GL_FUNC_LOAD_5(VertexAttribI4i,GLvoid, GLuint,GLint,GLint,GLint,GLint, "3.0")
70
+ GL_FUNC_LOAD_2(VertexAttribI1ui,GLvoid, GLuint,GLuint, "3.0")
71
+ GL_FUNC_LOAD_3(VertexAttribI2ui,GLvoid, GLuint,GLuint,GLuint, "3.0")
72
+ GL_FUNC_LOAD_4(VertexAttribI3ui,GLvoid, GLuint,GLuint,GLuint,GLuint, "3.0")
73
+ GL_FUNC_LOAD_5(VertexAttribI4ui,GLvoid, GLuint,GLuint,GLuint,GLuint,GLuint, "3.0")
74
+
75
+ #define GLVERTEXATTRIB_VFUNC(_name_,_type_,_conv_,_size_) \
76
+ static VALUE \
77
+ gl_##_name_(obj,arg1,arg2) \
78
+ VALUE obj,arg1,arg2; \
79
+ { \
80
+ _type_ value[_size_]; \
81
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLuint,const _type_ *)); \
82
+ LOAD_GL_FUNC(gl##_name_, "3.0"); \
83
+ _conv_(arg2,value,_size_); \
84
+ fptr_gl##_name_(NUM2UINT(arg1),value); \
85
+ CHECK_GLERROR_FROM("gl" #_name_); \
86
+ return Qnil; \
87
+ }
88
+
89
+ GLVERTEXATTRIB_VFUNC(VertexAttribI1iv,GLint,ary2cint,1)
90
+ GLVERTEXATTRIB_VFUNC(VertexAttribI2iv,GLint,ary2cint,2)
91
+ GLVERTEXATTRIB_VFUNC(VertexAttribI3iv,GLint,ary2cint,3)
92
+ GLVERTEXATTRIB_VFUNC(VertexAttribI4iv,GLint,ary2cint,4)
93
+ GLVERTEXATTRIB_VFUNC(VertexAttribI1uiv,GLuint,ary2cuint,1)
94
+ GLVERTEXATTRIB_VFUNC(VertexAttribI2uiv,GLuint,ary2cuint,2)
95
+ GLVERTEXATTRIB_VFUNC(VertexAttribI3uiv,GLuint,ary2cuint,3)
96
+ GLVERTEXATTRIB_VFUNC(VertexAttribI4uiv,GLuint,ary2cuint,4)
97
+ GLVERTEXATTRIB_VFUNC(VertexAttribI4bv,GLbyte,ary2cbyte,4)
98
+ GLVERTEXATTRIB_VFUNC(VertexAttribI4sv,GLshort,ary2cshort,4)
99
+ GLVERTEXATTRIB_VFUNC(VertexAttribI4ubv,GLubyte,ary2cubyte,4)
100
+ GLVERTEXATTRIB_VFUNC(VertexAttribI4usv,GLushort,ary2cushort,4)
101
+ #undef GLVERTEXATTRIB_VFUNC
102
+
103
+ #define GETVERTEXATTRIB_FUNC(_name_,_type_,_conv_,_extension_) \
104
+ static VALUE \
105
+ gl_##_name_(obj,arg1,arg2) \
106
+ VALUE obj,arg1,arg2; \
107
+ { \
108
+ GLuint index; \
109
+ GLenum pname; \
110
+ _type_ params[4] = {0,0,0,0}; \
111
+ GLint size; \
112
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLuint,GLenum,_type_ *)); \
113
+ LOAD_GL_FUNC(gl##_name_, _extension_); \
114
+ index = (GLuint)NUM2UINT(arg1); \
115
+ pname = (GLenum)NUM2INT(arg2); \
116
+ if (pname==GL_CURRENT_VERTEX_ATTRIB_ARB) \
117
+ size = 4; \
118
+ else \
119
+ size = 1; \
120
+ fptr_gl##_name_(index,pname,params); \
121
+ RET_ARRAY_OR_SINGLE_BOOL("gl" #_name_, size, _conv_, pname, params); \
122
+ }
123
+
124
+ GETVERTEXATTRIB_FUNC(GetVertexAttribIiv,GLint,cond_GLBOOL2RUBY,"3.0")
125
+ GETVERTEXATTRIB_FUNC(GetVertexAttribIuiv,GLuint,cond_GLBOOL2RUBY_U,"3.0")
126
+ #undef GETVERTEXATTRIB_FUNC
127
+
128
+ static VALUE gl_VertexAttribIPointer(VALUE obj,VALUE arg1,VALUE arg2,VALUE arg3,VALUE arg4,VALUE arg5)
129
+ {
130
+ GLuint index;
131
+ GLuint size;
132
+ GLenum type;
133
+ GLsizei stride;
134
+
135
+ DECL_GL_FUNC_PTR(GLvoid,glVertexAttribIPointer,(GLuint,GLint,GLenum,GLsizei,const GLvoid *));
136
+ LOAD_GL_FUNC(glVertexAttribIPointer, "3.0");
137
+
138
+ index = (GLuint)NUM2UINT(arg1);
139
+ size = (GLuint)NUM2UINT(arg2);
140
+ type = (GLenum)NUM2INT(arg3);
141
+ stride = (GLsizei)NUM2UINT(arg4);
142
+ if (index>_MAX_VERTEX_ATTRIBS)
143
+ rb_raise(rb_eArgError, "Index too large, maximum allowed value '%i'",_MAX_VERTEX_ATTRIBS);
144
+
145
+ if (CHECK_BUFFER_BINDING(GL_ARRAY_BUFFER_BINDING)) {
146
+ GET_GLIMPL_VARIABLE(VertexAttrib_ptr)[index] = arg5;
147
+ fptr_glVertexAttribIPointer(index,size,type,stride,(GLvoid *)NUM2SIZET(arg5));
148
+ } else {
149
+ VALUE data;
150
+ data = pack_array_or_pass_string(type,arg5);
151
+ rb_str_freeze(data);
152
+ GET_GLIMPL_VARIABLE(VertexAttrib_ptr)[index] = data;
153
+ fptr_glVertexAttribIPointer(index,size,type,stride,(GLvoid *)RSTRING_PTR(data));
154
+ }
155
+
156
+ CHECK_GLERROR_FROM("glVertexAttribIPointer");
157
+ return Qnil;
158
+ }
159
+
160
+ GL_FUNC_LOAD_2(Uniform1ui,GLvoid, GLint,GLuint, "3.0")
161
+ GL_FUNC_LOAD_3(Uniform2ui,GLvoid, GLint,GLuint,GLuint, "3.0")
162
+ GL_FUNC_LOAD_4(Uniform3ui,GLvoid, GLint,GLuint,GLuint,GLuint, "3.0")
163
+ GL_FUNC_LOAD_5(Uniform4ui,GLvoid, GLint,GLuint,GLuint,GLuint,GLuint, "3.0")
164
+
165
+ #define GLUNIFORM_VFUNC(_name_,_type_,_conv_,_size_) \
166
+ static VALUE \
167
+ gl_##_name_(obj,arg1,arg2) \
168
+ VALUE obj,arg1,arg2; \
169
+ { \
170
+ GLint location; \
171
+ GLsizei count; \
172
+ _type_ *value; \
173
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLint,GLsizei,const _type_ *)); \
174
+ LOAD_GL_FUNC(gl##_name_, "3.0"); \
175
+ Check_Type(arg2,T_ARRAY); \
176
+ count = (GLsizei)RARRAY_LENINT(arg2); \
177
+ if (count<=0 || (count % _size_) != 0) \
178
+ rb_raise(rb_eArgError, "Parameter array size must be multiplication of %i",_size_); \
179
+ location = (GLint)NUM2INT(arg1); \
180
+ value = ALLOC_N(_type_,count); \
181
+ _conv_(arg2,value,count); \
182
+ fptr_gl##_name_(location,count / _size_,value); \
183
+ xfree(value); \
184
+ CHECK_GLERROR_FROM("gl" #_name_); \
185
+ return Qnil; \
186
+ }
187
+
188
+ GLUNIFORM_VFUNC(Uniform1uiv,GLuint,ary2cuint,1)
189
+ GLUNIFORM_VFUNC(Uniform2uiv,GLuint,ary2cuint,2)
190
+ GLUNIFORM_VFUNC(Uniform3uiv,GLuint,ary2cuint,3)
191
+ GLUNIFORM_VFUNC(Uniform4uiv,GLuint,ary2cuint,4)
192
+ #undef GLUNIFORM_VFUNC
193
+
194
+ #define GETUNIFORM_FUNC(_name_,_type_) \
195
+ static VALUE \
196
+ gl_##_name_(obj,arg1,arg2) \
197
+ VALUE obj,arg1,arg2; \
198
+ { \
199
+ GLuint program; \
200
+ GLint location; \
201
+ _type_ params[16]; \
202
+ GLint unused = 0; \
203
+ GLenum uniform_type = 0; \
204
+ GLint uniform_size = 0; \
205
+ \
206
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLuint,GLint,_type_ *)); \
207
+ DECL_GL_FUNC_PTR(GLvoid,glGetActiveUniformARB,(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*)); \
208
+ LOAD_GL_FUNC(gl##_name_, "3.0"); \
209
+ LOAD_GL_FUNC(glGetActiveUniformARB, "3.0"); \
210
+ program = (GLuint)NUM2UINT(arg1); \
211
+ location = (GLint)NUM2INT(arg2); \
212
+ \
213
+ fptr_glGetActiveUniformARB(program,location,0,NULL,&unused,&uniform_type,NULL); \
214
+ CHECK_GLERROR_FROM("glGetActiveUniformARB"); \
215
+ if (uniform_type==0) \
216
+ rb_raise(rb_eTypeError, "Can't determine the uniform's type"); \
217
+ \
218
+ uniform_size = get_uniform_size(uniform_type); \
219
+ \
220
+ memset(params,0,16*sizeof(_type_)); \
221
+ fptr_gl##_name_(program,location,params); \
222
+ RET_ARRAY_OR_SINGLE("gl" #_name_, uniform_size, RETCONV_##_type_, params); \
223
+ }
224
+
225
+ GETUNIFORM_FUNC(GetUniformuiv,GLuint)
226
+ #undef GETUNIFORM_FUNC
227
+
228
+ static VALUE gl_BindFragDataLocation(VALUE obj,VALUE arg1,VALUE arg2,VALUE arg3)
229
+ {
230
+ DECL_GL_FUNC_PTR(GLvoid,glBindFragDataLocation,(GLuint,GLuint,const GLchar *));
231
+ LOAD_GL_FUNC(glBindFragDataLocation, "3.0");
232
+ Check_Type(arg3,T_STRING);
233
+ fptr_glBindFragDataLocation(NUM2UINT(arg1),NUM2UINT(arg2),RSTRING_PTR(arg3));
234
+ CHECK_GLERROR_FROM("glBindFragDataLocation");
235
+ return Qnil;
236
+ }
237
+
238
+ static VALUE gl_GetFragDataLocation(VALUE obj,VALUE arg1,VALUE arg2)
239
+ {
240
+ GLint ret;
241
+ DECL_GL_FUNC_PTR(GLint,glGetFragDataLocation,(GLuint,const GLchar *));
242
+ LOAD_GL_FUNC(glGetFragDataLocation, "3.0");
243
+ Check_Type(arg2,T_STRING);
244
+ ret = fptr_glGetFragDataLocation(NUM2UINT(arg1),RSTRING_PTR(arg2));
245
+ CHECK_GLERROR_FROM("glGetFragDataLocation");
246
+ return INT2NUM(ret);
247
+ }
248
+
249
+ /* ARB_map_buffer_range */
250
+
251
+ /* #39 GL_ARB_color_buffer_float */
252
+
253
+ GL_FUNC_LOAD_2(ClampColor,GLvoid, GLenum,GLenum, "3.0")
254
+
255
+ /* #334 GL_NV_depth_buffer_float */
256
+
257
+ GL_FUNC_LOAD_2(DepthRanged,GLvoid, GLdouble,GLdouble, "3.0")
258
+ GL_FUNC_LOAD_1(ClearDepthd,GLvoid, GLdouble, "3.0")
259
+ GL_FUNC_LOAD_2(DepthBoundsd,GLvoid, GLdouble,GLdouble, "3.0")
260
+
261
+ /* GL_ARB_framebuffer_object */
262
+ GL_FUNC_LOAD_1(IsRenderbuffer,GLboolean, GLuint, "3.0")
263
+ GL_FUNC_LOAD_2(BindRenderbuffer,GLvoid, GLenum,GLuint, "3.0")
264
+ GL_FUNC_LOAD_4(RenderbufferStorage,GLvoid, GLenum,GLenum,GLsizei,GLsizei, "3.0")
265
+ GL_FUNC_GENOBJECTS_LOAD(GenRenderbuffers,"3.0")
266
+ GL_FUNC_DELETEOBJECTS_LOAD(DeleteRenderbuffers,"3.0")
267
+
268
+ static VALUE gl_GetRenderbufferParameteriv(VALUE obj,VALUE arg1,VALUE arg2)
269
+ {
270
+ GLint param = 0;
271
+ DECL_GL_FUNC_PTR(GLvoid,glGetRenderbufferParameteriv,(GLenum,GLenum,GLint *));
272
+ LOAD_GL_FUNC(glGetRenderbufferParameteriv, "3.0");
273
+ fptr_glGetRenderbufferParameteriv(NUM2UINT(arg1),NUM2UINT(arg2),&param);
274
+ CHECK_GLERROR_FROM("glGetRenderbufferParameteriv");
275
+ return INT2NUM(param);
276
+ }
277
+
278
+ GL_FUNC_GENOBJECTS_LOAD(GenFramebuffers,"3.0")
279
+ GL_FUNC_DELETEOBJECTS_LOAD(DeleteFramebuffers,"3.0")
280
+ GL_FUNC_LOAD_1(IsFramebuffer,GLboolean, GLuint, "3.0")
281
+ GL_FUNC_LOAD_2(BindFramebuffer,GLvoid, GLenum,GLuint, "3.0")
282
+ GL_FUNC_LOAD_1(CheckFramebufferStatus,GLenum, GLenum, "3.0")
283
+ GL_FUNC_LOAD_5(FramebufferTexture1D,GLvoid, GLenum,GLenum,GLenum,GLuint,GLint, "3.0")
284
+ GL_FUNC_LOAD_5(FramebufferTexture2D,GLvoid, GLenum,GLenum,GLenum,GLuint,GLint, "3.0")
285
+ GL_FUNC_LOAD_6(FramebufferTexture3D,GLvoid, GLenum,GLenum,GLenum,GLuint,GLint,GLint, "3.0")
286
+ GL_FUNC_LOAD_5(FramebufferTextureLayer,GLvoid, GLenum,GLenum,GLuint,GLint,GLint, "3.0")
287
+ GL_FUNC_LOAD_4(FramebufferRenderbuffer,GLvoid, GLuint,GLuint,GLuint,GLuint, "3.0")
288
+
289
+ static VALUE gl_GetFramebufferAttachmentParameteriv(VALUE obj,VALUE arg1, VALUE arg2, VALUE arg3)
290
+ {
291
+ GLint ret = 0;
292
+ DECL_GL_FUNC_PTR(GLvoid,glGetFramebufferAttachmentParameteriv,(GLenum,GLenum,GLenum,GLint *));
293
+ LOAD_GL_FUNC(glGetFramebufferAttachmentParameteriv, "3.0");
294
+ fptr_glGetFramebufferAttachmentParameteriv(NUM2UINT(arg1),NUM2UINT(arg2),NUM2UINT(arg3),&ret);
295
+ CHECK_GLERROR_FROM("glGetFramebufferAttachmentParameteriv");
296
+ return cond_GLBOOL2RUBY(NUM2UINT(arg3),ret);
297
+ }
298
+
299
+ GL_FUNC_LOAD_1(GenerateMipmap,GLvoid, GLenum, "3.0")
300
+
301
+ /* GL_NV_half_float */
302
+
303
+ /* #317 - GL_EXT_framebuffer_multisample */
304
+ GL_FUNC_LOAD_5(RenderbufferStorageMultisample,GLvoid, GLenum,GLsizei,GLenum,GLsizei,GLsizei, "3.0")
305
+
306
+ /* #316 - GL_EXT_framebuffer_blit */
307
+ GL_FUNC_LOAD_10(BlitFramebuffer,GLvoid, GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum, "3.0")
308
+
309
+ /* #343 - GL_EXT_texture_integer */
310
+ GL_FUNC_LOAD_4(ClearColorIi,GLvoid, GLint,GLint,GLint,GLint, "3.0")
311
+ GL_FUNC_LOAD_4(ClearColorIui,GLvoid, GLuint,GLuint,GLuint,GLuint, "3.0")
312
+
313
+ #define TEXPARAMETER_VFUNC(_name_,_type_,_conv_) \
314
+ static VALUE \
315
+ gl_##_name_(obj,arg1,arg2,arg3) \
316
+ VALUE obj,arg1,arg2,arg3; \
317
+ { \
318
+ GLenum target; \
319
+ GLenum pname; \
320
+ _type_ params[4] = {0,0,0,0}; \
321
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLenum,GLenum,_type_ *)); \
322
+ LOAD_GL_FUNC(gl##_name_, "3.0"); \
323
+ target = (GLenum)NUM2UINT(arg1); \
324
+ pname = (GLenum)NUM2UINT(arg2); \
325
+ Check_Type(arg3,T_ARRAY); \
326
+ _conv_(arg3,params,4); \
327
+ fptr_gl##_name_(target,pname,params); \
328
+ CHECK_GLERROR_FROM("gl" #_name_); \
329
+ return Qnil; \
330
+ }
331
+
332
+ TEXPARAMETER_VFUNC(TexParameterIiv,GLint,ary2cint)
333
+ TEXPARAMETER_VFUNC(TexParameterIuiv,GLuint,ary2cuint)
334
+ #undef TEXPARAMETER_VFUNC
335
+
336
+ #define GETTEXPARAMETER_VFUNC(_name_,_type_,_conv_) \
337
+ static VALUE \
338
+ gl_##_name_(obj,arg1,arg2) \
339
+ VALUE obj,arg1,arg2; \
340
+ { \
341
+ GLenum target; \
342
+ GLenum pname; \
343
+ _type_ params[4] = {0,0,0,0}; \
344
+ int size; \
345
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLenum,GLenum,_type_ *)); \
346
+ LOAD_GL_FUNC(gl##_name_, "3.0"); \
347
+ target = (GLenum)NUM2INT(arg1); \
348
+ pname = (GLenum)NUM2INT(arg2); \
349
+ switch(pname) { \
350
+ case GL_TEXTURE_BORDER_COLOR: \
351
+ case GL_TEXTURE_BORDER_VALUES_NV: \
352
+ case GL_POST_TEXTURE_FILTER_BIAS_SGIX: \
353
+ case GL_POST_TEXTURE_FILTER_SCALE_SGIX: \
354
+ size = 4; \
355
+ break; \
356
+ default: \
357
+ size = 1; \
358
+ break; \
359
+ } \
360
+ fptr_gl##_name_(target,pname,params); \
361
+ RET_ARRAY_OR_SINGLE_BOOL("gl" #_name_, size, _conv_, pname, params); \
362
+ }
363
+
364
+ GETTEXPARAMETER_VFUNC(GetTexParameterIiv,GLint,cond_GLBOOL2RUBY)
365
+ GETTEXPARAMETER_VFUNC(GetTexParameterIuiv,GLuint,cond_GLBOOL2RUBY_U)
366
+ #undef GETTEXPARAMETER_VFUNC
367
+
368
+ /* #340 - GL_EXT_draw_buffers2 */
369
+ GL_FUNC_LOAD_5(ColorMaski,GLvoid, GLuint,GLboolean,GLboolean,GLboolean,GLboolean, "3.0")
370
+
371
+ #define GETINDEXED_FUNC(_name_,_type_,_conv_,_extension_) \
372
+ static VALUE \
373
+ gl_##_name_(obj,arg1,arg2) \
374
+ VALUE obj,arg1,arg2; \
375
+ { \
376
+ GLenum target; \
377
+ GLenum pname; \
378
+ _type_ result; \
379
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(GLenum,GLenum,_type_ *)); \
380
+ LOAD_GL_FUNC(gl##_name_, _extension_); \
381
+ target = (GLenum)NUM2INT(arg1); \
382
+ pname = (GLuint)NUM2INT(arg2); \
383
+ fptr_gl##_name_(target,pname,&result); \
384
+ return _conv_(result); \
385
+ }
386
+
387
+ GETINDEXED_FUNC(GetBooleani_v, GLboolean, GLBOOL2RUBY, "3.0")
388
+ GETINDEXED_FUNC(GetIntegeri_v, GLint, INT2NUM, "3.0")
389
+ #undef GETINDEXED_FUNC
390
+
391
+ GL_FUNC_LOAD_2(Enablei,GLvoid, GLenum,GLuint, "3.0")
392
+ GL_FUNC_LOAD_2(Disablei,GLvoid, GLenum,GLuint, "3.0")
393
+ GL_FUNC_LOAD_2(IsEnabledi,GLvoid, GLenum,GLuint, "3.0")
394
+
395
+ /* GL_APPLE_vertex_array_object --> ARB_vertex_array_object */
396
+ GL_FUNC_GENOBJECTS_LOAD(GenVertexArrays, "3.0");
397
+ GL_FUNC_DELETEOBJECTS_LOAD(DeleteVertexArrays, "3.0");
398
+ GL_FUNC_LOAD_1(BindVertexArray,GLvoid, GLuint, "3.0");
399
+ GL_FUNC_LOAD_1(IsVertexArray,GLboolean, GLuint, "3.0");
400
+
401
+
402
+ void gl_init_functions_3_0(VALUE klass)
403
+ {
404
+ /* GL_NV_conditional_render */
405
+ rb_define_method(klass, "glBeginConditionalRender", gl_BeginConditionalRender, 2);
406
+ rb_define_method(klass, "glEndConditionalRender", gl_EndConditionalRender, 0);
407
+
408
+ /* #326 - GL_EXT_gpu_shader4 */
409
+ rb_define_method(klass, "glVertexAttribI1i", gl_VertexAttribI1i, 2);
410
+ rb_define_method(klass, "glVertexAttribI2i", gl_VertexAttribI2i, 3);
411
+ rb_define_method(klass, "glVertexAttribI3i", gl_VertexAttribI3i, 4);
412
+ rb_define_method(klass, "glVertexAttribI4i", gl_VertexAttribI4i, 5);
413
+ rb_define_method(klass, "glVertexAttribI1ui", gl_VertexAttribI1ui, 2);
414
+ rb_define_method(klass, "glVertexAttribI2ui", gl_VertexAttribI2ui, 3);
415
+ rb_define_method(klass, "glVertexAttribI3ui", gl_VertexAttribI3ui, 4);
416
+ rb_define_method(klass, "glVertexAttribI4ui", gl_VertexAttribI4ui, 5);
417
+ rb_define_method(klass, "glVertexAttribI1iv", gl_VertexAttribI1iv, 2);
418
+ rb_define_method(klass, "glVertexAttribI2iv", gl_VertexAttribI2iv, 2);
419
+ rb_define_method(klass, "glVertexAttribI3iv", gl_VertexAttribI3iv, 2);
420
+ rb_define_method(klass, "glVertexAttribI4iv", gl_VertexAttribI4iv, 2);
421
+ rb_define_method(klass, "glVertexAttribI1uiv", gl_VertexAttribI1uiv, 2);
422
+ rb_define_method(klass, "glVertexAttribI2uiv", gl_VertexAttribI2uiv, 2);
423
+ rb_define_method(klass, "glVertexAttribI3uiv", gl_VertexAttribI3uiv, 2);
424
+ rb_define_method(klass, "glVertexAttribI4uiv", gl_VertexAttribI4uiv, 2);
425
+ rb_define_method(klass, "glVertexAttribI4bv", gl_VertexAttribI4bv, 2);
426
+ rb_define_method(klass, "glVertexAttribI4sv", gl_VertexAttribI4sv, 2);
427
+ rb_define_method(klass, "glVertexAttribI4ubv", gl_VertexAttribI4ubv, 2);
428
+ rb_define_method(klass, "glVertexAttribI4usv", gl_VertexAttribI4usv, 2);
429
+ rb_define_method(klass, "glVertexAttribIPointer", gl_VertexAttribIPointer, 5);
430
+ rb_define_method(klass, "glGetVertexAttribIiv", gl_GetVertexAttribIiv, 2);
431
+ rb_define_method(klass, "glGetVertexAttribIuiv", gl_GetVertexAttribIuiv, 2);
432
+ rb_define_method(klass, "glUniform1ui", gl_Uniform1ui, 2);
433
+ rb_define_method(klass, "glUniform2ui", gl_Uniform2ui, 3);
434
+ rb_define_method(klass, "glUniform3ui", gl_Uniform3ui, 4);
435
+ rb_define_method(klass, "glUniform4ui", gl_Uniform4ui, 5);
436
+ rb_define_method(klass, "glUniform1uiv", gl_Uniform1uiv, 2);
437
+ rb_define_method(klass, "glUniform2uiv", gl_Uniform2uiv, 2);
438
+ rb_define_method(klass, "glUniform3uiv", gl_Uniform3uiv, 2);
439
+ rb_define_method(klass, "glUniform4uiv", gl_Uniform4uiv, 2);
440
+ rb_define_method(klass, "glGetUniformuiv", gl_GetUniformuiv, 2);
441
+ rb_define_method(klass, "glBindFragDataLocation", gl_BindFragDataLocation, 3);
442
+ rb_define_method(klass, "glGetFragDataLocation", gl_GetFragDataLocation, 2);
443
+
444
+ /* GL_NV_conditional_render */
445
+
446
+ /* GL_APPLE_flush_buffer_range */
447
+
448
+ /* #39 GL_ARB_color_buffer_float */
449
+ rb_define_method(klass, "glClampColor", gl_ClampColor, 2);
450
+
451
+ /* #334 GL_NV_depth_buffer_float */
452
+ rb_define_method(klass, "glDepthRanged", gl_DepthRanged, 2);
453
+ rb_define_method(klass, "glClearDepthd", gl_ClearDepthd, 1);
454
+ rb_define_method(klass, "glDepthBoundsd", gl_DepthBoundsd, 2);
455
+
456
+ /* #310 - GL_EXT_framebuffer_object */
457
+ rb_define_method(klass, "glIsRenderbuffer", gl_IsRenderbuffer, 1);
458
+ rb_define_method(klass, "glBindRenderbuffer", gl_BindRenderbuffer, 2);
459
+ rb_define_method(klass, "glDeleteRenderbuffers", gl_DeleteRenderbuffers, 1);
460
+ rb_define_method(klass, "glGenRenderbuffers", gl_GenRenderbuffers, 1);
461
+ rb_define_method(klass, "glRenderbufferStorage", gl_RenderbufferStorage, 4);
462
+ rb_define_method(klass, "glGetRenderbufferParameteriv", gl_GetRenderbufferParameteriv, 2);
463
+ rb_define_method(klass, "glIsFramebuffer", gl_IsFramebuffer, 1);
464
+ rb_define_method(klass, "glBindFramebuffer", gl_BindFramebuffer, 2);
465
+ rb_define_method(klass, "glDeleteFramebuffers", gl_DeleteFramebuffers, 1);
466
+ rb_define_method(klass, "glGenFramebuffers", gl_GenFramebuffers, 1);
467
+ rb_define_method(klass, "glCheckFramebufferStatus", gl_CheckFramebufferStatus, 1);
468
+ rb_define_method(klass, "glFramebufferTexture1D", gl_FramebufferTexture1D, 5);
469
+ rb_define_method(klass, "glFramebufferTexture2D", gl_FramebufferTexture2D, 5);
470
+ rb_define_method(klass, "glFramebufferTexture3D", gl_FramebufferTexture3D, 6);
471
+ rb_define_method(klass, "glFramebufferRenderbuffer", gl_FramebufferRenderbuffer, 4);
472
+ rb_define_method(klass, "glFramebufferTextureLayer", gl_FramebufferTextureLayer, 5);
473
+ rb_define_method(klass, "glGetFramebufferAttachmentParameteriv", gl_GetFramebufferAttachmentParameteriv, 3);
474
+ rb_define_method(klass, "glGenerateMipmap", gl_GenerateMipmap, 1);
475
+
476
+ /* #317 - GL_EXT_framebuffer_multisample */
477
+ rb_define_method(klass, "glRenderbufferStorageMultisample", gl_RenderbufferStorageMultisample, 5);
478
+
479
+ /* #316 - GL_EXT_framebuffer_blit */
480
+ rb_define_method(klass, "glBlitFramebuffer", gl_BlitFramebuffer, 10);
481
+
482
+ /* #343 - GL_EXT_texture_integer */
483
+ rb_define_method(klass, "glClearColorIi", gl_ClearColorIi, 4);
484
+ rb_define_method(klass, "glClearColorIui", gl_ClearColorIui, 4);
485
+ rb_define_method(klass, "glTexParameterIiv", gl_TexParameterIiv, 3);
486
+ rb_define_method(klass, "glTexParameterIuiv", gl_TexParameterIuiv, 3);
487
+ rb_define_method(klass, "glGetTexParameterIiv", gl_GetTexParameterIiv, 2);
488
+ rb_define_method(klass, "glGetTexParameterIuiv", gl_GetTexParameterIuiv, 2);
489
+
490
+ /* #340 - GL_EXT_draw_buffers2 */
491
+ rb_define_method(klass, "glColorMaski", gl_ColorMaski, 5);
492
+ rb_define_method(klass, "glGetBooleani_v", gl_GetBooleani_v, 2);
493
+ rb_define_method(klass, "glGetIntegeri_v", gl_GetIntegeri_v, 2);
494
+ rb_define_method(klass, "glEnablei", gl_Enablei, 2);
495
+ rb_define_method(klass, "glDisablei", gl_Disablei, 2);
496
+ rb_define_method(klass, "glIsEnabledi", gl_IsEnabledi, 2);
497
+
498
+ rb_define_method(klass, "glBindVertexArray", gl_BindVertexArray, 1);
499
+ rb_define_method(klass, "glDeleteVertexArrays", gl_DeleteVertexArrays, 1);
500
+ rb_define_method(klass, "glGenVertexArrays", gl_GenVertexArrays, 1);
501
+ rb_define_method(klass, "glIsVertexArray", gl_IsVertexArray, 1);
502
+ }