ruby-opengl 0.50.0 → 0.60.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/Rakefile +15 -11
  2. data/doc/build_install.txt +10 -6
  3. data/doc/extensions.txt.in +348 -0
  4. data/doc/history.txt +4 -0
  5. data/doc/roadmap.txt +4 -6
  6. data/doc/scientific_use.txt +7 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +5 -0
  9. data/doc/tutorial.txt +431 -121
  10. data/examples/NeHe/nehe_lesson02.rb +1 -1
  11. data/examples/NeHe/nehe_lesson03.rb +1 -1
  12. data/examples/NeHe/nehe_lesson04.rb +1 -1
  13. data/examples/NeHe/nehe_lesson05.rb +1 -1
  14. data/examples/NeHe/nehe_lesson36.rb +1 -1
  15. data/examples/OrangeBook/brick.rb +3 -15
  16. data/examples/OrangeBook/particle.rb +2 -20
  17. data/examples/RedBook/aapoly.rb +1 -1
  18. data/examples/RedBook/aargb.rb +2 -2
  19. data/examples/RedBook/accanti.rb +1 -1
  20. data/examples/RedBook/accpersp.rb +1 -1
  21. data/examples/RedBook/alpha.rb +2 -2
  22. data/examples/RedBook/alpha3D.rb +1 -1
  23. data/examples/RedBook/bezcurve.rb +1 -1
  24. data/examples/RedBook/bezmesh.rb +1 -1
  25. data/examples/RedBook/checker.rb +1 -1
  26. data/examples/RedBook/clip.rb +1 -1
  27. data/examples/RedBook/colormat.rb +1 -1
  28. data/examples/RedBook/cube.rb +1 -1
  29. data/examples/RedBook/depthcue.rb +1 -1
  30. data/examples/RedBook/dof.rb +1 -1
  31. data/examples/RedBook/double.rb +1 -1
  32. data/examples/RedBook/drawf.rb +1 -1
  33. data/examples/RedBook/feedback.rb +1 -1
  34. data/examples/RedBook/fog.rb +1 -1
  35. data/examples/RedBook/font.rb +2 -2
  36. data/examples/RedBook/hello.rb +1 -1
  37. data/examples/RedBook/image.rb +4 -4
  38. data/examples/RedBook/lines.rb +1 -1
  39. data/examples/RedBook/list.rb +1 -1
  40. data/examples/RedBook/material.rb +1 -1
  41. data/examples/RedBook/mipmap.rb +1 -1
  42. data/examples/RedBook/model.rb +1 -1
  43. data/examples/RedBook/movelight.rb +1 -1
  44. data/examples/RedBook/pickdepth.rb +1 -1
  45. data/examples/RedBook/planet.rb +5 -5
  46. data/examples/RedBook/quadric.rb +1 -1
  47. data/examples/RedBook/robot.rb +5 -5
  48. data/examples/RedBook/select.rb +1 -1
  49. data/examples/RedBook/smooth.rb +1 -1
  50. data/examples/RedBook/stencil.rb +1 -1
  51. data/examples/RedBook/stroke.rb +2 -2
  52. data/examples/RedBook/surface.rb +1 -1
  53. data/examples/RedBook/teaambient.rb +1 -1
  54. data/examples/RedBook/teapots.rb +1 -1
  55. data/examples/RedBook/tess.rb +1 -1
  56. data/examples/RedBook/texbind.rb +1 -1
  57. data/examples/RedBook/texgen.rb +5 -5
  58. data/examples/RedBook/texturesurf.rb +1 -1
  59. data/examples/RedBook/varray.rb +1 -1
  60. data/examples/RedBook/wrap.rb +5 -5
  61. data/examples/misc/OGLBench.rb +337 -0
  62. data/examples/misc/anisotropic.rb +1 -1
  63. data/examples/misc/fbo_test.rb +356 -0
  64. data/examples/misc/font-glut.rb +1 -1
  65. data/examples/misc/glfwtest.rb +30 -0
  66. data/examples/misc/md2model.rb +15 -0
  67. data/examples/misc/plane.rb +1 -1
  68. data/examples/misc/readpixel.rb +1 -1
  69. data/examples/misc/sdltest.rb +34 -0
  70. data/examples/misc/trislam.rb +828 -0
  71. data/ext/common/common.h +126 -218
  72. data/ext/common/conv.h +244 -0
  73. data/ext/common/funcdef.h +280 -0
  74. data/ext/common/gl-error.h +23 -0
  75. data/ext/common/gl-types.h +14 -0
  76. data/ext/gl/gl-1.0-1.1.c +497 -1255
  77. data/ext/gl/gl-1.2.c +121 -304
  78. data/ext/gl/gl-1.3.c +78 -339
  79. data/ext/gl/gl-1.4.c +102 -164
  80. data/ext/gl/gl-1.5.c +42 -173
  81. data/ext/gl/gl-2.0.c +273 -1039
  82. data/ext/gl/gl-2.1.c +15 -19
  83. data/ext/gl/gl-enums.c +3 -2
  84. data/ext/gl/gl-error.c +104 -0
  85. data/ext/gl/gl-ext-3dfx.c +27 -0
  86. data/ext/gl/gl-ext-arb.c +812 -12
  87. data/ext/gl/gl-ext-ati.c +41 -0
  88. data/ext/gl/gl-ext-ext.c +791 -119
  89. data/ext/gl/gl-ext-gremedy.c +41 -0
  90. data/ext/gl/gl-ext-nv.c +679 -0
  91. data/ext/gl/gl.c +48 -28
  92. data/ext/gl/mkrf_conf.rb +13 -10
  93. data/ext/glu/glu-enums.c +3 -2
  94. data/ext/glu/glu.c +136 -41
  95. data/ext/glu/mkrf_conf.rb +15 -12
  96. data/ext/glut/glut.c +37 -80
  97. data/ext/glut/mkrf_conf.rb +17 -13
  98. data/lib/opengl.rb +29 -53
  99. data/test/tc_common.rb +9 -3
  100. data/test/tc_ext_arb.rb +397 -3
  101. data/test/tc_ext_ati.rb +33 -0
  102. data/test/tc_ext_ext.rb +479 -2
  103. data/test/tc_ext_gremedy.rb +36 -0
  104. data/test/tc_ext_nv.rb +357 -0
  105. data/test/tc_func_10_11.rb +93 -67
  106. data/test/tc_func_12.rb +11 -11
  107. data/test/tc_func_13.rb +38 -18
  108. data/test/tc_func_14.rb +2 -2
  109. data/test/tc_func_15.rb +10 -10
  110. data/test/tc_func_20.rb +20 -20
  111. data/test/tc_func_21.rb +53 -22
  112. data/test/tc_glu.rb +9 -4
  113. data/test/tc_misc.rb +15 -2
  114. metadata +22 -8
  115. data/doc/extensions.txt +0 -361
  116. data/examples/RedBook/aaindex.rb +0 -97
  117. data/examples/misc/smooth.rb +0 -42
  118. data/examples/misc/test.rb +0 -65
@@ -15,22 +15,45 @@
15
15
 
16
16
  #include "../common/common.h"
17
17
 
18
- GL_SIMPLE_FUNC_LOAD(BlendEquationSeparate,2,GLenum,NUM2INT)
19
- GL_SIMPLE_FUNC_LOAD(StencilOpSeparate,4,GLenum,NUM2INT)
20
- GL_SIMPLE_FUNC_LOAD(AttachShader,2,GLuint,NUM2UINT)
21
- GL_SIMPLE_FUNC_LOAD(CompileShader,1,GLuint,NUM2UINT)
22
- GL_SIMPLE_FUNC_LOAD(DeleteProgram,1,GLuint,NUM2UINT)
23
- GL_SIMPLE_FUNC_LOAD(DeleteShader,1,GLuint,NUM2UINT)
24
- GL_SIMPLE_FUNC_LOAD(DetachShader,2,GLuint,NUM2UINT)
25
- GL_SIMPLE_FUNC_LOAD(DisableVertexAttribArray,1,GLuint,NUM2UINT)
26
- GL_SIMPLE_FUNC_LOAD(EnableVertexAttribArray,1,GLuint,NUM2UINT)
27
- GL_SIMPLE_FUNC_LOAD(LinkProgram,1,GLuint,NUM2UINT)
28
- GL_SIMPLE_FUNC_LOAD(UseProgram,1,GLuint,NUM2UINT)
29
- GL_SIMPLE_FUNC_LOAD(ValidateProgram,1,GLuint,NUM2UINT)
30
- GL_SIMPLE_FUNC_LOAD(Uniform1i,2,GLint,NUM2INT)
31
- GL_SIMPLE_FUNC_LOAD(Uniform2i,3,GLint,NUM2INT)
32
- GL_SIMPLE_FUNC_LOAD(Uniform3i,4,GLint,NUM2INT)
33
- GL_SIMPLE_FUNC_LOAD(Uniform4i,5,GLint,NUM2INT)
18
+ GL_FUNC_LOAD_2(BlendEquationSeparate,GLvoid, GLenum,GLenum, "2.0")
19
+ GL_FUNC_LOAD_4(StencilOpSeparate,GLvoid, GLenum,GLenum,GLenum,GLenum, "2.0")
20
+ GL_FUNC_LOAD_2(AttachShader,GLvoid, GLuint,GLuint, "2.0")
21
+ GL_FUNC_LOAD_1(CompileShader,GLvoid, GLuint, "2.0")
22
+ GL_FUNC_LOAD_1(DeleteProgram,GLvoid, GLuint, "2.0")
23
+ GL_FUNC_LOAD_1(DeleteShader,GLvoid, GLuint, "2.0")
24
+ GL_FUNC_LOAD_2(DetachShader,GLvoid, GLuint,GLuint, "2.0")
25
+ GL_FUNC_LOAD_1(DisableVertexAttribArray,GLvoid, GLuint, "2.0")
26
+ GL_FUNC_LOAD_1(EnableVertexAttribArray,GLvoid, GLuint, "2.0")
27
+ GL_FUNC_LOAD_1(LinkProgram,GLvoid, GLuint, "2.0")
28
+ GL_FUNC_LOAD_1(UseProgram,GLvoid, GLuint, "2.0")
29
+ GL_FUNC_LOAD_1(ValidateProgram,GLvoid, GLuint, "2.0")
30
+ GL_FUNC_LOAD_4(StencilFuncSeparate,GLvoid, GLenum,GLenum,GLint,GLuint, "2.0")
31
+ GL_FUNC_LOAD_2(StencilMaskSeparate,GLvoid, GLenum,GLuint, "2.0")
32
+ GL_FUNC_LOAD_0(CreateProgram,GLuint, "2.0")
33
+ GL_FUNC_LOAD_1(CreateShader,GLuint, GLenum, "2.0")
34
+ GL_FUNC_LOAD_1(IsProgram,GLboolean, GLuint, "2.0")
35
+ GL_FUNC_LOAD_1(IsShader,GLboolean, GLuint, "2.0")
36
+ GL_FUNC_LOAD_2(Uniform1f,GLvoid, GLint,GLfloat, "2.0")
37
+ GL_FUNC_LOAD_2(Uniform1i,GLvoid, GLint,GLint, "2.0")
38
+ GL_FUNC_LOAD_3(Uniform2f,GLvoid, GLint,GLfloat,GLfloat, "2.0")
39
+ GL_FUNC_LOAD_3(Uniform2i,GLvoid, GLint,GLint,GLint, "2.0")
40
+ GL_FUNC_LOAD_4(Uniform3f,GLvoid, GLint,GLfloat,GLfloat,GLfloat, "2.0")
41
+ GL_FUNC_LOAD_4(Uniform3i,GLvoid, GLint,GLint,GLint,GLint, "2.0")
42
+ GL_FUNC_LOAD_5(Uniform4f,GLvoid, GLint,GLfloat,GLfloat,GLfloat,GLfloat, "2.0")
43
+ GL_FUNC_LOAD_5(Uniform4i,GLvoid, GLint,GLint,GLint,GLint,GLint, "2.0")
44
+ GL_FUNC_LOAD_2(VertexAttrib1d,GLvoid, GLuint,GLdouble, "2.0")
45
+ GL_FUNC_LOAD_2(VertexAttrib1f,GLvoid, GLuint,GLfloat, "2.0")
46
+ GL_FUNC_LOAD_2(VertexAttrib1s,GLvoid, GLuint,GLshort, "2.0")
47
+ GL_FUNC_LOAD_3(VertexAttrib2d,GLvoid, GLuint,GLdouble,GLdouble, "2.0")
48
+ GL_FUNC_LOAD_3(VertexAttrib2f,GLvoid, GLuint,GLfloat,GLfloat, "2.0")
49
+ GL_FUNC_LOAD_3(VertexAttrib2s,GLvoid, GLuint,GLshort,GLshort, "2.0")
50
+ GL_FUNC_LOAD_4(VertexAttrib3d,GLvoid, GLuint,GLdouble,GLdouble,GLdouble, "2.0")
51
+ GL_FUNC_LOAD_4(VertexAttrib3f,GLvoid, GLuint,GLfloat,GLfloat,GLfloat, "2.0")
52
+ GL_FUNC_LOAD_4(VertexAttrib3s,GLvoid, GLuint,GLshort,GLshort,GLshort, "2.0")
53
+ GL_FUNC_LOAD_5(VertexAttrib4d,GLvoid, GLuint,GLdouble,GLdouble,GLdouble,GLdouble, "2.0")
54
+ GL_FUNC_LOAD_5(VertexAttrib4f,GLvoid, GLuint,GLfloat,GLfloat,GLfloat,GLfloat, "2.0")
55
+ GL_FUNC_LOAD_5(VertexAttrib4s,GLvoid, GLuint,GLshort,GLshort,GLshort,GLshort, "2.0")
56
+ GL_FUNC_LOAD_5(VertexAttrib4Nub,GLvoid, GLuint,GLubyte,GLubyte,GLubyte,GLubyte, "2.0")
34
57
 
