opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +2 -1
- data/.travis.yml +19 -0
- data/History.rdoc +26 -0
- data/Manifest.txt +3 -23
- data/README.rdoc +43 -37
- data/Rakefile +6 -62
- data/examples/NeHe/nehe_lesson02.rb +3 -2
- data/examples/NeHe/nehe_lesson03.rb +3 -2
- data/examples/NeHe/nehe_lesson04.rb +3 -1
- data/examples/NeHe/nehe_lesson05.rb +4 -1
- data/examples/NeHe/nehe_lesson06.rb +9 -6
- data/examples/NeHe/nehe_lesson07.rb +9 -6
- data/examples/NeHe/nehe_lesson08.rb +9 -6
- data/examples/NeHe/nehe_lesson09.rb +10 -6
- data/examples/NeHe/nehe_lesson11.rb +9 -6
- data/examples/NeHe/nehe_lesson12.rb +9 -6
- data/examples/NeHe/nehe_lesson16.rb +50 -47
- data/examples/NeHe/nehe_lesson19.rb +10 -7
- data/examples/NeHe/nehe_lesson36.rb +234 -229
- data/examples/OrangeBook/brick.rb +227 -225
- data/examples/OrangeBook/particle.rb +233 -231
- data/examples/RedBook/aapoly.rb +71 -70
- data/examples/RedBook/aargb.rb +54 -52
- data/examples/RedBook/accanti.rb +96 -94
- data/examples/RedBook/accpersp.rb +106 -104
- data/examples/RedBook/alpha.rb +54 -52
- data/examples/RedBook/alpha3D.rb +90 -88
- data/examples/RedBook/bezcurve.rb +48 -46
- data/examples/RedBook/bezmesh.rb +71 -69
- data/examples/RedBook/checker.rb +57 -55
- data/examples/RedBook/clip.rb +41 -39
- data/examples/RedBook/colormat.rb +72 -70
- data/examples/RedBook/cube.rb +39 -37
- data/examples/RedBook/depthcue.rb +37 -35
- data/examples/RedBook/dof.rb +110 -109
- data/examples/RedBook/double.rb +40 -38
- data/examples/RedBook/drawf.rb +30 -28
- data/examples/RedBook/feedback.rb +79 -77
- data/examples/RedBook/fog.rb +90 -89
- data/examples/RedBook/font.rb +78 -76
- data/examples/RedBook/hello.rb +29 -27
- data/examples/RedBook/image.rb +57 -55
- data/examples/RedBook/jitter.rb +131 -131
- data/examples/RedBook/light.rb +2 -1
- data/examples/RedBook/lines.rb +70 -68
- data/examples/RedBook/list.rb +48 -46
- data/examples/RedBook/material.rb +200 -199
- data/examples/RedBook/mipmap.rb +84 -82
- data/examples/RedBook/model.rb +55 -53
- data/examples/RedBook/movelight.rb +52 -50
- data/examples/RedBook/pickdepth.rb +103 -101
- data/examples/RedBook/planet.rb +46 -44
- data/examples/RedBook/quadric.rb +97 -95
- data/examples/RedBook/robot.rb +55 -53
- data/examples/RedBook/select.rb +118 -116
- data/examples/RedBook/smooth.rb +35 -33
- data/examples/RedBook/stencil.rb +96 -94
- data/examples/RedBook/stroke.rb +75 -73
- data/examples/RedBook/surface.rb +93 -91
- data/examples/RedBook/teaambient.rb +71 -69
- data/examples/RedBook/teapots.rb +105 -103
- data/examples/RedBook/tess.rb +96 -94
- data/examples/RedBook/texbind.rb +79 -77
- data/examples/RedBook/texgen.rb +88 -86
- data/examples/RedBook/texturesurf.rb +57 -55
- data/examples/RedBook/varray.rb +85 -83
- data/examples/RedBook/wrap.rb +76 -74
- data/examples/misc/OGLBench.rb +114 -113
- data/examples/misc/anisotropic.rb +154 -152
- data/examples/misc/fbo_test.rb +37 -36
- data/examples/misc/font-glut.rb +47 -46
- data/examples/misc/glfwtest.rb +16 -16
- data/examples/misc/plane.rb +13 -13
- data/examples/misc/readpixel.rb +66 -65
- data/examples/misc/sdltest.rb +21 -19
- data/examples/misc/trislam.rb +548 -547
- data/ext/opengl/common.h +16 -38
- data/ext/opengl/conv.h +39 -41
- data/ext/opengl/extconf.rb +4 -31
- data/ext/opengl/funcdef.h +126 -124
- data/ext/opengl/gl-1.0-1.1.c +1917 -1917
- data/ext/opengl/gl-1.2.c +4 -667
- data/ext/opengl/gl-1.3.c +9 -9
- data/ext/opengl/gl-1.4.c +8 -8
- data/ext/opengl/gl-1.5.c +1 -1
- data/ext/opengl/gl-2.0.c +392 -388
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +1523 -5
- data/ext/opengl/gl-enums.h +4679 -122
- data/ext/opengl/gl-error.c +7 -7
- data/ext/opengl/gl-error.h +4 -4
- data/ext/opengl/gl-ext-arb.c +468 -464
- data/ext/opengl/gl-ext-ext.c +18 -18
- data/ext/opengl/gl-ext-nv.c +15 -15
- data/ext/opengl/gl.c +2 -0
- data/ext/opengl/gl_buffer.c +92 -92
- data/ext/opengl/opengl.c +1 -7
- data/lib/opengl.rb +23 -59
- data/lib/opengl/1.9/opengl.so +0 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +1 -2
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +18 -22
- data/test/test_gl_10_11.rb +220 -220
- data/test/test_gl_12.rb +11 -122
- data/test/test_gl_13.rb +202 -210
- data/test/test_gl_14.rb +16 -19
- data/test/test_gl_15.rb +2 -4
- data/test/test_gl_20.rb +45 -58
- data/test/test_gl_21.rb +46 -163
- data/test/test_gl_ext_arb.rb +54 -72
- data/test/test_gl_ext_ati.rb +0 -2
- data/test/test_gl_ext_ext.rb +66 -66
- data/test/test_gl_ext_gremedy.rb +8 -15
- data/test/test_gl_ext_nv.rb +109 -112
- data/test/test_opengl_buffer.rb +8 -25
- data/utils/README +0 -5
- data/utils/enumgen.rb +72 -76
- data/utils/extlistgen.rb +55 -55
- metadata +90 -67
- metadata.gz.sig +0 -0
- data/Rakefile.cross +0 -107
- data/docs/build_install.txt +0 -119
- data/docs/extensions.txt.in +0 -348
- data/docs/history.txt +0 -66
- data/docs/requirements_and_design.txt +0 -117
- data/docs/roadmap.txt +0 -28
- data/docs/scientific_use.txt +0 -35
- data/docs/supplies/page_template.html +0 -71
- data/docs/thanks.txt +0 -29
- data/docs/tutorial.txt +0 -469
- data/ext/opengl/glu-enums.c +0 -164
- data/ext/opengl/glu-enums.h +0 -463
- data/ext/opengl/glu.c +0 -1534
- data/ext/opengl/glut.c +0 -1145
- data/ext/opengl/glut_callbacks.c +0 -845
- data/lib/glu.rb +0 -1
- data/lib/glut.rb +0 -1
- data/lib/opengl/opengl.so +0 -0
- data/test/test_glu.rb +0 -309
- data/utils/mkdn2html.rb +0 -59
- data/utils/post-mkdn2html.rb +0 -91
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +0 -198
data/ext/opengl/common.h
CHANGED
@@ -31,14 +31,6 @@
|
|
31
31
|
#include <OpenGL/gl.h>
|
32
32
|
#endif
|
33
33
|
|
34
|
-
#ifdef HAVE_OPENGL_GLU_H
|
35
|
-
#include <OpenGL/glu.h>
|
36
|
-
#endif
|
37
|
-
|
38
|
-
#ifdef HAVE_GLUT_GLUT_H
|
39
|
-
#include <GLUT/glut.h>
|
40
|
-
#endif
|
41
|
-
|
42
34
|
#ifdef HAVE_DLFCN_H
|
43
35
|
#include <dlfcn.h>
|
44
36
|
#endif
|
@@ -55,21 +47,12 @@
|
|
55
47
|
#include <GL/gl.h>
|
56
48
|
#endif
|
57
49
|
|
58
|
-
#ifdef HAVE_GL_GLU_H
|
59
|
-
#include <GL/glu.h>
|
60
|
-
#endif
|
61
|
-
|
62
|
-
#ifdef HAVE_GL_GLUT_H
|
63
|
-
#include <GL/glut.h>
|
64
|
-
#endif
|
65
|
-
|
66
50
|
#ifdef HAVE_GL_GLX_H
|
67
51
|
#include <GL/glx.h>
|
68
52
|
#endif
|
69
53
|
|
70
54
|
#include "gl-types.h"
|
71
55
|
#include "gl-enums.h"
|
72
|
-
#include "glu-enums.h"
|
73
56
|
#include "gl-error.h"
|
74
57
|
|
75
58
|
#include "funcdef.h"
|
@@ -83,10 +66,6 @@
|
|
83
66
|
#define CALLBACK
|
84
67
|
#endif
|
85
68
|
|
86
|
-
#ifndef GLUTCALLBACK
|
87
|
-
#define GLUTCALLBACK
|
88
|
-
#endif
|
89
|
-
|
90
69
|
#ifdef HAVE_WINDOWS_H
|
91
70
|
#define DLLEXPORT __declspec(dllexport)
|
92
71
|
#else
|
@@ -387,13 +366,25 @@ static inline void *load_gl_function(const char *name,int raise)
|
|
387
366
|
|
388
367
|
#if defined(__APPLE__)
|
389
368
|
void *library = NULL;
|
390
|
-
|
369
|
+
library = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY | RTLD_LOCAL | RTLD_FIRST);
|
391
370
|
|
392
371
|
if (library == NULL)
|
393
372
|
rb_raise(rb_eRuntimeError,"Can't load OpenGL library for dynamic loading");
|
394
|
-
|
395
|
-
|
396
|
-
|
373
|
+
|
374
|
+
func_ptr = dlsym(library, name);
|
375
|
+
|
376
|
+
if(func_ptr == NULL)
|
377
|
+
{
|
378
|
+
/* prepend a '_' for the Unix C symbol mangling convention */
|
379
|
+
char *symbol_name = ALLOC_N(char, strlen(name) + 2);
|
380
|
+
symbol_name[0] = '_';
|
381
|
+
strcpy(symbol_name + 1, name);
|
382
|
+
func_ptr = dlsym(library, symbol_name);
|
383
|
+
xfree(symbol_name);
|
384
|
+
}
|
385
|
+
|
386
|
+
dlclose(library);
|
387
|
+
|
397
388
|
#elif HAVE_WGLGETPROCADDRESS
|
398
389
|
func_ptr = wglGetProcAddress((LPCSTR)name);
|
399
390
|
#elif defined(GLX_VERSION_1_4)
|
@@ -434,17 +425,4 @@ static inline VALUE pack_array_or_pass_string(GLenum type,VALUE ary)
|
|
434
425
|
return rb_funcall(ary,rb_intern("pack"),1,rb_str_new2(type_str));
|
435
426
|
}
|
436
427
|
|
437
|
-
/* GLUT */
|
438
|
-
|
439
|
-
#define GLUT_SIMPLE_FUNCTION(_name_) \
|
440
|
-
static VALUE \
|
441
|
-
glut_##_name_(obj) \
|
442
|
-
VALUE obj; \
|
443
|
-
{ \
|
444
|
-
glut##_name_(); \
|
445
|
-
return Qnil; \
|
446
|
-
}
|
447
|
-
|
448
|
-
VALUE rb_glut_check_callback(VALUE, VALUE);
|
449
|
-
|
450
428
|
#endif
|
data/ext/opengl/conv.h
CHANGED
@@ -16,15 +16,15 @@
|
|
16
16
|
/* Functions and macros for datatype conversion between Ruby and C */
|
17
17
|
|
18
18
|
/*
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
Fast inline conversion functions as a replacement for the ones in libruby.
|
20
|
+
FIXNUM_P is simple logical AND check so it comes first, TYPE() is simple function,
|
21
|
+
and specified in header file so it can be inlined. For conversion, FIX2LONG is
|
22
|
+
simple right shift, and RFLOAT()-> just pointer dereference. For converting
|
23
|
+
Fixnum and Float types (which accounts for 99.9% of things you would want to pass
|
24
|
+
to OpenGL), there is large performance boost as result.
|
25
|
+
|
26
|
+
Also ruby 'true' and 'false' are converted to GL_TRUE/GL_FALSE for compatibility, and
|
27
|
+
finally, we fallback to library functions for any other data types (and error handling).
|
28
28
|
*/
|
29
29
|
|
30
30
|
#if HAVE_STRUCT_RFLOAT_FLOAT_VALUE
|
@@ -66,12 +66,14 @@ FASTCONV(num2uint,unsigned long,FIX2ULONG,(unsigned int)NUM2ULONG)
|
|
66
66
|
#undef FASTCONV
|
67
67
|
|
68
68
|
#define RUBY2GLENUM(x) \
|
69
|
-
|
69
|
+
(x) == Qtrue ? GL_TRUE : ((x) == Qfalse ? GL_FALSE : NUM2INT(x))
|
70
70
|
|
71
71
|
/* For conversion between ruby and GL boolean values */
|
72
72
|
#define GLBOOL2RUBY(x) \
|
73
|
-
|
74
|
-
|
73
|
+
(x) == GL_TRUE ? Qtrue : ((x)==GL_FALSE ? Qfalse : INT2NUM((x)))
|
74
|
+
|
75
|
+
#define RUBYBOOL2GL(x) \
|
76
|
+
(x) == Qtrue ? GL_TRUE : GL_FALSE
|
75
77
|
|
76
78
|
#define cond_GLBOOL2RUBY_FUNC(_name_,_type_,_conv_) \
|
77
79
|
static inline VALUE _name_(GLenum pname,_type_ value) \
|
@@ -97,9 +99,6 @@ static inline VALUE _name_(GLenum pname,_type_ value) \
|
|
97
99
|
case GL_TEXTURE_FLOAT_COMPONENTS_NV: \
|
98
100
|
case GL_SHADER_CONSISTENT_NV: \
|
99
101
|
case GL_TEXTURE_COMPARE_SGIX: \
|
100
|
-
case GLU_TESS_BOUNDARY_ONLY: \
|
101
|
-
case GLU_CULLING: \
|
102
|
-
case GLU_AUTO_LOAD_MATRIX: \
|
103
102
|
return GLBOOL2RUBY(value); \
|
104
103
|
default: \
|
105
104
|
return _conv_(value); \
|
@@ -124,15 +123,15 @@ VALUE arg; \
|
|
124
123
|
GL##_type_ cary[]; \
|
125
124
|
long maxlen; \
|
126
125
|
{ \
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
126
|
+
long i; \
|
127
|
+
VALUE ary = rb_Array(arg); \
|
128
|
+
if (maxlen < 1) \
|
129
|
+
maxlen = RARRAY_LEN(ary); \
|
130
|
+
else \
|
131
|
+
maxlen = maxlen < RARRAY_LEN(ary) ? maxlen : RARRAY_LEN(ary); \
|
132
|
+
for (i=0; i < maxlen; i++) \
|
133
|
+
cary[i] = (GL##_type_)_convert_(rb_ary_entry(ary,i)); \
|
134
|
+
return i; \
|
136
135
|
}
|
137
136
|
|
138
137
|
ARY2CTYPE(int,NUM2INT)
|
@@ -201,32 +200,32 @@ ARY2CMATCNT(float)
|
|
201
200
|
#define FREE(_x_) xfree(_x_);
|
202
201
|
|
203
202
|
#define RET_ARRAY_OR_SINGLE(_name_, _size_, _conv_, _params_) \
|
204
|
-
|
203
|
+
RET_ARRAY_OR_SINGLE_FUNC(_name_, _size_, _conv_, _params_, EMPTY)
|
205
204
|
|
206
205
|
#define RET_ARRAY_OR_SINGLE_FREE(_name, _size_, _conv_, _params_) \
|
207
|
-
|
206
|
+
RET_ARRAY_OR_SINGLE_FUNC(_name, _size_, _conv_, _params_, FREE(_params_))
|
208
207
|
|
209
208
|
#define RET_ARRAY_OR_SINGLE_FUNC(_name_, _size_, _conv_, _params_, _extra_) \
|
210
209
|
do { \
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
210
|
+
int iter; \
|
211
|
+
VALUE return_array; \
|
212
|
+
if (_size_ == 1) { \
|
213
|
+
return_array = _conv_(_params_[0]); \
|
214
|
+
} else { \
|
215
|
+
return_array = rb_ary_new2(_size_); \
|
216
|
+
for(iter=0;iter<_size_;iter++) \
|
217
|
+
rb_ary_push(return_array, _conv_(_params_[iter])); \
|
218
|
+
} \
|
219
|
+
_extra_ \
|
220
|
+
CHECK_GLERROR_FROM(_name_); \
|
221
|
+
return return_array; \
|
223
222
|
} while (0)
|
224
223
|
|
225
224
|
#define RET_ARRAY_OR_SINGLE_BOOL(_name_, _size_, _conv_, _enum_, _params_) \
|
226
|
-
|
225
|
+
RET_ARRAY_OR_SINGLE_BOOL_FUNC(_name_, _size_, _conv_, _enum_, _params_, EMPTY)
|
227
226
|
|
228
227
|
#define RET_ARRAY_OR_SINGLE_BOOL_FREE(_name_, _size_, _conv_, _enum_, _params_) \
|
229
|
-
|
228
|
+
RET_ARRAY_OR_SINGLE_BOOL_FUNC(_name_, _size_, _conv_, _enum_, _params_, FREE(_params_))
|
230
229
|
|
231
230
|
#define RET_ARRAY_OR_SINGLE_BOOL_FUNC(_name_, _size_, _conv_, _enum_, _params_, _extra_) \
|
232
231
|
do { \
|
@@ -243,4 +242,3 @@ do { \
|
|
243
242
|
CHECK_GLERROR_FROM(_name_); \
|
244
243
|
return return_array; \
|
245
244
|
} while (0)
|
246
|
-
|
data/ext/opengl/extconf.rb
CHANGED
@@ -15,40 +15,18 @@ end unless respond_to? :have_framework
|
|
15
15
|
|
16
16
|
if ENV['CROSS_COMPILING']
|
17
17
|
dir_config("installed")
|
18
|
-
|
19
|
-
$defs.push "-DFREEGLUT_EXPORTS"
|
20
|
-
|
21
|
-
# libfreeglut is linked to gdi32 and winmm
|
22
|
-
have_library( 'gdi32', 'CreateDC' ) && append_library( $libs, 'gdi32' )
|
23
|
-
have_library( 'winmm', 'timeBeginPeriod' ) && append_library( $libs, 'winmm' )
|
24
18
|
end
|
25
19
|
|
26
20
|
ok =
|
27
|
-
(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
have_library('glu32') &&
|
32
|
-
have_library('glut')) ||
|
33
|
-
(have_library('GL', 'glVertex3d') &&
|
34
|
-
have_library('GLU', 'gluLookAt') &&
|
35
|
-
have_library('glut', 'glutSolidTeapot')) ||
|
36
|
-
(have_framework('OpenGL') &&
|
37
|
-
have_framework('GLUT') &&
|
38
|
-
have_framework('Cocoa'))
|
21
|
+
(have_framework('OpenGL') && have_framework('Cocoa')) ||
|
22
|
+
have_library('opengl32.lib', 'glVertex3d') ||
|
23
|
+
have_library('opengl32') ||
|
24
|
+
have_library('GL', 'glVertex3d')
|
39
25
|
|
40
26
|
ok &&=
|
41
27
|
have_header('GL/gl.h') ||
|
42
28
|
have_header('OpenGL/gl.h') # OS X
|
43
29
|
|
44
|
-
ok &&=
|
45
|
-
have_header('GL/glu.h') ||
|
46
|
-
have_header('OpenGL/glu.h') # OS X
|
47
|
-
|
48
|
-
ok &&=
|
49
|
-
have_header('GL/glut.h') ||
|
50
|
-
have_header('GLUT/glut.h') # OS X
|
51
|
-
|
52
30
|
have_header 'GL/glx.h' # *NIX only?
|
53
31
|
have_header 'dlfcn.h' # OS X dynamic loader
|
54
32
|
have_header 'windows.h'
|
@@ -63,12 +41,7 @@ have_struct_member 'struct RFloat', 'float_value'
|
|
63
41
|
have_type 'int64_t', 'stdint.h'
|
64
42
|
have_type 'uint64_t', 'stdint.h'
|
65
43
|
|
66
|
-
if String === ?a then
|
67
|
-
$defs.push "-DHAVE_SINGLE_BYTE_STRINGS"
|
68
|
-
end
|
69
|
-
|
70
44
|
if ok then
|
71
45
|
create_header
|
72
46
|
create_makefile 'opengl/opengl'
|
73
47
|
end
|
74
|
-
|
data/ext/opengl/funcdef.h
CHANGED
@@ -13,13 +13,14 @@
|
|
13
13
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
14
|
*/
|
15
15
|
|
16
|
-
/*
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
/*
|
17
|
+
These macros are for simplification of function definition, as passing
|
18
|
+
arguments from/to OpenGL usually follows the same few patterns. It would
|
19
|
+
be probably wise to adapt the whole bindings to C++ (templates, overloaded
|
20
|
+
functions, etc.), but for now supporting ruby extension for Windows means
|
21
|
+
MSVC6, and that in turn means unspeakable horrors and pains for everyone
|
22
|
+
attempting to merely write, much less debug or maintain any template-based
|
23
|
+
code.
|
23
24
|
*/
|
24
25
|
|
25
26
|
/*
|
@@ -28,30 +29,31 @@
|
|
28
29
|
* then required or the required extension is not supported.
|
29
30
|
*/
|
30
31
|
#define LOAD_GL_FUNC(_NAME_, _VEREXT_) \
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
do { \
|
33
|
+
if (fptr_##_NAME_==NULL) { \
|
34
|
+
if (CheckVersionExtension(_VEREXT_) == GL_FALSE) { \
|
35
|
+
if (isdigit(_VEREXT_[0])) { \
|
36
|
+
rb_raise(rb_eNotImpError, \
|
37
|
+
"OpenGL version %s is not available on this system",_VEREXT_); \
|
38
|
+
} else { \
|
39
|
+
rb_raise(rb_eNotImpError, \
|
40
|
+
"Extension %s is not available on this system",_VEREXT_); \
|
41
|
+
} \
|
42
|
+
} \
|
43
|
+
\
|
44
|
+
fptr_##_NAME_ = load_gl_function(#_NAME_, 1); \
|
45
|
+
} \
|
46
|
+
} while (0)
|
46
47
|
|
47
|
-
/*
|
48
|
-
|
48
|
+
/*
|
49
|
+
Macroset for defining simple functions, i.e. functions that take n arguments and
|
50
|
+
pass them to GL API function without any additional processing.
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
+
Some checking is implicit in _conversion_ argument - e.g. NUM2INT makes sure that
|
53
|
+
user is really passing type that can be converted to INT, otherwire raises.
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
+
*_LOAD version of macros are for defining functions where we load function pointer
|
56
|
+
instead of direct call - that means all functions above OpenGL 1.1 (including all extensions)
|
55
57
|
*/
|
56
58
|
|
57
59
|
#define ARGLIST0
|
@@ -67,7 +69,7 @@
|
|
67
69
|
#define ARGLIST10 ,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10
|
68
70
|
|
69
71
|
#define CONV_GLenum (GLenum)RUBY2GLENUM
|
70
|
-
#define CONV_GLboolean (GLboolean)
|
72
|
+
#define CONV_GLboolean (GLboolean)RUBYBOOL2GL
|
71
73
|
#define CONV_GLbitfield (GLbitfield)NUM2UINT
|
72
74
|
#define CONV_GLbyte (GLbyte)NUM2INT
|
73
75
|
#define CONV_GLshort (GLshort)NUM2INT
|
@@ -159,153 +161,153 @@
|
|
159
161
|
#define CALLCONV10(cv1,cv2,cv3,cv4,cv5,cv6,cv7,cv8,cv9,cv10) CONV_##cv1(arg1),CONV_##cv2(arg2),CONV_##cv3(arg3),CONV_##cv4(arg4),CONV_##cv5(arg5),CONV_##cv6(arg6),CONV_##cv7(arg7),CONV_##cv8(arg8),CONV_##cv9(arg9),CONV_##cv10(arg10)
|
160
162
|
|
161
163
|
#define GL_FUNC_LOAD(_num_,_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_) \
|
162
|
-
|
164
|
+
static _returntype_ (APIENTRY * fptr_gl##_name_)(PROTOPARAM##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
|
163
165
|
static VALUE \
|
164
166
|
gl_##_name_(obj ARGLIST##_num_) \
|
165
167
|
VALUE obj ARGLIST##_num_; \
|
166
168
|
{ \
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
169
|
+
RETDECL_##_returntype_ \
|
170
|
+
LOAD_GL_FUNC(gl##_name_,_ver_); \
|
171
|
+
RETSTAT_##_returntype_ fptr_gl##_name_(CALLCONV##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
|
172
|
+
CHECK_GLERROR_FROM("gl" #_name_); \
|
173
|
+
return RETCONV_##_returntype_(ret) ; \
|
172
174
|
}
|
173
175
|
|
174
176
|
#define GL_FUNC_STATIC(_num_,_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10) \
|
175
|
-
|
177
|
+
static VALUE \
|
176
178
|
gl_##_name_(obj ARGLIST##_num_) \
|
177
179
|
VALUE obj ARGLIST##_num_; \
|
178
180
|
{ \
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
181
|
+
RETDECL_##_returntype_ \
|
182
|
+
RETSTAT_##_returntype_ gl##_name_(CALLCONV##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
|
183
|
+
CHECK_GLERROR_FROM("gl" #_name_); \
|
184
|
+
return RETCONV_##_returntype_(ret) ; \
|
183
185
|
}
|
184
186
|
|
185
187
|
#define GL_FUNC_LOAD_0(_name_,_returntype_,_ver_) \
|
186
|
-
|
188
|
+
GL_FUNC_LOAD(0, _name_,_returntype_,0,0,0,0,0,0,0,0,0,0,_ver_)
|
187
189
|
#define GL_FUNC_LOAD_1(_name_,_returntype_,targ1,_ver_) \
|
188
|
-
|
190
|
+
GL_FUNC_LOAD(1, _name_,_returntype_,targ1,0,0,0,0,0,0,0,0,0,_ver_)
|
189
191
|
#define GL_FUNC_LOAD_2(_name_,_returntype_,targ1,targ2,_ver_) \
|
190
|
-
|
192
|
+
GL_FUNC_LOAD(2, _name_,_returntype_,targ1,targ2,0,0,0,0,0,0,0,0,_ver_)
|
191
193
|
#define GL_FUNC_LOAD_3(_name_,_returntype_,targ1,targ2,targ3,_ver_) \
|
192
|
-
|
194
|
+
GL_FUNC_LOAD(3, _name_,_returntype_,targ1,targ2,targ3,0,0,0,0,0,0,0,_ver_)
|
193
195
|
#define GL_FUNC_LOAD_4(_name_,_returntype_,targ1,targ2,targ3,targ4,_ver_) \
|
194
|
-
|
196
|
+
GL_FUNC_LOAD(4, _name_,_returntype_,targ1,targ2,targ3,targ4,0,0,0,0,0,0,_ver_)
|
195
197
|
#define GL_FUNC_LOAD_5(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,_ver_) \
|
196
|
-
|
198
|
+
GL_FUNC_LOAD(5, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,0,0,0,0,0,_ver_)
|
197
199
|
#define GL_FUNC_LOAD_6(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,_ver_) \
|
198
|
-
|
200
|
+
GL_FUNC_LOAD(6, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,0,0,0,0,_ver_)
|
199
201
|
#define GL_FUNC_LOAD_7(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,_ver_) \
|
200
|
-
|
202
|
+
GL_FUNC_LOAD(7, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,0,0,0,_ver_)
|
201
203
|
#define GL_FUNC_LOAD_8(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,_ver_) \
|
202
|
-
|
204
|
+
GL_FUNC_LOAD(8, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,0,0,_ver_)
|
203
205
|
#define GL_FUNC_LOAD_9(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,_ver_) \
|
204
|
-
|
206
|
+
GL_FUNC_LOAD(9, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,0,_ver_)
|
205
207
|
#define GL_FUNC_LOAD_10(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_) \
|
206
|
-
|
208
|
+
GL_FUNC_LOAD(10, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_)
|
207
209
|
|
208
210
|
#define GL_FUNC_STATIC_0(_name_,_returntype_) \
|
209
|
-
|
211
|
+
GL_FUNC_STATIC(0, _name_,_returntype_,0,0,0,0,0,0,0,0,0,0)
|
210
212
|
#define GL_FUNC_STATIC_1(_name_,_returntype_,targ1) \
|
211
|
-
|
213
|
+
GL_FUNC_STATIC(1, _name_,_returntype_,targ1,0,0,0,0,0,0,0,0,0)
|
212
214
|
#define GL_FUNC_STATIC_2(_name_,_returntype_,targ1,targ2) \
|
213
|
-
|
215
|
+
GL_FUNC_STATIC(2, _name_,_returntype_,targ1,targ2,0,0,0,0,0,0,0,0)
|
214
216
|
#define GL_FUNC_STATIC_3(_name_,_returntype_,targ1,targ2,targ3) \
|
215
|
-
|
217
|
+
GL_FUNC_STATIC(3, _name_,_returntype_,targ1,targ2,targ3,0,0,0,0,0,0,0)
|
216
218
|
#define GL_FUNC_STATIC_4(_name_,_returntype_,targ1,targ2,targ3,targ4) \
|
217
|
-
|
219
|
+
GL_FUNC_STATIC(4, _name_,_returntype_,targ1,targ2,targ3,targ4,0,0,0,0,0,0)
|
218
220
|
#define GL_FUNC_STATIC_5(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5) \
|
219
|
-
|
221
|
+
GL_FUNC_STATIC(5, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,0,0,0,0,0)
|
220
222
|
#define GL_FUNC_STATIC_6(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6) \
|
221
|
-
|
223
|
+
GL_FUNC_STATIC(6, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,0,0,0,0)
|
222
224
|
#define GL_FUNC_STATIC_7(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7) \
|
223
|
-
|
225
|
+
GL_FUNC_STATIC(7, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,0,0,0)
|
224
226
|
#define GL_FUNC_STATIC_8(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8) \
|
225
|
-
|
227
|
+
GL_FUNC_STATIC(8, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,0,0)
|
226
228
|
#define GL_FUNC_STATIC_9(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9) \
|
227
|
-
|
229
|
+
GL_FUNC_STATIC(9, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,0)
|
228
230
|
#define GL_FUNC_STATIC_10(_name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10_ver_) \
|
229
|
-
|
231
|
+
GL_FUNC_STATIC(10, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)
|
230
232
|
|
231
233
|
/* Templates for glGen* and glDelete* */
|
232
234
|
|
233
235
|
#define GL_FUNC_GENOBJECTS_LOAD(_name_,_ver_) \
|
234
|
-
|
236
|
+
static void (APIENTRY * fptr_gl##_name_)(GLsizei,GLuint *); \
|
235
237
|
static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
|
236
238
|
{ \
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
239
|
+
GLsizei n; \
|
240
|
+
GLuint *objects; \
|
241
|
+
VALUE ret; \
|
242
|
+
GLsizei i; \
|
243
|
+
LOAD_GL_FUNC(gl##_name_,_ver_); \
|
244
|
+
n = CONV_GLsizei(arg1); \
|
245
|
+
objects = ALLOC_N(GLuint, n); \
|
246
|
+
fptr_gl##_name_(n,objects); \
|
247
|
+
ret = rb_ary_new2(n); \
|
248
|
+
for (i = 0; i < n; i++) \
|
249
|
+
rb_ary_push(ret, RETCONV_GLuint(objects[i])); \
|
250
|
+
xfree(objects); \
|
251
|
+
CHECK_GLERROR_FROM("gl" #_name_); \
|
252
|
+
return ret; \
|
251
253
|
}
|
252
254
|
|
253
255
|
#define GL_FUNC_GENOBJECTS(_name_) \
|
254
|
-
|
256
|
+
static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
|
255
257
|
{ \
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
258
|
+
GLsizei n; \
|
259
|
+
GLuint *objects; \
|
260
|
+
VALUE ret; \
|
261
|
+
GLsizei i; \
|
262
|
+
n = CONV_GLsizei(arg1); \
|
263
|
+
objects = ALLOC_N(GLuint, n); \
|
264
|
+
gl##_name_(n,objects); \
|
265
|
+
ret = rb_ary_new2(n); \
|
266
|
+
for (i = 0; i < n; i++) \
|
267
|
+
rb_ary_push(ret, RETCONV_GLuint(objects[i])); \
|
268
|
+
xfree(objects); \
|
269
|
+
CHECK_GLERROR_FROM("gl" #_name_); \
|
270
|
+
return ret; \
|
269
271
|
}
|
270
272
|
|
271
273
|
#define GL_FUNC_DELETEOBJECTS_LOAD(_name_,_ver_) \
|
272
|
-
|
274
|
+
static void (APIENTRY * fptr_gl##_name_)(GLsizei,const GLuint *); \
|
273
275
|
static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
|
274
276
|
{ \
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
277
|
+
GLsizei n; \
|
278
|
+
LOAD_GL_FUNC(gl##_name_,_ver_); \
|
279
|
+
if (TYPE(arg1)==T_ARRAY) { \
|
280
|
+
GLuint *objects; \
|
281
|
+
n = (GLsizei)RARRAY_LENINT(arg1); \
|
282
|
+
objects = ALLOC_N(GLuint,n); \
|
283
|
+
ary2cuint(arg1,objects,n); \
|
284
|
+
fptr_gl##_name_(n,objects); \
|
285
|
+
xfree(objects); \
|
286
|
+
} else { \
|
287
|
+
GLuint object; \
|
288
|
+
object = CONV_GLsizei(arg1); \
|
289
|
+
fptr_gl##_name_(1,&object); \
|
290
|
+
} \
|
291
|
+
CHECK_GLERROR_FROM("gl" #_name_); \
|
292
|
+
return Qnil; \
|
291
293
|
}
|
292
294
|
|
293
295
|
#define GL_FUNC_DELETEOBJECTS(_name_) \
|
294
|
-
|
296
|
+
static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
|
295
297
|
{ \
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
298
|
+
GLsizei n; \
|
299
|
+
if (TYPE(arg1)==T_ARRAY) { \
|
300
|
+
GLuint *objects; \
|
301
|
+
n = (GLsizei)RARRAY_LENINT(arg1); \
|
302
|
+
objects = ALLOC_N(GLuint,n); \
|
303
|
+
ary2cuint(arg1,objects,n); \
|
304
|
+
gl##_name_(n,objects); \
|
305
|
+
xfree(objects); \
|
306
|
+
} else { \
|
307
|
+
GLuint object; \
|
308
|
+
object = CONV_GLsizei(arg1); \
|
309
|
+
gl##_name_(1,&object); \
|
310
|
+
} \
|
311
|
+
CHECK_GLERROR_FROM("gl" #_name_); \
|
312
|
+
return Qnil; \
|
311
313
|
}
|