opengl 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/test_case.rb +1 -2
  103. data/test/dummy.xorg.conf +140 -0
  104. data/test/test_gl.rb +18 -22
  105. data/test/test_gl_10_11.rb +220 -220
  106. data/test/test_gl_12.rb +11 -122
  107. data/test/test_gl_13.rb +202 -210
  108. data/test/test_gl_14.rb +16 -19
  109. data/test/test_gl_15.rb +2 -4
  110. data/test/test_gl_20.rb +45 -58
  111. data/test/test_gl_21.rb +46 -163
  112. data/test/test_gl_ext_arb.rb +54 -72
  113. data/test/test_gl_ext_ati.rb +0 -2
  114. data/test/test_gl_ext_ext.rb +66 -66
  115. data/test/test_gl_ext_gremedy.rb +8 -15
  116. data/test/test_gl_ext_nv.rb +109 -112
  117. data/test/test_opengl_buffer.rb +8 -25
  118. data/utils/README +0 -5
  119. data/utils/enumgen.rb +72 -76
  120. data/utils/extlistgen.rb +55 -55
  121. metadata +87 -66
  122. metadata.gz.sig +2 -0
  123. data/Rakefile.cross +0 -107
  124. data/docs/build_install.txt +0 -119
  125. data/docs/extensions.txt.in +0 -348
  126. data/docs/history.txt +0 -66
  127. data/docs/requirements_and_design.txt +0 -117
  128. data/docs/roadmap.txt +0 -28
  129. data/docs/scientific_use.txt +0 -35
  130. data/docs/supplies/page_template.html +0 -71
  131. data/docs/thanks.txt +0 -29
  132. data/docs/tutorial.txt +0 -469
  133. data/ext/opengl/glu-enums.c +0 -164
  134. data/ext/opengl/glu-enums.h +0 -463
  135. data/ext/opengl/glu.c +0 -1534
  136. data/ext/opengl/glut.c +0 -1145
  137. data/ext/opengl/glut_callbacks.c +0 -845
  138. data/lib/glu.rb +0 -1
  139. data/lib/glut.rb +0 -1
  140. data/test/test_glu.rb +0 -309
  141. data/utils/mkdn2html.rb +0 -59
  142. data/utils/post-mkdn2html.rb +0 -91
  143. data/website/images/ogl.jpg +0 -0
  144. data/website/images/tab_bottom.gif +0 -0
  145. data/website/style.css +0 -198
@@ -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
- library = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY | RTLD_LOCAL | RTLD_FIRST);
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
- func_ptr = dlsym(library, name);
396
- dlclose(library);
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
@@ -16,15 +16,15 @@
16
16
  /* Functions and macros for datatype conversion between Ruby and C */
17
17
 
18
18
  /*
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).
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
- (x) == Qtrue ? GL_TRUE : (((x) == Qfalse) ? GL_FALSE : NUM2INT(x))
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
- (x) == GL_TRUE ? Qtrue : ((x)==GL_FALSE ? Qfalse : INT2NUM((x)))
74
- #define RUBYBOOL2GL(x) (x)==Qtrue? GL_TRUE : GL_FALSE
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
- long i; \
128
- VALUE ary = rb_Array(arg); \
129
- if (maxlen < 1) \
130
- maxlen = RARRAY_LEN(ary); \
131
- else \
132
- maxlen = maxlen < RARRAY_LEN(ary) ? maxlen : RARRAY_LEN(ary); \
133
- for (i=0; i < maxlen; i++) \
134
- cary[i] = (GL##_type_)_convert_(rb_ary_entry(ary,i)); \
135
- return i; \
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
- RET_ARRAY_OR_SINGLE_FUNC(_name_, _size_, _conv_, _params_, EMPTY)
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
- RET_ARRAY_OR_SINGLE_FUNC(_name, _size_, _conv_, _params_, FREE(_params_))
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
- int iter; \
212
- VALUE return_array; \
213
- if (_size_ == 1) { \
214
- return_array = _conv_(_params_[0]); \
215
- } else { \
216
- return_array = rb_ary_new2(_size_); \
217
- for(iter=0;iter<_size_;iter++) \
218
- rb_ary_push(return_array, _conv_(_params_[iter])); \
219
- } \
220
- _extra_ \
221
- CHECK_GLERROR_FROM(_name_); \
222
- return return_array; \
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
- RET_ARRAY_OR_SINGLE_BOOL_FUNC(_name_, _size_, _conv_, _enum_, _params_, EMPTY)
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
- RET_ARRAY_OR_SINGLE_BOOL_FUNC(_name_, _size_, _conv_, _enum_, _params_, FREE(_params_))
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
-
@@ -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
- (have_library('opengl32.lib', 'glVertex3d') &&
28
- have_library('glu32.lib', 'gluLookAt') &&
29
- have_library('glut32.lib', 'gluSolidTeapot')) ||
30
- (have_library('opengl32') &&
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
-
@@ -13,13 +13,14 @@
13
13
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
14
  */