35
58
  static void (APIENTRY * fptr_glDrawBuffers)(GLsizei,GLenum *);
36
59
  static VALUE
@@ -39,45 +62,14 @@ VALUE obj,arg1;
39
62
  {
40
63
  GLsizei size;
41
64
  GLenum *buffers;
42
- LOAD_GL_FUNC(glDrawBuffers)
65
+ LOAD_GL_FUNC(glDrawBuffers,"2.0")
43
66
  Check_Type(arg1,T_ARRAY);
44
67
  size = RARRAY(arg1)->len;
45
68
  buffers = ALLOC_N(GLenum,size);
46
69
  ary2cuint(arg1,buffers,size);
47
70
  fptr_glDrawBuffers(size,buffers);
48
71
  xfree(buffers);
49
- return Qnil;
50
- }
51
-
52
- static void (APIENTRY * fptr_glStencilFuncSeparate)(GLenum,GLenum,GLint,GLuint);
53
- static VALUE
54
- gl_StencilFuncSeparate(obj,arg1,arg2,arg3,arg4)
55
- VALUE obj,arg1,arg2,arg3,arg4;
56
- {
57
- GLenum face;
58
- GLenum func;
59
- GLint ref;
60
- GLuint mask;
61
- LOAD_GL_FUNC(glStencilFuncSeparate)
62
- face = (GLenum)NUM2INT(arg1);
63
- func = (GLenum)NUM2INT(arg2);
64
- ref = (GLint)NUM2INT(arg3);
65
- mask = (GLuint)NUM2UINT(arg4);
66
- fptr_glStencilFuncSeparate(face,func,ref,mask);
67
- return Qnil;
68
- }
69
-
70
- static void (APIENTRY * fptr_glStencilMaskSeparate)(GLenum face,GLuint mask);
71
- static VALUE
72
- gl_StencilMaskSeparate(obj,arg1,arg2)
73
- VALUE obj,arg1,arg2;
74
- {
75
- GLenum face;
76
- GLuint mask;
77
- LOAD_GL_FUNC(glStencilMaskSeparate)
78
- face = (GLenum)NUM2INT(arg1);
79
- mask = (GLenum)NUM2INT(arg2);
80
- fptr_glStencilMaskSeparate(face,mask);
72
+ CHECK_GLERROR
81
73
  return Qnil;
82
74
  }
83
75
 
@@ -88,38 +80,15 @@ VALUE obj,arg1,arg2,arg3;
88
80
  {
89
81
  GLuint program;
90
82
  GLuint index;
91
- LOAD_GL_FUNC(glBindAttribLocation)
83
+ LOAD_GL_FUNC(glBindAttribLocation,"2.0")
92
84
  program = (GLuint)NUM2UINT(arg1);
93
85
  index = (GLuint)NUM2UINT(arg2);
94
86
  Check_Type(arg3, T_STRING);
95
- fptr_glBindAttribLocation(program,index,RSTRING(arg3)->ptr);
87
+ fptr_glBindAttribLocation(program,index,RSTRING_PTR(arg3));
88
+ CHECK_GLERROR
96
89
  return Qnil;
97
90
  }
98
91
 
99
- static GLuint (APIENTRY * fptr_glCreateProgram)(void);
100
- static VALUE
101
- gl_CreateProgram(obj)
102
- VALUE obj;
103
- {
104
- GLuint ret;
105
- LOAD_GL_FUNC(glCreateProgram)
106
- ret = fptr_glCreateProgram();
107
- return INT2NUM(ret);
108
- }
109
-
110
- static GLuint (APIENTRY * fptr_glCreateShader)(GLenum);
111
- static VALUE
112
- gl_CreateShader(obj,arg1)
113
- VALUE obj,arg1;
114
- {
115
- GLenum shaderType;
116
- GLuint ret;
117
- LOAD_GL_FUNC(glCreateShader)
118
- shaderType = (GLenum)NUM2INT(arg1);
119
- ret = fptr_glCreateShader(shaderType);
120
- return INT2NUM(ret);
121
- }
122
-
123
92
  static void (APIENTRY * fptr_glGetProgramiv)(GLuint,GLenum,GLint *);
124
93
  static VALUE
125
94
  gl_GetProgramiv(obj,arg1,arg2)
@@ -128,11 +97,12 @@ VALUE obj,arg1,arg2;
128
97
  GLuint program;
129
98
  GLenum pname;
130
99
  GLint params = 0;
131
- LOAD_GL_FUNC(glGetProgramiv)
100
+ LOAD_GL_FUNC(glGetProgramiv,"2.0")
132
101
  program = (GLuint)NUM2UINT(arg1);
133
102
  pname = (GLenum)NUM2INT(arg2);
134
103
  fptr_glGetProgramiv(program,pname,&params);
135
- return INT2NUM(params);
104
+ CHECK_GLERROR
105
+ return cond_GLBOOL2RUBY(pname,params);
136
106
  }
137
107
 
138
108
  static void (APIENTRY * fptr_glGetActiveAttrib)(GLuint,GLuint,GLsizei,GLsizei *,GLint *,GLenum *,GLchar *);
@@ -148,26 +118,28 @@ VALUE obj,arg1,arg2;
148
118
  GLenum attrib_type = 0;
149
119
  VALUE buffer;
150
120
  VALUE retary;
151
- LOAD_GL_FUNC(glGetActiveAttrib)
152
- LOAD_GL_FUNC(glGetProgramiv)
121
+ LOAD_GL_FUNC(glGetActiveAttrib,"2.0")
122
+ LOAD_GL_FUNC(glGetProgramiv,"2.0")
153
123
  program = (GLuint)NUM2UINT(arg1);
154
124
  index = (GLuint)NUM2UINT(arg2);
155
125
  fptr_glGetProgramiv(program,GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,&max_size);
126
+ CHECK_GLERROR
156
127
  if (max_size==0)
157
128
  rb_raise(rb_eTypeError, "Can't determine maximum attribute name length");
158
129
  buffer = allocate_buffer_with_string(max_size-1);
159
- fptr_glGetActiveAttrib(program,index,max_size,&written,&attrib_size,&attrib_type,RSTRING(buffer)->ptr);
130
+ fptr_glGetActiveAttrib(program,index,max_size,&written,&attrib_size,&attrib_type,RSTRING_PTR(buffer));
160
131
  retary = rb_ary_new2(3);
161
132
  rb_ary_push(retary, INT2NUM(attrib_size));
162
133
  rb_ary_push(retary, INT2NUM(attrib_type));
163
134
  rb_ary_push(retary, buffer);
135
+ CHECK_GLERROR
164
136
  return retary;
165
137
  }
166
138
 
167
139
  static void (APIENTRY * fptr_glGetActiveUniform)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*);
168
140
  static VALUE
169
- gl_GetActiveUniform(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
170
- VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7;
141
+ gl_GetActiveUniform(obj,arg1,arg2)
142
+ VALUE obj,arg1,arg2;
171
143
  {
172
144
  GLuint program;
173
145
  GLuint index;
@@ -177,19 +149,21 @@ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7;
177
149
  GLenum uniform_type = 0;
178
150
  VALUE buffer;
179
151
  VALUE retary;
180
- LOAD_GL_FUNC(glGetActiveUniform)
181
- LOAD_GL_FUNC(glGetProgramiv)
152
+ LOAD_GL_FUNC(glGetActiveUniform,"2.0")
153
+ LOAD_GL_FUNC(glGetProgramiv,"2.0")
182
154
  program = (GLuint)NUM2UINT(arg1);
183
155
  index = (GLuint)NUM2UINT(arg2);
184
156
  fptr_glGetProgramiv(program,GL_ACTIVE_UNIFORM_MAX_LENGTH,&max_size);
157
+ CHECK_GLERROR
185
158
  if (max_size==0)
186
159
  rb_raise(rb_eTypeError, "Can't determine maximum uniform name length");
187
160
  buffer = allocate_buffer_with_string(max_size-1);
188
- fptr_glGetActiveUniform(program,index,max_size,&written,&uniform_size,&uniform_type,RSTRING(buffer)->ptr);
161
+ fptr_glGetActiveUniform(program,index,max_size,&written,&uniform_size,&uniform_type,RSTRING_PTR(buffer));
189
162
  retary = rb_ary_new2(3);
190
163
  rb_ary_push(retary, INT2NUM(uniform_size));
191
164
  rb_ary_push(retary, INT2NUM(uniform_type));
192
165
  rb_ary_push(retary, buffer);
166
+ CHECK_GLERROR
193
167
  return retary;
194
168
  }
195
169
 
@@ -201,22 +175,17 @@ VALUE obj,arg1;
201
175
  GLuint program;
202
176
  GLint shaders_num = 0;
203
177
  GLuint *shaders;
204
- VALUE retary;
205
178
  GLsizei count = 0;
206
- GLint i;
207
- LOAD_GL_FUNC(glGetAttachedShaders)
208
- LOAD_GL_FUNC(glGetProgramiv)
179
+ LOAD_GL_FUNC(glGetAttachedShaders,"2.0")
180
+ LOAD_GL_FUNC(glGetProgramiv,"2.0")
209
181
  program = (GLuint)NUM2UINT(arg1);
210
182
  fptr_glGetProgramiv(program,GL_ATTACHED_SHADERS,&shaders_num);
183
+ CHECK_GLERROR
211
184
  if (shaders_num<=0)
212
185
  return Qnil;
213
186
  shaders = ALLOC_N(GLuint,shaders_num);
214
187
  fptr_glGetAttachedShaders(program,shaders_num,&count,shaders);
215
- retary = rb_ary_new2(shaders_num);
216
- for(i=0;i<shaders_num;i++)
217
- rb_ary_push(retary, INT2NUM(shaders[i]));
218
- xfree(shaders);
219
- return retary;
188
+ RET_ARRAY_OR_SINGLE_FREE(count,RETCONV_GLuint,shaders)
220
189
  }
