ruby-opengl 0.40.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -2
- data/doc/build_install.txt +48 -28
- data/doc/extensions.txt +361 -0
- data/doc/history.txt +8 -2
- data/doc/requirements_and_design.txt +0 -13
- data/doc/roadmap.txt +11 -13
- data/doc/supplies/page_template.html +11 -5
- data/doc/thanks.txt +2 -4
- data/doc/tutorial.txt +1 -4
- data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
- data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
- data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
- data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -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 +388 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +424 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +13 -83
- data/examples/RedBook/aaindex.rb +97 -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/{legacy → RedBook}/double.rb +59 -58
- data/examples/{legacy → RedBook}/drawf.rb +47 -54
- 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/{legacy → RedBook}/jitter.rb +60 -62
- 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/{legacy → RedBook}/model.rb +66 -72
- data/examples/{legacy → RedBook}/movelight.rb +67 -75
- data/examples/RedBook/pickdepth.rb +179 -0
- data/examples/{legacy → RedBook}/planet.rb +62 -66
- 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/anisotropic.rb +194 -0
- data/examples/misc/font-glut.rb +46 -0
- data/examples/{plane.rb → misc/plane.rb} +0 -0
- data/examples/misc/readpixel.rb +65 -0
- data/examples/{smooth.rb → misc/smooth.rb} +0 -0
- data/examples/{test.rb → misc/test.rb} +0 -0
- data/ext/common/common.h +252 -70
- data/ext/common/gl-enums.h +6102 -7334
- data/ext/common/gl-types.h +47 -0
- data/ext/common/glu-enums.h +469 -0
- data/ext/gl/gl-1.0-1.1.c +842 -2464
- data/ext/gl/gl-1.2.c +217 -281
- data/ext/gl/gl-1.3.c +113 -133
- data/ext/gl/gl-1.4.c +98 -334
- data/ext/gl/gl-1.5.c +28 -34
- data/ext/gl/gl-2.0.c +26 -235
- data/ext/gl/gl-2.1.c +31 -124
- data/ext/gl/gl-enums.c +786 -631
- data/ext/gl/gl-ext-arb.c +66 -0
- data/ext/gl/gl-ext-ext.c +218 -0
- data/ext/gl/gl.c +138 -31
- data/ext/gl/mkrf_conf.rb +1 -0
- data/ext/glu/glu-enums.c +163 -0
- data/ext/glu/glu.c +1003 -1205
- data/ext/glu/mkrf_conf.rb +1 -0
- data/ext/glut/glut.c +1056 -1175
- data/lib/opengl.rb +90 -3
- data/test/tc_common.rb +26 -13
- data/test/tc_ext_arb.rb +73 -0
- data/test/tc_ext_ext.rb +74 -0
- data/test/tc_func_12.rb +8 -8
- data/test/tc_func_13.rb +17 -11
- data/test/tc_func_14.rb +8 -8
- data/test/tc_func_15.rb +190 -2
- data/test/tc_func_20.rb +36 -10
- data/test/tc_func_21.rb +445 -2
- data/test/tc_glu.rb +305 -0
- data/test/tc_misc.rb +1 -0
- metadata +84 -68
- data/doc/screenshots.txt +0 -23
- data/examples/legacy/COPYRIGHT +0 -8
- data/examples/legacy/aaindex.rb +0 -98
- data/examples/legacy/aapoly.rb +0 -153
- data/examples/legacy/aargb.rb +0 -139
- data/examples/legacy/accanti.rb +0 -159
- data/examples/legacy/accpersp.rb +0 -216
- data/examples/legacy/alpha.rb +0 -133
- data/examples/legacy/alpha3D.rb +0 -165
- data/examples/legacy/bezcurve.rb +0 -107
- data/examples/legacy/bezmesh.rb +0 -131
- data/examples/legacy/checker.rb +0 -121
- data/examples/legacy/clip.rb +0 -104
- data/examples/legacy/colormat.rb +0 -145
- data/examples/legacy/cube.rb +0 -73
- data/examples/legacy/depthcue.rb +0 -101
- data/examples/legacy/dof.rb +0 -212
- data/examples/legacy/feedback.rb +0 -152
- data/examples/legacy/fog.rb +0 -172
- data/examples/legacy/font-glut.rb +0 -41
- data/examples/legacy/font.rb +0 -158
- data/examples/legacy/hello.rb +0 -75
- data/examples/legacy/image.rb +0 -145
- data/examples/legacy/lines.rb +0 -135
- data/examples/legacy/list.rb +0 -120
- data/examples/legacy/material.rb +0 -290
- data/examples/legacy/mipmap.rb +0 -159
- data/examples/legacy/pickdepth.rb +0 -180
- data/examples/legacy/quadric.rb +0 -180
- data/examples/legacy/readpixel.rb +0 -59
- data/examples/legacy/robot.rb +0 -120
- data/examples/legacy/select.rb +0 -207
- data/examples/legacy/smooth.rb +0 -41
- data/examples/legacy/stencil.rb +0 -154
- data/examples/legacy/stroke.rb +0 -170
- data/examples/legacy/surface.rb +0 -170
- data/examples/legacy/teaambient.rb +0 -132
- data/examples/legacy/teapots.rb +0 -188
- data/examples/legacy/tess.rb +0 -222
- data/examples/legacy/texbind.rb +0 -157
- data/examples/legacy/texgen.rb +0 -171
- data/examples/legacy/texturesurf.rb +0 -128
- data/examples/legacy/varray.rb +0 -167
- data/examples/legacy/wrap.rb +0 -158
- data/lib/gl_prev.rb +0 -46
- data/lib/glu_prev.rb +0 -46
- data/lib/glut_prev.rb +0 -45
data/ext/gl/gl-ext-arb.c
ADDED
@@ -0,0 +1,66 @@
|
|
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 ARB extensions */
|
19
|
+
|
20
|
+
/* #3 GL_ARB_transpose_matrix */
|
21
|
+
#define TRANSPOSEMATRIX_FUNC(_name_,_type_,_shorttype_) \
|
22
|
+
static void (APIENTRY * fptr_gl##_name_)(const _type_[]); \
|
23
|
+
static VALUE \
|
24
|
+
gl_##_name_(obj,arg1) \
|
25
|
+
VALUE obj,arg1; \
|
26
|
+
{ \
|
27
|
+
_type_ m[4*4]; \
|
28
|
+
LOAD_GL_EXT_FUNC(gl##_name_,"GL_ARB_transpose_matrix") \
|
29
|
+
ary2cmat4x4##_shorttype_(arg1, m); \
|
30
|
+
fptr_gl##_name_(m); \
|
31
|
+
return Qnil; \
|
32
|
+
}
|
33
|
+
|
34
|
+
TRANSPOSEMATRIX_FUNC(LoadTransposeMatrixfARB,GLfloat,flt)
|
35
|
+
TRANSPOSEMATRIX_FUNC(LoadTransposeMatrixdARB,GLdouble,dbl)
|
36
|
+
TRANSPOSEMATRIX_FUNC(MultTransposeMatrixfARB,GLfloat,flt)
|
37
|
+
TRANSPOSEMATRIX_FUNC(MultTransposeMatrixdARB,GLdouble,dbl)
|
38
|
+
|
39
|
+
#undef TRANSPOSEMATRIX_FUNC
|
40
|
+
|
41
|
+
/* #5 GL_ARB_multisample */
|
42
|
+
static void (APIENTRY * fptr_glSampleCoverageARB)(GLclampf,GLboolean);
|
43
|
+
static VALUE gl_SampleCoverageARB(VALUE obj,VALUE arg1,VALUE arg2)
|
44
|
+
{
|
45
|
+
LOAD_GL_EXT_FUNC(glSampleCoverageARB,"GL_ARB_multisample")
|
46
|
+
fptr_glSampleCoverageARB((GLclampf)NUM2DBL(arg1),(GLboolean)NUM2INT(arg2));
|
47
|
+
return Qnil;
|
48
|
+
}
|
49
|
+
|
50
|
+
/* #39 GL_ARB_color_buffer_float */
|
51
|
+
GL_EXT_SIMPLE_FUNC_LOAD(ClampColorARB,2,GLenum,NUM2INT,"GL_ARB_color_buffer_float")
|
52
|
+
|
53
|
+
void gl_init_functions_ext_arb(VALUE module)
|
54
|
+
{
|
55
|
+
/* #3 GL_ARB_transpose_matrix */
|
56
|
+
rb_define_module_function(module, "glLoadTransposeMatrixfARB", gl_LoadTransposeMatrixfARB, 1);
|
57
|
+
rb_define_module_function(module, "glLoadTransposeMatrixdARB", gl_LoadTransposeMatrixdARB, 1);
|
58
|
+
rb_define_module_function(module, "glMultTransposeMatrixfARB", gl_MultTransposeMatrixfARB, 1);
|
59
|
+
rb_define_module_function(module, "glMultTransposeMatrixdARB", gl_MultTransposeMatrixdARB, 1);
|
60
|
+
|
61
|
+
/* #5 GL_ARB_multisample */
|
62
|
+
rb_define_module_function(module, "glSampleCoverageARB", gl_SampleCoverageARB, 2);
|
63
|
+
|
64
|
+
/* #39 GL_ARB_color_buffer_float */
|
65
|
+
rb_define_module_function(module, "glClampColorARB", gl_ClampColorARB, 2);
|
66
|
+
}
|
data/ext/gl/gl-ext-ext.c
ADDED
@@ -0,0 +1,218 @@
|
|
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 EXT extensions */
|
19
|
+
/* Those are extensions that are not blessed by ARB committee but were
|
20
|
+
created or agreed upon by multiple vendors */
|
21
|
+
|
22
|
+
/* #310 - GL_EXT_framebuffer_object */
|
23
|
+
static GLboolean (APIENTRY * fptr_glIsRenderbufferEXT)(GLuint);
|
24
|
+
static VALUE gl_IsRenderbufferEXT(VALUE obj,VALUE arg1)
|
25
|
+
{
|
26
|
+
GLboolean ret;
|
27
|
+
LOAD_GL_EXT_FUNC(glIsRenderbufferEXT,"GL_EXT_framebuffer_object")
|
28
|
+
ret = fptr_glIsRenderbufferEXT((GLuint)NUM2UINT(arg1));
|
29
|
+
return INT2NUM(ret);
|
30
|
+
}
|
31
|
+
|
32
|
+
static void (APIENTRY * fptr_glBindRenderbufferEXT)(GLenum,GLuint);
|
33
|
+
static VALUE gl_BindRenderbufferEXT(VALUE obj,VALUE arg1,VALUE arg2)
|
34
|
+
{
|
35
|
+
LOAD_GL_EXT_FUNC(glBindRenderbufferEXT,"GL_EXT_framebuffer_object")
|
36
|
+
fptr_glBindRenderbufferEXT((GLenum)NUM2INT(arg1),(GLuint)NUM2UINT(arg2));
|
37
|
+
return Qnil;
|
38
|
+
}
|
39
|
+
|
40
|
+
static void (APIENTRY * fptr_glDeleteRenderbuffersEXT)(GLsizei,const GLuint *);
|
41
|
+
static VALUE gl_DeleteRenderbuffersEXT(VALUE obj,VALUE arg1)
|
42
|
+
{
|
43
|
+
GLsizei n;
|
44
|
+
LOAD_GL_EXT_FUNC(glDeleteRenderbuffersEXT,"GL_EXT_framebuffer_object")
|
45
|
+
if (TYPE(arg1)==T_ARRAY) {
|
46
|
+
GLuint *renderbuffers;
|
47
|
+
n = RARRAY(arg1)->len;
|
48
|
+
renderbuffers = ALLOC_N(GLuint,n);
|
49
|
+
ary2cuint(arg1,renderbuffers,n);
|
50
|
+
fptr_glDeleteRenderbuffersEXT(n,renderbuffers);
|
51
|
+
xfree(renderbuffers);
|
52
|
+
} else {
|
53
|
+
GLuint renderbuffer;
|
54
|
+
renderbuffer = NUM2UINT(arg1);
|
55
|
+
fptr_glDeleteRenderbuffersEXT(1,&renderbuffer);
|
56
|
+
}
|
57
|
+
return Qnil;
|
58
|
+
}
|
59
|
+
|
60
|
+
static void (APIENTRY * fptr_glGenRenderbuffersEXT)(GLsizei,GLuint *);
|
61
|
+
static VALUE gl_GenRenderbuffersEXT(VALUE obj,VALUE arg1)
|
62
|
+
{
|
63
|
+
GLsizei n;
|
64
|
+
GLuint *renderbuffers;
|
65
|
+
VALUE ret;
|
66
|
+
int i;
|
67
|
+
LOAD_GL_EXT_FUNC(glGenRenderbuffersEXT,"GL_EXT_framebuffer_object")
|
68
|
+
n = (GLsizei)NUM2UINT(arg1);
|
69
|
+
renderbuffers = ALLOC_N(GLuint, n);
|
70
|
+
fptr_glGenRenderbuffersEXT(n,renderbuffers);
|
71
|
+
ret = rb_ary_new2(n);
|
72
|
+
for (i = 0; i < n; i++)
|
73
|
+
rb_ary_push(ret, INT2NUM(renderbuffers[i]));
|
74
|
+
xfree(renderbuffers);
|
75
|
+
return ret;
|
76
|
+
}
|
77
|
+
|
78
|
+
static void (APIENTRY * fptr_glRenderbufferStorageEXT)(GLenum,GLenum,GLsizei,GLsizei);
|
79
|
+
static VALUE gl_RenderbufferStorageEXT(VALUE obj,VALUE arg1,VALUE arg2,VALUE arg3,VALUE arg4)
|
80
|
+
{
|
81
|
+
LOAD_GL_EXT_FUNC(glRenderbufferStorageEXT,"GL_EXT_framebuffer_object")
|
82
|
+
fptr_glRenderbufferStorageEXT(NUM2UINT(arg1),NUM2UINT(arg2),NUM2INT(arg3),NUM2INT(arg4));
|
83
|
+
return Qnil;
|
84
|
+
}
|
85
|
+
|
86
|
+
static void (APIENTRY * fptr_glGetRenderbufferParameterivEXT)(GLenum,GLenum,GLint *);
|
87
|
+
static VALUE gl_GetRenderbufferParameterivEXT(VALUE obj,VALUE arg1,VALUE arg2)
|
88
|
+
{
|
89
|
+
GLint param = 0;
|
90
|
+
LOAD_GL_EXT_FUNC(glGetRenderbufferParameterivEXT,"GL_EXT_framebuffer_object")
|
91
|
+
fptr_glGetRenderbufferParameterivEXT(NUM2UINT(arg1),NUM2UINT(arg2),¶m);
|
92
|
+
return INT2NUM(param);
|
93
|
+
}
|
94
|
+
|
95
|
+
static GLboolean (APIENTRY * fptr_glIsFramebufferEXT)(GLuint);
|
96
|
+
static VALUE gl_IsFramebufferEXT(VALUE obj,VALUE arg1)
|
97
|
+
{
|
98
|
+
GLboolean ret;
|
99
|
+
LOAD_GL_EXT_FUNC(glIsFramebufferEXT,"GL_EXT_framebuffer_object")
|
100
|
+
ret = fptr_glIsFramebufferEXT(NUM2UINT(arg1));
|
101
|
+
return INT2NUM(ret);
|
102
|
+
}
|
103
|
+
|
104
|
+
static void (APIENTRY * fptr_glBindFramebufferEXT)(GLenum,GLuint);
|
105
|
+
static VALUE gl_BindFramebufferEXT(VALUE obj,VALUE arg1,VALUE arg2)
|
106
|
+
{
|
107
|
+
LOAD_GL_EXT_FUNC(glBindFramebufferEXT,"GL_EXT_framebuffer_object")
|
108
|
+
fptr_glBindFramebufferEXT((GLenum)NUM2INT(arg1),(GLuint)NUM2UINT(arg2));
|
109
|
+
return Qnil;
|
110
|
+
}
|
111
|
+
|
112
|
+
static void (APIENTRY * fptr_glDeleteFramebuffersEXT)(GLsizei,const GLuint *);
|
113
|
+
static VALUE gl_DeleteFramebuffersEXT(VALUE obj,VALUE arg1)
|
114
|
+
{
|
115
|
+
GLsizei n;
|
116
|
+
LOAD_GL_EXT_FUNC(glDeleteFramebuffersEXT,"GL_EXT_framebuffer_object")
|
117
|
+
if (TYPE(arg1)==T_ARRAY) {
|
118
|
+
GLuint *framebuffers;
|
119
|
+
n = RARRAY(arg1)->len;
|
120
|
+
framebuffers = ALLOC_N(GLuint,n);
|
121
|
+
ary2cuint(arg1,framebuffers,n);
|
122
|
+
fptr_glDeleteFramebuffersEXT(n,framebuffers);
|
123
|
+
xfree(framebuffers);
|
124
|
+
} else {
|
125
|
+
GLuint framebuffer;
|
126
|
+
framebuffer = NUM2UINT(arg1);
|
127
|
+
fptr_glDeleteFramebuffersEXT(1,&framebuffer);
|
128
|
+
}
|
129
|
+
return Qnil;
|
130
|
+
}
|
131
|
+
|
132
|
+
static void (APIENTRY * fptr_glGenFramebuffersEXT)(GLsizei,GLuint *);
|
133
|
+
static VALUE gl_GenFramebuffersEXT(VALUE obj,VALUE arg1)
|
134
|
+
{
|
135
|
+
GLsizei n;
|
136
|
+
GLuint *framebuffers;
|
137
|
+
VALUE ret;
|
138
|
+
int i;
|
139
|
+
LOAD_GL_EXT_FUNC(glGenFramebuffersEXT,"GL_EXT_framebuffer_object")
|
140
|
+
n = (GLsizei)NUM2UINT(arg1);
|
141
|
+
framebuffers = ALLOC_N(GLuint, n);
|
142
|
+
fptr_glGenFramebuffersEXT(n,framebuffers);
|
143
|
+
ret = rb_ary_new2(n);
|
144
|
+
for (i = 0; i < n; i++)
|
145
|
+
rb_ary_push(ret, INT2NUM(framebuffers[i]));
|
146
|
+
xfree(framebuffers);
|
147
|
+
return ret;
|
148
|
+
}
|
149
|
+
|
150
|
+
static GLenum (APIENTRY * fptr_glCheckFramebufferStatusEXT)(GLenum);
|
151
|
+
static VALUE gl_CheckFramebufferStatusEXT(VALUE obj,VALUE arg1)
|
152
|
+
{
|
153
|
+
GLenum ret;
|
154
|
+
LOAD_GL_EXT_FUNC(glCheckFramebufferStatusEXT,"GL_EXT_framebuffer_object")
|
155
|
+
ret = fptr_glCheckFramebufferStatusEXT(NUM2UINT(arg1));
|
156
|
+
return INT2NUM(ret);
|
157
|
+
}
|
158
|
+
|
159
|
+
static void (APIENTRY * fptr_glFramebufferTexture1DEXT)(GLenum,GLenum,GLenum,GLuint,GLint);
|
160
|
+
static VALUE gl_FramebufferTexture1DEXT(VALUE obj,VALUE arg1,VALUE arg2,VALUE arg3,VALUE arg4,VALUE arg5)
|
161
|
+
{
|
162
|
+
LOAD_GL_EXT_FUNC(glFramebufferTexture1DEXT,"GL_EXT_framebuffer_object")
|
163
|
+
fptr_glFramebufferTexture1DEXT(NUM2UINT(arg1),NUM2UINT(arg2),NUM2UINT(arg3),NUM2UINT(arg4),NUM2INT(arg5));
|
164
|
+
return Qnil;
|
165
|
+
}
|
166
|
+
|
167
|
+
static void (APIENTRY * fptr_glFramebufferTexture2DEXT)(GLenum,GLenum,GLenum,GLuint,GLint);
|
168
|
+
static VALUE gl_FramebufferTexture2DEXT(VALUE obj,VALUE arg1,VALUE arg2,VALUE arg3,VALUE arg4,VALUE arg5)
|
169
|
+
{
|
170
|
+
LOAD_GL_EXT_FUNC(glFramebufferTexture2DEXT,"GL_EXT_framebuffer_object")
|
171
|
+
fptr_glFramebufferTexture2DEXT(NUM2UINT(arg1),NUM2UINT(arg2),NUM2UINT(arg3),NUM2UINT(arg4),NUM2INT(arg5));
|
172
|
+
return Qnil;
|
173
|
+
}
|
174
|
+
|
175
|
+
static void (APIENTRY * fptr_glFramebufferTexture3DEXT)(GLenum,GLenum,GLenum,GLuint,GLint,GLint);
|
176
|
+
static VALUE gl_FramebufferTexture3DEXT(VALUE obj,VALUE arg1,VALUE arg2,VALUE arg3,VALUE arg4,VALUE arg5,VALUE arg6)
|
177
|
+
{
|
178
|
+
LOAD_GL_EXT_FUNC(glFramebufferTexture3DEXT,"GL_EXT_framebuffer_object")
|
179
|
+
fptr_glFramebufferTexture3DEXT(NUM2UINT(arg1),NUM2UINT(arg2),NUM2UINT(arg3),NUM2UINT(arg4),NUM2INT(arg5),NUM2INT(arg6));
|
180
|
+
return Qnil;
|
181
|
+
}
|
182
|
+
|
183
|
+
GL_EXT_SIMPLE_FUNC_LOAD(FramebufferRenderbufferEXT,4,GLuint,NUM2UINT,"GL_EXT_framebuffer_object")
|
184
|
+
|
185
|
+
|
186
|
+
static void (APIENTRY * fptr_glGetFramebufferAttachmentParameterivEXT)(GLenum,GLenum,GLenum,GLint *);
|
187
|
+
static VALUE gl_GetFramebufferAttachmentParameterivEXT(VALUE obj,VALUE arg1, VALUE arg2, VALUE arg3)
|
188
|
+
{
|
189
|
+
GLint ret = 0;
|
190
|
+
LOAD_GL_EXT_FUNC(glGetFramebufferAttachmentParameterivEXT,"GL_EXT_framebuffer_object")
|
191
|
+
fptr_glGetFramebufferAttachmentParameterivEXT(NUM2UINT(arg1),NUM2UINT(arg2),NUM2UINT(arg3),&ret);
|
192
|
+
return INT2NUM(ret);
|
193
|
+
}
|
194
|
+
|
195
|
+
GL_EXT_SIMPLE_FUNC_LOAD(GenerateMipmapEXT,1,GLenum,NUM2UINT,"GL_EXT_framebuffer_object")
|
196
|
+
|
197
|
+
void gl_init_functions_ext_ext(VALUE module)
|
198
|
+
{
|
199
|
+
/* #310 - GL_EXT_framebuffer_object */
|
200
|
+
rb_define_module_function(module, "glIsRenderbufferEXT", gl_IsRenderbufferEXT, 1);
|
201
|
+
rb_define_module_function(module, "glBindRenderbufferEXT", gl_BindRenderbufferEXT, 2);
|
202
|
+
rb_define_module_function(module, "glDeleteRenderbuffersEXT", gl_DeleteRenderbuffersEXT, 1);
|
203
|
+
rb_define_module_function(module, "glGenRenderbuffersEXT", gl_GenRenderbuffersEXT, 1);
|
204
|
+
rb_define_module_function(module, "glRenderbufferStorageEXT", gl_RenderbufferStorageEXT, 4);
|
205
|
+
rb_define_module_function(module, "glGetRenderbufferParameterivEXT", gl_GetRenderbufferParameterivEXT, 2);
|
206
|
+
rb_define_module_function(module, "glIsFramebufferEXT", gl_IsFramebufferEXT, 1);
|
207
|
+
rb_define_module_function(module, "glBindFramebufferEXT", gl_BindFramebufferEXT, 2);
|
208
|
+
rb_define_module_function(module, "glDeleteFramebuffersEXT", gl_DeleteFramebuffersEXT, 1);
|
209
|
+
rb_define_module_function(module, "glGenFramebuffersEXT", gl_GenFramebuffersEXT, 1);
|
210
|
+
rb_define_module_function(module, "glCheckFramebufferStatusEXT", gl_CheckFramebufferStatusEXT, 1);
|
211
|
+
rb_define_module_function(module, "glFramebufferTexture1DEXT", gl_FramebufferTexture1DEXT, 5);
|
212
|
+
rb_define_module_function(module, "glFramebufferTexture2DEXT", gl_FramebufferTexture2DEXT, 5);
|
213
|
+
rb_define_module_function(module, "glFramebufferTexture3DEXT", gl_FramebufferTexture3DEXT, 6);
|
214
|
+
rb_define_module_function(module, "glFramebufferRenderbufferEXT", gl_FramebufferRenderbufferEXT, 4);
|
215
|
+
rb_define_module_function(module, "glGetFramebufferAttachmentParameterivEXT", gl_GetFramebufferAttachmentParameterivEXT, 3);
|
216
|
+
rb_define_module_function(module, "glGenerateMipmapEXT", gl_GenerateMipmapEXT, 1);
|
217
|
+
|
218
|
+
}
|
data/ext/gl/gl.c
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
|
3
3
|
* Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
|
4
|
+
* Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
|
4
5
|
*
|
5
6
|
* This program is distributed under the terms of the MIT license.
|
6
7
|
* See the included MIT-LICENSE file for the terms of this license.
|
@@ -14,22 +15,8 @@
|
|
14
15
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
15
16
|
*/
|
16
17
|
|
17
|
-
#ifdef __APPLE__
|
18
|
-
#include <OpenGL/gl.h>
|
19
|
-
#elif defined WIN32
|
20
|
-
#include <windows.h>
|
21
|
-
#include <GL/gl.h>
|
22
|
-
#else
|
23
|
-
#include <GL/gl.h>
|
24
|
-
#endif
|
25
18
|
#include "../common/common.h"
|
26
19
|
|
27
|
-
#ifdef WIN32
|
28
|
-
#define DLLEXPORT __declspec(dllexport)
|
29
|
-
#else
|
30
|
-
#define DLLEXPORT
|
31
|
-
#endif
|
32
|
-
|
33
20
|
static VALUE module;
|
34
21
|
|
35
22
|
void gl_init_enums(VALUE);
|
@@ -40,40 +27,158 @@ void gl_init_functions_1_4(VALUE);
|
|
40
27
|
void gl_init_functions_1_5(VALUE);
|
41
28
|
void gl_init_functions_2_0(VALUE);
|
42
29
|
void gl_init_functions_2_1(VALUE);
|
30
|
+
void gl_init_functions_ext_arb(VALUE);
|
31
|
+
void gl_init_functions_ext_ext(VALUE);
|
32
|
+
|
33
|
+
static int opengl_version[2]; /* major, minor */
|
34
|
+
static char *opengl_extensions = NULL;
|
43
35
|
|
44
|
-
|
36
|
+
/* Returns current OpenGL version as major, minor or 0,0 if
|
37
|
+
* unknown (context not yet initialised etc.) The version is
|
38
|
+
* cached for subsequent calls.
|
39
|
+
*/
|
40
|
+
const int *GetOpenglVersion(void)
|
45
41
|
{
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
if (opengl_version[0]==0) { /* not cached, query */
|
43
|
+
const char *vstr = (const char *) glGetString(GL_VERSION);
|
44
|
+
if (vstr)
|
45
|
+
sscanf( vstr, "%d.%d", &opengl_version[0], &opengl_version[1] );
|
46
|
+
}
|
47
|
+
return opengl_version;
|
48
|
+
}
|
49
|
+
|
50
|
+
/* Checks if OpenGL version is at least the same or higher than
|
51
|
+
* major.minor
|
52
|
+
*/
|
53
|
+
GLboolean CheckOpenglVersion(int major, int minor)
|
54
|
+
{
|
55
|
+
const int *version;
|
56
|
+
|
57
|
+
version = GetOpenglVersion();
|
58
|
+
|
59
|
+
if (version[0]>major || (version[0]==major && version[1] >=minor))
|
60
|
+
return GL_TRUE;
|
50
61
|
else
|
51
|
-
return
|
62
|
+
return GL_FALSE;
|
63
|
+
}
|
64
|
+
|
65
|
+
/* Returns supported OpenGL extensions as char* or NULL
|
66
|
+
* if unknown (context not yet initialised etc.) The list is
|
67
|
+
* cached for subsequent calls.
|
68
|
+
*/
|
69
|
+
const char *GetOpenglExtensions(void)
|
70
|
+
{
|
71
|
+
if (opengl_extensions == NULL) {
|
72
|
+
const char *estr = (const char *) glGetString(GL_EXTENSIONS);
|
73
|
+
if (estr) {
|
74
|
+
int len = strlen(estr);
|
75
|
+
opengl_extensions = ALLOC_N(GLchar,len+1+1); /* terminating null and added space */
|
76
|
+
strcpy(opengl_extensions,estr);
|
77
|
+
opengl_extensions[len] = ' '; /* add space char for easy searchs */
|
78
|
+
opengl_extensions[len+1] = '\0';
|
79
|
+
}
|
80
|
+
}
|
81
|
+
return opengl_extensions;
|
82
|
+
}
|
83
|
+
|
84
|
+
/* Checks if extension is supported by the current OpenGL implementation
|
85
|
+
*/
|
86
|
+
GLboolean CheckExtension(const char *name)
|
87
|
+
{
|
88
|
+
const char *extensions;
|
89
|
+
char *name_tmp;
|
90
|
+
int name_len;
|
91
|
+
GLboolean res;
|
92
|
+
|
93
|
+
extensions = GetOpenglExtensions();
|
94
|
+
|
95
|
+
if(extensions==NULL)
|
96
|
+
return GL_FALSE;
|
97
|
+
|
98
|
+
/* add trailing space */
|
99
|
+
name_len = strlen(name);
|
100
|
+
name_tmp = ALLOC_N(GLchar,name_len+1+1); /* terminating null and added space */
|
101
|
+
strcpy(name_tmp,name);
|
102
|
+
name_tmp[name_len] = ' '; /* add space char for search */
|
103
|
+
name_tmp[name_len+1] = '\0';
|
104
|
+
|
105
|
+
if (strstr(extensions,name_tmp))
|
106
|
+
res = GL_TRUE;
|
107
|
+
else
|
108
|
+
res = GL_FALSE;
|
109
|
+
|
110
|
+
xfree(name_tmp);
|
111
|
+
return res;
|
52
112
|
}
|
53
113
|
|
54
114
|
static VALUE
|
55
115
|
IsAvailable(obj,arg1)
|
56
116
|
VALUE obj,arg1;
|
57
117
|
{
|
58
|
-
char *name =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
118
|
+
char *name = NULL;
|
119
|
+
VALUE s;
|
120
|
+
|
121
|
+
s = rb_funcall(arg1, rb_intern("to_s"),0);
|
122
|
+
name = RSTRING(s)->ptr;
|
123
|
+
|
124
|
+
if (name && name[0] && name[0]>='0' && name[0]<='9') { /* GL version query */
|
125
|
+
int major,minor;
|
126
|
+
|
127
|
+
if (sscanf( name, "%d.%d", &major, &minor ) != 2)
|
128
|
+
return Qfalse;
|
129
|
+
|
130
|
+
if (CheckOpenglVersion(major,minor)==1)
|
131
|
+
return Qtrue;
|
132
|
+
else
|
63
133
|
return Qfalse;
|
64
|
-
|
134
|
+
} else if (name && name[0] && (name[0]=='G' || name[0]=='W')) { /* GL_, GLX_, WGL_ extension */
|
135
|
+
GLboolean res;
|
136
|
+
|
137
|
+
res = CheckExtension(name);
|
138
|
+
if (res==GL_TRUE)
|
139
|
+
return Qtrue;
|
140
|
+
else
|
65
141
|
return Qfalse;
|
66
|
-
|
67
|
-
sprintf(buf,"Gl.glGetString(Gl::GL_EXTENSIONS).split(' ').include?('%s')", name);
|
68
|
-
return rb_eval_string(buf);
|
69
142
|
} else { /* function */
|
70
|
-
|
143
|
+
GLvoid *ret;
|
144
|
+
ret = load_gl_function(name,0); /* won't raise */
|
145
|
+
if (ret==NULL)
|
146
|
+
return Qfalse;
|
147
|
+
else
|
148
|
+
return Qtrue;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
/* Checks whether non-zero buffer of type $buffer is bound
|
153
|
+
* - this affects several functions that pass data from/to OpenGL.
|
154
|
+
*/
|
155
|
+
GLint CheckBufferBinding(GLint buffer)
|
156
|
+
{
|
157
|
+
GLint result = 0;
|
158
|
+
|
159
|
+
/* check if the buffer functionality is supported */
|
160
|
+
switch(buffer) {
|
161
|
+
case GL_ARRAY_BUFFER_BINDING:
|
162
|
+
case GL_ELEMENT_ARRAY_BUFFER_BINDING:
|
163
|
+
if (!CheckOpenglVersion(1,5))
|
164
|
+
return 0;
|
165
|
+
break;
|
166
|
+
case GL_PIXEL_PACK_BUFFER_BINDING:
|
167
|
+
case GL_PIXEL_UNPACK_BUFFER_BINDING:
|
168
|
+
if (!CheckOpenglVersion(2,1))
|
169
|
+
return 0;
|
170
|
+
break;
|
171
|
+
default:
|
172
|
+
rb_raise(rb_eRuntimeError,"Internal Error: buffer type '%i' does not exist", buffer);
|
173
|
+
break;
|
71
174
|
}
|
175
|
+
glGetIntegerv(buffer,&result);
|
176
|
+
return result;
|
72
177
|
}
|
73
178
|
|
74
179
|
DLLEXPORT void Init_gl()
|
75
180
|
{
|
76
|
-
|
181
|
+
module = rb_define_module("Gl");
|
77
182
|
gl_init_enums(module);
|
78
183
|
gl_init_functions_1_0__1_1(module);
|
79
184
|
gl_init_functions_1_2(module);
|
@@ -82,6 +187,8 @@ DLLEXPORT void Init_gl()
|
|
82
187
|
gl_init_functions_1_5(module);
|
83
188
|
gl_init_functions_2_0(module);
|
84
189
|
gl_init_functions_2_1(module);
|
190
|
+
gl_init_functions_ext_arb(module);
|
191
|
+
gl_init_functions_ext_ext(module);
|
85
192
|
|
86
193
|
rb_define_module_function(module, "is_available?", IsAvailable, 1);
|
87
194
|
}
|