opengl 0.7.0.pre1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +8 -0
- data/History.txt +36 -0
- data/MIT-LICENSE +18 -0
- data/Manifest.txt +140 -0
- data/README.rdoc +51 -0
- data/Rakefile +129 -0
- data/Rakefile.cross +104 -0
- data/doc/build_install.txt +119 -0
- data/doc/extensions.txt.in +348 -0
- data/doc/history.txt +66 -0
- data/doc/requirements_and_design.txt +117 -0
- data/doc/roadmap.txt +28 -0
- data/doc/scientific_use.txt +35 -0
- data/doc/supplies/page_template.html +71 -0
- data/doc/thanks.txt +29 -0
- data/doc/tutorial.txt +469 -0
- data/examples/NeHe/nehe_lesson02.rb +117 -0
- data/examples/NeHe/nehe_lesson03.rb +122 -0
- data/examples/NeHe/nehe_lesson04.rb +133 -0
- data/examples/NeHe/nehe_lesson05.rb +186 -0
- data/examples/NeHe/nehe_lesson36.rb +303 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +376 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +406 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +16 -0
- data/examples/RedBook/aapoly.rb +142 -0
- data/examples/RedBook/aargb.rb +119 -0
- data/examples/RedBook/accanti.rb +162 -0
- data/examples/RedBook/accpersp.rb +215 -0
- data/examples/RedBook/alpha.rb +123 -0
- data/examples/RedBook/alpha3D.rb +158 -0
- data/examples/RedBook/bezcurve.rb +105 -0
- data/examples/RedBook/bezmesh.rb +137 -0
- data/examples/RedBook/checker.rb +124 -0
- data/examples/RedBook/clip.rb +95 -0
- data/examples/RedBook/colormat.rb +135 -0
- data/examples/RedBook/cube.rb +69 -0
- data/examples/RedBook/depthcue.rb +99 -0
- data/examples/RedBook/dof.rb +205 -0
- data/examples/RedBook/double.rb +105 -0
- data/examples/RedBook/drawf.rb +91 -0
- data/examples/RedBook/feedback.rb +145 -0
- data/examples/RedBook/fog.rb +167 -0
- data/examples/RedBook/font.rb +151 -0
- data/examples/RedBook/hello.rb +79 -0
- data/examples/RedBook/image.rb +137 -0
- data/examples/RedBook/jitter.rb +207 -0
- data/examples/RedBook/lines.rb +128 -0
- data/examples/RedBook/list.rb +111 -0
- data/examples/RedBook/material.rb +275 -0
- data/examples/RedBook/mipmap.rb +156 -0
- data/examples/RedBook/model.rb +113 -0
- data/examples/RedBook/movelight.rb +132 -0
- data/examples/RedBook/pickdepth.rb +179 -0
- data/examples/RedBook/planet.rb +108 -0
- data/examples/RedBook/quadric.rb +158 -0
- data/examples/RedBook/robot.rb +115 -0
- data/examples/RedBook/select.rb +196 -0
- data/examples/RedBook/smooth.rb +95 -0
- data/examples/RedBook/stencil.rb +163 -0
- data/examples/RedBook/stroke.rb +167 -0
- data/examples/RedBook/surface.rb +166 -0
- data/examples/RedBook/teaambient.rb +132 -0
- data/examples/RedBook/teapots.rb +182 -0
- data/examples/RedBook/tess.rb +183 -0
- data/examples/RedBook/texbind.rb +147 -0
- data/examples/RedBook/texgen.rb +169 -0
- data/examples/RedBook/texturesurf.rb +128 -0
- data/examples/RedBook/varray.rb +159 -0
- data/examples/RedBook/wrap.rb +148 -0
- data/examples/misc/OGLBench.rb +337 -0
- data/examples/misc/anisotropic.rb +194 -0
- data/examples/misc/fbo_test.rb +356 -0
- data/examples/misc/font-glut.rb +46 -0
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/plane.rb +161 -0
- data/examples/misc/readpixel.rb +65 -0
- data/examples/misc/sdltest.rb +34 -0
- data/examples/misc/trislam.rb +828 -0
- data/ext/common/common.h +448 -0
- data/ext/common/conv.h +234 -0
- data/ext/common/funcdef.h +280 -0
- data/ext/common/gl-enums.h +10031 -0
- data/ext/common/gl-error.h +23 -0
- data/ext/common/gl-types.h +67 -0
- data/ext/common/glu-enums.h +463 -0
- data/ext/gl/extconf.rb +43 -0
- data/ext/gl/gl-1.0-1.1.c +2811 -0
- data/ext/gl/gl-1.2.c +814 -0
- data/ext/gl/gl-1.3.c +443 -0
- data/ext/gl/gl-1.4.c +348 -0
- data/ext/gl/gl-1.5.c +225 -0
- data/ext/gl/gl-2.0.c +657 -0
- data/ext/gl/gl-2.1.c +57 -0
- data/ext/gl/gl-enums.c +3354 -0
- data/ext/gl/gl-error.c +104 -0
- data/ext/gl/gl-ext-3dfx.c +27 -0
- data/ext/gl/gl-ext-arb.c +866 -0
- data/ext/gl/gl-ext-ati.c +41 -0
- data/ext/gl/gl-ext-ext.c +889 -0
- data/ext/gl/gl-ext-gremedy.c +41 -0
- data/ext/gl/gl-ext-nv.c +679 -0
- data/ext/gl/gl.c +216 -0
- data/ext/glu/extconf.rb +51 -0
- data/ext/glu/glu-enums.c +164 -0
- data/ext/glu/glu.c +1530 -0
- data/ext/glut/extconf.rb +67 -0
- data/ext/glut/glut.c +1624 -0
- data/lib/opengl.rb +89 -0
- data/test/README +10 -0
- data/test/tc_common.rb +98 -0
- data/test/tc_ext_arb.rb +467 -0
- data/test/tc_ext_ati.rb +33 -0
- data/test/tc_ext_ext.rb +551 -0
- data/test/tc_ext_gremedy.rb +36 -0
- data/test/tc_ext_nv.rb +357 -0
- data/test/tc_func_10_11.rb +1281 -0
- data/test/tc_func_12.rb +186 -0
- data/test/tc_func_13.rb +229 -0
- data/test/tc_func_14.rb +197 -0
- data/test/tc_func_15.rb +270 -0
- data/test/tc_func_20.rb +346 -0
- data/test/tc_func_21.rb +541 -0
- data/test/tc_glu.rb +310 -0
- data/test/tc_include_gl.rb +35 -0
- data/test/tc_misc.rb +54 -0
- data/test/tc_require_gl.rb +34 -0
- data/utils/README +11 -0
- data/utils/enumgen.rb +112 -0
- data/utils/extlistgen.rb +90 -0
- data/utils/mkdn2html.rb +59 -0
- data/utils/post-mkdn2html.rb +91 -0
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +198 -0
- metadata +274 -0
data/ext/gl/gl-1.5.c
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
|
3
|
+
*
|
4
|
+
* This program is distributed under the terms of the MIT license.
|
5
|
+
* See the included MIT-LICENSE file for the terms of this license.
|
6
|
+
*
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
8
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
9
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
10
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
11
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
12
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
13
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
|
+
*/
|
15
|
+
|
16
|
+
#include "../common/common.h"
|
17
|
+
|
18
|
+
/* OpenGL 1.5 functions */
|
19
|
+
|
20
|
+
GL_FUNC_LOAD_1(EndQuery,GLvoid, GLenum, "1.5")
|
21
|
+
GL_FUNC_LOAD_1(IsQuery,GLboolean, GLuint, "1.5")
|
22
|
+
GL_FUNC_LOAD_2(BeginQuery,GLvoid, GLenum,GLuint, "1.5")
|
23
|
+
GL_FUNC_LOAD_2(BindBuffer,GLvoid, GLenum,GLuint, "1.5")
|
24
|
+
GL_FUNC_LOAD_1(IsBuffer,GLboolean, GLuint, "1.5")
|
25
|
+
GL_FUNC_GENOBJECTS_LOAD(GenQueries,"1.5")
|
26
|
+
GL_FUNC_DELETEOBJECTS_LOAD(DeleteQueries,"1.5")
|
27
|
+
GL_FUNC_GENOBJECTS_LOAD(GenBuffers,"1.5")
|
28
|
+
GL_FUNC_DELETEOBJECTS_LOAD(DeleteBuffers,"1.5")
|
29
|
+
|
30
|
+
static void (APIENTRY * fptr_glGetQueryiv)(GLenum,GLenum,GLint *);
|
31
|
+
static VALUE
|
32
|
+
gl_GetQueryiv(obj,arg1,arg2)
|
33
|
+
VALUE obj,arg1,arg2;
|
34
|
+
{
|
35
|
+
GLenum target;
|
36
|
+
GLenum pname;
|
37
|
+
GLint params = 0;
|
38
|
+
LOAD_GL_FUNC(glGetQueryiv,"1.5")
|
39
|
+
target = (GLenum)NUM2INT(arg1);
|
40
|
+
pname = (GLenum)NUM2INT(arg2);
|
41
|
+
fptr_glGetQueryiv(target,pname,¶ms);
|
42
|
+
CHECK_GLERROR
|
43
|
+
return RETCONV_GLint(params);
|
44
|
+
}
|
45
|
+
|
46
|
+
static void (APIENTRY * fptr_glGetQueryObjectiv)(GLuint,GLenum,GLint *);
|
47
|
+
static VALUE
|
48
|
+
gl_GetQueryObjectiv(obj,arg1,arg2)
|
49
|
+
VALUE obj,arg1,arg2;
|
50
|
+
{
|
51
|
+
GLuint id;
|
52
|
+
GLenum pname;
|
53
|
+
GLint params = 0;
|
54
|
+
LOAD_GL_FUNC(glGetQueryObjectiv,"1.5")
|
55
|
+
id = (GLuint)NUM2UINT(arg1);
|
56
|
+
pname = (GLenum)NUM2INT(arg2);
|
57
|
+
fptr_glGetQueryObjectiv(id,pname,¶ms);
|
58
|
+
CHECK_GLERROR
|
59
|
+
return cond_GLBOOL2RUBY(pname,params);
|
60
|
+
}
|
61
|
+
|
62
|
+
static void (APIENTRY * fptr_glGetQueryObjectuiv)(GLuint,GLenum,GLuint *);
|
63
|
+
static VALUE
|
64
|
+
gl_GetQueryObjectuiv(obj,arg1,arg2)
|
65
|
+
VALUE obj,arg1,arg2;
|
66
|
+
{
|
67
|
+
GLuint id;
|
68
|
+
GLenum pname;
|
69
|
+
GLuint params = 0;
|
70
|
+
LOAD_GL_FUNC(glGetQueryObjectuiv,"1.5")
|
71
|
+
id = (GLuint)NUM2UINT(arg1);
|
72
|
+
pname = (GLenum)NUM2INT(arg2);
|
73
|
+
fptr_glGetQueryObjectuiv(id,pname,¶ms);
|
74
|
+
CHECK_GLERROR
|
75
|
+
return cond_GLBOOL2RUBY_U(pname,params);
|
76
|
+
}
|
77
|
+
|
78
|
+
static void (APIENTRY * fptr_glBufferData)(GLenum,GLsizeiptr,GLvoid *,GLenum);
|
79
|
+
static VALUE
|
80
|
+
gl_BufferData(obj,arg1,arg2,arg3,arg4)
|
81
|
+
VALUE obj,arg1,arg2,arg3,arg4;
|
82
|
+
{
|
83
|
+
GLenum target;
|
84
|
+
GLsizeiptr size;
|
85
|
+
GLenum usage;
|
86
|
+
LOAD_GL_FUNC(glBufferData,"1.5")
|
87
|
+
target = (GLenum)NUM2INT(arg1);
|
88
|
+
size = (GLsizeiptr)NUM2INT(arg2);
|
89
|
+
usage = (GLenum)NUM2INT(arg4);
|
90
|
+
if (TYPE(arg3) == T_STRING) {
|
91
|
+
fptr_glBufferData(target,size,(GLvoid *)RSTRING_PTR(arg3),usage);
|
92
|
+
} else if (NIL_P(arg3)) {
|
93
|
+
fptr_glBufferData(target,size,NULL,usage);
|
94
|
+
} else {
|
95
|
+
Check_Type(arg3,T_STRING); /* force exception */
|
96
|
+
}
|
97
|
+
CHECK_GLERROR
|
98
|
+
return Qnil;
|
99
|
+
}
|
100
|
+
|
101
|
+
static void (APIENTRY * fptr_glBufferSubData)(GLenum,GLintptr,GLsizeiptr,GLvoid *);
|
102
|
+
static VALUE
|
103
|
+
gl_BufferSubData(obj,arg1,arg2,arg3,arg4)
|
104
|
+
VALUE obj,arg1,arg2,arg3,arg4;
|
105
|
+
{
|
106
|
+
GLenum target;
|
107
|
+
GLintptr offset;
|
108
|
+
GLsizeiptr size;
|
109
|
+
LOAD_GL_FUNC(glBufferSubData,"1.5")
|
110
|
+
target = (GLenum)NUM2INT(arg1);
|
111
|
+
offset = (GLintptr)NUM2INT(arg2);
|
112
|
+
size = (GLsizeiptr)NUM2INT(arg3);
|
113
|
+
Check_Type(arg4,T_STRING);
|
114
|
+
fptr_glBufferSubData(target,offset,size,(GLvoid *)RSTRING_PTR(arg4));
|
115
|
+
CHECK_GLERROR
|
116
|
+
return Qnil;
|
117
|
+
}
|
118
|
+
|
119
|
+
static void (APIENTRY * fptr_glGetBufferSubData)(GLenum,GLintptr,GLsizeiptr,GLvoid *);
|
120
|
+
static VALUE
|
121
|
+
gl_GetBufferSubData(obj,arg1,arg2,arg3)
|
122
|
+
VALUE obj,arg1,arg2,arg3;
|
123
|
+
{
|
124
|
+
GLenum target;
|
125
|
+
GLintptr offset;
|
126
|
+
GLsizeiptr size;
|
127
|
+
VALUE data;
|
128
|
+
LOAD_GL_FUNC(glGetBufferSubData,"1.5")
|
129
|
+
target = (GLenum)NUM2INT(arg1);
|
130
|
+
offset = (GLintptr)NUM2INT(arg2);
|
131
|
+
size = (GLsizeiptr)NUM2INT(arg3);
|
132
|
+
data = allocate_buffer_with_string((long)size);
|
133
|
+
fptr_glGetBufferSubData(target,offset,size,(GLvoid *)RSTRING_PTR(data));
|
134
|
+
CHECK_GLERROR
|
135
|
+
return data;
|
136
|
+
}
|
137
|
+
|
138
|
+
static void (APIENTRY * fptr_glGetBufferParameteriv)(GLenum,GLenum,GLint *);
|
139
|
+
static VALUE
|
140
|
+
gl_GetBufferParameteriv(obj,arg1,arg2)
|
141
|
+
VALUE obj,arg1,arg2;
|
142
|
+
{
|
143
|
+
GLenum target;
|
144
|
+
GLenum value;
|
145
|
+
GLint data = 0;
|
146
|
+
LOAD_GL_FUNC(glGetBufferParameteriv,"1.5")
|
147
|
+
target = (GLenum)NUM2INT(arg1);
|
148
|
+
value = (GLenum)NUM2INT(arg2);
|
149
|
+
fptr_glGetBufferParameteriv(target,value,&data);
|
150
|
+
CHECK_GLERROR
|
151
|
+
return cond_GLBOOL2RUBY(value,data);
|
152
|
+
}
|
153
|
+
|
154
|
+
static GLvoid * (APIENTRY * fptr_glMapBuffer)(GLenum,GLenum);
|
155
|
+
static VALUE
|
156
|
+
gl_MapBuffer(obj,arg1,arg2)
|
157
|
+
VALUE obj,arg1,arg2;
|
158
|
+
{
|
159
|
+
GLenum target;
|
160
|
+
GLenum access;
|
161
|
+
GLint size = 0;
|
162
|
+
VALUE data;
|
163
|
+
GLvoid *buffer_ptr = NULL;
|
164
|
+
LOAD_GL_FUNC(glMapBuffer,"1.5")
|
165
|
+
LOAD_GL_FUNC(glGetBufferParameteriv,"1.5")
|
166
|
+
target = (GLenum)NUM2INT(arg1);
|
167
|
+
access = (GLenum)NUM2INT(arg2);
|
168
|
+
fptr_glGetBufferParameteriv(target,GL_BUFFER_SIZE,&size);
|
169
|
+
CHECK_GLERROR
|
170
|
+
buffer_ptr = fptr_glMapBuffer(target,access);
|
171
|
+
CHECK_GLERROR
|
172
|
+
if (buffer_ptr==NULL || size<=0)
|
173
|
+
return Qnil;
|
174
|
+
data = allocate_buffer_with_string(size);
|
175
|
+
memcpy(RSTRING_PTR(data), buffer_ptr, size);
|
176
|
+
return data;
|
177
|
+
}
|
178
|
+
|
179
|
+
static GLboolean (APIENTRY * fptr_glUnmapBuffer)(GLenum);
|
180
|
+
static VALUE
|
181
|
+
gl_UnmapBuffer(obj,arg1)
|
182
|
+
VALUE obj,arg1;
|
183
|
+
{
|
184
|
+
GLenum target;
|
185
|
+
GLboolean ret;
|
186
|
+
LOAD_GL_FUNC(glUnmapBuffer,"1.5")
|
187
|
+
target = (GLenum)NUM2INT(arg1);
|
188
|
+
ret = fptr_glUnmapBuffer(target);
|
189
|
+
CHECK_GLERROR
|
190
|
+
return GLBOOL2RUBY(ret);
|
191
|
+
}
|
192
|
+
|
193
|
+
static void (APIENTRY * fptr_glGetBufferPointerv)(GLenum,GLenum,GLvoid **);
|
194
|
+
static VALUE
|
195
|
+
gl_GetBufferPointerv(obj,arg1,arg2,arg3)
|
196
|
+
VALUE obj,arg1,arg2,arg3;
|
197
|
+
{
|
198
|
+
LOAD_GL_FUNC(glGetBufferPointerv,"1.5")
|
199
|
+
rb_raise(rb_eArgError, "glGetBufferPointerv not implemented");
|
200
|
+
CHECK_GLERROR
|
201
|
+
return Qnil;
|
202
|
+
}
|
203
|
+
|
204
|
+
void gl_init_functions_1_5(VALUE module)
|
205
|
+
{
|
206
|
+
rb_define_module_function(module, "glGenQueries", gl_GenQueries, 1);
|
207
|
+
rb_define_module_function(module, "glDeleteQueries", gl_DeleteQueries, 1);
|
208
|
+
rb_define_module_function(module, "glIsQuery", gl_IsQuery, 1);
|
209
|
+
rb_define_module_function(module, "glBeginQuery", gl_BeginQuery, 2);
|
210
|
+
rb_define_module_function(module, "glEndQuery", gl_EndQuery, 1);
|
211
|
+
rb_define_module_function(module, "glGetQueryiv", gl_GetQueryiv, 2);
|
212
|
+
rb_define_module_function(module, "glGetQueryObjectiv", gl_GetQueryObjectiv, 2);
|
213
|
+
rb_define_module_function(module, "glGetQueryObjectuiv", gl_GetQueryObjectuiv, 2);
|
214
|
+
rb_define_module_function(module, "glBindBuffer", gl_BindBuffer, 2);
|
215
|
+
rb_define_module_function(module, "glDeleteBuffers", gl_DeleteBuffers, 1);
|
216
|
+
rb_define_module_function(module, "glGenBuffers", gl_GenBuffers, 1);
|
217
|
+
rb_define_module_function(module, "glIsBuffer", gl_IsBuffer, 1);
|
218
|
+
rb_define_module_function(module, "glBufferData", gl_BufferData, 4);
|
219
|
+
rb_define_module_function(module, "glBufferSubData", gl_BufferSubData, 4);
|
220
|
+
rb_define_module_function(module, "glGetBufferSubData", gl_GetBufferSubData, 3);
|
221
|
+
rb_define_module_function(module, "glMapBuffer", gl_MapBuffer, 2);
|
222
|
+
rb_define_module_function(module, "glUnmapBuffer", gl_UnmapBuffer, 1);
|
223
|
+
rb_define_module_function(module, "glGetBufferParameteriv", gl_GetBufferParameteriv, 2);
|
224
|
+
rb_define_module_function(module, "glGetBufferPointerv", gl_GetBufferPointerv, 3);
|
225
|
+
}
|
data/ext/gl/gl-2.0.c
ADDED
@@ -0,0 +1,657 @@
|
|
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/common.h"
|
17
|
+
|
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")
|
57
|
+
|
58
|
+
static void (APIENTRY * fptr_glDrawBuffers)(GLsizei,GLenum *);
|
59
|
+
static VALUE
|
60
|
+
gl_DrawBuffers(obj,arg1)
|
61
|
+
VALUE obj,arg1;
|
62
|
+
{
|
63
|
+
GLsizei size;
|
64
|
+
GLenum *buffers;
|
65
|
+
LOAD_GL_FUNC(glDrawBuffers,"2.0")
|
66
|
+
Check_Type(arg1,T_ARRAY);
|
67
|
+
size = (GLsizei)RARRAY_LENINT(arg1);
|
68
|
+
buffers = ALLOC_N(GLenum,size);
|
69
|
+
ary2cuint(arg1,buffers,size);
|
70
|
+
fptr_glDrawBuffers(size,buffers);
|
71
|
+
xfree(buffers);
|
72
|
+
CHECK_GLERROR
|
73
|
+
return Qnil;
|
74
|
+
}
|
75
|
+
|
76
|
+
static void (APIENTRY * fptr_glBindAttribLocation)(GLuint,GLuint,GLchar *);
|
77
|
+
static VALUE
|
78
|
+
gl_BindAttribLocation(obj,arg1,arg2,arg3)
|
79
|
+
VALUE obj,arg1,arg2,arg3;
|
80
|
+
{
|
81
|
+
GLuint program;
|
82
|
+
GLuint index;
|
83
|
+
LOAD_GL_FUNC(glBindAttribLocation,"2.0")
|
84
|
+
program = (GLuint)NUM2UINT(arg1);
|
85
|
+
index = (GLuint)NUM2UINT(arg2);
|
86
|
+
Check_Type(arg3, T_STRING);
|
87
|
+
fptr_glBindAttribLocation(program,index,RSTRING_PTR(arg3));
|
88
|
+
CHECK_GLERROR
|
89
|
+
return Qnil;
|
90
|
+
}
|
91
|
+
|
92
|
+
static void (APIENTRY * fptr_glGetProgramiv)(GLuint,GLenum,GLint *);
|
93
|
+
static VALUE
|
94
|
+
gl_GetProgramiv(obj,arg1,arg2)
|
95
|
+
VALUE obj,arg1,arg2;
|
96
|
+
{
|
97
|
+
GLuint program;
|
98
|
+
GLenum pname;
|
99
|
+
GLint params = 0;
|
100
|
+
LOAD_GL_FUNC(glGetProgramiv,"2.0")
|
101
|
+
program = (GLuint)NUM2UINT(arg1);
|
102
|
+
pname = (GLenum)NUM2INT(arg2);
|
103
|
+
fptr_glGetProgramiv(program,pname,¶ms);
|
104
|
+
CHECK_GLERROR
|
105
|
+
return cond_GLBOOL2RUBY(pname,params);
|
106
|
+
}
|
107
|
+
|
108
|
+
static void (APIENTRY * fptr_glGetActiveAttrib)(GLuint,GLuint,GLsizei,GLsizei *,GLint *,GLenum *,GLchar *);
|
109
|
+
static VALUE
|
110
|
+
gl_GetActiveAttrib(obj,arg1,arg2)
|
111
|
+
VALUE obj,arg1,arg2;
|
112
|
+
{
|
113
|
+
GLuint program;
|
114
|
+
GLuint index;
|
115
|
+
GLsizei max_size = 0;
|
116
|
+
GLsizei written = 0;
|
117
|
+
GLint attrib_size = 0;
|
118
|
+
GLenum attrib_type = 0;
|
119
|
+
VALUE buffer;
|
120
|
+
VALUE retary;
|
121
|
+
LOAD_GL_FUNC(glGetActiveAttrib,"2.0")
|
122
|
+
LOAD_GL_FUNC(glGetProgramiv,"2.0")
|
123
|
+
program = (GLuint)NUM2UINT(arg1);
|
124
|
+
index = (GLuint)NUM2UINT(arg2);
|
125
|
+
fptr_glGetProgramiv(program,GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,&max_size);
|
126
|
+
CHECK_GLERROR
|
127
|
+
if (max_size==0)
|
128
|
+
rb_raise(rb_eTypeError, "Can't determine maximum attribute name length");
|
129
|
+
buffer = allocate_buffer_with_string(max_size-1);
|
130
|
+
fptr_glGetActiveAttrib(program,index,max_size,&written,&attrib_size,&attrib_type,RSTRING_PTR(buffer));
|
131
|
+
retary = rb_ary_new2(3);
|
132
|
+
rb_ary_push(retary, INT2NUM(attrib_size));
|
133
|
+
rb_ary_push(retary, INT2NUM(attrib_type));
|
134
|
+
rb_ary_push(retary, buffer);
|
135
|
+
CHECK_GLERROR
|
136
|
+
return retary;
|
137
|
+
}
|
138
|
+
|
139
|
+
static void (APIENTRY * fptr_glGetActiveUniform)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*);
|
140
|
+
static VALUE
|
141
|
+
gl_GetActiveUniform(obj,arg1,arg2)
|
142
|
+
VALUE obj,arg1,arg2;
|
143
|
+
{
|
144
|
+
GLuint program;
|
145
|
+
GLuint index;
|
146
|
+
GLsizei max_size = 0;
|
147
|
+
GLsizei written = 0;
|
148
|
+
GLint uniform_size = 0;
|
149
|
+
GLenum uniform_type = 0;
|
150
|
+
VALUE buffer;
|
151
|
+
VALUE retary;
|
152
|
+
LOAD_GL_FUNC(glGetActiveUniform,"2.0")
|
153
|
+
LOAD_GL_FUNC(glGetProgramiv,"2.0")
|
154
|
+
program = (GLuint)NUM2UINT(arg1);
|
155
|
+
index = (GLuint)NUM2UINT(arg2);
|
156
|
+
fptr_glGetProgramiv(program,GL_ACTIVE_UNIFORM_MAX_LENGTH,&max_size);
|
157
|
+
CHECK_GLERROR
|
158
|
+
if (max_size==0)
|
159
|
+
rb_raise(rb_eTypeError, "Can't determine maximum uniform name length");
|
160
|
+
buffer = allocate_buffer_with_string(max_size-1);
|
161
|
+
fptr_glGetActiveUniform(program,index,max_size,&written,&uniform_size,&uniform_type,RSTRING_PTR(buffer));
|
162
|
+
retary = rb_ary_new2(3);
|
163
|
+
rb_ary_push(retary, INT2NUM(uniform_size));
|
164
|
+
rb_ary_push(retary, INT2NUM(uniform_type));
|
165
|
+
rb_ary_push(retary, buffer);
|
166
|
+
CHECK_GLERROR
|
167
|
+
return retary;
|
168
|
+
}
|
169
|
+
|
170
|
+
static void (APIENTRY * fptr_glGetAttachedShaders)(GLuint,GLsizei,GLsizei *,GLuint *);
|
171
|
+
static VALUE
|
172
|
+
gl_GetAttachedShaders(obj,arg1)
|
173
|
+
VALUE obj,arg1;
|
174
|
+
{
|
175
|
+
GLuint program;
|
176
|
+
GLint shaders_num = 0;
|
177
|
+
GLuint *shaders;
|
178
|
+
GLsizei count = 0;
|
179
|
+
LOAD_GL_FUNC(glGetAttachedShaders,"2.0")
|
180
|
+
LOAD_GL_FUNC(glGetProgramiv,"2.0")
|
181
|
+
program = (GLuint)NUM2UINT(arg1);
|
182
|
+
fptr_glGetProgramiv(program,GL_ATTACHED_SHADERS,&shaders_num);
|
183
|
+
CHECK_GLERROR
|
184
|
+
if (shaders_num<=0)
|
185
|
+
return Qnil;
|
186
|
+
shaders = ALLOC_N(GLuint,shaders_num);
|
187
|
+
fptr_glGetAttachedShaders(program,shaders_num,&count,shaders);
|
188
|
+
RET_ARRAY_OR_SINGLE_FREE(count,RETCONV_GLuint,shaders)
|
189
|
+
}
|
190
|
+
|
191
|
+
static GLint (APIENTRY * fptr_glGetAttribLocation)(GLuint, GLchar *);
|
192
|
+
static VALUE
|
193
|
+
gl_GetAttribLocation(obj,arg1,arg2)
|
194
|
+
VALUE obj,arg1,arg2;
|
195
|
+
{
|
196
|
+
GLuint program;
|
197
|
+
GLint ret;
|
198
|
+
LOAD_GL_FUNC(glGetAttribLocation,"2.0")
|
199
|
+
program=(GLuint)NUM2UINT(arg1);
|
200
|
+
Check_Type(arg2,T_STRING);
|
201
|
+
ret = fptr_glGetAttribLocation(program,RSTRING_PTR(arg2));
|
202
|
+
CHECK_GLERROR
|
203
|
+
return INT2NUM(ret);
|
204
|
+
}
|
205
|
+
|
206
|
+
static void (APIENTRY * fptr_glGetProgramInfoLog)(GLuint,GLsizei,GLsizei *,GLchar *);
|
207
|
+
static VALUE
|
208
|
+
gl_GetProgramInfoLog(obj,arg1)
|
209
|
+
VALUE obj,arg1;
|
210
|
+
{
|
211
|
+
GLuint program;
|
212
|
+
GLint max_size = 0;
|
213
|
+
GLsizei ret_length = 0;
|
214
|
+
VALUE buffer;
|
215
|
+
LOAD_GL_FUNC(glGetProgramInfoLog,"2.0")
|
216
|
+
LOAD_GL_FUNC(glGetProgramiv,"2.0")
|
217
|
+
program = (GLuint)NUM2UINT(arg1);
|
218
|
+
fptr_glGetProgramiv(program,GL_INFO_LOG_LENGTH,&max_size);
|
219
|
+
CHECK_GLERROR
|
220
|
+
if (max_size<=0)
|
221
|
+
return rb_str_new2("");
|
222
|
+
buffer = allocate_buffer_with_string(max_size);
|
223
|
+
fptr_glGetProgramInfoLog(program,max_size,&ret_length,RSTRING_PTR(buffer));
|
224
|
+
CHECK_GLERROR
|
225
|
+
return buffer;
|
226
|
+
}
|
227
|
+
|
228
|
+
static void (APIENTRY * fptr_glGetShaderiv)(GLuint,GLenum,GLint *);
|
229
|
+
static VALUE
|
230
|
+
gl_GetShaderiv(obj,arg1,arg2)
|
231
|
+
VALUE obj,arg1,arg2;
|
232
|
+
{
|
233
|
+
GLuint program;
|
234
|
+
GLenum pname;
|
235
|
+
GLint params = 0;
|
236
|
+
LOAD_GL_FUNC(glGetShaderiv,"2.0")
|
237
|
+
program = (GLuint)NUM2UINT(arg1);
|
238
|
+
pname = (GLenum)NUM2INT(arg2);
|
239
|
+
fptr_glGetShaderiv(program,pname,¶ms);
|
240
|
+
CHECK_GLERROR
|
241
|
+
return cond_GLBOOL2RUBY(pname,params);
|
242
|
+
}
|
243
|
+
|
244
|
+
static void (APIENTRY * fptr_glGetShaderInfoLog)(GLuint,GLsizei,GLsizei *,GLchar *);
|
245
|
+
static VALUE
|
246
|
+
gl_GetShaderInfoLog(obj,arg1)
|
247
|
+
VALUE obj,arg1;
|
248
|
+
{
|
249
|
+
GLuint program;
|
250
|
+
GLint max_size = 0;
|
251
|
+
GLsizei ret_length = 0;
|
252
|
+
VALUE ret_buffer;
|
253
|
+
GLchar *buffer;
|
254
|
+
LOAD_GL_FUNC(glGetShaderInfoLog,"2.0")
|
255
|
+
LOAD_GL_FUNC(glGetShaderiv,"2.0")
|
256
|
+
program = (GLuint)NUM2UINT(arg1);
|
257
|
+
fptr_glGetShaderiv(program,GL_INFO_LOG_LENGTH,&max_size);
|
258
|
+
CHECK_GLERROR
|
259
|
+
if (max_size<=0)
|
260
|
+
return rb_str_new2("");
|
261
|
+
buffer = ALLOC_N(GLchar,max_size+1);
|
262
|
+
memset(buffer,0,sizeof(GLchar) * (max_size+1));
|
263
|
+
fptr_glGetShaderInfoLog(program,max_size,&ret_length,buffer);
|
264
|
+
ret_buffer = rb_str_new(buffer, ret_length);
|
265
|
+
xfree(buffer);
|
266
|
+
CHECK_GLERROR
|
267
|
+
return ret_buffer;
|
268
|
+
}
|
269
|
+
|
270
|
+
static void (APIENTRY * fptr_glGetShaderSource)(GLuint,GLsizei,GLsizei *,GLchar *);
|
271
|
+
static VALUE
|
272
|
+
gl_GetShaderSource(obj,arg1)
|
273
|
+
VALUE obj,arg1;
|
274
|
+
{
|
275
|
+
GLuint shader;
|
276
|
+
GLint max_size = 0;
|
277
|
+
GLsizei ret_length = 0;
|
278
|
+
VALUE buffer;
|
279
|
+
LOAD_GL_FUNC(glGetShaderSource,"2.0")
|
280
|
+
LOAD_GL_FUNC(glGetShaderiv,"2.0")
|
281
|
+
shader = (GLuint)NUM2UINT(arg1);
|
282
|
+
fptr_glGetShaderiv(shader,GL_SHADER_SOURCE_LENGTH,&max_size);
|
283
|
+
CHECK_GLERROR
|
284
|
+
if (max_size==0)
|
285
|
+
rb_raise(rb_eTypeError, "Can't determine maximum shader source length");
|
286
|
+
buffer = allocate_buffer_with_string(max_size-1);
|
287
|
+
fptr_glGetShaderSource(shader,max_size,&ret_length,RSTRING_PTR(buffer));
|
288
|
+
CHECK_GLERROR
|
289
|
+
return buffer;
|
290
|
+
}
|
291
|
+
|
292
|
+
static GLint (APIENTRY * fptr_glGetUniformLocation)(GLuint,const GLchar*);
|
293
|
+
static VALUE
|
294
|
+
gl_GetUniformLocation(obj,arg1,arg2)
|
295
|
+
VALUE obj,arg1,arg2;
|
296
|
+
{
|
297
|
+
GLuint program;
|
298
|
+
GLint ret;
|
299
|
+
LOAD_GL_FUNC(glGetUniformLocation,"2.0")
|
300
|
+
program=(GLuint)NUM2UINT(arg1);
|
301
|
+
Check_Type(arg2,T_STRING);
|
302
|
+
ret = fptr_glGetUniformLocation(program,RSTRING_PTR(arg2));
|
303
|
+
CHECK_GLERROR
|
304
|
+
return INT2NUM(ret);
|
305
|
+
}
|
306
|
+
|
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
|
366
|
+
|
367
|
+
static void (APIENTRY * fptr_glGetVertexAttribiv)(GLuint,GLenum,GLint *);
|
368
|
+
static VALUE
|
369
|
+
gl_GetVertexAttribiv(obj,arg1,arg2)
|
370
|
+
VALUE obj,arg1,arg2;
|
371
|
+
{
|
372
|
+
GLuint index;
|
373
|
+
GLenum pname;
|
374
|
+
GLint params[4] = {0,0,0,0};
|
375
|
+
GLint size;
|
376
|
+
LOAD_GL_FUNC(glGetVertexAttribiv,"2.0")
|
377
|
+
index = (GLuint)NUM2UINT(arg1);
|
378
|
+
pname = (GLenum)NUM2INT(arg2);
|
379
|
+
if (pname==GL_CURRENT_VERTEX_ATTRIB)
|
380
|
+
size = 4;
|
381
|
+
else
|
382
|
+
size = 1;
|
383
|
+
fptr_glGetVertexAttribiv(index,pname,params);
|
384
|
+
RET_ARRAY_OR_SINGLE_BOOL(size,cond_GLBOOL2RUBY,pname,params)
|
385
|
+
}
|
386
|
+
|
387
|
+
|
388
|
+
VALUE g_VertexAttrib_ptr[_MAX_VERTEX_ATTRIBS];
|
389
|
+
|
390
|
+
static void (APIENTRY * fptr_glGetVertexAttribPointerv)(GLuint,GLenum,GLvoid **);
|
391
|
+
static VALUE
|
392
|
+
gl_GetVertexAttribPointerv(obj,arg1)
|
393
|
+
VALUE obj,arg1;
|
394
|
+
{
|
395
|
+
GLuint index;
|
396
|
+
LOAD_GL_FUNC(glGetVertexAttribPointerv,"2.0")
|
397
|
+
index =(GLuint) NUM2INT(arg1);
|
398
|
+
if (index>_MAX_VERTEX_ATTRIBS)
|
399
|
+
rb_raise(rb_eArgError, "Index too large, maximum allowed value '%i'",_MAX_VERTEX_ATTRIBS);
|
400
|
+
|
401
|
+
return g_VertexAttrib_ptr[index];
|
402
|
+
}
|
403
|
+
|
404
|
+
static void (APIENTRY * fptr_glShaderSource)(GLuint,GLsizei,GLchar**,GLint *);
|
405
|
+
static VALUE
|
406
|
+
gl_ShaderSource(obj,arg1,arg2)
|
407
|
+
VALUE obj,arg1,arg2;
|
408
|
+
{
|
409
|
+
GLuint shader;
|
410
|
+
GLint length;
|
411
|
+
GLchar *str;
|
412
|
+
LOAD_GL_FUNC(glShaderSource,"2.0")
|
413
|
+
shader = (GLuint)NUM2UINT(arg1);
|
414
|
+
Check_Type(arg2,T_STRING);
|
415
|
+
str = RSTRING_PTR(arg2);
|
416
|
+
length = (GLint)RSTRING_LENINT(arg2);
|
417
|
+
fptr_glShaderSource(shader,1,&str,&length);
|
418
|
+
CHECK_GLERROR
|
419
|
+
return Qnil;
|
420
|
+
}
|
421
|
+
|
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 = (GLsizei)RARRAY_LENINT(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; \
|
443
|
+
}
|
444
|
+
|
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
|
454
|
+
|
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 = (GLsizei)RARRAY_LENINT(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; \
|
475
|
+
}
|
476
|
+
|
477
|
+
UNIFORMMATRIX_FUNC(UniformMatrix2fv,2)
|
478
|
+
UNIFORMMATRIX_FUNC(UniformMatrix3fv,3)
|
479
|
+
UNIFORMMATRIX_FUNC(UniformMatrix4fv,4)
|
480
|
+
#undef UNIFORMMATRIX_FUNC
|
481
|
+
|
482
|
+
#define VERTEXATTRIB_FUNC_V(_name_,_type_,_conv_,_size_) \
|
483
|
+
static void (APIENTRY * fptr_gl##_name_)(GLuint,_type_ *); \
|
484
|
+
static VALUE \
|
485
|
+
gl_##_name_(obj,arg1,arg2) \
|
486
|
+
VALUE obj,arg1,arg2; \
|
487
|
+
{ \
|
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 \
|
495
|
+
return Qnil; \
|
496
|
+
}
|
497
|
+
|
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
|
522
|
+
|
523
|
+
static void (APIENTRY * fptr_glVertexAttribPointer)(GLuint,GLint,GLenum,GLboolean,GLsizei,GLvoid *);
|
524
|
+
static VALUE
|
525
|
+
gl_VertexAttribPointer(obj,arg1,arg2,arg3,arg4,arg5,arg6)
|
526
|
+
VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
|
527
|
+
{
|
528
|
+
GLuint index;
|
529
|
+
GLuint size;
|
530
|
+
GLenum type;
|
531
|
+
GLboolean normalized;
|
532
|
+
GLsizei stride;
|
533
|
+
LOAD_GL_FUNC(glVertexAttribPointer,"2.0")
|
534
|
+
index = (GLuint)NUM2UINT(arg1);
|
535
|
+
size = (GLuint)NUM2UINT(arg2);
|
536
|
+
type = (GLenum)NUM2INT(arg3);
|
537
|
+
normalized = (GLboolean)NUM2INT(arg4);
|
538
|
+
stride = (GLsizei)NUM2UINT(arg5);
|
539
|
+
if (index>_MAX_VERTEX_ATTRIBS)
|
540
|
+
rb_raise(rb_eArgError, "Index too large, maximum allowed value '%i'",_MAX_VERTEX_ATTRIBS);
|
541
|
+
|
542
|
+
if (CheckBufferBinding(GL_ARRAY_BUFFER_BINDING)) {
|
543
|
+
g_VertexAttrib_ptr[index] = arg6;
|
544
|
+
fptr_glVertexAttribPointer(index,size,type,normalized,stride,(GLvoid *)NUM2LONG(arg6));
|
545
|
+
} else {
|
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));
|
551
|
+
}
|
552
|
+
CHECK_GLERROR
|
553
|
+
return Qnil;
|
554
|
+
}
|
555
|
+
|
556
|
+
void gl_init_functions_2_0(VALUE module)
|
557
|
+
{
|
558
|
+
rb_define_module_function(module, "glBlendEquationSeparate", gl_BlendEquationSeparate, 2);
|
559
|
+
rb_define_module_function(module, "glDrawBuffers", gl_DrawBuffers, 1);
|
560
|
+
rb_define_module_function(module, "glStencilOpSeparate", gl_StencilOpSeparate, 4);
|
561
|
+
rb_define_module_function(module, "glStencilFuncSeparate", gl_StencilFuncSeparate, 4);
|
562
|
+
rb_define_module_function(module, "glStencilMaskSeparate", gl_StencilMaskSeparate, 2);
|
563
|
+
rb_define_module_function(module, "glAttachShader", gl_AttachShader, 2);
|
564
|
+
rb_define_module_function(module, "glBindAttribLocation", gl_BindAttribLocation, 3);
|
565
|
+
rb_define_module_function(module, "glCompileShader", gl_CompileShader, 1);
|
566
|
+
rb_define_module_function(module, "glCreateProgram", gl_CreateProgram, 0);
|
567
|
+
rb_define_module_function(module, "glCreateShader", gl_CreateShader, 1);
|
568
|
+
rb_define_module_function(module, "glDeleteProgram", gl_DeleteProgram, 1);
|
569
|
+
rb_define_module_function(module, "glDeleteShader", gl_DeleteShader, 1);
|
570
|
+
rb_define_module_function(module, "glDetachShader", gl_DetachShader, 2);
|
571
|
+
rb_define_module_function(module, "glDisableVertexAttribArray", gl_DisableVertexAttribArray, 1);
|
572
|
+
rb_define_module_function(module, "glEnableVertexAttribArray", gl_EnableVertexAttribArray, 1);
|
573
|
+
rb_define_module_function(module, "glGetActiveAttrib", gl_GetActiveAttrib, 2);
|
574
|
+
rb_define_module_function(module, "glGetActiveUniform", gl_GetActiveUniform, 2);
|
575
|
+
rb_define_module_function(module, "glGetAttachedShaders", gl_GetAttachedShaders, 1);
|
576
|
+
rb_define_module_function(module, "glGetAttribLocation", gl_GetAttribLocation, 2);
|
577
|
+
rb_define_module_function(module, "glGetProgramiv", gl_GetProgramiv, 2);
|
578
|
+
rb_define_module_function(module, "glGetProgramInfoLog", gl_GetProgramInfoLog, 1);
|
579
|
+
rb_define_module_function(module, "glGetShaderiv", gl_GetShaderiv, 2);
|
580
|
+
rb_define_module_function(module, "glGetShaderInfoLog", gl_GetShaderInfoLog, 1);
|
581
|
+
rb_define_module_function(module, "glGetShaderSource", gl_GetShaderSource, 1);
|
582
|
+
rb_define_module_function(module, "glGetUniformLocation", gl_GetUniformLocation, 2);
|
583
|
+
rb_define_module_function(module, "glGetUniformfv", gl_GetUniformfv, 2);
|
584
|
+
rb_define_module_function(module, "glGetUniformiv", gl_GetUniformiv, 2);
|
585
|
+
rb_define_module_function(module, "glGetVertexAttribdv", gl_GetVertexAttribdv, 2);
|
586
|
+
rb_define_module_function(module, "glGetVertexAttribfv", gl_GetVertexAttribfv, 2);
|
587
|
+
rb_define_module_function(module, "glGetVertexAttribiv", gl_GetVertexAttribiv, 2);
|
588
|
+
rb_define_module_function(module, "glGetVertexAttribPointerv", gl_GetVertexAttribPointerv, 1);
|
589
|
+
rb_define_module_function(module, "glIsProgram", gl_IsProgram, 1);
|
590
|
+
rb_define_module_function(module, "glIsShader", gl_IsShader, 1);
|
591
|
+
rb_define_module_function(module, "glLinkProgram", gl_LinkProgram, 1);
|
592
|
+
rb_define_module_function(module, "glShaderSource", gl_ShaderSource, 2);
|
593
|
+
rb_define_module_function(module, "glUseProgram", gl_UseProgram, 1);
|
594
|
+
rb_define_module_function(module, "glUniform1f", gl_Uniform1f, 2);
|
595
|
+
rb_define_module_function(module, "glUniform2f", gl_Uniform2f, 3);
|
596
|
+
rb_define_module_function(module, "glUniform3f", gl_Uniform3f, 4);
|
597
|
+
rb_define_module_function(module, "glUniform4f", gl_Uniform4f, 5);
|
598
|
+
rb_define_module_function(module, "glUniform1i", gl_Uniform1i, 2);
|
599
|
+
rb_define_module_function(module, "glUniform2i", gl_Uniform2i, 3);
|
600
|
+
rb_define_module_function(module, "glUniform3i", gl_Uniform3i, 4);
|
601
|
+
rb_define_module_function(module, "glUniform4i", gl_Uniform4i, 5);
|
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);
|
613
|
+
rb_define_module_function(module, "glValidateProgram", gl_ValidateProgram, 1);
|
614
|
+
rb_define_module_function(module, "glVertexAttrib1d", gl_VertexAttrib1d, 2);
|
615
|
+
rb_define_module_function(module, "glVertexAttrib1f", gl_VertexAttrib1f, 2);
|
616
|
+
rb_define_module_function(module, "glVertexAttrib1s", gl_VertexAttrib1s, 2);
|
617
|
+
rb_define_module_function(module, "glVertexAttrib2d", gl_VertexAttrib2d, 3);
|
618
|
+
rb_define_module_function(module, "glVertexAttrib2f", gl_VertexAttrib2f, 3);
|
619
|
+
rb_define_module_function(module, "glVertexAttrib2s", gl_VertexAttrib2s, 3);
|
620
|
+
rb_define_module_function(module, "glVertexAttrib3d", gl_VertexAttrib3d, 4);
|
621
|
+
rb_define_module_function(module, "glVertexAttrib3f", gl_VertexAttrib3f, 4);
|
622
|
+
rb_define_module_function(module, "glVertexAttrib3s", gl_VertexAttrib3s, 4);
|
623
|
+
rb_define_module_function(module, "glVertexAttrib4Nbv", gl_VertexAttrib4Nbv, 2);
|
624
|
+
rb_define_module_function(module, "glVertexAttrib4Niv", gl_VertexAttrib4Niv, 2);
|
625
|
+
rb_define_module_function(module, "glVertexAttrib4Nsv", gl_VertexAttrib4Nsv, 2);
|
626
|
+
rb_define_module_function(module, "glVertexAttrib4Nub", gl_VertexAttrib4Nub, 5);
|
627
|
+
rb_define_module_function(module, "glVertexAttrib4Nubv", gl_VertexAttrib4Nubv, 2);
|
628
|
+
rb_define_module_function(module, "glVertexAttrib4Nuiv", gl_VertexAttrib4Nuiv, 2);
|
629
|
+
rb_define_module_function(module, "glVertexAttrib4Nusv", gl_VertexAttrib4Nusv, 2);
|
630
|
+
rb_define_module_function(module, "glVertexAttrib4bv", gl_VertexAttrib4bv, 2);
|
631
|
+
rb_define_module_function(module, "glVertexAttrib4d", gl_VertexAttrib4d, 5);
|
632
|
+
rb_define_module_function(module, "glVertexAttrib4f", gl_VertexAttrib4f, 5);
|
633
|
+
rb_define_module_function(module, "glVertexAttrib4iv", gl_VertexAttrib4iv, 2);
|
634
|
+
rb_define_module_function(module, "glVertexAttrib4s", gl_VertexAttrib4s, 5);
|
635
|
+
rb_define_module_function(module, "glVertexAttrib4ubv", gl_VertexAttrib4ubv, 2);
|
636
|
+
rb_define_module_function(module, "glVertexAttrib4uiv", gl_VertexAttrib4uiv, 2);
|
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);
|
650
|
+
rb_define_module_function(module, "glVertexAttribPointer", gl_VertexAttribPointer, 6);
|
651
|
+
|
652
|
+
{
|
653
|
+
int i;
|
654
|
+
for (i=0;i<_MAX_VERTEX_ATTRIBS;i++)
|
655
|
+
rb_global_variable(&g_VertexAttrib_ptr[i]);
|
656
|
+
}
|
657
|
+
}
|