15
15
 
16
- /* These macros are for simplification of function definition, as passing
17
- arguments from/to OpenGL usually follows the same few patterns. It would
18
- be probably wise to adapt the whole bindings to C++ (templates, overloaded
19
- functions, etc.), but for now supporting ruby extension for Windows means
20
- MSVC6, and that in turn means unspeakable horrors and pains for everyone
21
- attempting to merely write, much less debug or maintain any template-based
22
- code.
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
- do { \
32
- if (fptr_##_NAME_==NULL) { \
33
- if (CheckVersionExtension(_VEREXT_) == GL_FALSE) { \
34
- if (isdigit(_VEREXT_[0])) { \
35
- rb_raise(rb_eNotImpError, \
36
- "OpenGL version %s is not available on this system",_VEREXT_); \
37
- } else { \
38
- rb_raise(rb_eNotImpError, \
39
- "Extension %s is not available on this system",_VEREXT_); \
40
- } \
41
- } \
42
- \
43
- fptr_##_NAME_ = load_gl_function(#_NAME_, 1); \
44
- } \
45
- } while (0)
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
- /* Macroset for defining simple functions, i.e. functions that take n arguments and
48
- pass them to GL API function without any additional processing.
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
- Some checking is implicit in _conversion_ argument - e.g. NUM2INT makes sure that
51
- user is really passing type that can be converted to INT, otherwire raises.
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
- *_LOAD version of macros are for defining functions where we load function pointer
54
- instead of direct call - that means all functions above OpenGL 1.1 (including all extensions)
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)GLBOOL2RUBY
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
- static _returntype_ (APIENTRY * fptr_gl##_name_)(PROTOPARAM##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
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
- RETDECL_##_returntype_ \
168
- LOAD_GL_FUNC(gl##_name_,_ver_); \
169
- RETSTAT_##_returntype_ fptr_gl##_name_(CALLCONV##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
170
- CHECK_GLERROR_FROM("gl" #_name_); \
171
- return RETCONV_##_returntype_(ret) ; \
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
- static VALUE \
177
+ static VALUE \
176
178
  gl_##_name_(obj ARGLIST##_num_) \
177
179
  VALUE obj ARGLIST##_num_; \
178
180
  { \
179
- RETDECL_##_returntype_ \
180
- RETSTAT_##_returntype_ gl##_name_(CALLCONV##_num_(targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)); \
181
- CHECK_GLERROR_FROM("gl" #_name_); \
182
- return RETCONV_##_returntype_(ret) ; \
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
- GL_FUNC_LOAD(0, _name_,_returntype_,0,0,0,0,0,0,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(1, _name_,_returntype_,targ1,0,0,0,0,0,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(2, _name_,_returntype_,targ1,targ2,0,0,0,0,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(3, _name_,_returntype_,targ1,targ2,targ3,0,0,0,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(4, _name_,_returntype_,targ1,targ2,targ3,targ4,0,0,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(5, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,0,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(6, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,0,0,0,0,_ver_)
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
- GL_FUNC_LOAD(7, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,0,0,0,_ver_)
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
- GL_FUNC_LOAD(8, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,0,0,_ver_)
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
- GL_FUNC_LOAD(9, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,0,_ver_)
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
- GL_FUNC_LOAD(10, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10,_ver_)
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
- GL_FUNC_STATIC(0, _name_,_returntype_,0,0,0,0,0,0,0,0,0,0)
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
- GL_FUNC_STATIC(1, _name_,_returntype_,targ1,0,0,0,0,0,0,0,0,0)
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
- GL_FUNC_STATIC(2, _name_,_returntype_,targ1,targ2,0,0,0,0,0,0,0,0)
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
- GL_FUNC_STATIC(3, _name_,_returntype_,targ1,targ2,targ3,0,0,0,0,0,0,0)
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
- GL_FUNC_STATIC(4, _name_,_returntype_,targ1,targ2,targ3,targ4,0,0,0,0,0,0)
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
- GL_FUNC_STATIC(5, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,0,0,0,0,0)
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
- GL_FUNC_STATIC(6, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,0,0,0,0)
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
- GL_FUNC_STATIC(7, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,0,0,0)
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
- GL_FUNC_STATIC(8, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,0,0)
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
- GL_FUNC_STATIC(9, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,0)
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
- GL_FUNC_STATIC(10, _name_,_returntype_,targ1,targ2,targ3,targ4,targ5,targ6,targ7,targ8,targ9,targ10)
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
- static void (APIENTRY * fptr_gl##_name_)(GLsizei,GLuint *); \
236
+ static void (APIENTRY * fptr_gl##_name_)(GLsizei,GLuint *); \
235
237
  static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
236
238
  { \
237
- GLsizei n; \
238
- GLuint *objects; \
239
- VALUE ret; \
240
- GLsizei i; \
241
- LOAD_GL_FUNC(gl##_name_,_ver_); \
242
- n = CONV_GLsizei(arg1); \
243
- objects = ALLOC_N(GLuint, n); \
244
- fptr_gl##_name_(n,objects); \
245
- ret = rb_ary_new2(n); \
246
- for (i = 0; i < n; i++) \
247
- rb_ary_push(ret, RETCONV_GLuint(objects[i])); \
248
- xfree(objects); \
249
- CHECK_GLERROR_FROM("gl" #_name_); \
250
- return ret; \
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
- static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
256
+ static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
255
257
  { \
256
- GLsizei n; \
257
- GLuint *objects; \
258
- VALUE ret; \
259
- GLsizei i; \
260
- n = CONV_GLsizei(arg1); \
261
- objects = ALLOC_N(GLuint, n); \
262
- gl##_name_(n,objects); \
263
- ret = rb_ary_new2(n); \
264
- for (i = 0; i < n; i++) \
265
- rb_ary_push(ret, RETCONV_GLuint(objects[i])); \
266
- xfree(objects); \
267
- CHECK_GLERROR_FROM("gl" #_name_); \
268
- return ret; \
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
- static void (APIENTRY * fptr_gl##_name_)(GLsizei,const GLuint *); \
274
+ static void (APIENTRY * fptr_gl##_name_)(GLsizei,const GLuint *); \
273
275
  static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
274
276
  { \
275
- GLsizei n; \
276
- LOAD_GL_FUNC(gl##_name_,_ver_); \
277
- if (TYPE(arg1)==T_ARRAY) { \
278
- GLuint *objects; \
279
- n = (GLsizei)RARRAY_LENINT(arg1); \
280
- objects = ALLOC_N(GLuint,n); \
281
- ary2cuint(arg1,objects,n); \
282
- fptr_gl##_name_(n,objects); \
283
- xfree(objects); \
284
- } else { \
285
- GLuint object; \
286
- object = CONV_GLsizei(arg1); \
287
- fptr_gl##_name_(1,&object); \
288
- } \
289
- CHECK_GLERROR_FROM("gl" #_name_); \
290
- return Qnil; \
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
- static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
296
+ static VALUE gl_##_name_(VALUE obj,VALUE arg1) \
295
297
  { \
296
- GLsizei n; \
297
- if (TYPE(arg1)==T_ARRAY) { \
298
- GLuint *objects; \
299
- n = (GLsizei)RARRAY_LENINT(arg1); \
300
- objects = ALLOC_N(GLuint,n); \
301
- ary2cuint(arg1,objects,n); \
302
- gl##_name_(n,objects); \
303
- xfree(objects); \
304
- } else { \
305
- GLuint object; \
306
- object = CONV_GLsizei(arg1); \
307
- gl##_name_(1,&object); \
308
- } \
309
- CHECK_GLERROR_FROM("gl" #_name_); \
310
- return Qnil; \
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
  }