221
190
 
222
191
  static GLint (APIENTRY * fptr_glGetAttribLocation)(GLuint, GLchar *);
@@ -226,10 +195,11 @@ VALUE obj,arg1,arg2;
226
195
  {
227
196
  GLuint program;
228
197
  GLint ret;
229
- LOAD_GL_FUNC(glGetAttribLocation)
198
+ LOAD_GL_FUNC(glGetAttribLocation,"2.0")
230
199
  program=(GLuint)NUM2UINT(arg1);
231
200
  Check_Type(arg2,T_STRING);
232
- ret = fptr_glGetAttribLocation(program,RSTRING(arg2)->ptr);
201
+ ret = fptr_glGetAttribLocation(program,RSTRING_PTR(arg2));
202
+ CHECK_GLERROR
233
203
  return INT2NUM(ret);
234
204
  }
235
205
 
@@ -242,15 +212,16 @@ VALUE obj,arg1;
242
212
  GLint max_size = 0;
243
213
  GLsizei ret_length = 0;
244
214
  VALUE buffer;
245
- LOAD_GL_FUNC(glGetProgramInfoLog)
246
- LOAD_GL_FUNC(glGetProgramiv)
215
+ LOAD_GL_FUNC(glGetProgramInfoLog,"2.0")
216
+ LOAD_GL_FUNC(glGetProgramiv,"2.0")
247
217
  program = (GLuint)NUM2UINT(arg1);
248
218
  fptr_glGetProgramiv(program,GL_INFO_LOG_LENGTH,&max_size);
219
+ CHECK_GLERROR
249
220
  if (max_size<=0)
250
221
  return rb_str_new2("");
251
222
  buffer = allocate_buffer_with_string(max_size);
252
- fptr_glGetProgramInfoLog(program,max_size,&ret_length,RSTRING(buffer)->ptr);
253
- RSTRING(buffer)->len = ret_length;
223
+ fptr_glGetProgramInfoLog(program,max_size,&ret_length,RSTRING_PTR(buffer));
224
+ CHECK_GLERROR
254
225
  return buffer;
255
226
  }
256
227
 
@@ -262,11 +233,12 @@ VALUE obj,arg1,arg2;
262
233
  GLuint program;
263
234
  GLenum pname;
264
235
  GLint params = 0;
265
- LOAD_GL_FUNC(glGetShaderiv)
236
+ LOAD_GL_FUNC(glGetShaderiv,"2.0")
266
237
  program = (GLuint)NUM2UINT(arg1);
267
238
  pname = (GLenum)NUM2INT(arg2);
268
239
  fptr_glGetShaderiv(program,pname,&params);
269
- return INT2NUM(params);
240
+ CHECK_GLERROR
241
+ return cond_GLBOOL2RUBY(pname,params);
270
242
  }
271
243
 
272
244
  static void (APIENTRY * fptr_glGetShaderInfoLog)(GLuint,GLsizei,GLsizei *,GLchar *);
@@ -279,10 +251,11 @@ VALUE obj,arg1;
279
251
  GLsizei ret_length = 0;
280
252
  VALUE ret_buffer;
281
253
  GLchar *buffer;
282
- LOAD_GL_FUNC(glGetShaderInfoLog)
283
- LOAD_GL_FUNC(glGetShaderiv)
254
+ LOAD_GL_FUNC(glGetShaderInfoLog,"2.0")
255
+ LOAD_GL_FUNC(glGetShaderiv,"2.0")
284
256
  program = (GLuint)NUM2UINT(arg1);
285
257
  fptr_glGetShaderiv(program,GL_INFO_LOG_LENGTH,&max_size);
258
+ CHECK_GLERROR
286
259
  if (max_size<=0)
287
260
  return rb_str_new2("");
288
261
  buffer = ALLOC_N(GLchar,max_size+1);
@@ -290,6 +263,7 @@ VALUE obj,arg1;
290
263
  fptr_glGetShaderInfoLog(program,max_size,&ret_length,buffer);
291
264
  ret_buffer = rb_str_new(buffer, ret_length);
292
265
  xfree(buffer);
266
+ CHECK_GLERROR
293
267
  return ret_buffer;
294
268
  }
295
269
 
@@ -302,14 +276,16 @@ VALUE obj,arg1;
302
276
  GLint max_size = 0;
303
277
  GLsizei ret_length = 0;
304
278
  VALUE buffer;
305
- LOAD_GL_FUNC(glGetShaderSource)
306
- LOAD_GL_FUNC(glGetShaderiv)
279
+ LOAD_GL_FUNC(glGetShaderSource,"2.0")
280
+ LOAD_GL_FUNC(glGetShaderiv,"2.0")
307
281
  shader = (GLuint)NUM2UINT(arg1);
308
282
  fptr_glGetShaderiv(shader,GL_SHADER_SOURCE_LENGTH,&max_size);
283
+ CHECK_GLERROR
309
284
  if (max_size==0)
310
285
  rb_raise(rb_eTypeError, "Can't determine maximum shader source length");
311
286
  buffer = allocate_buffer_with_string(max_size-1);
312
- fptr_glGetShaderSource(shader,max_size,&ret_length,RSTRING(buffer)->ptr);
287
+ fptr_glGetShaderSource(shader,max_size,&ret_length,RSTRING_PTR(buffer));
288
+ CHECK_GLERROR
313
289
  return buffer;
314
290
  }
315
291
 
@@ -320,179 +296,73 @@ VALUE obj,arg1,arg2;
320
296
  {
321
297
  GLuint program;
322
298
  GLint ret;
323
- LOAD_GL_FUNC(glGetUniformLocation)
299
+ LOAD_GL_FUNC(glGetUniformLocation,"2.0")
324
300
  program=(GLuint)NUM2UINT(arg1);
325
301
  Check_Type(arg2,T_STRING);
326
- ret = fptr_glGetUniformLocation(program,RSTRING(arg2)->ptr);
302
+ ret = fptr_glGetUniformLocation(program,RSTRING_PTR(arg2));
303
+ CHECK_GLERROR
327
304
  return INT2NUM(ret);
328
305
  }
329
306
 
330
-
331
- #define GET_UNIFORM_SIZE \
332
- switch (uniform_type) { \
333
- case GL_FLOAT: \
334
- case GL_INT: \
335
- case GL_BOOL: \
336
- case GL_SAMPLER_1D: \
337
- case GL_SAMPLER_2D: \
338
- case GL_SAMPLER_3D: \
339
- case GL_SAMPLER_CUBE: \
340
- case GL_SAMPLER_1D_SHADOW: \
341
- case GL_SAMPLER_2D_SHADOW: \
342
- uniform_size = 1; \
343
- break; \
344
- case GL_FLOAT_VEC2: \
345
- case GL_INT_VEC2: \
346
- case GL_BOOL_VEC2: \
347
- uniform_size = 2; \
348
- break; \
349
- case GL_FLOAT_VEC3: \
350
- case GL_INT_VEC3: \
351
- case GL_BOOL_VEC3: \
352
- uniform_size = 3; \
353
- break; \
354
- case GL_FLOAT_VEC4: \
355
- case GL_INT_VEC4: \
356
- case GL_BOOL_VEC4: \
357
- case GL_FLOAT_MAT2: \
358
- uniform_size = 4; \
359
- break; \
360
- case GL_FLOAT_MAT2x3: \
361
- case GL_FLOAT_MAT3x2: \
362
- uniform_size = 6; \
363
- break; \
364
- case GL_FLOAT_MAT2x4: \
365
- case GL_FLOAT_MAT4x2: \
366
- uniform_size = 8; \
367
- break; \
368
- case GL_FLOAT_MAT3: \
369
- uniform_size = 9; \
370
- break; \
371
- case GL_FLOAT_MAT4x3: \
372
- case GL_FLOAT_MAT3x4: \
373
- uniform_size = 12; \
374
- break; \
375
- case GL_FLOAT_MAT4: \
376
- uniform_size = 16; \
377
- break; \
378
- default: \
379
- rb_raise(rb_eTypeError, "Unsupported type '%i'",uniform_type); \
380
- }
381
-
382
- static void (APIENTRY * fptr_glGetUniformfv)(GLuint,GLint,GLfloat *);
383
- static VALUE
384
- gl_GetUniformfv(obj,arg1,arg2)
385
- VALUE obj,arg1,arg2;
386
- {
387
- GLuint program;
388
- GLint location;
389
- GLfloat params[16];
390
- VALUE retary;
391
- GLint i;
392
- GLint unused = 0;
393
- GLenum uniform_type = 0;
394
- GLint uniform_size = 0;
395
-
396
- LOAD_GL_FUNC(glGetUniformfv)
397
- LOAD_GL_FUNC(glGetActiveUniform)
398
- program = (GLuint)NUM2UINT(arg1);
399
- location = (GLint)NUM2INT(arg2);
400
-
401
- fptr_glGetActiveUniform(program,location,0,NULL,&unused,&uniform_type,NULL);
402
- if (uniform_type==0)
403
- rb_raise(rb_eTypeError, "Can't determine the uniform's type");
404
-
405
- GET_UNIFORM_SIZE
406
-
407
- memset(params,0,16*sizeof(GLfloat));
408
- fptr_glGetUniformfv(program,location,params);
409
- retary = rb_ary_new2(uniform_size);
410
- for(i=0;i<uniform_size;i++)
411
- rb_ary_push(retary, rb_float_new(params[i]));
412
- return retary;
413
- }
414
-
415
- static void (APIENTRY * fptr_glGetUniformiv)(GLuint,GLint,GLint *);
416
- static VALUE
417
- gl_GetUniformiv(obj,arg1,arg2)
418
- VALUE obj,arg1,arg2;
419
- {
420
- GLuint program;
421
- GLint location;
422
- GLint params[16];
423
- VALUE retary;
424
- GLint i;
425
- GLint unused = 0;
426
- GLenum uniform_type = 0;
427
- GLint uniform_size = 0;
428
- LOAD_GL_FUNC(glGetUniformiv)
429
- LOAD_GL_FUNC(glGetActiveUniform)
430
- program = (GLuint)NUM2UINT(arg1);
431
- location = (GLint)NUM2INT(arg2);
432
-
433
- fptr_glGetActiveUniform(program,location,0,NULL,&unused,&uniform_type,NULL);
434
- if (uniform_type==0)
435
- rb_raise(rb_eTypeError, "Can't determine the uniform's type");
436
-
437
- GET_UNIFORM_SIZE
438
-
439
- memset(params,0,16*sizeof(GLint));
440
- fptr_glGetUniformiv(program,location,params);
441
- retary = rb_ary_new2(uniform_size);
442
- for(i=0;i<uniform_size;i++)
443
- rb_ary_push(retary, INT2NUM(params[i]));
444
- return retary;
445
- }
446
-
447
- static void (APIENTRY * fptr_glGetVertexAttribdv)(GLuint,GLenum,GLdouble *);
448
- static VALUE
449
- gl_GetVertexAttribdv(obj,arg1,arg2)
450
- VALUE obj,arg1,arg2;
451
- {
452
- GLuint index;
453
- GLenum pname;
454
- GLdouble params[4] = {0.0,0.0,0.0,0.0};
455
- GLint size;
456
- GLint i;
457
- VALUE retary;
458
- LOAD_GL_FUNC(glGetVertexAttribdv)
459
- index = (GLuint)NUM2UINT(arg1);
460
- pname = (GLenum)NUM2INT(arg2);
461
- if (pname==GL_CURRENT_VERTEX_ATTRIB)
462
- size = 4;
463
- else
464
- size = 1;
465
- fptr_glGetVertexAttribdv(index,pname,params);
466
- retary = rb_ary_new2(size);
467
- for(i=0;i<size;i++)
468
- rb_ary_push(retary, rb_float_new(params[i]));
469
- return retary;
470
- }
471
-
472
- static void (APIENTRY * fptr_glGetVertexAttribfv)(GLuint,GLenum,GLfloat *);
473
- static VALUE
474
- gl_GetVertexAttribfv(obj,arg1,arg2)
475
- VALUE obj,arg1,arg2;
476
- {
477
- GLuint index;
478
- GLenum pname;
479
- GLfloat params[4] = {0.0,0.0,0.0,0.0};
480
- GLint size;
481
- GLint i;
482
- VALUE retary;
483
- LOAD_GL_FUNC(glGetVertexAttribfv)
484
- index = (GLuint)NUM2UINT(arg1);
485
- pname = (GLenum)NUM2INT(arg2);
486
- if (pname==GL_CURRENT_VERTEX_ATTRIB)
487
- size = 4;
488
- else
489
- size = 1;
490
- fptr_glGetVertexAttribfv(index,pname,params);
491
- retary = rb_ary_new2(size);
492
- for(i=0;i<size;i++)
493
- rb_ary_push(retary, rb_float_new(params[i]));
494
- return retary;
495
- }
307
+ #define GETUNIFORM_FUNC(_name_,_type_) \
308
+ static void (APIENTRY * fptr_gl##_name_)(GLuint,GLint,_type_ *); \
309
+ static VALUE \
310
+ gl_##_name_(obj,arg1,arg2) \
311
+ VALUE obj,arg1,arg2; \
312
+ { \
313
+ GLuint program; \
314
+ GLint location; \
315
+ _type_ params[16]; \
316
+ GLint unused = 0; \
317
+ GLenum uniform_type = 0; \
318
+ GLint uniform_size = 0; \
319
+ \
320
+ LOAD_GL_FUNC(gl##_name_,"2.0") \
321
+ LOAD_GL_FUNC(glGetActiveUniform,"2.0") \
322
+ program = (GLuint)NUM2UINT(arg1); \
323
+ location = (GLint)NUM2INT(arg2); \
324
+ \
325
+ fptr_glGetActiveUniform(program,location,0,NULL,&unused,&uniform_type,NULL); \
326
+ CHECK_GLERROR \
327
+ if (uniform_type==0) \
328
+ rb_raise(rb_eTypeError, "Can't determine the uniform's type"); \
329
+ \
330
+ uniform_size = get_uniform_size(uniform_type); \
331
+ \
332
+ memset(params,0,16*sizeof(_type_)); \
333
+ fptr_gl##_name_(program,location,params); \
334
+ RET_ARRAY_OR_SINGLE(uniform_size,RETCONV_##_type_,params) \
335
+ }
336
+
337
+ GETUNIFORM_FUNC(GetUniformfv,GLfloat)
338
+ GETUNIFORM_FUNC(GetUniformiv,GLint)
339
+ #undef GETUNIFORM_FUNC
340
+
341
+ #define GETVERTEXATTRIB_FUNC(_name_,_type_) \
342
+ static void (APIENTRY * fptr_gl##_name_)(GLuint,GLenum,_type_ *); \
343
+ static VALUE \
344
+ gl_##_name_(obj,arg1,arg2) \
345
+ VALUE obj,arg1,arg2; \
346
+ { \
347
+ GLuint index; \
348
+ GLenum pname; \
349
+ _type_ params[4] = {0,0,0,0}; \
350
+ GLint size; \
351
+ LOAD_GL_FUNC(gl##_name_,"2.0") \
352
+ index = (GLuint)NUM2UINT(arg1); \
353
+ pname = (GLenum)NUM2INT(arg2); \
354
+ if (pname==GL_CURRENT_VERTEX_ATTRIB) \
355
+ size = 4; \
356
+ else \
357
+ size = 1; \
358
+ fptr_gl##_name_(index,pname,params); \
359
+ RET_ARRAY_OR_SINGLE(size,RETCONV_##_type_,params) \
360
+ }
361
+
362
+ GETVERTEXATTRIB_FUNC(GetVertexAttribdv,GLdouble)
363
+ GETVERTEXATTRIB_FUNC(GetVertexAttribfv,GLfloat)
364
+ //GETVERTEXATTRIB_FUNC(GetVertexAttribiv,GLint,cond_GLBOOL2RUBY)
365
+ #undef GETVERTEXATTRIB_FUNC
496
366
 
497
367
  static void (APIENTRY * fptr_glGetVertexAttribiv)(GLuint,GLenum,GLint *);
498
368
  static VALUE
@@ -503,9 +373,7 @@ VALUE obj,arg1,arg2;
503
373
  GLenum pname;
504
374
  GLint params[4] = {0,0,0,0};
505
375
  GLint size;
506
- GLint i;
507
- VALUE retary;
508
- LOAD_GL_FUNC(glGetVertexAttribiv)
376
+ LOAD_GL_FUNC(glGetVertexAttribiv,"2.0")
509
377
  index = (GLuint)NUM2UINT(arg1);
510
378
  pname = (GLenum)NUM2INT(arg2);
511
379
  if (pname==GL_CURRENT_VERTEX_ATTRIB)
@@ -513,14 +381,11 @@ VALUE obj,arg1,arg2;
513
381
  else
514
382
  size = 1;
515
383
  fptr_glGetVertexAttribiv(index,pname,params);
516
- retary = rb_ary_new2(size);
517
- for(i=0;i<size;i++)
518
- rb_ary_push(retary, INT2NUM(params[i]));
519
- return retary;
384
+ RET_ARRAY_OR_SINGLE_BOOL(size,cond_GLBOOL2RUBY,pname,params)
520
385
  }
521
386
 
522
- #define _MAX_VERTEX_ATTRIBS 64 /* at least GL_MAX_VERTEX_ATTRIBS - usually 16 or 32 on today's high-end cards */
523
- static VALUE g_VertexAttrib_ptr[_MAX_VERTEX_ATTRIBS];
387
+
388
+ VALUE g_VertexAttrib_ptr[_MAX_VERTEX_ATTRIBS];
524
389
 
525
390
  static void (APIENTRY * fptr_glGetVertexAttribPointerv)(GLuint,GLenum,GLvoid **);
526
391
  static VALUE
@@ -528,7 +393,7 @@ gl_GetVertexAttribPointerv(obj,arg1)
528
393
  VALUE obj,arg1;
529
394
  {
530
395
  GLuint index;
531
- LOAD_GL_FUNC(glGetVertexAttribPointerv)
396
+ LOAD_GL_FUNC(glGetVertexAttribPointerv,"2.0")
532
397
  index =(GLuint) NUM2INT(arg1);
533
398
  if (index>_MAX_VERTEX_ATTRIBS)
534
399
  rb_raise(rb_eArgError, "Index too large, maximum allowed value '%i'",_MAX_VERTEX_ATTRIBS);
@@ -536,32 +401,6 @@ VALUE obj,arg1;
536
401
  return g_VertexAttrib_ptr[index];
537
402
  }
538
403
 
539
- static GLboolean (APIENTRY * fptr_glIsProgram)(GLuint);
540
- static VALUE
541
- gl_IsProgram(obj,arg1)
542
- VALUE obj,arg1;
543
- {
544
- GLuint program;
545
- GLboolean ret;
546
- LOAD_GL_FUNC(glIsProgram)
547
- program = (GLuint)NUM2UINT(arg1);
548
- ret = fptr_glIsProgram(program);
549
- return INT2NUM(ret);
550
- }
551
-
552
- static GLboolean (APIENTRY * fptr_glIsShader)(GLuint);
553
- static VALUE
554
- gl_IsShader(obj,arg1)
555
- VALUE obj,arg1;
556
- {
557
- GLuint program;
558
- GLboolean ret;
559
- LOAD_GL_FUNC(glIsShader)
560
- program = (GLuint)NUM2UINT(arg1);
561
- ret = fptr_glIsShader(program);
562
- return INT2NUM(ret);
563
- }
564
-
565
404
  static void (APIENTRY * fptr_glShaderSource)(GLuint,GLsizei,GLchar**,GLint *);
566
405
  static VALUE
567
406
  gl_ShaderSource(obj,arg1,arg2)
@@ -570,721 +409,116 @@ VALUE obj,arg1,arg2;
570
409
  GLuint shader;
571
410
  GLint length;
572
411
  GLchar *str;
573
- LOAD_GL_FUNC(glShaderSource)
412
+ LOAD_GL_FUNC(glShaderSource,"2.0")
574
413
  shader = (GLuint)NUM2UINT(arg1);
575
414
  Check_Type(arg2,T_STRING);
576
- str = RSTRING(arg2)->ptr;
577
- length = RSTRING(arg2)->len;
415
+ str = RSTRING_PTR(arg2);
416
+ length = RSTRING_LEN(arg2);
578
417
  fptr_glShaderSource(shader,1,&str,&length);
418
+ CHECK_GLERROR
579
419
  return Qnil;
580
420
  }
581
421
 
582
- static void (APIENTRY * fptr_glUniform1f)(GLint,GLfloat);
583
- static VALUE
584
- gl_Uniform1f(obj,arg1,arg2)
585
- VALUE obj,arg1,arg2;
586
- {
587
- GLint location;
588
- GLfloat v0;
589
- LOAD_GL_FUNC(glUniform1f)
590
- location = (GLint)NUM2INT(arg1);
591
- v0 = (GLfloat)NUM2DBL(arg2);
592
- fptr_glUniform1f(location,v0);
593
- return Qnil;
594
- }
595
-
596
- static void (APIENTRY * fptr_glUniform2f)(GLint,GLfloat,GLfloat);
597
- static VALUE
598
- gl_Uniform2f(obj,arg1,arg2,arg3)
599
- VALUE obj,arg1,arg2,arg3;
600
- {
601
- GLint location;
602
- GLfloat v0;
603
- GLfloat v1;
604
- LOAD_GL_FUNC(glUniform2f)
605
- location = (GLint)NUM2INT(arg1);
606
- v0 = (GLfloat)NUM2DBL(arg2);
607
- v1 = (GLfloat)NUM2DBL(arg3);
608
- fptr_glUniform2f(location,v0,v1);
609
- return Qnil;
610
- }
611
-
612
- static void (APIENTRY * fptr_glUniform3f)(GLint,GLfloat,GLfloat,GLfloat);
613
- static VALUE
614
- gl_Uniform3f(obj,arg1,arg2,arg3,arg4)
615
- VALUE obj,arg1,arg2,arg3,arg4;
616
- {
617
- GLint location;
618
- GLfloat v0;
619
- GLfloat v1;
620
- GLfloat v2;
621
- LOAD_GL_FUNC(glUniform3f)
622
- location = (GLint)NUM2INT(arg1);
623
- v0 = (GLfloat)NUM2DBL(arg2);
624
- v1 = (GLfloat)NUM2DBL(arg3);
625
- v2 = (GLfloat)NUM2DBL(arg4);
626
- fptr_glUniform3f(location,v0,v1,v2);
627
- return Qnil;
628
- }
629
-
630
- static void (APIENTRY * fptr_glUniform4f)(GLint,GLfloat,GLfloat,GLfloat,GLfloat);
631
- static VALUE
632
- gl_Uniform4f(obj,arg1,arg2,arg3,arg4,arg5)
633
- VALUE obj,arg1,arg2,arg3,arg4,arg5;
634
- {
635
- GLint location;
636
- GLfloat v0;
637
- GLfloat v1;
638
- GLfloat v2;
639
- GLfloat v3;
640
- LOAD_GL_FUNC(glUniform4f)
641
- location = (GLint)NUM2INT(arg1);
642
- v0 = (GLfloat)NUM2DBL(arg2);
643
- v1 = (GLfloat)NUM2DBL(arg3);
644
- v2 = (GLfloat)NUM2DBL(arg4);
645
- v3 = (GLfloat)NUM2DBL(arg5);
646
- fptr_glUniform4f(location,v0,v1,v2,v3);
647
- return Qnil;
648
- }
649
-
650
- static void (APIENTRY * fptr_glUniform1fv)(GLint,GLsizei,GLfloat *);
651
- static VALUE
652
- gl_Uniform1fv(obj,arg1,arg2,arg3)
653
- VALUE obj,arg1,arg2,arg3;
654
- {
655
- GLint location;
656
- GLsizei count;
657
- GLfloat *value;
658
- LOAD_GL_FUNC(glUniform1fv)
659
- location = (GLint)NUM2INT(arg1);
660
- count = (GLsizei)NUM2UINT(arg2);
661
- value = ALLOC_N(GLfloat,1*count);
662
- ary2cflt(arg3,value,1*count);
663
- fptr_glUniform1fv(location,count,value);
664
- xfree(value);
665
- return Qnil;
666
- }
667
-
668
- static void (APIENTRY * fptr_glUniform2fv)(GLint,GLsizei,GLfloat *);
669
- static VALUE
670
- gl_Uniform2fv(obj,arg1,arg2,arg3)
671
- VALUE obj,arg1,arg2,arg3;
672
- {
673
- GLint location;
674
- GLsizei count;
675
- GLfloat *value;
676
- LOAD_GL_FUNC(glUniform2fv)
677
- location = (GLint)NUM2INT(arg1);
678
- count = (GLsizei)NUM2UINT(arg2);
679
- value = ALLOC_N(GLfloat,2*count);
680
- ary2cflt(arg3,value,2*count);
681
- fptr_glUniform2fv(location,count,value);
682
- xfree(value);
683
- return Qnil;
684
- }
685
-
686
- static void (APIENTRY * fptr_glUniform3fv)(GLint,GLsizei,GLfloat *);
687
- static VALUE
688
- gl_Uniform3fv(obj,arg1,arg2,arg3)
689
- VALUE obj,arg1,arg2,arg3;
690
- {
691
- GLint location;
692
- GLsizei count;
693
- GLfloat *value;
694
- LOAD_GL_FUNC(glUniform3fv)
695
- location = (GLint)NUM2INT(arg1);
696
- count = (GLsizei)NUM2UINT(arg2);
697
- value = ALLOC_N(GLfloat,3*count);
698
- ary2cflt(arg3,value,3*count);
699
- fptr_glUniform3fv(location,count,value);
700
- xfree(value);
701
- return Qnil;
702
- }
703
-
704
- static void (APIENTRY * fptr_glUniform4fv)(GLint,GLsizei,GLfloat *);
705
- static VALUE
706
- gl_Uniform4fv(obj,arg1,arg2,arg3)
707
- VALUE obj,arg1,arg2,arg3;
708
- {
709
- GLint location;
710
- GLsizei count;
711
- GLfloat *value;
712
- LOAD_GL_FUNC(glUniform4fv)
713
- location = (GLint)NUM2INT(arg1);
714
- count = (GLsizei)NUM2UINT(arg2);
715
- value = ALLOC_N(GLfloat,4*count);
716
- ary2cflt(arg3,value,4*count);
717
- fptr_glUniform4fv(location,count,value);
718
- xfree(value);
719
- return Qnil;
720
- }
721
-
722
- static void (APIENTRY * fptr_glUniform1iv)(GLint,GLsizei,GLint *);
723
- static VALUE
724
- gl_Uniform1iv(obj,arg1,arg2,arg3)
725
- VALUE obj,arg1,arg2,arg3;
726
- {
727
- GLint location;
728
- GLsizei count;
729
- GLint *value;
730
- LOAD_GL_FUNC(glUniform1iv)
731
- location = (GLint)NUM2INT(arg1);
732
- count = (GLsizei)NUM2UINT(arg2);
733
- value = ALLOC_N(GLint,1*count);
734
- ary2cint(arg3,value,1*count);
735
- fptr_glUniform1iv(location,count,value);
736
- xfree(value);
737
- return Qnil;
738
- }
739
-
740
- static void (APIENTRY * fptr_glUniform2iv)(GLint,GLsizei,GLint *);
741
- static VALUE
742
- gl_Uniform2iv(obj,arg1,arg2,arg3)
743
- VALUE obj,arg1,arg2,arg3;
744
- {
745
- GLint location;
746
- GLsizei count;
747
- GLint *value;
748
- LOAD_GL_FUNC(glUniform2iv)
749
- location = (GLint)NUM2INT(arg1);
750
- count = (GLsizei)NUM2UINT(arg2);
751
- value = ALLOC_N(GLint,2*count);
752
- ary2cint(arg3,value,2*count);
753
- fptr_glUniform2iv(location,count,value);
754
- xfree(value);
755
- return Qnil;
756
- }
757
-
758
- static void (APIENTRY * fptr_glUniform3iv)(GLint,GLsizei,GLint *);
759
- static VALUE
760
- gl_Uniform3iv(obj,arg1,arg2,arg3)
761
- VALUE obj,arg1,arg2,arg3;
762
- {
763
- GLint location;
764
- GLsizei count;
765
- GLint *value;
766
- LOAD_GL_FUNC(glUniform3iv)
767
- location = (GLint)NUM2INT(arg1);
768
- count = (GLsizei)NUM2UINT(arg2);
769
- value = ALLOC_N(GLint,3*count);
770
- ary2cint(arg3,value,3*count);
771
- fptr_glUniform3iv(location,count,value);
772
- xfree(value);
773
- return Qnil;
774
- }
775
-
776
- static void (APIENTRY * fptr_glUniform4iv)(GLint,GLsizei,GLint *);
777
- static VALUE
778
- gl_Uniform4iv(obj,arg1,arg2,arg3)
779
- VALUE obj,arg1,arg2,arg3;
780
- {
781
- GLint location;
782
- GLsizei count;
783
- GLint *value;
784
- LOAD_GL_FUNC(glUniform4iv)
785
- location = (GLint)NUM2INT(arg1);
786
- count = (GLsizei)NUM2UINT(arg2);
787
- value = ALLOC_N(GLint,4*count);
788
- ary2cint(arg3,value,4*count);
789
- fptr_glUniform4iv(location,count,value);
790
- xfree(value);
791
- return Qnil;
792
- }
793
-
794
- static void (APIENTRY * fptr_glUniformMatrix2fv)(GLint,GLsizei,GLboolean,GLfloat *);
795
- static VALUE
796
- gl_UniformMatrix2fv(obj,arg1,arg2,arg3,arg4)
797
- VALUE obj,arg1,arg2,arg3,arg4;
798
- {
799
- GLint location;
800
- GLsizei count;
801
- GLboolean transpose;
802
- GLfloat *value;
803
- LOAD_GL_FUNC(glUniformMatrix2fv)
804
- location = (GLint)NUM2INT(arg1);
805
- count = (GLint)NUM2INT(arg2);
806
- transpose = (GLboolean)NUM2INT(arg3);
807
- value = ALLOC_N(GLfloat, 2*2*count);
808
- ary2cflt(arg4,value,2*2*count);
809
- fptr_glUniformMatrix2fv(location,count,transpose,value);
810
- xfree(value);
811
- return Qnil;
812
- }
813
-
814
- static void (APIENTRY * fptr_glUniformMatrix3fv)(GLint,GLsizei,GLboolean,GLfloat *);
815
- static VALUE
816
- gl_UniformMatrix3fv(obj,arg1,arg2,arg3,arg4)
817
- VALUE obj,arg1,arg2,arg3,arg4;
818
- {
819
- GLint location;
820
- GLsizei count;
821
- GLboolean transpose;
822
- GLfloat *value;
823
- LOAD_GL_FUNC(glUniformMatrix3fv)
824
- location = (GLint)NUM2INT(arg1);
825
- count = (GLint)NUM2INT(arg2);
826
- transpose = (GLboolean)NUM2INT(arg3);
827
- value = ALLOC_N(GLfloat, 3*3*count);
828
- ary2cflt(arg4,value,3*3*count);
829
- fptr_glUniformMatrix3fv(location,count,transpose,value);
830
- xfree(value);
831
- return Qnil;
832
- }
833
-
834
- static void (APIENTRY * fptr_glUniformMatrix4fv)(GLint,GLsizei,GLboolean,GLfloat *);
835
- static VALUE
836
- gl_UniformMatrix4fv(obj,arg1,arg2,arg3,arg4)
837
- VALUE obj,arg1,arg2,arg3,arg4;
838
- {
839
- GLint location;
840
- GLsizei count;
841
- GLboolean transpose;
842
- GLfloat *value;
843
- LOAD_GL_FUNC(glUniformMatrix4fv)
844
- location = (GLint)NUM2INT(arg1);
845
- count = (GLint)NUM2INT(arg2);
846
- transpose = (GLboolean)NUM2INT(arg3);
847
- value = ALLOC_N(GLfloat, 4*4*count);
848
- ary2cflt(arg4,value,4*4*count);
849
- fptr_glUniformMatrix4fv(location,count,transpose,value);
850
- xfree(value);
851
- return Qnil;
852
- }
853
-
854
- static void (APIENTRY * fptr_glVertexAttrib1d)(GLuint,GLdouble);
855
- static VALUE
856
- gl_VertexAttrib1d(obj,arg1,arg2)
857
- VALUE obj,arg1,arg2;
858
- {
859
- GLuint index;
860
- GLdouble v0;
861
- LOAD_GL_FUNC(glVertexAttrib1d)
862
- index = (GLuint)NUM2UINT(arg1);
863
- v0 = (GLdouble)NUM2DBL(arg2);
864
- fptr_glVertexAttrib1d(index,v0);
865
- return Qnil;
866
- }
867
-
868
- static void (APIENTRY * fptr_glVertexAttrib1f)(GLuint,GLfloat);
869
- static VALUE
870
- gl_VertexAttrib1f(obj,arg1,arg2)
871
- VALUE obj,arg1,arg2;
872
- {
873
- GLuint index;
874
- GLfloat v0;
875
- LOAD_GL_FUNC(glVertexAttrib1f)
876
- index = (GLuint)NUM2UINT(arg1);
877
- v0 = (GLfloat)NUM2DBL(arg2);
878
- fptr_glVertexAttrib1f(index,v0);
879
- return Qnil;
880
- }
881
-
882
- static void (APIENTRY * fptr_glVertexAttrib1s)(GLuint,GLshort);
883
- static VALUE
884
- gl_VertexAttrib1s(obj,arg1,arg2)
885
- VALUE obj,arg1,arg2;
886
- {
887
- GLuint index;
888
- GLshort v0;
889
- LOAD_GL_FUNC(glVertexAttrib1s)
890
- index = (GLuint)NUM2UINT(arg1);
891
- v0 = (GLshort)NUM2INT(arg2);
892
- fptr_glVertexAttrib1s(index,v0);
893
- return Qnil;
894
- }
895
-
896
- static void (APIENTRY * fptr_glVertexAttrib2d)(GLuint,GLdouble,GLdouble);
897
- static VALUE
898
- gl_VertexAttrib2d(obj,arg1,arg2,arg3)
899
- VALUE obj,arg1,arg2,arg3;
900
- {
901
- GLuint index;
902
- GLdouble v0;
903
- GLdouble v1;
904
- LOAD_GL_FUNC(glVertexAttrib2d)
905
- index = (GLuint)NUM2UINT(arg1);
906
- v0 = (GLdouble)NUM2DBL(arg2);
907
- v1 = (GLdouble)NUM2DBL(arg3);
908
- fptr_glVertexAttrib2d(index,v0,v1);
909
- return Qnil;
910
- }
911
-
912
- static void (APIENTRY * fptr_glVertexAttrib2f)(GLuint,GLfloat,GLfloat);
913
- static VALUE
914
- gl_VertexAttrib2f(obj,arg1,arg2,arg3)
915
- VALUE obj,arg1,arg2,arg3;
916
- {
917
- GLuint index;
918
- GLfloat v0;
919
- GLfloat v1;
920
- LOAD_GL_FUNC(glVertexAttrib2f)
921
- index = (GLuint)NUM2UINT(arg1);
922
- v0 = (GLfloat)NUM2DBL(arg2);
923
- v1 = (GLfloat)NUM2DBL(arg3);
924
- fptr_glVertexAttrib2f(index,v0,v1);
925
- return Qnil;
926
- }
927
-
928
- static void (APIENTRY * fptr_glVertexAttrib2s)(GLuint,GLshort,GLshort);
929
- static VALUE
930
- gl_VertexAttrib2s(obj,arg1,arg2,arg3)
931
- VALUE obj,arg1,arg2,arg3;
932
- {
933
- GLuint index;
934
- GLshort v0;
935
- GLshort v1;
936
- LOAD_GL_FUNC(glVertexAttrib2s)
937
- index = (GLuint)NUM2UINT(arg1);
938
- v0 = (GLshort)NUM2INT(arg2);
939
- v1 = (GLshort)NUM2INT(arg3);
940
- fptr_glVertexAttrib2s(index,v0,v1);
941
- return Qnil;
942
- }
943
-
944
- static void (APIENTRY * fptr_glVertexAttrib3d)(GLuint,GLdouble,GLdouble,GLdouble);
945
- static VALUE
946
- gl_VertexAttrib3d(obj,arg1,arg2,arg3,arg4)
947
- VALUE obj,arg1,arg2,arg3,arg4;
948
- {
949
- GLuint index;
950
- GLdouble v0;
951
- GLdouble v1;
952
- GLdouble v2;
953
- LOAD_GL_FUNC(glVertexAttrib3d)
954
- index = (GLuint)NUM2UINT(arg1);
955
- v0 = (GLdouble)NUM2DBL(arg2);
956
- v1 = (GLdouble)NUM2DBL(arg3);
957
- v2 = (GLdouble)NUM2DBL(arg4);
958
- fptr_glVertexAttrib3d(index,v0,v1,v2);
959
- return Qnil;
960
- }
961
-
962
- static void (APIENTRY * fptr_glVertexAttrib3f)(GLuint,GLfloat,GLfloat,GLfloat);
963
- static VALUE
964
- gl_VertexAttrib3f(obj,arg1,arg2,arg3,arg4)
965
- VALUE obj,arg1,arg2,arg3,arg4;
966
- {
967
- GLuint index;
968
- GLfloat v0;
969
- GLfloat v1;
970
- GLfloat v2;
971
- LOAD_GL_FUNC(glVertexAttrib3f)
972
- index = (GLuint)NUM2UINT(arg1);
973
- v0 = (GLfloat)NUM2DBL(arg2);
974
- v1 = (GLfloat)NUM2DBL(arg3);
975
- v2 = (GLfloat)NUM2DBL(arg4);
976
- fptr_glVertexAttrib3f(index,v0,v1,v2);
977
- return Qnil;
978
- }
979
-
980
- static void (APIENTRY * fptr_glVertexAttrib3s)(GLuint,GLshort,GLshort,GLshort);
981
- static VALUE
982
- gl_VertexAttrib3s(obj,arg1,arg2,arg3,arg4)
983
- VALUE obj,arg1,arg2,arg3,arg4;
984
- {
985
- GLuint index;
986
- GLshort v0;
987
- GLshort v1;
988
- GLshort v2;
989
- LOAD_GL_FUNC(glVertexAttrib3s)
990
- index = (GLuint)NUM2UINT(arg1);
991
- v0 = (GLshort)NUM2INT(arg2);
992
- v1 = (GLshort)NUM2INT(arg3);
993
- v2 = (GLshort)NUM2INT(arg4);
994
- fptr_glVertexAttrib3s(index,v0,v1,v2);
995
- return Qnil;
996
- }
997
-
998
- static void (APIENTRY * fptr_glVertexAttrib4Nbv)(GLuint,GLbyte *);
999
- static VALUE
1000
- gl_VertexAttrib4Nbv(obj,arg1,arg2)
1001
- VALUE obj,arg1,arg2;
1002
- {
1003
- GLuint index;
1004
- GLbyte v[4];
1005
- LOAD_GL_FUNC(glVertexAttrib4Nbv)
1006
- index = (GLuint)NUM2UINT(arg1);
1007
- ary2cbyte(arg2,v,4);
1008
- fptr_glVertexAttrib4Nbv(index,v);
1009
- return Qnil;
1010
- }
1011
-
1012
- static void (APIENTRY * fptr_glVertexAttrib4Niv)(GLuint,GLint *);
1013
- static VALUE
1014
- gl_VertexAttrib4Niv(obj,arg1,arg2)
1015
- VALUE obj,arg1,arg2;
1016
- {
1017
- GLuint index;
1018
- GLint v[4];
1019
- LOAD_GL_FUNC(glVertexAttrib4Niv)
1020
- index = (GLuint)NUM2UINT(arg1);
1021
- ary2cint(arg2,v,4);
1022
- fptr_glVertexAttrib4Niv(index,v);
1023
- return Qnil;
1024
- }
1025
-
1026
- static void (APIENTRY * fptr_glVertexAttrib4Nsv)(GLuint,GLshort *);
1027
- static VALUE
1028
- gl_VertexAttrib4Nsv(obj,arg1,arg2)
1029
- VALUE obj,arg1,arg2;
1030
- {
1031
- GLuint index;
1032
- GLshort v[4];
1033
- LOAD_GL_FUNC(glVertexAttrib4Nsv)
1034
- index = (GLuint)NUM2UINT(arg1);
1035
- ary2cshort(arg2,v,4);
1036
- fptr_glVertexAttrib4Nsv(index,v);
1037
- return Qnil;
1038
- }
1039
-
1040
- static void (APIENTRY * fptr_glVertexAttrib4Nub)(GLuint,GLubyte,GLubyte,GLubyte,GLubyte);
1041
- static VALUE
1042
- gl_VertexAttrib4Nub(obj,arg1,arg2,arg3,arg4,arg5)
1043
- VALUE obj,arg1,arg2,arg3,arg4,arg5;
1044
- {
1045
- GLuint index;
1046
- GLubyte v0;
1047
- GLubyte v1;
1048
- GLubyte v2;
1049
- GLubyte v3;
1050
- LOAD_GL_FUNC(glVertexAttrib4Nub)
1051
- index = (GLuint)NUM2UINT(arg1);
1052
- v0 = (GLubyte)NUM2INT(arg2);
1053
- v1 = (GLubyte)NUM2INT(arg3);
1054
- v2 = (GLubyte)NUM2INT(arg4);
1055
- v3 = (GLubyte)NUM2INT(arg5);
1056
- fptr_glVertexAttrib4Nub(index,v0,v1,v2,v3);
1057
- return Qnil;
1058
- }
1059
-
1060
- static void (APIENTRY * fptr_glVertexAttrib4Nubv)(GLuint,GLubyte *);
1061
- static VALUE
1062
- gl_VertexAttrib4Nubv(obj,arg1,arg2)
1063
- VALUE obj,arg1,arg2;
1064
- {
1065
- GLuint index;
1066
- GLubyte v[4];
1067
- LOAD_GL_FUNC(glVertexAttrib4Nubv)
1068
- index = (GLuint)NUM2UINT(arg1);
1069
- ary2cubyte(arg2,v,4);
1070
- fptr_glVertexAttrib4Nubv(index,v);
1071
- return Qnil;
1072
- }
1073
-
1074
- static void (APIENTRY * fptr_glVertexAttrib4Nuiv)(GLuint,GLuint *);
1075
- static VALUE
1076
- gl_VertexAttrib4Nuiv(obj,arg1,arg2)
1077
- VALUE obj,arg1,arg2;
1078
- {
1079
- GLuint index;
1080
- GLuint v[4];
1081
- LOAD_GL_FUNC(glVertexAttrib4Nuiv)
1082
- index = (GLuint)NUM2UINT(arg1);
1083
- ary2cuint(arg2,v,4);
1084
- fptr_glVertexAttrib4Nuiv(index,v);
1085
- return Qnil;
1086
- }
1087
-
1088
- static void (APIENTRY * fptr_glVertexAttrib4Nusv)(GLuint,GLushort *);
1089
- static VALUE
1090
- gl_VertexAttrib4Nusv(obj,arg1,arg2)
1091
- VALUE obj,arg1,arg2;
1092
- {
1093
- GLuint index;
1094
- GLushort v[4];
1095
- LOAD_GL_FUNC(glVertexAttrib4Nusv)
1096
- index = (GLuint)NUM2UINT(arg1);
1097
- ary2cushort(arg2,v,4);
1098
- fptr_glVertexAttrib4Nusv(index,v);
1099
- return Qnil;
1100
- }
1101
-
1102
- static void (APIENTRY * fptr_glVertexAttrib4bv)(GLuint,GLbyte *);
1103
- static VALUE
1104
- gl_VertexAttrib4bv(obj,arg1,arg2)
1105
- VALUE obj,arg1,arg2;
1106
- {
1107
- GLuint index;
1108
- GLbyte v[4];
1109
- LOAD_GL_FUNC(glVertexAttrib4bv)
1110
- index = (GLuint)NUM2UINT(arg1);
1111
- ary2cbyte(arg2,v,4);
1112
- fptr_glVertexAttrib4bv(index,v);
1113
- return Qnil;
1114
- }
1115
-
1116
- static void (APIENTRY * fptr_glVertexAttrib4d)(GLuint,GLdouble,GLdouble,GLdouble,GLdouble);
1117
- static VALUE
1118
- gl_VertexAttrib4d(obj,arg1,arg2,arg3,arg4,arg5)
1119
- VALUE obj,arg1,arg2,arg3,arg4,arg5;
1120
- {
1121
- GLuint index;
1122
- GLdouble v0;
1123
- GLdouble v1;
1124
- GLdouble v2;
1125
- GLdouble v3;
1126
- LOAD_GL_FUNC(glVertexAttrib4d)
1127
- index = (GLuint)NUM2UINT(arg1);
1128
- v0 = (GLdouble)NUM2DBL(arg2);
1129
- v1 = (GLdouble)NUM2DBL(arg3);
1130
- v2 = (GLdouble)NUM2DBL(arg4);
1131
- v3 = (GLdouble)NUM2DBL(arg5);
1132
- fptr_glVertexAttrib4d(index,v0,v1,v2,v3);
1133
- return Qnil;
1134
- }
1135
-
1136
- static void (APIENTRY * fptr_glVertexAttrib4f)(GLuint,GLfloat,GLfloat,GLfloat,GLfloat);
1137
- static VALUE
1138
- gl_VertexAttrib4f(obj,arg1,arg2,arg3,arg4,arg5)
1139
- VALUE obj,arg1,arg2,arg3,arg4,arg5;
1140
- {
1141
- GLuint index;
1142
- GLfloat v0;
1143
- GLfloat v1;
1144
- GLfloat v2;
1145
- GLfloat v3;
1146
- LOAD_GL_FUNC(glVertexAttrib4f)
1147
- index = (GLuint)NUM2UINT(arg1);
1148
- v0 = (GLfloat)NUM2DBL(arg2);
1149
- v1 = (GLfloat)NUM2DBL(arg3);
1150
- v2 = (GLfloat)NUM2DBL(arg4);
1151
- v3 = (GLfloat)NUM2DBL(arg5);
1152
- fptr_glVertexAttrib4f(index,v0,v1,v2,v3);
1153
- return Qnil;
1154
- }
1155
-
1156
- static void (APIENTRY * fptr_glVertexAttrib4iv)(GLuint,GLint *);
1157
- static VALUE
1158
- gl_VertexAttrib4iv(obj,arg1,arg2)
1159
- VALUE obj,arg1,arg2;
1160
- {
1161
- GLuint index;
1162
- GLint v[4];
1163
- LOAD_GL_FUNC(glVertexAttrib4iv)
1164
- index = (GLuint)NUM2UINT(arg1);
1165
- ary2cint(arg2,v,4);
1166
- fptr_glVertexAttrib4iv(index,v);
1167
- return Qnil;
1168
- }
1169
-
1170
- static void (APIENTRY * fptr_glVertexAttrib4s)(GLuint,GLshort,GLshort,GLshort,GLshort);
1171
- static VALUE
1172
- gl_VertexAttrib4s(obj,arg1,arg2,arg3,arg4,arg5)
1173
- VALUE obj,arg1,arg2,arg3,arg4,arg5;
1174
- {
1175
- GLuint index;
1176
- GLshort v0;
1177
- GLshort v1;
1178
- GLshort v2;
1179
- GLshort v3;
1180
- LOAD_GL_FUNC(glVertexAttrib4s)
1181
- index = (GLuint)NUM2UINT(arg1);
1182
- v0 = (GLshort)NUM2INT(arg2);
1183
- v1 = (GLshort)NUM2INT(arg3);
1184
- v2 = (GLshort)NUM2INT(arg4);
1185
- v3 = (GLshort)NUM2INT(arg5);
1186
- fptr_glVertexAttrib4s(index,v0,v1,v2,v3);
1187
- return Qnil;
422
+ #define UNIFORM_FUNC_V(_name_,_type_,_conv_,_size_) \
423
+ static void (APIENTRY * fptr_gl##_name_)(GLint,GLsizei,_type_ *); \
424
+ static VALUE \
425
+ gl_##_name_(obj,arg1,arg2) \
426
+ VALUE obj,arg1,arg2; \
427
+ { \
428
+ GLint location; \
429
+ GLsizei count; \
430
+ _type_ *value; \
431
+ LOAD_GL_FUNC(gl##_name_,"2.0") \
432
+ Check_Type(arg2,T_ARRAY); \
433
+ count = RARRAY_LEN(arg2); \
434
+ if (count<=0 || (count % _size_) != 0) \
435
+ rb_raise(rb_eArgError, "Parameter array size must be multiplication of %i",_size_); \
436
+ location = (GLint)NUM2INT(arg1); \
437
+ value = ALLOC_N(_type_,count); \
438
+ _conv_(arg2,value,count); \
439
+ fptr_gl##_name_(location,count / _size_,value); \
440
+ xfree(value); \
441
+ CHECK_GLERROR \
442
+ return Qnil; \
1188
443
  }
1189
444
 
1190
- static void (APIENTRY * fptr_glVertexAttrib4ubv)(GLuint,GLubyte *);
1191
- static VALUE
1192
- gl_VertexAttrib4ubv(obj,arg1,arg2)
1193
- VALUE obj,arg1,arg2;
1194
- {
1195
- GLuint index;
1196
- GLubyte v[4];
1197
- LOAD_GL_FUNC(glVertexAttrib4ubv)
1198
- index = (GLuint)NUM2UINT(arg1);
1199
- ary2cubyte(arg2,v,4);
1200
- fptr_glVertexAttrib4ubv(index,v);
1201
- return Qnil;
1202
- }
445
+ UNIFORM_FUNC_V(Uniform1fv,GLfloat,ary2cflt,1)
446
+ UNIFORM_FUNC_V(Uniform1iv,GLint,ary2cint,1)
447
+ UNIFORM_FUNC_V(Uniform2fv,GLfloat,ary2cflt,2)
448
+ UNIFORM_FUNC_V(Uniform2iv,GLint,ary2cint,2)
449
+ UNIFORM_FUNC_V(Uniform3fv,GLfloat,ary2cflt,3)
450
+ UNIFORM_FUNC_V(Uniform3iv,GLint,ary2cint,3)
451
+ UNIFORM_FUNC_V(Uniform4fv,GLfloat,ary2cflt,4)
452
+ UNIFORM_FUNC_V(Uniform4iv,GLint,ary2cint,4)
453
+ #undef UNIFORM_FUNC_V
1203
454
 
1204
- static void (APIENTRY * fptr_glVertexAttrib4uiv)(GLuint,GLuint *);
1205
- static VALUE
1206
- gl_VertexAttrib4uiv(obj,arg1,arg2)
1207
- VALUE obj,arg1,arg2;
1208
- {
1209
- GLuint index;
1210
- GLuint v[4];
1211
- LOAD_GL_FUNC(glVertexAttrib4uiv)
1212
- index = (GLuint)NUM2UINT(arg1);
1213
- ary2cuint(arg2,v,4);
1214
- fptr_glVertexAttrib4uiv(index,v);
1215
- return Qnil;
455
+ #define UNIFORMMATRIX_FUNC(_name_,_size_) \
456
+ static void (APIENTRY * fptr_gl##_name_)(GLint,GLsizei,GLboolean,GLfloat *); \
457
+ static VALUE \
458
+ gl_##_name_(obj,arg1,arg2,arg3) \
459
+ VALUE obj,arg1,arg2,arg3; \
460
+ { \
461
+ GLint location; \
462
+ GLsizei count; \
463
+ GLboolean transpose; \
464
+ GLfloat *value; \
465
+ LOAD_GL_FUNC(gl##_name_,"2.0") \
466
+ location = (GLint)NUM2INT(arg1); \
467
+ count = RARRAY_LEN(rb_funcall(rb_Array(arg3),rb_intern("flatten"),0)); \
468
+ transpose = (GLboolean)NUM2INT(arg2); \
469
+ value = ALLOC_N(GLfloat, count); \
470
+ ary2cmatfloatcount(arg3,value,_size_,_size_); \
471
+ fptr_gl##_name_(location,count / (_size_*_size_),transpose,value); \
472
+ xfree(value); \
473
+ CHECK_GLERROR \
474
+ return Qnil; \
1216
475
  }
1217
476
 
1218
- static void (APIENTRY * fptr_glVertexAttrib4usv)(GLuint,GLushort *);
1219
- static VALUE
1220
- gl_VertexAttrib4usv(obj,arg1,arg2)
1221
- VALUE obj,arg1,arg2;
1222
- {
1223
- GLuint index;
1224
- GLushort v[4];
1225
- LOAD_GL_FUNC(glVertexAttrib4usv)
1226
- index = (GLuint)NUM2UINT(arg1);
1227
- ary2cushort(arg2,v,4);
1228
- fptr_glVertexAttrib4usv(index,v);
1229
- return Qnil;
1230
- }
477
+ UNIFORMMATRIX_FUNC(UniformMatrix2fv,2)
478
+ UNIFORMMATRIX_FUNC(UniformMatrix3fv,3)
479
+ UNIFORMMATRIX_FUNC(UniformMatrix4fv,4)
480
+ #undef UNIFORMMATRIX_FUNC
1231
481
 
1232
- #define GLVERTEXATTRIB_VFUNC(_type_) \
482
+ #define VERTEXATTRIB_FUNC_V(_name_,_type_,_conv_,_size_) \
483
+ static void (APIENTRY * fptr_gl##_name_)(GLuint,_type_ *); \
1233
484
  static VALUE \
1234
- gl_VertexAttrib##_type_##v(argc,argv,obj) \
1235
- int argc; \
1236
- VALUE *argv; \
1237
- VALUE obj; \
485
+ gl_##_name_(obj,arg1,arg2) \
486
+ VALUE obj,arg1,arg2; \
1238
487
  { \
1239
- VALUE args[5]; \
1240
- RArray *ary; \
1241
- switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) { \
1242
- case 2: \
1243
- if (TYPE(args[1]) == T_ARRAY) { \
1244
- ary = RARRAY(args[1]); \
1245
- switch (ary->len) { \
1246
- case 1: \
1247
- gl_VertexAttrib1##_type_(obj,args[0],ary->ptr[0]); \
1248
- break; \
1249
- case 2: \
1250
- gl_VertexAttrib2##_type_(obj,args[0],ary->ptr[0],ary->ptr[1]); \
1251
- break; \
1252
- case 3: \
1253
- gl_VertexAttrib3##_type_(obj,args[0],ary->ptr[0],ary->ptr[1],ary->ptr[2]); \
1254
- break; \
1255
- case 4: \
1256
- gl_VertexAttrib4##_type_(obj,args[0],ary->ptr[0],ary->ptr[1],ary->ptr[2],ary->ptr[3]); \
1257
- break; \
1258
- default: \
1259
- rb_raise(rb_eRuntimeError, "glVertex vertex num error!:%d", ary->len); \
1260
- } \
1261
- } \
1262
- else { \
1263
- gl_VertexAttrib1##_type_(obj,args[0], args[1]); \
1264
- break; \
1265
- } \
1266
- break; \
1267
- case 3: \
1268
- gl_VertexAttrib2##_type_(obj,args[0], args[1], args[2]); \
1269
- break; \
1270
- case 4: \
1271
- gl_VertexAttrib3##_type_(obj,args[0], args[1], args[2], args[3]); \
1272
- break; \
1273
- case 5: \
1274
- gl_VertexAttrib4##_type_(obj,args[0], args[1], args[2], args[3], args[4]); \
1275
- break; \
1276
- default: \
1277
- rb_raise(rb_eArgError, "Argument number error!"); \
1278
- break; \
1279
- } \
488
+ GLuint index; \
489
+ _type_ v[_size_]; \
490
+ LOAD_GL_FUNC(gl##_name_,"2.0") \
491
+ index = (GLuint)NUM2UINT(arg1); \
492
+ _conv_(arg2,v,_size_); \
493
+ fptr_gl##_name_(index,v); \
494
+ CHECK_GLERROR \
1280
495
  return Qnil; \
1281
496
  }
1282
497
 
1283
- GLVERTEXATTRIB_VFUNC(d)
1284
- GLVERTEXATTRIB_VFUNC(f)
1285
- GLVERTEXATTRIB_VFUNC(s)
1286
-
1287
- #undef GLVERTEXATTRIB_VFUNC
498
+ VERTEXATTRIB_FUNC_V(VertexAttrib4Nbv,GLbyte,ary2cbyte,4)
499
+ VERTEXATTRIB_FUNC_V(VertexAttrib4Niv,GLint,ary2cint,4)
500
+ VERTEXATTRIB_FUNC_V(VertexAttrib4Nsv,GLshort,ary2cshort,4)
501
+ VERTEXATTRIB_FUNC_V(VertexAttrib4Nubv,GLubyte,ary2cubyte,4)
502
+ VERTEXATTRIB_FUNC_V(VertexAttrib4Nuiv,GLuint,ary2cuint,4)
503
+ VERTEXATTRIB_FUNC_V(VertexAttrib4Nusv,GLushort,ary2cushort,4)
504
+ VERTEXATTRIB_FUNC_V(VertexAttrib4uiv,GLuint,ary2cuint,4)
505
+ VERTEXATTRIB_FUNC_V(VertexAttrib4ubv,GLubyte,ary2cubyte,4)
506
+ VERTEXATTRIB_FUNC_V(VertexAttrib4usv,GLushort,ary2cushort,4)
507
+ VERTEXATTRIB_FUNC_V(VertexAttrib4bv,GLbyte,ary2cbyte,4)
508
+ VERTEXATTRIB_FUNC_V(VertexAttrib4iv,GLint,ary2cint,4)
509
+ VERTEXATTRIB_FUNC_V(VertexAttrib4dv,GLdouble,ary2cdbl,4)
510
+ VERTEXATTRIB_FUNC_V(VertexAttrib4fv,GLfloat,ary2cflt,4)
511
+ VERTEXATTRIB_FUNC_V(VertexAttrib4sv,GLshort,ary2cshort,4)
512
+ VERTEXATTRIB_FUNC_V(VertexAttrib3dv,GLdouble,ary2cdbl,3)
513
+ VERTEXATTRIB_FUNC_V(VertexAttrib3fv,GLfloat,ary2cflt,3)
514
+ VERTEXATTRIB_FUNC_V(VertexAttrib3sv,GLshort,ary2cshort,3)
515
+ VERTEXATTRIB_FUNC_V(VertexAttrib2dv,GLdouble,ary2cdbl,2)
516
+ VERTEXATTRIB_FUNC_V(VertexAttrib2fv,GLfloat,ary2cflt,2)
517
+ VERTEXATTRIB_FUNC_V(VertexAttrib2sv,GLshort,ary2cshort,2)
518
+ VERTEXATTRIB_FUNC_V(VertexAttrib1dv,GLdouble,ary2cdbl,1)
519
+ VERTEXATTRIB_FUNC_V(VertexAttrib1fv,GLfloat,ary2cflt,1)
520
+ VERTEXATTRIB_FUNC_V(VertexAttrib1sv,GLshort,ary2cshort,1)
521
+ #undef VERTEXATTRIB_FUNC_V
1288
522
 
1289
523
  static void (APIENTRY * fptr_glVertexAttribPointer)(GLuint,GLint,GLenum,GLboolean,GLsizei,GLvoid *);
1290
524
  static VALUE
@@ -1296,7 +530,7 @@ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
1296
530
  GLenum type;
1297
531
  GLboolean normalized;
1298
532
  GLsizei stride;
1299
- LOAD_GL_FUNC(glVertexAttribPointer)
533
+ LOAD_GL_FUNC(glVertexAttribPointer,"2.0")
1300
534
  index = (GLuint)NUM2UINT(arg1);
1301
535
  size = (GLuint)NUM2UINT(arg2);
1302
536
  type = (GLenum)NUM2INT(arg3);
@@ -1309,11 +543,13 @@ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
1309
543
  g_VertexAttrib_ptr[index] = arg6;
1310
544
  fptr_glVertexAttribPointer(index,size,type,normalized,stride,(GLvoid *)NUM2INT(arg6));
1311
545
  } else {
1312
- Check_Type(arg6, T_STRING);
1313
- rb_str_freeze(arg6);
1314
- g_VertexAttrib_ptr[index] = arg6;
1315
- fptr_glVertexAttribPointer(index,size,type,normalized,stride,(GLvoid *)RSTRING(arg6)->ptr);
546
+ VALUE data;
547
+ data = pack_array_or_pass_string(type,arg6);
548
+ rb_str_freeze(data);
549
+ g_VertexAttrib_ptr[index] = data;
550
+ fptr_glVertexAttribPointer(index,size,type,normalized,stride,(GLvoid *)RSTRING_PTR(data));
1316
551
  }
552
+ CHECK_GLERROR
1317
553
  return Qnil;
1318
554
  }
1319
555
 
@@ -1363,17 +599,17 @@ void gl_init_functions_2_0(VALUE module)
1363
599
  rb_define_module_function(module, "glUniform2i", gl_Uniform2i, 3);
1364
600
  rb_define_module_function(module, "glUniform3i", gl_Uniform3i, 4);
1365
601
  rb_define_module_function(module, "glUniform4i", gl_Uniform4i, 5);
1366
- rb_define_module_function(module, "glUniform1fv", gl_Uniform1fv, 3);
1367
- rb_define_module_function(module, "glUniform2fv", gl_Uniform2fv, 3);
1368
- rb_define_module_function(module, "glUniform3fv", gl_Uniform3fv, 3);
1369
- rb_define_module_function(module, "glUniform4fv", gl_Uniform4fv, 3);
1370
- rb_define_module_function(module, "glUniform1iv", gl_Uniform1iv, 3);
1371
- rb_define_module_function(module, "glUniform2iv", gl_Uniform2iv, 3);
1372
- rb_define_module_function(module, "glUniform3iv", gl_Uniform3iv, 3);
1373
- rb_define_module_function(module, "glUniform4iv", gl_Uniform4iv, 3);
1374
- rb_define_module_function(module, "glUniformMatrix2fv", gl_UniformMatrix2fv, 4);
1375
- rb_define_module_function(module, "glUniformMatrix3fv", gl_UniformMatrix3fv, 4);
1376
- rb_define_module_function(module, "glUniformMatrix4fv", gl_UniformMatrix4fv, 4);
602
+ rb_define_module_function(module, "glUniform1fv", gl_Uniform1fv, 2);
603
+ rb_define_module_function(module, "glUniform2fv", gl_Uniform2fv, 2);
604
+ rb_define_module_function(module, "glUniform3fv", gl_Uniform3fv, 2);
605
+ rb_define_module_function(module, "glUniform4fv", gl_Uniform4fv, 2);
606
+ rb_define_module_function(module, "glUniform1iv", gl_Uniform1iv, 2);
607
+ rb_define_module_function(module, "glUniform2iv", gl_Uniform2iv, 2);
608
+ rb_define_module_function(module, "glUniform3iv", gl_Uniform3iv, 2);
609
+ rb_define_module_function(module, "glUniform4iv", gl_Uniform4iv, 2);
610
+ rb_define_module_function(module, "glUniformMatrix2fv", gl_UniformMatrix2fv, 3);
611
+ rb_define_module_function(module, "glUniformMatrix3fv", gl_UniformMatrix3fv, 3);
612
+ rb_define_module_function(module, "glUniformMatrix4fv", gl_UniformMatrix4fv, 3);
1377
613
  rb_define_module_function(module, "glValidateProgram", gl_ValidateProgram, 1);
1378
614
  rb_define_module_function(module, "glVertexAttrib1d", gl_VertexAttrib1d, 2);
1379
615
  rb_define_module_function(module, "glVertexAttrib1f", gl_VertexAttrib1f, 2);
@@ -1399,22 +635,20 @@ void gl_init_functions_2_0(VALUE module)
1399
635
  rb_define_module_function(module, "glVertexAttrib4ubv", gl_VertexAttrib4ubv, 2);
1400
636
  rb_define_module_function(module, "glVertexAttrib4uiv", gl_VertexAttrib4uiv, 2);
1401
637
  rb_define_module_function(module, "glVertexAttrib4usv", gl_VertexAttrib4usv, 2);
638
+ rb_define_module_function(module, "glVertexAttrib1dv", gl_VertexAttrib1dv, 2);
639
+ rb_define_module_function(module, "glVertexAttrib1fv", gl_VertexAttrib1fv, 2);
640
+ rb_define_module_function(module, "glVertexAttrib1sv", gl_VertexAttrib1sv, 2);
641
+ rb_define_module_function(module, "glVertexAttrib2dv", gl_VertexAttrib2dv, 2);
642
+ rb_define_module_function(module, "glVertexAttrib2fv", gl_VertexAttrib2fv, 2);
643
+ rb_define_module_function(module, "glVertexAttrib2sv", gl_VertexAttrib2sv, 2);
644
+ rb_define_module_function(module, "glVertexAttrib3dv", gl_VertexAttrib3dv, 2);
645
+ rb_define_module_function(module, "glVertexAttrib3fv", gl_VertexAttrib3fv, 2);
646
+ rb_define_module_function(module, "glVertexAttrib3sv", gl_VertexAttrib3sv, 2);
647
+ rb_define_module_function(module, "glVertexAttrib4dv", gl_VertexAttrib4dv, 2);
648
+ rb_define_module_function(module, "glVertexAttrib4fv", gl_VertexAttrib4fv, 2);
649
+ rb_define_module_function(module, "glVertexAttrib4sv", gl_VertexAttrib4sv, 2);
1402
650
  rb_define_module_function(module, "glVertexAttribPointer", gl_VertexAttribPointer, 6);
1403
651
 
1404
- /* Additional functions */
1405
- rb_define_module_function(module, "glVertexAttrib1dv", gl_VertexAttribdv, -1);
1406
- rb_define_module_function(module, "glVertexAttrib1fv", gl_VertexAttribfv, -1);
1407
- rb_define_module_function(module, "glVertexAttrib1sv", gl_VertexAttribsv, -1);
1408
- rb_define_module_function(module, "glVertexAttrib2dv", gl_VertexAttribdv, -1);
1409
- rb_define_module_function(module, "glVertexAttrib2fv", gl_VertexAttribfv, -1);
1410
- rb_define_module_function(module, "glVertexAttrib2sv", gl_VertexAttribsv, -1);
1411
- rb_define_module_function(module, "glVertexAttrib3dv", gl_VertexAttribdv, -1);
1412
- rb_define_module_function(module, "glVertexAttrib3fv", gl_VertexAttribfv, -1);
1413
- rb_define_module_function(module, "glVertexAttrib3sv", gl_VertexAttribsv, -1);
1414
- rb_define_module_function(module, "glVertexAttrib4dv", gl_VertexAttribdv, -1);
1415
- rb_define_module_function(module, "glVertexAttrib4fv", gl_VertexAttribfv, -1);
1416
- rb_define_module_function(module, "glVertexAttrib4sv", gl_VertexAttribsv, -1);
1417
-
1418
652
  {
1419
653
  int i;
1420
654
  for (i=0;i<_MAX_VERTEX_ATTRIBS;i++)