ruby-opengl 0.40.1 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/Rakefile +2 -2
  2. data/doc/build_install.txt +48 -28
  3. data/doc/extensions.txt +361 -0
  4. data/doc/history.txt +8 -2
  5. data/doc/requirements_and_design.txt +0 -13
  6. data/doc/roadmap.txt +11 -13
  7. data/doc/supplies/page_template.html +11 -5
  8. data/doc/thanks.txt +2 -4
  9. data/doc/tutorial.txt +1 -4
  10. data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
  11. data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
  12. data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
  13. data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
  14. data/examples/NeHe/nehe_lesson36.rb +303 -0
  15. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  16. data/examples/OrangeBook/brick.frag +36 -0
  17. data/examples/OrangeBook/brick.rb +388 -0
  18. data/examples/OrangeBook/brick.vert +41 -0
  19. data/examples/OrangeBook/particle.frag +17 -0
  20. data/examples/OrangeBook/particle.rb +424 -0
  21. data/examples/OrangeBook/particle.vert +38 -0
  22. data/examples/README +13 -83
  23. data/examples/RedBook/aaindex.rb +97 -0
  24. data/examples/RedBook/aapoly.rb +142 -0
  25. data/examples/RedBook/aargb.rb +119 -0
  26. data/examples/RedBook/accanti.rb +162 -0
  27. data/examples/RedBook/accpersp.rb +215 -0
  28. data/examples/RedBook/alpha.rb +123 -0
  29. data/examples/RedBook/alpha3D.rb +158 -0
  30. data/examples/RedBook/bezcurve.rb +105 -0
  31. data/examples/RedBook/bezmesh.rb +137 -0
  32. data/examples/RedBook/checker.rb +124 -0
  33. data/examples/RedBook/clip.rb +95 -0
  34. data/examples/RedBook/colormat.rb +135 -0
  35. data/examples/RedBook/cube.rb +69 -0
  36. data/examples/RedBook/depthcue.rb +99 -0
  37. data/examples/RedBook/dof.rb +205 -0
  38. data/examples/{legacy → RedBook}/double.rb +59 -58
  39. data/examples/{legacy → RedBook}/drawf.rb +47 -54
  40. data/examples/RedBook/feedback.rb +145 -0
  41. data/examples/RedBook/fog.rb +167 -0
  42. data/examples/RedBook/font.rb +151 -0
  43. data/examples/RedBook/hello.rb +79 -0
  44. data/examples/RedBook/image.rb +137 -0
  45. data/examples/{legacy → RedBook}/jitter.rb +60 -62
  46. data/examples/RedBook/lines.rb +128 -0
  47. data/examples/RedBook/list.rb +111 -0
  48. data/examples/RedBook/material.rb +275 -0
  49. data/examples/RedBook/mipmap.rb +156 -0
  50. data/examples/{legacy → RedBook}/model.rb +66 -72
  51. data/examples/{legacy → RedBook}/movelight.rb +67 -75
  52. data/examples/RedBook/pickdepth.rb +179 -0
  53. data/examples/{legacy → RedBook}/planet.rb +62 -66
  54. data/examples/RedBook/quadric.rb +158 -0
  55. data/examples/RedBook/robot.rb +115 -0
  56. data/examples/RedBook/select.rb +196 -0
  57. data/examples/RedBook/smooth.rb +95 -0
  58. data/examples/RedBook/stencil.rb +163 -0
  59. data/examples/RedBook/stroke.rb +167 -0
  60. data/examples/RedBook/surface.rb +166 -0
  61. data/examples/RedBook/teaambient.rb +132 -0
  62. data/examples/RedBook/teapots.rb +182 -0
  63. data/examples/RedBook/tess.rb +183 -0
  64. data/examples/RedBook/texbind.rb +147 -0
  65. data/examples/RedBook/texgen.rb +169 -0
  66. data/examples/RedBook/texturesurf.rb +128 -0
  67. data/examples/RedBook/varray.rb +159 -0
  68. data/examples/RedBook/wrap.rb +148 -0
  69. data/examples/misc/anisotropic.rb +194 -0
  70. data/examples/misc/font-glut.rb +46 -0
  71. data/examples/{plane.rb → misc/plane.rb} +0 -0
  72. data/examples/misc/readpixel.rb +65 -0
  73. data/examples/{smooth.rb → misc/smooth.rb} +0 -0
  74. data/examples/{test.rb → misc/test.rb} +0 -0
  75. data/ext/common/common.h +252 -70
  76. data/ext/common/gl-enums.h +6102 -7334
  77. data/ext/common/gl-types.h +47 -0
  78. data/ext/common/glu-enums.h +469 -0
  79. data/ext/gl/gl-1.0-1.1.c +842 -2464
  80. data/ext/gl/gl-1.2.c +217 -281
  81. data/ext/gl/gl-1.3.c +113 -133
  82. data/ext/gl/gl-1.4.c +98 -334
  83. data/ext/gl/gl-1.5.c +28 -34
  84. data/ext/gl/gl-2.0.c +26 -235
  85. data/ext/gl/gl-2.1.c +31 -124
  86. data/ext/gl/gl-enums.c +786 -631
  87. data/ext/gl/gl-ext-arb.c +66 -0
  88. data/ext/gl/gl-ext-ext.c +218 -0
  89. data/ext/gl/gl.c +138 -31
  90. data/ext/gl/mkrf_conf.rb +1 -0
  91. data/ext/glu/glu-enums.c +163 -0
  92. data/ext/glu/glu.c +1003 -1205
  93. data/ext/glu/mkrf_conf.rb +1 -0
  94. data/ext/glut/glut.c +1056 -1175
  95. data/lib/opengl.rb +90 -3
  96. data/test/tc_common.rb +26 -13
  97. data/test/tc_ext_arb.rb +73 -0
  98. data/test/tc_ext_ext.rb +74 -0
  99. data/test/tc_func_12.rb +8 -8
  100. data/test/tc_func_13.rb +17 -11
  101. data/test/tc_func_14.rb +8 -8
  102. data/test/tc_func_15.rb +190 -2
  103. data/test/tc_func_20.rb +36 -10
  104. data/test/tc_func_21.rb +445 -2
  105. data/test/tc_glu.rb +305 -0
  106. data/test/tc_misc.rb +1 -0
  107. metadata +84 -68
  108. data/doc/screenshots.txt +0 -23
  109. data/examples/legacy/COPYRIGHT +0 -8
  110. data/examples/legacy/aaindex.rb +0 -98
  111. data/examples/legacy/aapoly.rb +0 -153
  112. data/examples/legacy/aargb.rb +0 -139
  113. data/examples/legacy/accanti.rb +0 -159
  114. data/examples/legacy/accpersp.rb +0 -216
  115. data/examples/legacy/alpha.rb +0 -133
  116. data/examples/legacy/alpha3D.rb +0 -165
  117. data/examples/legacy/bezcurve.rb +0 -107
  118. data/examples/legacy/bezmesh.rb +0 -131
  119. data/examples/legacy/checker.rb +0 -121
  120. data/examples/legacy/clip.rb +0 -104
  121. data/examples/legacy/colormat.rb +0 -145
  122. data/examples/legacy/cube.rb +0 -73
  123. data/examples/legacy/depthcue.rb +0 -101
  124. data/examples/legacy/dof.rb +0 -212
  125. data/examples/legacy/feedback.rb +0 -152
  126. data/examples/legacy/fog.rb +0 -172
  127. data/examples/legacy/font-glut.rb +0 -41
  128. data/examples/legacy/font.rb +0 -158
  129. data/examples/legacy/hello.rb +0 -75
  130. data/examples/legacy/image.rb +0 -145
  131. data/examples/legacy/lines.rb +0 -135
  132. data/examples/legacy/list.rb +0 -120
  133. data/examples/legacy/material.rb +0 -290
  134. data/examples/legacy/mipmap.rb +0 -159
  135. data/examples/legacy/pickdepth.rb +0 -180
  136. data/examples/legacy/quadric.rb +0 -180
  137. data/examples/legacy/readpixel.rb +0 -59
  138. data/examples/legacy/robot.rb +0 -120
  139. data/examples/legacy/select.rb +0 -207
  140. data/examples/legacy/smooth.rb +0 -41
  141. data/examples/legacy/stencil.rb +0 -154
  142. data/examples/legacy/stroke.rb +0 -170
  143. data/examples/legacy/surface.rb +0 -170
  144. data/examples/legacy/teaambient.rb +0 -132
  145. data/examples/legacy/teapots.rb +0 -188
  146. data/examples/legacy/tess.rb +0 -222
  147. data/examples/legacy/texbind.rb +0 -157
  148. data/examples/legacy/texgen.rb +0 -171
  149. data/examples/legacy/texturesurf.rb +0 -128
  150. data/examples/legacy/varray.rb +0 -167
  151. data/examples/legacy/wrap.rb +0 -158
  152. data/lib/gl_prev.rb +0 -46
  153. data/lib/glu_prev.rb +0 -46
  154. data/lib/glut_prev.rb +0 -45
data/ext/gl/mkrf_conf.rb CHANGED
@@ -25,6 +25,7 @@ Mkrf::Generator.new( 'gl' ) do |g|
25
25
  g.cflags << ' -DWIN32'
26
26
  g.include_library( 'opengl32.lib', 'glVertex3d')
27
27
  else
28
+ g.cflags << ' -Wall'
28
29
  g.include_library( 'GL', 'glVertex3d')
29
30
  end
30
31
  end
@@ -0,0 +1,163 @@
1
+ /* This file was genereated on Mon Jul 23 15:17:36 +0200 2007
2
+ source: http://oss.sgi.com/cgi-bin/cvsweb.cgi/~checkout~/projects/ogl-sample/main/doc/registry/specs/enumglu.spec
3
+ */
4
+
5
+ #include "../common/common.h"
6
+ void glu_init_enums(VALUE module)
7
+ {
8
+ rb_define_const(module, "GLU_AUTO_LOAD_MATRIX", INT2NUM(GLU_AUTO_LOAD_MATRIX));
9
+ rb_define_const(module, "GLU_BEGIN", INT2NUM(GLU_BEGIN));
10
+ rb_define_const(module, "GLU_CCW", INT2NUM(GLU_CCW));
11
+ rb_define_const(module, "GLU_CULLING", INT2NUM(GLU_CULLING));
12
+ rb_define_const(module, "GLU_CW", INT2NUM(GLU_CW));
13
+ rb_define_const(module, "GLU_DISPLAY_MODE", INT2NUM(GLU_DISPLAY_MODE));
14
+ rb_define_const(module, "GLU_DOMAIN_DISTANCE", INT2NUM(GLU_DOMAIN_DISTANCE));
15
+ rb_define_const(module, "GLU_EDGE_FLAG", INT2NUM(GLU_EDGE_FLAG));
16
+ rb_define_const(module, "GLU_END", INT2NUM(GLU_END));
17
+ rb_define_const(module, "GLU_ERROR", INT2NUM(GLU_ERROR));
18
+ rb_define_const(module, "GLU_EXTENSIONS", INT2NUM(GLU_EXTENSIONS));
19
+ rb_define_const(module, "GLU_EXTERIOR", INT2NUM(GLU_EXTERIOR));
20
+ rb_define_const(module, "GLU_EXT_nurbs_tessellator", INT2NUM(GLU_EXT_nurbs_tessellator));
21
+ rb_define_const(module, "GLU_EXT_object_space_tess", INT2NUM(GLU_EXT_object_space_tess));
22
+ rb_define_const(module, "GLU_FALSE", INT2NUM(GLU_FALSE));
23
+ rb_define_const(module, "GLU_FILL", INT2NUM(GLU_FILL));
24
+ rb_define_const(module, "GLU_FLAT", INT2NUM(GLU_FLAT));
25
+ rb_define_const(module, "GLU_INSIDE", INT2NUM(GLU_INSIDE));
26
+ rb_define_const(module, "GLU_INTERIOR", INT2NUM(GLU_INTERIOR));
27
+ rb_define_const(module, "GLU_INVALID_ENUM", INT2NUM(GLU_INVALID_ENUM));
28
+ rb_define_const(module, "GLU_INVALID_OPERATION", INT2NUM(GLU_INVALID_OPERATION));
29
+ rb_define_const(module, "GLU_INVALID_VALUE", INT2NUM(GLU_INVALID_VALUE));
30
+ rb_define_const(module, "GLU_LAGRANGIAN_SGI", INT2NUM(GLU_LAGRANGIAN_SGI));
31
+ rb_define_const(module, "GLU_LINE", INT2NUM(GLU_LINE));
32
+ rb_define_const(module, "GLU_MAP1_TRIM_2", INT2NUM(GLU_MAP1_TRIM_2));
33
+ rb_define_const(module, "GLU_MAP1_TRIM_3", INT2NUM(GLU_MAP1_TRIM_3));
34
+ rb_define_const(module, "GLU_MITCHELL_NETRAVALI_SGI", INT2NUM(GLU_MITCHELL_NETRAVALI_SGI));
35
+ rb_define_const(module, "GLU_NONE", INT2NUM(GLU_NONE));
36
+ rb_define_const(module, "GLU_NURBS_BEGIN", INT2NUM(GLU_NURBS_BEGIN));
37
+ rb_define_const(module, "GLU_NURBS_BEGIN_DATA", INT2NUM(GLU_NURBS_BEGIN_DATA));
38
+ rb_define_const(module, "GLU_NURBS_BEGIN_DATA_EXT", INT2NUM(GLU_NURBS_BEGIN_DATA_EXT));
39
+ rb_define_const(module, "GLU_NURBS_BEGIN_EXT", INT2NUM(GLU_NURBS_BEGIN_EXT));
40
+ rb_define_const(module, "GLU_NURBS_COLOR", INT2NUM(GLU_NURBS_COLOR));
41
+ rb_define_const(module, "GLU_NURBS_COLOR_DATA", INT2NUM(GLU_NURBS_COLOR_DATA));
42
+ rb_define_const(module, "GLU_NURBS_COLOR_DATA_EXT", INT2NUM(GLU_NURBS_COLOR_DATA_EXT));
43
+ rb_define_const(module, "GLU_NURBS_COLOR_EXT", INT2NUM(GLU_NURBS_COLOR_EXT));
44
+ rb_define_const(module, "GLU_NURBS_END", INT2NUM(GLU_NURBS_END));
45
+ rb_define_const(module, "GLU_NURBS_END_DATA", INT2NUM(GLU_NURBS_END_DATA));
46
+ rb_define_const(module, "GLU_NURBS_END_DATA_EXT", INT2NUM(GLU_NURBS_END_DATA_EXT));
47
+ rb_define_const(module, "GLU_NURBS_END_EXT", INT2NUM(GLU_NURBS_END_EXT));
48
+ rb_define_const(module, "GLU_NURBS_ERROR", INT2NUM(GLU_NURBS_ERROR));
49
+ rb_define_const(module, "GLU_NURBS_ERROR1", INT2NUM(GLU_NURBS_ERROR1));
50
+ rb_define_const(module, "GLU_NURBS_ERROR10", INT2NUM(GLU_NURBS_ERROR10));
51
+ rb_define_const(module, "GLU_NURBS_ERROR11", INT2NUM(GLU_NURBS_ERROR11));
52
+ rb_define_const(module, "GLU_NURBS_ERROR12", INT2NUM(GLU_NURBS_ERROR12));
53
+ rb_define_const(module, "GLU_NURBS_ERROR13", INT2NUM(GLU_NURBS_ERROR13));
54
+ rb_define_const(module, "GLU_NURBS_ERROR14", INT2NUM(GLU_NURBS_ERROR14));
55
+ rb_define_const(module, "GLU_NURBS_ERROR15", INT2NUM(GLU_NURBS_ERROR15));
56
+ rb_define_const(module, "GLU_NURBS_ERROR16", INT2NUM(GLU_NURBS_ERROR16));
57
+ rb_define_const(module, "GLU_NURBS_ERROR17", INT2NUM(GLU_NURBS_ERROR17));
58
+ rb_define_const(module, "GLU_NURBS_ERROR18", INT2NUM(GLU_NURBS_ERROR18));
59
+ rb_define_const(module, "GLU_NURBS_ERROR19", INT2NUM(GLU_NURBS_ERROR19));
60
+ rb_define_const(module, "GLU_NURBS_ERROR2", INT2NUM(GLU_NURBS_ERROR2));
61
+ rb_define_const(module, "GLU_NURBS_ERROR20", INT2NUM(GLU_NURBS_ERROR20));
62
+ rb_define_const(module, "GLU_NURBS_ERROR21", INT2NUM(GLU_NURBS_ERROR21));
63
+ rb_define_const(module, "GLU_NURBS_ERROR22", INT2NUM(GLU_NURBS_ERROR22));
64
+ rb_define_const(module, "GLU_NURBS_ERROR23", INT2NUM(GLU_NURBS_ERROR23));
65
+ rb_define_const(module, "GLU_NURBS_ERROR24", INT2NUM(GLU_NURBS_ERROR24));
66
+ rb_define_const(module, "GLU_NURBS_ERROR25", INT2NUM(GLU_NURBS_ERROR25));
67
+ rb_define_const(module, "GLU_NURBS_ERROR26", INT2NUM(GLU_NURBS_ERROR26));
68
+ rb_define_const(module, "GLU_NURBS_ERROR27", INT2NUM(GLU_NURBS_ERROR27));
69
+ rb_define_const(module, "GLU_NURBS_ERROR28", INT2NUM(GLU_NURBS_ERROR28));
70
+ rb_define_const(module, "GLU_NURBS_ERROR29", INT2NUM(GLU_NURBS_ERROR29));
71
+ rb_define_const(module, "GLU_NURBS_ERROR3", INT2NUM(GLU_NURBS_ERROR3));
72
+ rb_define_const(module, "GLU_NURBS_ERROR30", INT2NUM(GLU_NURBS_ERROR30));
73
+ rb_define_const(module, "GLU_NURBS_ERROR31", INT2NUM(GLU_NURBS_ERROR31));
74
+ rb_define_const(module, "GLU_NURBS_ERROR32", INT2NUM(GLU_NURBS_ERROR32));
75
+ rb_define_const(module, "GLU_NURBS_ERROR33", INT2NUM(GLU_NURBS_ERROR33));
76
+ rb_define_const(module, "GLU_NURBS_ERROR34", INT2NUM(GLU_NURBS_ERROR34));
77
+ rb_define_const(module, "GLU_NURBS_ERROR35", INT2NUM(GLU_NURBS_ERROR35));
78
+ rb_define_const(module, "GLU_NURBS_ERROR36", INT2NUM(GLU_NURBS_ERROR36));
79
+ rb_define_const(module, "GLU_NURBS_ERROR37", INT2NUM(GLU_NURBS_ERROR37));
80
+ rb_define_const(module, "GLU_NURBS_ERROR4", INT2NUM(GLU_NURBS_ERROR4));
81
+ rb_define_const(module, "GLU_NURBS_ERROR5", INT2NUM(GLU_NURBS_ERROR5));
82
+ rb_define_const(module, "GLU_NURBS_ERROR6", INT2NUM(GLU_NURBS_ERROR6));
83
+ rb_define_const(module, "GLU_NURBS_ERROR7", INT2NUM(GLU_NURBS_ERROR7));
84
+ rb_define_const(module, "GLU_NURBS_ERROR8", INT2NUM(GLU_NURBS_ERROR8));
85
+ rb_define_const(module, "GLU_NURBS_ERROR9", INT2NUM(GLU_NURBS_ERROR9));
86
+ rb_define_const(module, "GLU_NURBS_MODE", INT2NUM(GLU_NURBS_MODE));
87
+ rb_define_const(module, "GLU_NURBS_MODE_EXT", INT2NUM(GLU_NURBS_MODE_EXT));
88
+ rb_define_const(module, "GLU_NURBS_NORMAL", INT2NUM(GLU_NURBS_NORMAL));
89
+ rb_define_const(module, "GLU_NURBS_NORMAL_DATA", INT2NUM(GLU_NURBS_NORMAL_DATA));
90
+ rb_define_const(module, "GLU_NURBS_NORMAL_DATA_EXT", INT2NUM(GLU_NURBS_NORMAL_DATA_EXT));
91
+ rb_define_const(module, "GLU_NURBS_NORMAL_EXT", INT2NUM(GLU_NURBS_NORMAL_EXT));
92
+ rb_define_const(module, "GLU_NURBS_RENDERER", INT2NUM(GLU_NURBS_RENDERER));
93
+ rb_define_const(module, "GLU_NURBS_RENDERER_EXT", INT2NUM(GLU_NURBS_RENDERER_EXT));
94
+ rb_define_const(module, "GLU_NURBS_TESSELLATOR", INT2NUM(GLU_NURBS_TESSELLATOR));
95
+ rb_define_const(module, "GLU_NURBS_TESSELLATOR_EXT", INT2NUM(GLU_NURBS_TESSELLATOR_EXT));
96
+ rb_define_const(module, "GLU_NURBS_TEXTURE_COORD", INT2NUM(GLU_NURBS_TEXTURE_COORD));
97
+ rb_define_const(module, "GLU_NURBS_TEXTURE_COORD_DATA", INT2NUM(GLU_NURBS_TEXTURE_COORD_DATA));
98
+ rb_define_const(module, "GLU_NURBS_TEXTURE_COORD_DATA_EXT", INT2NUM(GLU_NURBS_TEXTURE_COORD_DATA_EXT));
99
+ rb_define_const(module, "GLU_NURBS_TEXTURE_COORD_EXT", INT2NUM(GLU_NURBS_TEXTURE_COORD_EXT));
100
+ rb_define_const(module, "GLU_NURBS_VERTEX", INT2NUM(GLU_NURBS_VERTEX));
101
+ rb_define_const(module, "GLU_NURBS_VERTEX_DATA", INT2NUM(GLU_NURBS_VERTEX_DATA));
102
+ rb_define_const(module, "GLU_NURBS_VERTEX_DATA_EXT", INT2NUM(GLU_NURBS_VERTEX_DATA_EXT));
103
+ rb_define_const(module, "GLU_NURBS_VERTEX_EXT", INT2NUM(GLU_NURBS_VERTEX_EXT));
104
+ rb_define_const(module, "GLU_OBJECT_PARAMETRIC_ERROR", INT2NUM(GLU_OBJECT_PARAMETRIC_ERROR));
105
+ rb_define_const(module, "GLU_OBJECT_PARAMETRIC_ERROR_EXT", INT2NUM(GLU_OBJECT_PARAMETRIC_ERROR_EXT));
106
+ rb_define_const(module, "GLU_OBJECT_PATH_LENGTH", INT2NUM(GLU_OBJECT_PATH_LENGTH));
107
+ rb_define_const(module, "GLU_OBJECT_PATH_LENGTH_EXT", INT2NUM(GLU_OBJECT_PATH_LENGTH_EXT));
108
+ rb_define_const(module, "GLU_OUTLINE_PATCH", INT2NUM(GLU_OUTLINE_PATCH));
109
+ rb_define_const(module, "GLU_OUTLINE_POLYGON", INT2NUM(GLU_OUTLINE_POLYGON));
110
+ rb_define_const(module, "GLU_OUTSIDE", INT2NUM(GLU_OUTSIDE));
111
+ rb_define_const(module, "GLU_OUT_OF_MEMORY", INT2NUM(GLU_OUT_OF_MEMORY));
112
+ rb_define_const(module, "GLU_PARAMETRIC_ERROR", INT2NUM(GLU_PARAMETRIC_ERROR));
113
+ rb_define_const(module, "GLU_PARAMETRIC_TOLERANCE", INT2NUM(GLU_PARAMETRIC_TOLERANCE));
114
+ rb_define_const(module, "GLU_PATH_LENGTH", INT2NUM(GLU_PATH_LENGTH));
115
+ rb_define_const(module, "GLU_POINT", INT2NUM(GLU_POINT));
116
+ rb_define_const(module, "GLU_SAMPLING_METHOD", INT2NUM(GLU_SAMPLING_METHOD));
117
+ rb_define_const(module, "GLU_SAMPLING_TOLERANCE", INT2NUM(GLU_SAMPLING_TOLERANCE));
118
+ rb_define_const(module, "GLU_SILHOUETTE", INT2NUM(GLU_SILHOUETTE));
119
+ rb_define_const(module, "GLU_SMOOTH", INT2NUM(GLU_SMOOTH));
120
+ rb_define_const(module, "GLU_TESS_BEGIN", INT2NUM(GLU_TESS_BEGIN));
121
+ rb_define_const(module, "GLU_TESS_BEGIN_DATA", INT2NUM(GLU_TESS_BEGIN_DATA));
122
+ rb_define_const(module, "GLU_TESS_BOUNDARY_ONLY", INT2NUM(GLU_TESS_BOUNDARY_ONLY));
123
+ rb_define_const(module, "GLU_TESS_COMBINE", INT2NUM(GLU_TESS_COMBINE));
124
+ rb_define_const(module, "GLU_TESS_COMBINE_DATA", INT2NUM(GLU_TESS_COMBINE_DATA));
125
+ rb_define_const(module, "GLU_TESS_COORD_TOO_LARGE", INT2NUM(GLU_TESS_COORD_TOO_LARGE));
126
+ rb_define_const(module, "GLU_TESS_EDGE_FLAG", INT2NUM(GLU_TESS_EDGE_FLAG));
127
+ rb_define_const(module, "GLU_TESS_EDGE_FLAG_DATA", INT2NUM(GLU_TESS_EDGE_FLAG_DATA));
128
+ rb_define_const(module, "GLU_TESS_END", INT2NUM(GLU_TESS_END));
129
+ rb_define_const(module, "GLU_TESS_END_DATA", INT2NUM(GLU_TESS_END_DATA));
130
+ rb_define_const(module, "GLU_TESS_ERROR", INT2NUM(GLU_TESS_ERROR));
131
+ rb_define_const(module, "GLU_TESS_ERROR1", INT2NUM(GLU_TESS_ERROR1));
132
+ rb_define_const(module, "GLU_TESS_ERROR2", INT2NUM(GLU_TESS_ERROR2));
133
+ rb_define_const(module, "GLU_TESS_ERROR3", INT2NUM(GLU_TESS_ERROR3));
134
+ rb_define_const(module, "GLU_TESS_ERROR4", INT2NUM(GLU_TESS_ERROR4));
135
+ rb_define_const(module, "GLU_TESS_ERROR5", INT2NUM(GLU_TESS_ERROR5));
136
+ rb_define_const(module, "GLU_TESS_ERROR6", INT2NUM(GLU_TESS_ERROR6));
137
+ rb_define_const(module, "GLU_TESS_ERROR7", INT2NUM(GLU_TESS_ERROR7));
138
+ rb_define_const(module, "GLU_TESS_ERROR8", INT2NUM(GLU_TESS_ERROR8));
139
+ rb_define_const(module, "GLU_TESS_ERROR_DATA", INT2NUM(GLU_TESS_ERROR_DATA));
140
+ rb_define_const(module, "GLU_TESS_MISSING_BEGIN_CONTOUR", INT2NUM(GLU_TESS_MISSING_BEGIN_CONTOUR));
141
+ rb_define_const(module, "GLU_TESS_MISSING_BEGIN_POLYGON", INT2NUM(GLU_TESS_MISSING_BEGIN_POLYGON));
142
+ rb_define_const(module, "GLU_TESS_MISSING_END_CONTOUR", INT2NUM(GLU_TESS_MISSING_END_CONTOUR));
143
+ rb_define_const(module, "GLU_TESS_MISSING_END_POLYGON", INT2NUM(GLU_TESS_MISSING_END_POLYGON));
144
+ rb_define_const(module, "GLU_TESS_NEED_COMBINE_CALLBACK", INT2NUM(GLU_TESS_NEED_COMBINE_CALLBACK));
145
+ rb_define_const(module, "GLU_TESS_TOLERANCE", INT2NUM(GLU_TESS_TOLERANCE));
146
+ rb_define_const(module, "GLU_TESS_VERTEX", INT2NUM(GLU_TESS_VERTEX));
147
+ rb_define_const(module, "GLU_TESS_VERTEX_DATA", INT2NUM(GLU_TESS_VERTEX_DATA));
148
+ rb_define_const(module, "GLU_TESS_WINDING_ABS_GEQ_TWO", INT2NUM(GLU_TESS_WINDING_ABS_GEQ_TWO));
149
+ rb_define_const(module, "GLU_TESS_WINDING_NEGATIVE", INT2NUM(GLU_TESS_WINDING_NEGATIVE));
150
+ rb_define_const(module, "GLU_TESS_WINDING_NONZERO", INT2NUM(GLU_TESS_WINDING_NONZERO));
151
+ rb_define_const(module, "GLU_TESS_WINDING_ODD", INT2NUM(GLU_TESS_WINDING_ODD));
152
+ rb_define_const(module, "GLU_TESS_WINDING_POSITIVE", INT2NUM(GLU_TESS_WINDING_POSITIVE));
153
+ rb_define_const(module, "GLU_TESS_WINDING_RULE", INT2NUM(GLU_TESS_WINDING_RULE));
154
+ rb_define_const(module, "GLU_TRUE", INT2NUM(GLU_TRUE));
155
+ rb_define_const(module, "GLU_UNKNOWN", INT2NUM(GLU_UNKNOWN));
156
+ rb_define_const(module, "GLU_U_STEP", INT2NUM(GLU_U_STEP));
157
+ rb_define_const(module, "GLU_VERSION", INT2NUM(GLU_VERSION));
158
+ rb_define_const(module, "GLU_VERSION_1_1", INT2NUM(GLU_VERSION_1_1));
159
+ rb_define_const(module, "GLU_VERSION_1_2", INT2NUM(GLU_VERSION_1_2));
160
+ rb_define_const(module, "GLU_VERSION_1_3", INT2NUM(GLU_VERSION_1_3));
161
+ rb_define_const(module, "GLU_VERTEX", INT2NUM(GLU_VERTEX));
162
+ rb_define_const(module, "GLU_V_STEP", INT2NUM(GLU_V_STEP));
163
+ }
data/ext/glu/glu.c CHANGED
@@ -17,73 +17,59 @@
17
17
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
18
  */
19
19
 
20
- #ifdef __APPLE__
21
- #include <OpenGL/gl.h>
22
- #include <OpenGL/glu.h>
23
- #elif defined WIN32
24
- #include <windows.h>
25
- #include <GL/gl.h>
26
- #include <GL/glu.h>
27
- #else
28
- #include <GL/gl.h>
29
- #include <GL/glu.h>
30
- #endif
31
-
32
- #include <ruby.h>
33
20
  #include "../common/common.h"
34
21
 
35
- #ifdef WIN32
36
- #define DLLEXPORT __declspec(dllexport)
37
- typedef void (CALLBACK*(VOIDFUNC))();
38
- #else
39
- #define DLLEXPORT
40
- typedef void (*VOIDFUNC)();
41
- #endif
22
+ static VALUE module;
23
+
24
+ void glu_init_enums(VALUE);
42
25
 
43
- #if defined(GLU_VERSION_1_2)
44
26
  typedef GLUtesselator tesselatorObj;
45
- #else /* GLU_VERSION_1_2 */
46
- typedef GLUtriangulatorObj tesselatorObj;
47
- #endif /* !GLU_VERSION_1_2 */
48
27
 
49
- #ifdef MESA
28
+ /* pointers passed to gluNurbsCurve/Surface etc.,
29
+ - some implementations (Mesa) needs these to be valid
30
+ at EndCurve/Surface etc. call., so we store them here
31
+ and free them after that call */
32
+
50
33
  struct glu_MesaStack {
51
- int len;
52
- GLfloat **ptr;
34
+ int len;
35
+ GLfloat **ptr;
53
36
  };
54
37
 
55
38
  static struct glu_MesaStack gms = {0, NULL};
56
- #endif
57
39
 
58
40
  struct nurbsdata {
59
- GLUnurbsObj *nobj;
41
+ GLUnurbsObj *nobj;
42
+ VALUE n_ref;
60
43
  };
61
44
  struct tessdata {
62
- tesselatorObj *tobj;
63
- VALUE t_ref;
45
+ tesselatorObj *tobj;
46
+ VALUE t_ref;
64
47
  };
65
48
 
66
49
  struct quaddata {
67
- GLUquadricObj *qobj;
50
+ GLUquadricObj *qobj;
51
+ VALUE q_ref;
68
52
  };
69
53
 
70
54
  static VALUE cNurbs;
71
55
  static VALUE cTess;
72
56
  static VALUE cQuad;
73
57
 
58
+ #define REF_LAST 15
59
+
74
60
  #define GetNURBS(obj, ndata) {\
75
- Data_Get_Struct(obj, struct nurbsdata, ndata);\
76
- if (ndata->nobj == NULL) rb_raise(rb_eRuntimeError, "Nurbs Object already deleted!");\
61
+ Data_Get_Struct(obj, struct nurbsdata, ndata);\
62
+ if (ndata->nobj == NULL) rb_raise(rb_eRuntimeError, "Nurbs Object already deleted!");\
77
63
  }
78
64
 
79
65
  #define GetTESS(obj, tdata) {\
80
- Data_Get_Struct(obj, struct tessdata, tdata);\
81
- if (tdata->tobj == NULL) rb_raise(rb_eRuntimeError, "Triangulator Object already deleted!");\
66
+ Data_Get_Struct(obj, struct tessdata, tdata);\
67
+ if (tdata->tobj == NULL) rb_raise(rb_eRuntimeError, "Triangulator Object already deleted!");\
82
68
  }
83
69
 
84
70
  #define GetQUAD(obj, qdata) {\
85
- Data_Get_Struct(obj, struct quaddata, qdata);\
86
- if (qdata->qobj == NULL) rb_raise(rb_eRuntimeError, "Quadric Object already deleted!");\
71
+ Data_Get_Struct(obj, struct quaddata, qdata);\
72
+ if (qdata->qobj == NULL) rb_raise(rb_eRuntimeError, "Quadric Object already deleted!");\
87
73
  }
88
74
 
89
75
  static ID callId;
@@ -101,119 +87,172 @@ static int
101
87
  get_curve_dim(type)
102
88
  GLenum type;
103
89
  {
104
- switch(type)
105
- {
106
- case GL_MAP1_VERTEX_3: return 3;
107
- case GL_MAP1_VERTEX_4: return 4;
108
- case GL_MAP1_INDEX: return 1;
109
- case GL_MAP1_COLOR_4: return 4;
110
- case GL_MAP1_NORMAL: return 3;
111
- case GL_MAP1_TEXTURE_COORD_1: return 1;
112
- case GL_MAP1_TEXTURE_COORD_2: return 2;
113
- case GL_MAP1_TEXTURE_COORD_3: return 3;
114
- case GL_MAP1_TEXTURE_COORD_4: return 4;
115
- default: abort(); /* TODO: is this OK? */
116
- }
117
- return 0; /*never get here*/
90
+ switch(type)
91
+ {
92
+ case GL_MAP1_VERTEX_3: return 3;
93
+ case GL_MAP1_VERTEX_4: return 4;
94
+ case GL_MAP1_INDEX: return 1;
95
+ case GL_MAP1_COLOR_4: return 4;
96
+ case GL_MAP1_NORMAL: return 3;
97
+ case GL_MAP1_TEXTURE_COORD_1: return 1;
98
+ case GL_MAP1_TEXTURE_COORD_2: return 2;
99
+ case GL_MAP1_TEXTURE_COORD_3: return 3;
100
+ case GL_MAP1_TEXTURE_COORD_4: return 4;
101
+ default:
102
+ rb_raise(rb_eArgError,"Unknown curve type '%i'",type);
103
+ }
104
+ return 0; /* never gets here */
118
105
  }
119
106
  /* from nurbssrf.c */
120
107
  static int
121
108
  get_surface_dim(GLenum type)
122
109
  {
123
- switch(type)
124
- {
125
- case GL_MAP2_VERTEX_3: return 3;
126
- case GL_MAP2_VERTEX_4: return 4;
127
- case GL_MAP2_INDEX: return 1;
128
- case GL_MAP2_COLOR_4: return 4;
129
- case GL_MAP2_NORMAL: return 3;
130
- case GL_MAP2_TEXTURE_COORD_1: return 1;
131
- case GL_MAP2_TEXTURE_COORD_2: return 2;
132
- case GL_MAP2_TEXTURE_COORD_3: return 3;
133
- case GL_MAP2_TEXTURE_COORD_4: return 4;
134
- default: abort(); /* TODO: is this OK? */
135
- }
136
- return 0; /*never get here*/
110
+ switch(type)
111
+ {
112
+ case GL_MAP2_VERTEX_3: return 3;
113
+ case GL_MAP2_VERTEX_4: return 4;
114
+ case GL_MAP2_INDEX: return 1;
115
+ case GL_MAP2_COLOR_4: return 4;
116
+ case GL_MAP2_NORMAL: return 3;
117
+ case GL_MAP2_TEXTURE_COORD_1: return 1;
118
+ case GL_MAP2_TEXTURE_COORD_2: return 2;
119
+ case GL_MAP2_TEXTURE_COORD_3: return 3;
120
+ case GL_MAP2_TEXTURE_COORD_4: return 4;
121
+ default:
122
+ rb_raise(rb_eArgError,"Unknown surface type '%i'",type);
123
+ }
124
+ return 0; /* never gets here */
137
125
  }
138
126
 
139
127
  /*
140
128
  * NURBS API
141
129
  */
130
+ static VALUE n_current;
131
+
142
132
  static void
143
133
  free_nurbs(ndata)
144
134
  struct nurbsdata *ndata;
145
135
  {
146
- if (ndata->nobj) gluDeleteNurbsRenderer(ndata->nobj);
147
- ndata->nobj = NULL;
136
+ if (ndata->nobj) gluDeleteNurbsRenderer(ndata->nobj);
137
+ ndata->nobj = NULL;
138
+ ndata->n_ref = Qnil;
139
+ }
140
+ static void
141
+ mark_nurbs(ndata)
142
+ struct nurbsdata* ndata;
143
+ {
144
+ if (ndata->nobj)
145
+ rb_gc_mark(ndata->n_ref);
148
146
  }
147
+
148
+ static void CALLBACK
149
+ n_error(errorno)
150
+ GLenum errorno;
151
+ {
152
+ VALUE nurbs;
153
+ struct nurbsdata *ndata;
154
+ nurbs = rb_ary_entry(n_current, -1);
155
+ if (nurbs == Qnil)
156
+ return;
157
+ GetNURBS(nurbs, ndata);
158
+ rb_funcall(rb_ary_entry(ndata->n_ref, GLU_ERROR), callId, 1, INT2NUM(errorno));
159
+ }
160
+
161
+ static VALUE
162
+ glu_NurbsCallback(obj, arg1, arg2, arg3)
163
+ VALUE obj, arg1, arg2, arg3;
164
+ {
165
+ struct nurbsdata* ndata;
166
+ GLenum type;
167
+ GetNURBS(arg1, ndata);
168
+ type = (GLenum)NUM2INT(arg2);
169
+ if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
170
+ rb_raise(rb_eTypeError, "gluNurbsCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
171
+
172
+ if (type!=GLU_ERROR)
173
+ return Qnil;
174
+
175
+ rb_ary_store(ndata->n_ref, type, arg3);
176
+ if (NIL_P(arg3))
177
+ gluNurbsCallback(ndata->nobj, type, NULL);
178
+ else
179
+ gluNurbsCallback(ndata->nobj, type, n_error);
180
+
181
+ return Qnil;
182
+ }
183
+
184
+
149
185
  static VALUE
150
186
  glu_NewNurbsRenderer(obj)
151
187
  VALUE obj;
152
188
  {
153
- VALUE ret;
154
- struct nurbsdata *ndata;
155
- ret = Data_Make_Struct(cNurbs, struct nurbsdata, 0, free_nurbs, ndata);
156
- ndata->nobj = gluNewNurbsRenderer();
157
- return ret;
189
+ VALUE ret;
190
+ struct nurbsdata *ndata;
191
+ ret = Data_Make_Struct(cNurbs, struct nurbsdata, mark_nurbs, free_nurbs, ndata);
192
+ ndata->nobj = gluNewNurbsRenderer();
193
+ ndata->n_ref = rb_ary_new2(REF_LAST);
194
+ return ret;
158
195
  }
159
196
  static VALUE
160
197
  glu_DeleteNurbsRenderer(obj, arg1)
161
198
  VALUE obj, arg1;
162
199
  {
163
- struct nurbsdata *ndata;
164
- GetNURBS(arg1, ndata);
165
- free_nurbs(ndata);
166
- return Qnil;
200
+ struct nurbsdata *ndata;
201
+ GetNURBS(arg1, ndata);
202
+ free_nurbs(ndata);
203
+ return Qnil;
167
204
  }
168
205
  static VALUE
169
206
  glu_NurbsProperty(obj, arg1, arg2, arg3)
170
207
  VALUE obj, arg1, arg2, arg3;
171
208
  {
172
- struct nurbsdata *ndata;
173
- GLenum property;
174
- GLfloat value;
175
- GetNURBS(arg1, ndata);
176
- property = (GLenum)NUM2INT(arg2);
177
- value = (GLfloat)NUM2DBL(arg3);
178
- gluNurbsProperty(ndata->nobj, property, value);
179
- return Qnil;
209
+ struct nurbsdata *ndata;
210
+ GLenum property;
211
+ GLfloat value;
212
+ GetNURBS(arg1, ndata);
213
+ property = (GLenum)NUM2INT(arg2);
214
+ value = (GLfloat)NUM2DBL(arg3);
215
+ gluNurbsProperty(ndata->nobj, property, value);
216
+ return Qnil;
180
217
  }
181
218
  static VALUE
182
219
  glu_GetNurbsProperty(obj, arg1, arg2)
183
220
  VALUE obj, arg1, arg2;
184
221
  {
185
- struct nurbsdata *ndata;
186
- GLenum property;
187
- GLfloat value;
188
- GetNURBS(arg1, ndata);
189
- property = (GLenum)NUM2INT(arg2);
190
- gluGetNurbsProperty(ndata->nobj, property, &value);
191
- return rb_float_new(value);
222
+ struct nurbsdata *ndata;
223
+ GLenum property;
224
+ GLfloat value;
225
+ GetNURBS(arg1, ndata);
226
+ property = (GLenum)NUM2INT(arg2);
227
+ gluGetNurbsProperty(ndata->nobj, property, &value);
228
+ return rb_float_new(value);
192
229
  }
193
230
  static VALUE
194
231
  glu_BeginCurve(obj, arg1)
195
232
  VALUE obj, arg1;
196
233
  {
197
- struct nurbsdata *ndata;
198
- GetNURBS(arg1, ndata);
199
- gluBeginCurve(ndata->nobj);
200
- return Qnil;
234
+ struct nurbsdata *ndata;
235
+ GetNURBS(arg1, ndata);
236
+ rb_ary_push(n_current, arg1);
237
+ gluBeginCurve(ndata->nobj);
238
+ return Qnil;
201
239
  }
202
240
  static VALUE
203
241
  glu_EndCurve(obj, arg1)
204
242
  VALUE obj, arg1;
205
243
  {
206
- struct nurbsdata *ndata;
207
- GetNURBS(arg1, ndata);
208
- gluEndCurve(ndata->nobj);
209
- /* hack for Mesa 3.1 */
210
- #ifdef MESA
211
- for (gms.len;gms.len>0;gms.len--)
212
- free(gms.ptr[gms.len-1]);
213
- free(gms.ptr);
214
- gms.ptr = NULL;
215
- #endif
216
- return Qnil;
244
+ struct nurbsdata *ndata;
245
+ GetNURBS(arg1, ndata);
246
+ gluEndCurve(ndata->nobj);
247
+
248
+ for (;gms.len>0;gms.len--)
249
+ free(gms.ptr[gms.len-1]);
250
+ free(gms.ptr);
251
+ gms.ptr = NULL;
252
+
253
+ rb_ary_pop(n_current);
254
+
255
+ return Qnil;
217
256
  }
218
257
  static VALUE
219
258
  glu_NurbsCurve(argc,argv,obj)
@@ -221,96 +260,83 @@ int argc;
221
260
  VALUE *argv;
222
261
  VALUE obj;
223
262
  {
224
- struct nurbsdata *ndata;
225
- GLint uknot_count;
226
- GLfloat *uknot;
227
- GLint u_stride;
228
- GLint uorder;
229
- GLfloat *ctlarray;
230
- GLenum type;
231
-
232
- VALUE args[7];
233
- GLfloat tmp[4];
234
- int i;
235
- struct RArray *ary_ctl1;
236
-
237
- switch (rb_scan_args(argc, argv, "43", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6])) {
238
- case 3:
239
- uknot_count = RARRAY(rb_Array(args[1]))->len;
240
- uknot = ALLOC_N(GLfloat, uknot_count);
241
- ary2cflt(args[1], uknot, uknot_count);
242
- ary_ctl1 = RARRAY(rb_Array(args[2]));
243
- type = (GLenum)NUM2INT(args[3]);
244
- u_stride = get_curve_dim(type);
245
- uorder = ary_ctl1->len;
246
- ctlarray = ALLOC_N(GLfloat, u_stride*uorder);
247
- for (i = 0; i < ary_ctl1->len; i++) {
248
- ary2cflt(ary_ctl1->ptr[i], tmp, 4);
249
- memcpy(&ctlarray[i*u_stride], tmp, u_stride);
250
- }
251
- break;
252
- case 7:
253
- uknot_count = (GLint)NUM2INT(args[1]);
254
- uknot = ALLOC_N(GLfloat, uknot_count);
255
- ary2cflt(args[2], uknot, uknot_count);
256
- u_stride = (GLint)NUM2INT(args[3]);
257
- uorder = (GLint)NUM2INT(args[5]);
258
- type = (GLenum)NUM2INT(args[6]); /* ---> line was missing */
259
- /* ctlarray = ALLOC_N(GLfloat, u_stride*uorder); //--->Mathematically incorrect */
260
- ctlarray = ALLOC_N(GLfloat, u_stride*(uknot_count-uorder));
261
- ary_ctl1 = RARRAY(rb_Array(args[4]));
262
- if (TYPE(ary_ctl1->ptr[0]) == T_ARRAY)
263
- for (i = 0; i < ary_ctl1->len; i++) {
264
- ary2cflt(ary_ctl1->ptr[i], tmp, 4);
265
- memcpy(&ctlarray[i*u_stride], tmp, u_stride);
266
- }
267
- else {
268
- /* ary2cflt((VALUE)ary_ctl1, ctlarray, u_stride*uorder); //--->Mathematically incorrect */
269
- ary2cflt((VALUE)ary_ctl1, ctlarray, (uknot_count-uorder)*u_stride);
270
- }
271
- break;
272
- default:
273
- rb_raise(rb_eArgError, "arg num:%d",argc);
274
- }
275
- GetNURBS(args[0], ndata);
276
- gluNurbsCurve(ndata->nobj, uknot_count, uknot, u_stride, ctlarray, uorder, type);
277
- /* as of Mesa 3.1, Mesa assumes all data that following pointers
278
- points to is valid at gluEndCurve. so, free them in
279
- glu_EndCurve() */
280
- #ifdef MESA
281
- gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=2);
282
- gms.ptr[gms.len - 2] = uknot;
283
- gms.ptr[gms.len - 1] = ctlarray;
284
- #else
285
- free(uknot);
286
- free(ctlarray);
287
- #endif
288
- return Qnil;
263
+ struct nurbsdata *ndata;
264
+ GLint uknot_count;
265
+ GLfloat *uknot;
266
+ GLint u_stride;
267
+ GLint uorder;
268
+ GLfloat *ctlarray;
269
+ GLenum type;
270
+
271
+ VALUE args[7];
272
+ VALUE ary_ctl1;
273
+
274
+ switch (rb_scan_args(argc, argv, "52", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6])) {
275
+ case 5:
276
+ uknot_count = RARRAY(args[1])->len;
277
+ uorder = (GLenum)NUM2INT(args[3]);
278
+ type = (GLenum)NUM2INT(args[4]);
279
+ u_stride = get_curve_dim(type);
280
+
281
+ uknot = ALLOC_N(GLfloat, uknot_count);
282
+ ary2cflt(args[1], uknot, uknot_count);
283
+
284
+ ary_ctl1 = rb_ary_new();
285
+ mary2ary(args[2], ary_ctl1); /* flatten */
286
+ break;
287
+ case 7:
288
+ uknot_count = (GLint)NUM2INT(args[1]);
289
+ u_stride = (GLint)NUM2INT(args[3]);
290
+ uorder = (GLint)NUM2INT(args[5]);
291
+ type = (GLenum)NUM2INT(args[6]);
292
+
293
+ uknot = ALLOC_N(GLfloat, uknot_count);
294
+ ary2cflt(args[2], uknot, uknot_count);
295
+
296
+ ary_ctl1 = rb_ary_new();
297
+ mary2ary(args[4], ary_ctl1); /* flatten */
298
+ break;
299
+ default:
300
+ rb_raise(rb_eArgError, "gluNurbsCurve needs 5 or 7 arguments",argc);
301
+ }
302
+ ctlarray = ALLOC_N(GLfloat, u_stride*(uknot_count-uorder));
303
+ ary2cflt((VALUE)ary_ctl1, ctlarray, (uknot_count-uorder)*u_stride);
304
+
305
+ GetNURBS(args[0], ndata);
306
+ gluNurbsCurve(ndata->nobj, uknot_count, uknot, u_stride, ctlarray, uorder, type);
307
+
308
+ /* store the pointers */
309
+ gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=2);
310
+ gms.ptr[gms.len - 2] = uknot;
311
+ gms.ptr[gms.len - 1] = ctlarray;
312
+ return Qnil;
289
313
  }
290
314
  static VALUE
291
315
  glu_BeginSurface(obj, arg1)
292
316
  VALUE obj, arg1;
293
317
  {
294
- struct nurbsdata *ndata;
295
- GetNURBS(arg1, ndata);
296
- gluBeginSurface(ndata->nobj);
297
- return Qnil;
318
+ struct nurbsdata *ndata;
319
+ GetNURBS(arg1, ndata);
320
+ rb_ary_push(n_current, arg1);
321
+ gluBeginSurface(ndata->nobj);
322
+ return Qnil;
298
323
  }
299
324
  static VALUE
300
325
  glu_EndSurface(obj, arg1)
301
326
  VALUE obj, arg1;
302
327
  {
303
- struct nurbsdata *ndata;
304
- GetNURBS(arg1, ndata);
305
- gluEndSurface(ndata->nobj);
306
- /* hack for Mesa 3.1 */
307
- #ifdef MESA
308
- for(gms.len; gms.len>0; gms.len--)
309
- free(gms.ptr[gms.len-1]);
310
- free(gms.ptr);
311
- gms.ptr = NULL;
312
- #endif
313
- return Qnil;
328
+ struct nurbsdata *ndata;
329
+ GetNURBS(arg1, ndata);
330
+ gluEndSurface(ndata->nobj);
331
+
332
+ for(; gms.len>0; gms.len--)
333
+ free(gms.ptr[gms.len-1]);
334
+ free(gms.ptr);
335
+ gms.ptr = NULL;
336
+
337
+ rb_ary_pop(n_current);
338
+
339
+ return Qnil;
314
340
  }
315
341
 
316
342
  static VALUE
@@ -319,107 +345,102 @@ int argc;
319
345
  VALUE *argv;
320
346
  VALUE obj;
321
347
  {
322
- struct nurbsdata *ndata;
323
- GLint sknot_count;
324
- GLfloat *sknot;
325
- GLint tknot_count;
326
- GLfloat *tknot;
327
- GLint s_stride;
328
- GLint t_stride;
329
- GLfloat *ctlarray;
330
- GLint sorder;
331
- GLint torder;
332
- GLenum type;
333
- VALUE work_ary;
334
-
335
- VALUE args[11];
336
- struct RArray *ary_ctl1;
337
- int type_len;
338
-
339
- switch (rb_scan_args(argc, argv, "56", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], &args[8], &args[9], &args[10])) {
340
- case 5:
341
- sknot_count = RARRAY(rb_Array(args[1]))->len;
342
- sknot = ALLOC_N(GLfloat, sknot_count);
343
- ary2cflt(args[1], sknot, sknot_count);
344
- tknot_count = RARRAY(rb_Array(args[2]))->len;
345
- tknot = ALLOC_N(GLfloat, tknot_count);
346
- ary2cflt(args[2], tknot, tknot_count);
347
- ary_ctl1 = RARRAY(rb_Array(args[3]));
348
- sorder = ary_ctl1->len;
349
- torder = RARRAY(rb_Array(ary_ctl1->ptr[0]))->len;
350
- type = (GLenum)NUM2INT(args[4]);
351
- t_stride = get_surface_dim(type);
352
- s_stride = t_stride * sorder;
353
- ctlarray = ALLOC_N(GLfloat, t_stride*s_stride);
354
- work_ary = rb_ary_new();
355
- mary2ary((VALUE)ary_ctl1, work_ary);
356
- ary2cflt(work_ary, ctlarray, t_stride*s_stride);
357
- case 11:
358
- sknot_count = (GLint)NUM2INT(args[1]);
359
- sknot = ALLOC_N(GLfloat, sknot_count);
360
- ary2cflt(args[2], sknot, sknot_count);
361
- tknot_count = (GLint)NUM2INT(args[3]);
362
- tknot = ALLOC_N(GLfloat, tknot_count);
363
- ary2cflt(args[4], tknot, tknot_count);
364
- s_stride = (GLint)NUM2INT(args[5]);
365
- t_stride = (GLint)NUM2INT(args[6]);
366
- sorder = (GLint)NUM2INT(args[8]);
367
- torder = (GLint)NUM2INT(args[9]);
368
- type = (GLint)NUM2INT(args[10]);
369
- type_len = get_surface_dim(type);
370
- /* ctlarray = ALLOC_N(GLfloat, sorder*torder*type_len); //--->Mathematically incorrect */
371
- ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*type_len);
372
- ary_ctl1 = RARRAY(rb_Array(args[7]));
373
- if (TYPE(ary_ctl1->ptr[0]) == T_ARRAY) {
374
- work_ary = rb_ary_new();
375
- mary2ary((VALUE)ary_ctl1, work_ary);
376
- /* ary2cflt(work_ary, ctlarray, sorder*torder*type_len); //--->Mathematically incorrect */
377
- ary2cflt(work_ary, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
378
- }
379
- else {
380
- /* ary2cflt((VALUE)ary_ctl1, ctlarray, sorder*torder*type_len); //--->Mathematically incorrect */
381
- ary2cflt((VALUE)ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
382
- }
383
- break;
384
- default:
385
- rb_raise(rb_eArgError, "arg num:%d",argc);
386
- }
387
- GetNURBS(args[0], ndata);
388
- gluNurbsSurface(ndata->nobj, sknot_count, sknot, tknot_count, tknot,
389
- s_stride, t_stride, ctlarray, sorder, torder, type);
390
-
391
- /* as of Mesa 3.1, Mesa assumes all data that following pointers
392
- points to is valid at gluEndSurface. so, free them in
393
- glu_EndSurface() */
394
- #ifdef MESA
395
- gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=3);
396
- gms.ptr[gms.len-3] = sknot;
397
- gms.ptr[gms.len-2] = tknot;
398
- gms.ptr[gms.len-1] = ctlarray;
399
- #else
400
- free(sknot);
401
- free(tknot);
402
- free(ctlarray);
403
- #endif
404
- return Qnil;
348
+ struct nurbsdata *ndata;
349
+ GLint sknot_count;
350
+ GLfloat *sknot;
351
+ GLint tknot_count;
352
+ GLfloat *tknot;
353
+ GLint s_stride;
354
+ GLint t_stride;
355
+ GLfloat *ctlarray;
356
+ GLint sorder;
357
+ GLint torder;
358
+ GLenum type;
359
+
360
+ VALUE args[11];
361
+ VALUE ary_ctl1;
362
+ int type_len;
363
+
364
+ switch (rb_scan_args(argc, argv, "74", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], &args[8], &args[9], &args[10])) {
365
+ case 7:
366
+ sknot_count = RARRAY(args[1])->len;
367
+ sknot = ALLOC_N(GLfloat, sknot_count);
368
+ ary2cflt(args[1], sknot, sknot_count);
369
+
370
+ tknot_count = RARRAY(args[2])->len;
371
+ tknot = ALLOC_N(GLfloat, tknot_count);
372
+ ary2cflt(args[2], tknot, tknot_count);
373
+
374
+ sorder = (GLint)NUM2INT(args[4]);
375
+ torder = (GLint)NUM2INT(args[5]);
376
+ type = (GLenum)NUM2INT(args[6]);
377
+
378
+ t_stride = get_surface_dim(type);
379
+ s_stride = t_stride * sorder;
380
+
381
+ ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*t_stride);
382
+ ary_ctl1 = rb_ary_new();
383
+ mary2ary(args[3], ary_ctl1); /* flatten */
384
+ ary2cflt(ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*t_stride);
385
+ break;
386
+ case 11:
387
+ sknot_count = (GLint)NUM2INT(args[1]);
388
+ sknot = ALLOC_N(GLfloat, sknot_count);
389
+ ary2cflt(args[2], sknot, sknot_count);
390
+
391
+ tknot_count = (GLint)NUM2INT(args[3]);
392
+ tknot = ALLOC_N(GLfloat, tknot_count);
393
+ ary2cflt(args[4], tknot, tknot_count);
394
+
395
+ s_stride = (GLint)NUM2INT(args[5]);
396
+ t_stride = (GLint)NUM2INT(args[6]);
397
+ sorder = (GLint)NUM2INT(args[8]);
398
+ torder = (GLint)NUM2INT(args[9]);
399
+ type = (GLint)NUM2INT(args[10]);
400
+ type_len = get_surface_dim(type);
401
+
402
+ ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*type_len);
403
+
404
+ ary_ctl1 = rb_ary_new();
405
+ mary2ary(args[7], ary_ctl1); /* flatten */
406
+ ary2cflt(ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
407
+ break;
408
+ default:
409
+ rb_raise(rb_eArgError, "gluNurbsSurface needs 7 or 11 arguments",argc);
410
+ return Qnil; /* not reached */
411
+ }
412
+ GetNURBS(args[0], ndata);
413
+ gluNurbsSurface(ndata->nobj, sknot_count, sknot, tknot_count, tknot,
414
+ s_stride, t_stride, ctlarray, sorder, torder, type);
415
+
416
+ /* store the pointers */
417
+
418
+ gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=3);
419
+ gms.ptr[gms.len-3] = sknot;
420
+ gms.ptr[gms.len-2] = tknot;
421
+ gms.ptr[gms.len-1] = ctlarray;
422
+
423
+ return Qnil;
405
424
  }
406
425
  static VALUE
407
426
  glu_BeginTrim(obj, arg1)
408
427
  VALUE obj, arg1;
409
428
  {
410
- struct nurbsdata *ndata;
411
- GetNURBS(arg1, ndata);
412
- gluBeginTrim(ndata->nobj);
413
- return Qnil;
429
+ struct nurbsdata *ndata;
430
+ GetNURBS(arg1, ndata);
431
+ rb_ary_push(n_current, arg1);
432
+ gluBeginTrim(ndata->nobj);
433
+ return Qnil;
414
434
  }
415
435
  static VALUE
416
436
  glu_EndTrim(obj, arg1)
417
437
  VALUE obj, arg1;
418
438
  {
419
- struct nurbsdata *ndata;
420
- GetNURBS(arg1, ndata);
421
- gluEndTrim(ndata->nobj);
422
- return Qnil;
439
+ struct nurbsdata *ndata;
440
+ GetNURBS(arg1, ndata);
441
+ gluEndTrim(ndata->nobj);
442
+ rb_ary_pop(n_current);
443
+ return Qnil;
423
444
  }
424
445
  static VALUE
425
446
  glu_PwlCurve(argc, argv, obj)
@@ -427,50 +448,63 @@ int argc;
427
448
  VALUE *argv;
428
449
  VALUE obj;
429
450
  {
430
- struct nurbsdata *ndata;
431
- GLint count;
432
- GLfloat *array;
433
- GLint stride;
434
- GLenum type;
435
-
436
- VALUE args[5];
437
- GLfloat tmp[3];
438
- struct RArray* ary_ctl1;
439
- int i;
440
-
441
- switch (rb_scan_args(argc, argv, "32", &args[0], &args[1], &args[2], &args[3], &args[4])) {
442
- case 3:
443
- ary_ctl1 = RARRAY(rb_Array(args[2]));
444
- count = ary_ctl1->len;
445
- type = NUM2INT(args[2]);
446
- stride = (type == GLU_MAP1_TRIM_2 ? 2 : 3);
447
- array = ALLOC_N(GLfloat, count*stride);
448
- for (i = 0; i < ary_ctl1->len; i++) {
449
- ary2cflt(ary_ctl1->ptr[i], tmp, 3);
450
- memcpy(&array[i*stride], tmp, stride);
451
- }
452
- break;
453
- case 5:
454
- count = NUM2INT(args[1]);
455
- stride = NUM2INT(args[3]);
456
- type = NUM2INT(args[4]);
457
- array = ALLOC_N(GLfloat, count*stride);
458
- ary_ctl1 = RARRAY(rb_Array(args[2]));
459
- if (TYPE(ary_ctl1->ptr[0]) == T_ARRAY)
460
- for (i = 0; i < ary_ctl1->len; i++) {
461
- ary2cflt(ary_ctl1->ptr[i], tmp, 3);
462
- memcpy(&array[i*stride], tmp, stride);
463
- }
464
- else
465
- ary2cflt((VALUE)ary_ctl1, array, count*stride);
466
- break;
467
- default:
468
- rb_raise(rb_eArgError, "arg num:%d",argc);
469
- }
470
- GetNURBS(args[0], ndata);
471
- gluPwlCurve(ndata->nobj, count, array, stride, type);
472
- free(array);
473
- return Qnil;
451
+ struct nurbsdata *ndata;
452
+ GLint count;
453
+ GLfloat *array;
454
+ GLint stride;
455
+ GLenum type;
456
+
457
+ VALUE args[5];
458
+ VALUE ary_ctl1;
459
+
460
+ switch (rb_scan_args(argc, argv, "32", &args[0], &args[1], &args[2], &args[3], &args[4])) {
461
+ case 3:
462
+ count = RARRAY(args[1])->len;
463
+ type = NUM2INT(args[2]);
464
+ stride = (type == GLU_MAP1_TRIM_2 ? 2 : 3);
465
+
466
+ array = ALLOC_N(GLfloat, count*stride);
467
+ ary_ctl1 = rb_ary_new();
468
+ mary2ary(args[1], ary_ctl1); /* flatten */
469
+ ary2cflt(ary_ctl1, array, count*stride);
470
+ break;
471
+ case 5:
472
+ count = NUM2INT(args[1]);
473
+ stride = NUM2INT(args[3]);
474
+ type = NUM2INT(args[4]);
475
+
476
+ array = ALLOC_N(GLfloat, count*stride);
477
+ ary_ctl1 = rb_ary_new();
478
+ mary2ary(args[2], ary_ctl1); /* flatten */
479
+ ary2cflt(ary_ctl1, array, count*stride);
480
+ break;
481
+ default:
482
+ rb_raise(rb_eArgError, "gluPwlCurve needs 3 or 5 arguments",argc);
483
+ return Qnil; /* not reached */
484
+ }
485
+
486
+ GetNURBS(args[0], ndata);
487
+ gluPwlCurve(ndata->nobj, count, array, stride, type);
488
+ free(array);
489
+ return Qnil;
490
+ }
491
+
492
+ static VALUE glu_LoadSamplingMatrices(obj,arg1,arg2,arg3,arg4)
493
+ VALUE obj, arg1,arg2,arg3,arg4;
494
+ {
495
+ struct nurbsdata *ndata;
496
+ GLfloat mdl_mtx[4*4];
497
+ GLfloat persp_mtx[4*4];
498
+ GLint viewport[4];
499
+
500
+ GetNURBS(arg1, ndata);
501
+ ary2cmat4x4flt(arg2,mdl_mtx);
502
+ ary2cmat4x4flt(arg3,persp_mtx);
503
+ ary2cint(arg4,viewport,4);
504
+
505
+ gluLoadSamplingMatrices(ndata->nobj,mdl_mtx,persp_mtx,viewport);
506
+
507
+ return Qnil;
474
508
  }
475
509
 
476
510
  /*
@@ -482,214 +516,162 @@ static VALUE t_current;
482
516
  #define TESS_VERTEX 2
483
517
  #define TESS_END 3
484
518
  #define TESS_ERROR 4
485
- #define TESS_EDGE 5
486
- #if defined(GLU_VERSION_1_2)
487
- # define TESS_OUTDATA 6
488
- # define TESS_COMBINE 7
489
- # define TESS_BEGIN_DATA 8
490
- # define TESS_VERTEX_DATA 9
491
- # define TESS_END_DATA 10
492
- # define TESS_ERROR_DATA 11
493
- # define TESS_EDGE_DATA 12
494
- # define TESS_COMBINE_DATA 13
495
- # define TESS_USERDATA 14
496
- # define REF_LAST 15
497
- #else /* !GLU_VERSION_1_2 */
498
- # define REF_LAST 6
499
- #endif /* GLU_VERSION_1_2 */
519
+ #define TESS_EDGE_FLAG 5
520
+ #define TESS_OUTDATA 6
521
+ #define TESS_COMBINE 7
522
+ #define TESS_BEGIN_DATA 8
523
+ #define TESS_VERTEX_DATA 9
524
+ #define TESS_END_DATA 10
525
+ #define TESS_ERROR_DATA 11
526
+ #define TESS_EDGE_FLAG_DATA 12
527
+ #define TESS_COMBINE_DATA 13
528
+ #define TESS_USERDATA 14
529
+
500
530
  static void
501
531
  mark_tess(tdata)
502
532
  struct tessdata* tdata;
503
533
  {
504
- if (tdata->tobj)
505
- rb_gc_mark(tdata->t_ref);
534
+ if (tdata->tobj)
535
+ rb_gc_mark(tdata->t_ref);
506
536
  }
507
537
  static void
508
538
  free_tess(tdata)
509
539
  struct tessdata *tdata;
510
540
  {
511
- ID id;
512
- VALUE call_key;
513
-
514
- if (tdata->tobj) {
515
- gluDeleteTess(tdata->tobj);
516
- }
517
- tdata->t_ref = Qnil;
518
- tdata->tobj = NULL;
541
+ if (tdata->tobj)
542
+ gluDeleteTess(tdata->tobj);
543
+ tdata->t_ref = Qnil;
544
+ tdata->tobj = NULL;
519
545
  }
520
546
  static VALUE
521
547
  glu_NewTess(obj)
522
548
  VALUE obj;
523
549
  {
524
- VALUE ret;
525
- struct tessdata *tdata;
526
- ret = Data_Make_Struct(cTess, struct tessdata, mark_tess, free_tess, tdata);
527
- tdata->tobj = gluNewTess();
528
- tdata->t_ref = rb_ary_new2(REF_LAST);
529
- return ret;
550
+ VALUE ret;
551
+ struct tessdata *tdata;
552
+ ret = Data_Make_Struct(cTess, struct tessdata, mark_tess, free_tess, tdata);
553
+ tdata->tobj = gluNewTess();
554
+ tdata->t_ref = rb_ary_new2(REF_LAST);
555
+ return ret;
530
556
  }
531
557
  static VALUE
532
558
  glu_DeleteTess(obj, arg1)
533
559
  VALUE obj, arg1;
534
560
  {
535
- struct tessdata *tdata;
536
- GetTESS(arg1, tdata);
537
- free_tess(tdata);
538
- return Qnil;
561
+ struct tessdata *tdata;
562
+ GetTESS(arg1, tdata);
563
+ free_tess(tdata);
564
+ return Qnil;
539
565
  }
540
- void
566
+
567
+ /* tess* callback function wrappers */
568
+ #define TESS_CALLBACK_COMMON \
569
+ VALUE tess; \
570
+ struct tessdata *tdata; \
571
+ tess = rb_ary_entry(t_current, -1); \
572
+ if (tess == Qnil) \
573
+ return; \
574
+ GetTESS(tess, tdata);
575
+
576
+ static void CALLBACK
541
577
  t_begin(type)
542
578
  GLenum type;
543
579
  {
544
- VALUE tess;
545
- struct tessdata *tdata;
546
- tess = rb_ary_entry(t_current, -1);
547
- if (tess != Qnil) {
548
- GetTESS(tess, tdata);
549
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN), callId, 1, INT2NUM(type));
550
- }
580
+ TESS_CALLBACK_COMMON
581
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN), callId, 1, INT2NUM(type));
551
582
  }
552
- static void
583
+ static void CALLBACK
553
584
  t_edgeFlag(flag)
554
585
  GLboolean flag;
555
586
  {
556
- VALUE tess;
557
- struct tessdata *tdata;
558
- tess = rb_ary_entry(t_current, -1);
559
- if (tess != Qnil) {
560
- GetTESS(tess, tdata);
561
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE), callId, 1, INT2NUM(flag));
562
- }
587
+ TESS_CALLBACK_COMMON
588
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE_FLAG), callId, 1, INT2NUM(flag));
563
589
  }
564
- static void
590
+ static void CALLBACK
565
591
  t_vertex(data)
566
592
  void* data;
567
593
  {
568
- VALUE tess;
569
- struct tessdata *tdata;
570
- tess = rb_ary_entry(t_current, -1);
571
- if (tess != Qnil) {
572
- GetTESS(tess, tdata);
573
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX), callId, 1, data);
574
- }
594
+ TESS_CALLBACK_COMMON
595
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX), callId, 1, data);
575
596
  }
576
- static void
597
+ static void CALLBACK
577
598
  t_end()
578
599
  {
579
- VALUE tess;
580
- struct tessdata *tdata;
581
- tess = rb_ary_entry(t_current, -1);
582
- if (tess != Qnil) {
583
- GetTESS(tess, tdata);
584
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END), callId, 0);
585
- }
600
+ TESS_CALLBACK_COMMON
601
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END), callId, 0);
586
602
  }
587
- static void
603
+ static void CALLBACK
588
604
  t_error(errorno)
589
605
  GLenum errorno;
590
606
  {
591
- VALUE tess;
592
- struct tessdata *tdata;
593
- tess = rb_ary_entry(t_current, -1);
594
- if (tess != Qnil) {
595
- GetTESS(tess, tdata);
596
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR), callId, 1, INT2NUM(errorno));
597
- }
607
+ TESS_CALLBACK_COMMON
608
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR), callId, 1, INT2NUM(errorno));
598
609
  }
599
-
600
- #if defined(GLU_VERSION_1_2)
601
- static void
610
+ static void CALLBACK
602
611
  t_begin_data(type, user_data)
603
612
  GLenum type;
604
613
  void* user_data;
605
614
  {
606
- VALUE tess;
607
- struct tessdata *tdata;
608
- tess = rb_ary_entry(t_current, -1);
609
- if (tess != Qnil) {
610
- GetTESS(tess, tdata);
611
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN_DATA), callId, 2, INT2NUM(type), user_data);
612
- }
615
+ TESS_CALLBACK_COMMON
616
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_BEGIN_DATA), callId, 2, INT2NUM(type), user_data);
613
617
  }
614
- static void
618
+ static void CALLBACK
615
619
  t_edgeFlag_data(flag, user_data)
616
620
  GLboolean flag;
617
621
  void* user_data;
618
622
  {
619
- VALUE tess;
620
- struct tessdata *tdata;
621
- tess = rb_ary_entry(t_current, -1);
622
- if (tess != Qnil) {
623
- GetTESS(tess, tdata);
624
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE_DATA), callId, 2, INT2NUM(flag), user_data);
625
- }
623
+ TESS_CALLBACK_COMMON
624
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_EDGE_FLAG_DATA), callId, 2, INT2NUM(flag), user_data);
626
625
  }
627
- static void
626
+ static void CALLBACK
628
627
  t_vertex_data(data, user_data)
629
628
  void* data;
630
629
  void* user_data;
631
630
  {
632
- VALUE tess;
633
- struct tessdata *tdata;
634
- tess = rb_ary_entry(t_current, -1);
635
- if (tess != Qnil) {
636
- GetTESS(tess, tdata);
637
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX_DATA), callId, 2, data, user_data);
638
- }
631
+ TESS_CALLBACK_COMMON
632
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_VERTEX_DATA), callId, 2, data, user_data);
639
633
  }
640
- static void
634
+ static void CALLBACK
641
635
  t_end_data(user_data)
642
636
  void* user_data;
643
637
  {
644
- VALUE tess;
645
- struct tessdata *tdata;
646
- tess = rb_ary_entry(t_current, -1);
647
- if (tess != Qnil) {
648
- GetTESS(tess, tdata);
649
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END_DATA), callId, 1, user_data);
650
- }
638
+ TESS_CALLBACK_COMMON
639
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_END_DATA), callId, 1, user_data);
651
640
  }
652
- static void
641
+ static void CALLBACK
653
642
  t_error_data(errorno, user_data)
654
643
  GLenum errorno;
655
644
  void* user_data;
656
645
  {
657
- VALUE tess;
658
- struct tessdata *tdata;
659
- tess = rb_ary_entry(t_current, -1);
660
- if (tess != Qnil) {
661
- GetTESS(tess, tdata);
662
- rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR_DATA), callId, 2, INT2NUM(errorno), user_data);
663
- }
646
+ TESS_CALLBACK_COMMON
647
+ rb_funcall(rb_ary_entry(tdata->t_ref, TESS_ERROR_DATA), callId, 2, INT2NUM(errorno), user_data);
664
648
  }
665
- static void
649
+
650
+ static void CALLBACK
666
651
  t_combine(coords, vertex_data, weight, outData)
667
652
  GLdouble coords[3];
668
653
  void* vertex_data[4];
669
654
  GLfloat weight[4];
670
655
  void** outData;
671
656
  {
672
- VALUE tess;
673
- struct tessdata *tdata;
674
- VALUE rb_coord, rb_vertex_data, rb_weight;
675
- int i;
676
- tess = rb_ary_entry(t_current, -1);
677
- if (tess != Qnil) {
678
- GetTESS(tess, tdata);
679
- rb_coord = rb_ary_new2(3);
680
- for (i = 0; i < 3; i++)
681
- rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
682
- rb_vertex_data = rb_ary_new2(4);
683
- for (i = 0; i < 4; i++)
684
- rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
685
- rb_weight = rb_ary_new2(4);
686
- for (i = 0; i < 4; i++)
687
- rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
688
- *outData = (void*)rb_funcall(rb_ary_entry(tdata->t_ref, TESS_COMBINE), callId, 3, rb_coord, rb_vertex_data, rb_weight);
689
- rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
690
- }
657
+ VALUE rb_coord, rb_vertex_data, rb_weight;
658
+ int i;
659
+ TESS_CALLBACK_COMMON
660
+
661
+ rb_coord = rb_ary_new2(3);
662
+ for (i = 0; i < 3; i++)
663
+ rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
664
+ rb_vertex_data = rb_ary_new2(4);
665
+ for (i = 0; i < 4; i++)
666
+ rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
667
+ rb_weight = rb_ary_new2(4);
668
+ for (i = 0; i < 4; i++)
669
+ rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
670
+ *outData = (void*)rb_funcall(rb_ary_entry(tdata->t_ref, TESS_COMBINE), callId, 3, rb_coord, rb_vertex_data, rb_weight);
671
+ rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
691
672
  }
692
- static void
673
+
674
+ static void CALLBACK
693
675
  t_combine_data(coords, vertex_data, weight, outData, user_data)
694
676
  GLdouble coords[3];
695
677
  void* vertex_data[4];
@@ -697,487 +679,460 @@ GLfloat weight[4];
697
679
  void** outData;
698
680
  void* user_data;
699
681
  {
700
- VALUE tess;
701
- struct tessdata *tdata;
702
- VALUE rb_coord, rb_vertex_data, rb_weight;
703
- int i;
704
- tess = rb_ary_entry(t_current, -1);
705
- if (tess != Qnil) {
706
- GetTESS(tess, tdata);
707
- rb_coord = rb_ary_new2(3);
708
- for (i = 0; i < 3; i++)
709
- rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
710
- rb_vertex_data = rb_ary_new2(4);
711
- for (i = 0; i < 4; i++)
712
- rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
713
- rb_weight = rb_ary_new2(4);
714
- for (i = 0; i < 4; i++)
715
- rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
716
- *outData = (void*)rb_funcall(rb_ary_entry(tdata->t_ref, TESS_COMBINE_DATA), callId, 4, rb_coord, rb_vertex_data, rb_weight, (VALUE)user_data);
717
- rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
718
- }
682
+ VALUE rb_coord, rb_vertex_data, rb_weight;
683
+ int i;
684
+ TESS_CALLBACK_COMMON
685
+
686
+ rb_coord = rb_ary_new2(3);
687
+ for (i = 0; i < 3; i++)
688
+ rb_ary_store(rb_coord, i, rb_float_new(coords[i]));
689
+ rb_vertex_data = rb_ary_new2(4);
690
+ for (i = 0; i < 4; i++)
691
+ rb_ary_store(rb_vertex_data, i, (VALUE)vertex_data[i]);
692
+ rb_weight = rb_ary_new2(4);
693
+ for (i = 0; i < 4; i++)
694
+ rb_ary_store(rb_weight, i, rb_float_new(weight[i]));
695
+
696
+ *outData = (void*)rb_funcall(rb_ary_entry(tdata->t_ref, TESS_COMBINE_DATA), callId, 4, rb_coord, rb_vertex_data, rb_weight, (VALUE)user_data);
697
+
698
+ rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_OUTDATA), (VALUE)*outData);
719
699
  }
700
+
701
+ #undef TESS_CALLBACK_COMMON
702
+
720
703
  static VALUE
721
704
  glu_TessProperty(obj, arg1, arg2, arg3)
722
705
  VALUE obj, arg1, arg2;
723
706
  {
724
- struct tessdata* tdata;
725
- GLenum property;
726
- GLdouble value;
727
- GetTESS(arg1, tdata);
728
- property = (GLenum)NUM2INT(arg2);
729
- value = (GLdouble)NUM2DBL(arg3);
730
- gluTessProperty(tdata->tobj, property, value);
731
- return Qnil;
707
+ struct tessdata* tdata;
708
+ GLenum property;
709
+ GLdouble value;
710
+ GetTESS(arg1, tdata);
711
+ property = (GLenum)NUM2INT(arg2);
712
+ value = (GLdouble)NUM2DBL(arg3);
713
+ gluTessProperty(tdata->tobj, property, value);
714
+ return Qnil;
732
715
  }
733
716
  static VALUE
734
717
  glu_GetTessProperty(obj, arg1, arg2)
735
718
  VALUE obj, arg1, arg2;
736
719
  {
737
- struct tessdata* tdata;
738
- GLenum property;
739
- GLdouble value;
740
- GetTESS(arg1, tdata);
741
- property = (GLenum)NUM2INT(arg2);
742
- gluGetTessProperty(tdata->tobj, property, &value);
743
- return rb_float_new(value);
720
+ struct tessdata* tdata;
721
+ GLenum property;
722
+ GLdouble value;
723
+ GetTESS(arg1, tdata);
724
+ property = (GLenum)NUM2INT(arg2);
725
+ gluGetTessProperty(tdata->tobj, property, &value);
726
+ return rb_float_new(value);
744
727
  }
745
728
  static VALUE
746
729
  glu_TessNormal(obj, arg1, arg2, arg3, arg4)
747
730
  VALUE obj, arg1, arg2, arg3, arg4;
748
731
  {
749
- struct tessdata* tdata;
750
- GLdouble x, y, z;
751
- GetTESS(arg1, tdata);
752
- x = (GLdouble)NUM2DBL(arg2);
753
- y = (GLdouble)NUM2DBL(arg3);
754
- z = (GLdouble)NUM2DBL(arg4);
755
- gluTessNormal(tdata->tobj, x, y, z);
756
- return Qnil;
732
+ struct tessdata* tdata;
733
+ GLdouble x, y, z;
734
+ GetTESS(arg1, tdata);
735
+ x = (GLdouble)NUM2DBL(arg2);
736
+ y = (GLdouble)NUM2DBL(arg3);
737
+ z = (GLdouble)NUM2DBL(arg4);
738
+ gluTessNormal(tdata->tobj, x, y, z);
739
+ return Qnil;
757
740
  }
758
741
  static VALUE
759
742
  glu_TessBeginPolygon(obj, arg1, arg2)
760
743
  VALUE obj, arg1, arg2;
761
744
  {
762
- struct tessdata* tdata;
763
- GetTESS(arg1, tdata);
764
- rb_ary_store(tdata->t_ref, TESS_USERDATA, arg2);
765
- rb_ary_store(tdata->t_ref, TESS_OUTDATA, rb_ary_new());
766
- rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
767
- rb_ary_push(t_current, arg1);
768
- gluTessBeginPolygon(tdata->tobj, (void*)arg2);
769
- return Qnil;
745
+ struct tessdata* tdata;
746
+ GetTESS(arg1, tdata);
747
+ rb_ary_store(tdata->t_ref, TESS_USERDATA, arg2);
748
+ rb_ary_store(tdata->t_ref, TESS_OUTDATA, rb_ary_new());
749
+ rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
750
+ rb_ary_push(t_current, arg1);
751
+ gluTessBeginPolygon(tdata->tobj, (void*)arg2);
752
+ return Qnil;
770
753
  }
771
754
  static VALUE
772
755
  glu_TessEndPolygon(obj, arg1)
773
756
  VALUE obj, arg1;
774
757
  {
775
- struct tessdata* tdata;
776
- GetTESS(arg1, tdata);
777
- gluTessEndPolygon(tdata->tobj);
778
- rb_ary_store(tdata->t_ref, TESS_USERDATA, Qnil);
779
- rb_ary_store(tdata->t_ref, TESS_OUTDATA, Qnil);
780
- rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
781
- rb_ary_pop(t_current);
782
- return Qnil;
758
+ struct tessdata* tdata;
759
+ GetTESS(arg1, tdata);
760
+ gluTessEndPolygon(tdata->tobj);
761
+ rb_ary_store(tdata->t_ref, TESS_USERDATA, Qnil);
762
+ rb_ary_store(tdata->t_ref, TESS_OUTDATA, Qnil);
763
+ rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
764
+ rb_ary_pop(t_current);
765
+ return Qnil;
783
766
  }
784
767
  static VALUE
785
768
  glu_TessBeginContour(obj, arg1)
786
769
  VALUE obj, arg1;
787
770
  {
788
- struct tessdata* tdata;
789
- GetTESS(arg1, tdata);
790
- gluTessBeginContour(tdata->tobj);
791
- return Qnil;
771
+ struct tessdata* tdata;
772
+ GetTESS(arg1, tdata);
773
+ gluTessBeginContour(tdata->tobj);
774
+ return Qnil;
792
775
  }
793
776
  static VALUE
794
777
  glu_TessEndContour(obj, arg1)
795
778
  {
796
- struct tessdata* tdata;
797
- GetTESS(arg1, tdata);
798
- gluTessEndContour(tdata->tobj);
799
- return Qnil;
779
+ struct tessdata* tdata;
780
+ GetTESS(arg1, tdata);
781
+ gluTessEndContour(tdata->tobj);
782
+ return Qnil;
800
783
  }
801
- #endif /* GLU_VERSION_1_2 */
784
+
785
+ #define TESS_CALLBACK_CASE(_type_,_function_) \
786
+ case GLU_##_type_: \
787
+ rb_ary_store(tdata->t_ref, _type_, arg3); \
788
+ if (NIL_P(arg3)) \
789
+ gluTessCallback(tdata->tobj, type, NULL); \
790
+ else \
791
+ gluTessCallback(tdata->tobj, type, _function_); \
792
+ break;
802
793
 
803
794
  static VALUE
804
795
  glu_TessCallback(obj, arg1, arg2, arg3)
805
796
  VALUE obj, arg1, arg2, arg3;
806
797
  {
807
- struct tessdata* tdata;
808
- GLenum type;
809
- ID id;
810
- GetTESS(arg1, tdata);
811
- type = (GLenum)NUM2INT(arg2);
812
- id = rb_intern("[]=");
813
- if (!rb_obj_is_kind_of(arg3,rb_cProc) && NIL_P(arg3))
814
- rb_raise(rb_eTypeError, "GLU.TessCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
815
-
816
- switch (type) {
817
- #if defined(GLU_VERSION_1_2)
818
- case GLU_TESS_BEGIN:
819
- #else
820
- case GLU_BEGIN:
821
- #endif
822
- rb_ary_store(tdata->t_ref, TESS_BEGIN, arg3);
823
- if (NIL_P(arg3))
824
- gluTessCallback(tdata->tobj, type, NULL);
825
- else
826
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_begin));
827
- break;
828
- #if defined(GLU_VERSION_1_2)
829
- case GLU_TESS_EDGE_FLAG:
830
- #else
831
- case GLU_EDGE_FLAG:
832
- #endif
833
- rb_ary_store(tdata->t_ref, TESS_EDGE, arg3);
834
- if (NIL_P(arg3))
835
- gluTessCallback(tdata->tobj, type, NULL);
836
- else
837
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_edgeFlag);
838
- break;
839
- #if defined(GLU_VERSION_1_2)
840
- case GLU_TESS_VERTEX:
841
- #else
842
- case GLU_VERTEX:
843
- #endif
844
- rb_ary_store(tdata->t_ref, TESS_VERTEX, arg3);
845
- if (NIL_P(arg3))
846
- gluTessCallback(tdata->tobj, type, NULL);
847
- else
848
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_vertex);
849
- break;
850
- #if defined(GLU_VERSION_1_2)
851
- case GLU_TESS_END:
852
- #else
853
- case GLU_END:
854
- #endif
855
- rb_ary_store(tdata->t_ref, TESS_END, arg3);
856
- if (NIL_P(arg3))
857
- gluTessCallback(tdata->tobj, type, NULL);
858
- else
859
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_end);
860
- break;
861
- #if defined(GLU_VERSION_1_2)
862
- case GLU_TESS_ERROR:
863
- #else
864
- case GLU_ERROR:
865
- #endif
866
- rb_ary_store(tdata->t_ref, TESS_ERROR, arg3);
867
- if (NIL_P(arg3))
868
- gluTessCallback(tdata->tobj, type, NULL);
869
- else
870
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)t_error);
871
- break;
872
- #if defined(GLU_VERSION_1_2)
873
- case GLU_TESS_COMBINE:
874
- rb_ary_store(tdata->t_ref, TESS_COMBINE, arg3);
875
- if (NIL_P(arg3))
876
- gluTessCallback(tdata->tobj, type, NULL);
877
- else
878
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_combine));
879
- break;
880
- case GLU_TESS_BEGIN_DATA:
881
- rb_ary_store(tdata->t_ref, TESS_BEGIN_DATA, arg3);
882
- if (NIL_P(arg3))
883
- gluTessCallback(tdata->tobj, type, NULL);
884
- else
885
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_begin_data));
886
- break;
887
- case GLU_TESS_VERTEX_DATA:
888
- rb_ary_store(tdata->t_ref, TESS_VERTEX_DATA, arg3);
889
- if (NIL_P(arg3))
890
- gluTessCallback(tdata->tobj, type, NULL);
891
- else
892
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_vertex_data));
893
- break;
894
- case GLU_TESS_END_DATA:
895
- rb_ary_store(tdata->t_ref, TESS_END_DATA, arg3);
896
- if (NIL_P(arg3))
897
- gluTessCallback(tdata->tobj, type, NULL);
898
- else
899
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_end_data));
900
- break;
901
- case GLU_TESS_ERROR_DATA:
902
- rb_ary_store(tdata->t_ref, TESS_ERROR_DATA, arg3);
903
- if (NIL_P(arg3))
904
- gluTessCallback(tdata->tobj, type, NULL);
905
- else
906
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_error_data));
907
- break;
908
- case GLU_TESS_EDGE_FLAG_DATA:
909
- rb_ary_store(tdata->t_ref, TESS_EDGE_DATA, arg3);
910
- if (NIL_P(arg3))
911
- gluTessCallback(tdata->tobj, type, NULL);
912
- else
913
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_edgeFlag_data));
914
- break;
915
- case GLU_TESS_COMBINE_DATA:
916
- rb_ary_store(tdata->t_ref, TESS_COMBINE_DATA, arg3);
917
- if (NIL_P(arg3))
918
- gluTessCallback(tdata->tobj, type, NULL);
919
- else
920
- gluTessCallback(tdata->tobj, type, (VOIDFUNC)(t_combine_data));
921
- break;
922
- #endif /* GLU_VERSION_1_2 */
923
- }
924
- return Qnil;
925
- }
798
+ struct tessdata* tdata;
799
+ GLenum type;
800
+ GetTESS(arg1, tdata);
801
+ type = (GLenum)NUM2INT(arg2);
802
+ if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
803
+ rb_raise(rb_eTypeError, "gluTessCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
804
+
805
+ switch (type) {
806
+ TESS_CALLBACK_CASE(TESS_BEGIN,t_begin)
807
+ TESS_CALLBACK_CASE(TESS_BEGIN_DATA,t_begin_data)
808
+ TESS_CALLBACK_CASE(TESS_EDGE_FLAG,t_edgeFlag)
809
+ TESS_CALLBACK_CASE(TESS_EDGE_FLAG_DATA,t_edgeFlag_data)
810
+ TESS_CALLBACK_CASE(TESS_VERTEX,t_vertex)
811
+ TESS_CALLBACK_CASE(TESS_VERTEX_DATA,t_vertex_data)
812
+ TESS_CALLBACK_CASE(TESS_END,t_end)
813
+ TESS_CALLBACK_CASE(TESS_END_DATA,t_end_data)
814
+ TESS_CALLBACK_CASE(TESS_ERROR,t_error)
815
+ TESS_CALLBACK_CASE(TESS_ERROR_DATA,t_error_data)
816
+ TESS_CALLBACK_CASE(TESS_COMBINE,t_combine)
817
+ TESS_CALLBACK_CASE(TESS_COMBINE_DATA,t_combine_data)
818
+ }
819
+ return Qnil;
820
+ }
821
+ #undef TESS_CALLBACK_CASE
822
+
926
823
  static VALUE
927
824
  glu_BeginPolygon(obj, arg1)
928
825
  VALUE obj, arg1;
929
826
  {
930
- struct tessdata* tdata;
931
- GetTESS(arg1, tdata);
932
- rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
933
- rb_ary_push(t_current, arg1);
934
- gluBeginPolygon(tdata->tobj);
935
- return Qnil;
827
+ struct tessdata* tdata;
828
+ GetTESS(arg1, tdata);
829
+ rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
830
+ rb_ary_push(t_current, arg1);
831
+ gluBeginPolygon(tdata->tobj);
832
+ return Qnil;
936
833
  }
937
834
  static VALUE
938
835
  glu_TessVertex(obj, arg1, arg2, arg3)
939
836
  VALUE obj, arg1, arg2, arg3;
940
837
  {
941
- struct tessdata* tdata;
942
- GLdouble v[3];
943
- VALUE call_key;
944
- ID id;
945
- GetTESS(arg1, tdata);
946
- rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_DATA), arg3);
947
- ary2cdbl(arg2, v, 3);
948
- gluTessVertex(tdata->tobj, v,(void *)arg3);
949
- return Qnil;
838
+ struct tessdata* tdata;
839
+ GLdouble v[3] = {0.0,0.0,0.0};
840
+ GetTESS(arg1, tdata);
841
+ rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_DATA), arg3);
842
+ Check_Type(arg2,T_ARRAY);
843
+ ary2cdbl(arg2, v, 3);
844
+ gluTessVertex(tdata->tobj, v,(void *)arg3);
845
+ return Qnil;
950
846
  }
951
847
  static VALUE
952
848
  glu_NextContour(obj, arg1, arg2)
953
849
  VALUE obj, arg1, arg2;
954
850
  {
955
- struct tessdata* tdata;
956
- GLenum type;
957
- GetTESS(arg1, tdata);
958
- type = (GLenum)NUM2INT(arg2);
959
- gluNextContour(tdata->tobj, type);
960
- return Qnil;
851
+ struct tessdata* tdata;
852
+ GLenum type;
853
+ GetTESS(arg1, tdata);
854
+ type = (GLenum)NUM2INT(arg2);
855
+ gluNextContour(tdata->tobj, type);
856
+ return Qnil;
961
857
  }
962
858
  static VALUE
963
859
  glu_EndPolygon(obj, arg1)
964
860
  VALUE obj, arg1;
965
861
  {
966
- struct tessdata* tdata;
967
- GetTESS(arg1, tdata);
968
- gluEndPolygon(tdata->tobj);
969
- rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
970
- rb_ary_pop(t_current);
971
- return Qnil;
862
+ struct tessdata* tdata;
863
+ GetTESS(arg1, tdata);
864
+ gluEndPolygon(tdata->tobj);
865
+ rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
866
+ rb_ary_pop(t_current);
867
+ return Qnil;
972
868
  }
973
869
 
974
870
  /*
975
871
  * Quadric API
976
872
  */
873
+ static VALUE q_current;
874
+
875
+ static void CALLBACK
876
+ q_error(errorno)
877
+ GLenum errorno;
878
+ {
879
+ VALUE quad;
880
+ struct quaddata *qdata;
881
+ quad = rb_ary_entry(q_current, -1);
882
+ if (quad == Qnil)
883
+ return;
884
+ GetQUAD(quad, qdata);
885
+ rb_funcall(rb_ary_entry(qdata->q_ref, GLU_ERROR), callId, 1, INT2NUM(errorno));
886
+ }
887
+
888
+ static VALUE
889
+ glu_QuadricCallback(obj, arg1, arg2, arg3)
890
+ VALUE obj, arg1, arg2, arg3;
891
+ {
892
+ struct quaddata* qdata;
893
+ GLenum type;
894
+ GetQUAD(arg1, qdata);
895
+ type = (GLenum)NUM2INT(arg2);
896
+ if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
897
+ rb_raise(rb_eTypeError, "gluQuadricCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
898
+
899
+ if (type!=GLU_ERROR)
900
+ return Qnil;
901
+
902
+ rb_ary_store(qdata->q_ref, type, arg3);
903
+ if (NIL_P(arg3))
904
+ gluQuadricCallback(qdata->qobj, type, NULL);
905
+ else
906
+ gluQuadricCallback(qdata->qobj, type, q_error);
907
+
908
+ return Qnil;
909
+ }
910
+
977
911
  static void
978
912
  free_quad(qdata)
979
913
  struct quaddata *qdata;
980
914
  {
981
915
  if (qdata->qobj) gluDeleteQuadric(qdata->qobj);
982
916
  qdata->qobj = NULL;
917
+ qdata->q_ref = Qnil;
918
+ }
919
+ static void
920
+ mark_quad(qdata)
921
+ struct quaddata* qdata;
922
+ {
923
+ if (qdata->qobj)
924
+ rb_gc_mark(qdata->q_ref);
983
925
  }
984
926
  static VALUE
985
927
  glu_NewQuadric(obj)
986
928
  VALUE obj;
987
929
  {
988
- VALUE ret;
989
- struct quaddata *qdata;
990
- ret = Data_Make_Struct(cQuad, struct quaddata, 0, free_quad, qdata);
991
- qdata->qobj = gluNewQuadric();
992
- return ret;
930
+ VALUE ret;
931
+ struct quaddata *qdata;
932
+ ret = Data_Make_Struct(cQuad, struct quaddata, mark_quad, free_quad, qdata);
933
+ qdata->qobj = gluNewQuadric();
934
+ qdata->q_ref = rb_ary_new2(REF_LAST);
935
+ return ret;
993
936
  }
994
937
  static VALUE
995
938
  glu_DeleteQuadric(obj, arg1)
996
939
  VALUE obj, arg1;
997
940
  {
998
- struct quaddata *qdata;
999
- GetQUAD(arg1, qdata);
1000
- free_quad(qdata);
1001
- return Qnil;
941
+ struct quaddata *qdata;
942
+ GetQUAD(arg1, qdata);
943
+ free_quad(qdata);
944
+ return Qnil;
1002
945
  }
1003
946
  static VALUE
1004
947
  glu_QuadricNormals(obj, arg1, arg2)
1005
948
  VALUE obj, arg1, arg2;
1006
949
  {
1007
- struct quaddata* qdata;
1008
- GLenum normals;
1009
- GetQUAD(arg1, qdata);
1010
- normals = (GLenum)NUM2INT(arg2);
1011
- gluQuadricNormals(qdata->qobj, normals);
1012
- return Qnil;
950
+ struct quaddata* qdata;
951
+ GLenum normals;
952
+ GetQUAD(arg1, qdata);
953
+ normals = (GLenum)NUM2INT(arg2);
954
+ gluQuadricNormals(qdata->qobj, normals);
955
+ return Qnil;
1013
956
  }
1014
957
  static VALUE
1015
958
  glu_QuadricTexture(obj, arg1, arg2)
1016
959
  VALUE obj, arg1, arg2;
1017
960
  {
1018
- struct quaddata* qdata;
1019
- GLboolean textureCoords;
1020
- GetQUAD(arg1, qdata);
1021
- textureCoords = (GLboolean)NUM2INT(arg2);
1022
- gluQuadricTexture(qdata->qobj, textureCoords);
1023
- return Qnil;
961
+ struct quaddata* qdata;
962
+ GLboolean textureCoords;
963
+ GetQUAD(arg1, qdata);
964
+ textureCoords = (GLboolean)NUM2INT(arg2);
965
+ gluQuadricTexture(qdata->qobj, textureCoords);
966
+ return Qnil;
1024
967
  }
1025
968
  static VALUE
1026
969
  glu_QuadricOrientation(obj, arg1, arg2)
1027
970
  VALUE obj, arg1, arg2;
1028
971
  {
1029
- struct quaddata* qdata;
1030
- GLenum orientation;
1031
- GetQUAD(arg1, qdata);
1032
- orientation = (GLenum)NUM2INT(arg2);
1033
- gluQuadricOrientation(qdata->qobj, orientation);
1034
- return Qnil;
972
+ struct quaddata* qdata;
973
+ GLenum orientation;
974
+ GetQUAD(arg1, qdata);
975
+ orientation = (GLenum)NUM2INT(arg2);
976
+ gluQuadricOrientation(qdata->qobj, orientation);
977
+ return Qnil;
1035
978
  }
1036
979
  static VALUE
1037
980
  glu_QuadricDrawStyle(obj, arg1, arg2)
1038
981
  VALUE obj, arg1, arg2;
1039
982
  {
1040
- struct quaddata* qdata;
1041
- GLenum drawStyle;
1042
- GetQUAD(arg1, qdata);
1043
- drawStyle = (GLenum)NUM2INT(arg2);
1044
- gluQuadricDrawStyle(qdata->qobj, drawStyle);
1045
- return Qnil;
983
+ struct quaddata* qdata;
984
+ GLenum drawStyle;
985
+ GetQUAD(arg1, qdata);
986
+ drawStyle = (GLenum)NUM2INT(arg2);
987
+ gluQuadricDrawStyle(qdata->qobj, drawStyle);
988
+ return Qnil;
1046
989
  }
1047
990
  static VALUE
1048
991
  glu_Cylinder(obj, arg1, arg2, arg3, arg4, arg5, arg6)
1049
992
  VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
1050
993
  {
1051
- struct quaddata* qdata;
1052
- GLdouble baseRadius;
1053
- GLdouble topRadius;
1054
- GLdouble height;
1055
- GLint slices;
1056
- GLint stacks;
994
+ struct quaddata* qdata;
995
+ GLdouble baseRadius;
996
+ GLdouble topRadius;
997
+ GLdouble height;
998
+ GLint slices;
999
+ GLint stacks;
1057
1000
 
1058
- GetQUAD(arg1, qdata);
1059
- baseRadius = (GLdouble)NUM2DBL(arg2);
1060
- topRadius = (GLdouble)NUM2DBL(arg3);
1061
- height = (GLdouble)NUM2DBL(arg4);
1062
- slices = (GLint)NUM2INT(arg5);
1063
- stacks = (GLint)NUM2INT(arg6);
1001
+ GetQUAD(arg1, qdata);
1002
+ baseRadius = (GLdouble)NUM2DBL(arg2);
1003
+ topRadius = (GLdouble)NUM2DBL(arg3);
1004
+ height = (GLdouble)NUM2DBL(arg4);
1005
+ slices = (GLint)NUM2INT(arg5);
1006
+ stacks = (GLint)NUM2INT(arg6);
1064
1007
 
1065
- gluCylinder(qdata->qobj, baseRadius, topRadius, height, slices, stacks);
1066
- return Qnil;
1008
+ rb_ary_push(q_current, arg1);
1009
+ gluCylinder(qdata->qobj, baseRadius, topRadius, height, slices, stacks);
1010
+ rb_ary_pop(q_current);
1011
+ return Qnil;
1067
1012
  }
1068
1013
  static VALUE
1069
1014
  glu_Disk(obj, arg1, arg2, arg3, arg4, arg5)
1070
1015
  VALUE obj, arg1, arg2, arg3, arg4, arg5;
1071
1016
  {
1072
- struct quaddata* qdata;
1073
- GLdouble innerRadius;
1074
- GLdouble outerRadius;
1075
- GLint slices;
1076
- GLint loops;
1017
+ struct quaddata* qdata;
1018
+ GLdouble innerRadius;
1019
+ GLdouble outerRadius;
1020
+ GLint slices;
1021
+ GLint loops;
1022
+
1023
+ GetQUAD(arg1, qdata);
1024
+ innerRadius = (GLdouble)NUM2DBL(arg2);
1025
+ outerRadius = (GLdouble)NUM2DBL(arg3);
1026
+ slices = (GLint)NUM2INT(arg4);
1027
+ loops = (GLint)NUM2INT(arg5);
1077
1028
 
1078
- GetQUAD(arg1, qdata);
1079
- innerRadius = (GLdouble)NUM2DBL(arg2);
1080
- outerRadius = (GLdouble)NUM2DBL(arg3);
1081
- slices = (GLint)NUM2INT(arg4);
1082
- loops = (GLint)NUM2INT(arg5);
1029
+ rb_ary_push(q_current, arg1);
1083
1030
 
1084
- gluDisk(qdata->qobj, innerRadius, outerRadius, slices, loops);
1085
- return Qnil;
1031
+ gluDisk(qdata->qobj, innerRadius, outerRadius, slices, loops);
1032
+ rb_ary_pop(q_current);
1033
+ return Qnil;
1086
1034
  }
1087
1035
  static VALUE
1088
1036
  glu_PartialDisk(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
1089
1037
  VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
1090
1038
  {
1091
- struct quaddata* qdata;
1092
- GLdouble innerRadius;
1093
- GLdouble outerRadius;
1094
- GLint slices;
1095
- GLint loops;
1096
- GLdouble startAngle;
1097
- GLdouble sweepAngle;
1098
-
1099
- GetQUAD(arg1, qdata);
1100
- innerRadius = (GLdouble)NUM2DBL(arg2);
1101
- outerRadius = (GLdouble)NUM2DBL(arg3);
1102
- slices = (GLint)NUM2INT(arg4);
1103
- loops = (GLint)NUM2INT(arg5);
1104
- startAngle = (GLdouble)NUM2DBL(arg6);
1105
- sweepAngle = (GLdouble)NUM2DBL(arg7);
1106
-
1107
- gluPartialDisk(qdata->qobj, innerRadius, outerRadius, slices, loops, startAngle, sweepAngle);
1108
- return Qnil;
1039
+ struct quaddata* qdata;
1040
+ GLdouble innerRadius;
1041
+ GLdouble outerRadius;
1042
+ GLint slices;
1043
+ GLint loops;
1044
+ GLdouble startAngle;
1045
+ GLdouble sweepAngle;
1046
+
1047
+ GetQUAD(arg1, qdata);
1048
+ innerRadius = (GLdouble)NUM2DBL(arg2);
1049
+ outerRadius = (GLdouble)NUM2DBL(arg3);
1050
+ slices = (GLint)NUM2INT(arg4);
1051
+ loops = (GLint)NUM2INT(arg5);
1052
+ startAngle = (GLdouble)NUM2DBL(arg6);
1053
+ sweepAngle = (GLdouble)NUM2DBL(arg7);
1054
+
1055
+ rb_ary_push(q_current, arg1);
1056
+ gluPartialDisk(qdata->qobj, innerRadius, outerRadius, slices, loops, startAngle, sweepAngle);
1057
+ rb_ary_pop(q_current);
1058
+ return Qnil;
1109
1059
  }
1110
1060
  static VALUE
1111
1061
  glu_Sphere(obj, arg1, arg2, arg3, arg4)
1112
1062
  VALUE obj, arg1, arg2, arg3, arg4;
1113
1063
  {
1114
- struct quaddata* qdata;
1115
- GLdouble radius;
1116
- GLint slices;
1117
- GLint stacks;
1064
+ struct quaddata* qdata;
1065
+ GLdouble radius;
1066
+ GLint slices;
1067
+ GLint stacks;
1118
1068
 
1119
- GetQUAD(arg1, qdata);
1120
- radius = (GLdouble)NUM2DBL(arg2);
1121
- slices = (GLint)NUM2INT(arg3);
1122
- stacks = (GLint)NUM2INT(arg4);
1069
+ GetQUAD(arg1, qdata);
1070
+ radius = (GLdouble)NUM2DBL(arg2);
1071
+ slices = (GLint)NUM2INT(arg3);
1072
+ stacks = (GLint)NUM2INT(arg4);
1123
1073
 
1124
- gluSphere(qdata->qobj, radius, slices, stacks);
1125
- return Qnil;
1074
+ rb_ary_push(q_current, arg1);
1075
+ gluSphere(qdata->qobj, radius, slices, stacks);
1076
+ rb_ary_pop(q_current);
1077
+ return Qnil;
1126
1078
  }
1079
+
1080
+ /* */
1081
+
1127
1082
  static VALUE
1128
1083
  glu_LookAt(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
1129
1084
  VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
1130
1085
  {
1131
- GLdouble eyex;
1132
- GLdouble eyey;
1133
- GLdouble eyez;
1134
- GLdouble centerx;
1135
- GLdouble centery;
1136
- GLdouble centerz;
1137
- GLdouble upx;
1138
- GLdouble upy;
1139
- GLdouble upz;
1140
- eyex = (GLdouble)NUM2DBL(arg1);
1141
- eyey = (GLdouble)NUM2DBL(arg2);
1142
- eyez = (GLdouble)NUM2DBL(arg3);
1143
- centerx = (GLdouble)NUM2DBL(arg4);
1144
- centery = (GLdouble)NUM2DBL(arg5);
1145
- centerz = (GLdouble)NUM2DBL(arg6);
1146
- upx = (GLdouble)NUM2DBL(arg7);
1147
- upy = (GLdouble)NUM2DBL(arg8);
1148
- upz = (GLdouble)NUM2DBL(arg9);
1149
- gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz );
1150
- return Qnil;
1086
+ GLdouble eyex;
1087
+ GLdouble eyey;
1088
+ GLdouble eyez;
1089
+ GLdouble centerx;
1090
+ GLdouble centery;
1091
+ GLdouble centerz;
1092
+ GLdouble upx;
1093
+ GLdouble upy;
1094
+ GLdouble upz;
1095
+ eyex = (GLdouble)NUM2DBL(arg1);
1096
+ eyey = (GLdouble)NUM2DBL(arg2);
1097
+ eyez = (GLdouble)NUM2DBL(arg3);
1098
+ centerx = (GLdouble)NUM2DBL(arg4);
1099
+ centery = (GLdouble)NUM2DBL(arg5);
1100
+ centerz = (GLdouble)NUM2DBL(arg6);
1101
+ upx = (GLdouble)NUM2DBL(arg7);
1102
+ upy = (GLdouble)NUM2DBL(arg8);
1103
+ upz = (GLdouble)NUM2DBL(arg9);
1104
+ gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz );
1105
+ return Qnil;
1151
1106
  }
1152
1107
  static VALUE
1153
1108
  glu_Ortho2D(obj,arg1,arg2,arg3,arg4)
1154
1109
  VALUE obj,arg1,arg2,arg3,arg4;
1155
1110
  {
1156
- GLdouble left;
1157
- GLdouble right;
1158
- GLdouble bottom;
1159
- GLdouble top;
1160
- left = (GLdouble)NUM2DBL(arg1);
1161
- right = (GLdouble)NUM2DBL(arg2);
1162
- bottom = (GLdouble)NUM2DBL(arg3);
1163
- top = (GLdouble)NUM2DBL(arg4);
1164
- gluOrtho2D(left,right,bottom,top);
1165
- return Qnil;
1111
+ GLdouble left;
1112
+ GLdouble right;
1113
+ GLdouble bottom;
1114
+ GLdouble top;
1115
+ left = (GLdouble)NUM2DBL(arg1);
1116
+ right = (GLdouble)NUM2DBL(arg2);
1117
+ bottom = (GLdouble)NUM2DBL(arg3);
1118
+ top = (GLdouble)NUM2DBL(arg4);
1119
+ gluOrtho2D(left,right,bottom,top);
1120
+ return Qnil;
1166
1121
  }
1167
1122
  static VALUE
1168
1123
  glu_Perspective(obj,arg1,arg2,arg3,arg4)
1169
1124
  VALUE obj,arg1,arg2,arg3,arg4;
1170
1125
  {
1171
- GLdouble fovy;
1172
- GLdouble aspect;
1173
- GLdouble zNear;
1174
- GLdouble zFar;
1175
- fovy = (GLdouble)NUM2DBL(arg1);
1176
- aspect = (GLdouble)NUM2DBL(arg2);
1177
- zNear = (GLdouble)NUM2DBL(arg3);
1178
- zFar = (GLdouble)NUM2DBL(arg4);
1179
- gluPerspective(fovy,aspect,zNear,zFar);
1180
- return Qnil;
1126
+ GLdouble fovy;
1127
+ GLdouble aspect;
1128
+ GLdouble zNear;
1129
+ GLdouble zFar;
1130
+ fovy = (GLdouble)NUM2DBL(arg1);
1131
+ aspect = (GLdouble)NUM2DBL(arg2);
1132
+ zNear = (GLdouble)NUM2DBL(arg3);
1133
+ zFar = (GLdouble)NUM2DBL(arg4);
1134
+ gluPerspective(fovy,aspect,zNear,zFar);
1135
+ return Qnil;
1181
1136
  }
1182
1137
  static VALUE
1183
1138
  glu_PickMatrix(argc,argv,obj)
@@ -1185,37 +1140,37 @@ int argc;
1185
1140
  VALUE* argv;
1186
1141
  VALUE obj;
1187
1142
  {
1188
- GLdouble x;
1189
- GLdouble y;
1190
- GLdouble width;
1191
- GLdouble height;
1192
- GLint viewport[4];
1193
-
1194
- VALUE args[5];
1195
-
1196
- switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) {
1197
- case 2:
1198
- width = 5.0f;
1199
- height = 5.0f;
1200
- glGetIntegerv(GL_VIEWPORT, viewport);
1201
- break;
1202
- case 4:
1203
- width = (GLdouble)NUM2DBL(args[2]);
1204
- height = (GLdouble)NUM2DBL(args[3]);
1205
- glGetIntegerv(GL_VIEWPORT, viewport);
1206
- break;
1207
- case 5:
1208
- width = (GLdouble)NUM2DBL(args[2]);
1209
- height = (GLdouble)NUM2DBL(args[3]);
1210
- ary2cint(args[4], viewport, 4);
1211
- break;
1212
- default:
1213
- rb_raise(rb_eArgError, "GLU.PickMatrix args len:%d",argc);
1214
- }
1215
- x = (GLdouble)NUM2DBL(args[0]);
1216
- y = (GLdouble)NUM2DBL(args[1]);
1217
- gluPickMatrix(x, y, width, height, viewport);
1218
- return Qnil;
1143
+ GLdouble x;
1144
+ GLdouble y;
1145
+ GLdouble width;
1146
+ GLdouble height;
1147
+ GLint viewport[4];
1148
+
1149
+ VALUE args[5];
1150
+
1151
+ switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) {
1152
+ case 2:
1153
+ width = 5.0f;
1154
+ height = 5.0f;
1155
+ glGetIntegerv(GL_VIEWPORT, viewport);
1156
+ break;
1157
+ case 4:
1158
+ width = (GLdouble)NUM2DBL(args[2]);
1159
+ height = (GLdouble)NUM2DBL(args[3]);
1160
+ glGetIntegerv(GL_VIEWPORT, viewport);
1161
+ break;
1162
+ case 5:
1163
+ width = (GLdouble)NUM2DBL(args[2]);
1164
+ height = (GLdouble)NUM2DBL(args[3]);
1165
+ ary2cint(args[4], viewport, 4);
1166
+ break;
1167
+ default:
1168
+ rb_raise(rb_eArgError, "gluPickMatrix needs 2,4 or 5 parameters",argc);
1169
+ }
1170
+ x = (GLdouble)NUM2DBL(args[0]);
1171
+ y = (GLdouble)NUM2DBL(args[1]);
1172
+ gluPickMatrix(x, y, width, height, viewport);
1173
+ return Qnil;
1219
1174
  }
1220
1175
 
1221
1176
  static VALUE
@@ -1224,44 +1179,40 @@ int argc;
1224
1179
  VALUE* argv;
1225
1180
  VALUE obj;
1226
1181
  {
1227
- GLdouble ox;
1228
- GLdouble oy;
1229
- GLdouble oz;
1230
- GLdouble mdl_mtx[4*4];
1231
- GLdouble prj_mtx[4*4];
1232
- GLint vport[4];
1233
- GLdouble wx;
1234
- GLdouble wy;
1235
- GLdouble wz;
1236
-
1237
- VALUE args[6];
1238
- VALUE ret;
1239
-
1240
- switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
1241
- case 3:
1242
- glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
1243
- glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
1244
- glGetIntegerv(GL_VIEWPORT, vport);
1245
- break;
1246
- case 6:
1247
- ary2cmat4x4dbl(args[3], mdl_mtx);
1248
- ary2cmat4x4dbl(args[4], prj_mtx);
1249
- ary2cint(args[5], vport, 4);
1250
- break;
1251
- default:
1252
- rb_raise(rb_eArgError, "GLU.Project args len:%d",argc);
1253
- }
1254
- ox = (GLdouble)NUM2DBL(args[0]);
1255
- oy = (GLdouble)NUM2DBL(args[1]);
1256
- oz = (GLdouble)NUM2DBL(args[2]);
1257
-
1258
- if (gluProject(ox, oy, oz, mdl_mtx, prj_mtx, vport, &wx, &wy, &wz)
1259
- == GL_TRUE) {
1260
- ret = rb_ary_new3(3, rb_float_new(wx), rb_float_new(wy), rb_float_new(wz));
1261
- return ret;
1262
- }
1263
- else
1264
- return Qnil;
1182
+ GLdouble ox;
1183
+ GLdouble oy;
1184
+ GLdouble oz;
1185
+ GLdouble mdl_mtx[4*4];
1186
+ GLdouble prj_mtx[4*4];
1187
+ GLint vport[4];
1188
+ GLdouble wx;
1189
+ GLdouble wy;
1190
+ GLdouble wz;
1191
+
1192
+ VALUE args[6];
1193
+
1194
+ switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
1195
+ case 3:
1196
+ glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
1197
+ glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
1198
+ glGetIntegerv(GL_VIEWPORT, vport);
1199
+ break;
1200
+ case 6:
1201
+ ary2cmat4x4dbl(args[3], mdl_mtx);
1202
+ ary2cmat4x4dbl(args[4], prj_mtx);
1203
+ ary2cint(args[5], vport, 4);
1204
+ break;
1205
+ default:
1206
+ rb_raise(rb_eArgError, "gluProject needs 3 or 6 parameters");
1207
+ }
1208
+ ox = (GLdouble)NUM2DBL(args[0]);
1209
+ oy = (GLdouble)NUM2DBL(args[1]);
1210
+ oz = (GLdouble)NUM2DBL(args[2]);
1211
+
1212
+ if (gluProject(ox, oy, oz, mdl_mtx, prj_mtx, vport, &wx, &wy, &wz) == GL_TRUE)
1213
+ return rb_ary_new3(3, rb_float_new(wx), rb_float_new(wy), rb_float_new(wz));
1214
+ else
1215
+ return Qnil;
1265
1216
  }
1266
1217
  static VALUE
1267
1218
  glu_UnProject(argc,argv,obj)
@@ -1269,369 +1220,216 @@ int argc;
1269
1220
  VALUE* argv;
1270
1221
  VALUE obj;
1271
1222
  {
1272
- GLdouble wx;
1273
- GLdouble wy;
1274
- GLdouble wz;
1275
- GLdouble mdl_mtx[4*4];
1276
- GLdouble prj_mtx[4*4];
1277
- GLint vport[4];
1278
- GLdouble ox;
1279
- GLdouble oy;
1280
- GLdouble oz;
1281
-
1282
- VALUE args[6];
1283
- VALUE ret;
1284
-
1285
- switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
1286
- case 3:
1287
- glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
1288
- glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
1289
- glGetIntegerv(GL_VIEWPORT, vport);
1290
- break;
1291
- case 6:
1292
- ary2cmat4x4dbl(args[3], mdl_mtx);
1293
- ary2cmat4x4dbl(args[4], prj_mtx);
1294
- ary2cint(args[5], vport, 4);
1295
- break;
1296
- default:
1297
- rb_raise(rb_eArgError, "GLU.UnProject args len:%d",argc);
1298
- }
1299
- wx = (GLdouble)NUM2DBL(args[0]);
1300
- wy = (GLdouble)NUM2DBL(args[1]);
1301
- wz = (GLdouble)NUM2DBL(args[2]);
1302
-
1303
- if (gluUnProject(wx, wy, wz, mdl_mtx, prj_mtx, vport, &ox, &oy, &oz)
1304
- == GL_TRUE) {
1305
- ret = rb_ary_new3(3, rb_float_new(ox), rb_float_new(oy), rb_float_new(oz));
1306
- return ret;
1307
- }
1308
- else
1309
- return Qnil;
1223
+ GLdouble wx;
1224
+ GLdouble wy;
1225
+ GLdouble wz;
1226
+ GLdouble mdl_mtx[4*4];
1227
+ GLdouble prj_mtx[4*4];
1228
+ GLint vport[4];
1229
+ GLdouble ox;
1230
+ GLdouble oy;
1231
+ GLdouble oz;
1232
+
1233
+ VALUE args[6];
1234
+
1235
+ switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
1236
+ case 3:
1237
+ glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
1238
+ glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
1239
+ glGetIntegerv(GL_VIEWPORT, vport);
1240
+ break;
1241
+ case 6:
1242
+ ary2cmat4x4dbl(args[3], mdl_mtx);
1243
+ ary2cmat4x4dbl(args[4], prj_mtx);
1244
+ ary2cint(args[5], vport, 4);
1245
+ break;
1246
+ default:
1247
+ rb_raise(rb_eArgError, "gluUnProject needs 3 or 6 parameters");
1248
+ }
1249
+ wx = (GLdouble)NUM2DBL(args[0]);
1250
+ wy = (GLdouble)NUM2DBL(args[1]);
1251
+ wz = (GLdouble)NUM2DBL(args[2]);
1252
+
1253
+ if (gluUnProject(wx, wy, wz, mdl_mtx, prj_mtx, vport, &ox, &oy, &oz) == GL_TRUE)
1254
+ return rb_ary_new3(3, rb_float_new(ox), rb_float_new(oy), rb_float_new(oz));
1255
+ else
1256
+ return Qnil;
1257
+ }
1258
+
1259
+ static VALUE
1260
+ glu_Build1DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6)
1261
+ VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
1262
+ {
1263
+ GLenum target;
1264
+ GLint components;
1265
+ GLint width;
1266
+ GLenum format;
1267
+ GLenum type;
1268
+
1269
+ target = (GLenum)NUM2INT(arg1);
1270
+ components = (GLint)NUM2INT(arg2);
1271
+ width = (GLint)NUM2INT(arg3);
1272
+ format = (GLenum)NUM2INT(arg4);
1273
+ type = (GLenum)NUM2INT(arg5);
1274
+ Check_Type(arg6,T_STRING);
1275
+ CheckDataSize(type,format,width,arg6);
1276
+
1277
+ return INT2NUM(gluBuild1DMipmaps(target, components, width, format, type, RSTRING(arg6)->ptr));
1310
1278
  }
1311
1279
 
1312
1280
  static VALUE
1313
1281
  glu_Build2DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
1314
1282
  VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
1315
1283
  {
1316
- GLenum target;
1317
- GLint components;
1318
- GLint width;
1319
- GLint height;
1320
- GLenum format;
1321
- GLenum type;
1322
- void* data;
1323
-
1324
- int type_size;
1325
- int format_size;
1326
- int size;
1327
-
1328
- target = (GLenum)NUM2INT(arg1);
1329
- components = (GLint)NUM2INT(arg2);
1330
- width = (GLint)NUM2INT(arg3);
1331
- height = (GLint)NUM2INT(arg4);
1332
- format = (GLenum)NUM2INT(arg5);
1333
- type = (GLenum)NUM2INT(arg6);
1334
- if (TYPE(arg7) == T_STRING) {
1335
- type_size = gltype_size(type) / 8;
1336
- format_size = glformat_size(format);
1337
- if (type_size == -1 || format_size == -1)
1338
- return Qnil;
1339
- size = type_size*format_size*height*width;
1340
- if (RSTRING(arg7)->len < size)
1341
- rb_raise(rb_eArgError, "string length:%d",RSTRING(arg7)->len);
1342
- data = RSTRING(arg7)->ptr;
1343
- } else
1344
- rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg7));
1345
- return INT2NUM(gluBuild2DMipmaps(target, components, width, height, format, type, data));
1284
+ GLenum target;
1285
+ GLint components;
1286
+ GLint width;
1287
+ GLint height;
1288
+ GLenum format;
1289
+ GLenum type;
1290
+
1291
+ target = (GLenum)NUM2INT(arg1);
1292
+ components = (GLint)NUM2INT(arg2);
1293
+ width = (GLint)NUM2INT(arg3);
1294
+ height = (GLint)NUM2INT(arg4);
1295
+ format = (GLenum)NUM2INT(arg5);
1296
+ type = (GLenum)NUM2INT(arg6);
1297
+ Check_Type(arg7,T_STRING);
1298
+ CheckDataSize(type,format,width*height,arg7);
1299
+
1300
+ return INT2NUM(gluBuild2DMipmaps(target, components, width, height, format, type, RSTRING(arg7)->ptr));
1346
1301
  }
1347
1302
 
1348
1303
  static VALUE
1349
1304
  glu_ScaleImage(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
1350
1305
  VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
1351
1306
  {
1352
- GLenum format;
1353
- GLint widthin;
1354
- GLint heightin;
1355
- GLenum typein;
1356
- void* datain;
1357
- GLint widthout;
1358
- GLint heightout;
1359
- GLenum typeout;
1360
- int type_size;
1361
- int format_size;
1362
- int size;
1363
- VALUE ret;
1364
-
1365
- format = (GLenum)NUM2INT(arg1);
1366
- widthin = (GLint)NUM2INT(arg2);
1367
- heightin = (GLint)NUM2INT(arg3);
1368
- typein = (GLenum)NUM2INT(arg4);
1369
- if (TYPE(arg5) == T_STRING) {
1370
- type_size = gltype_size(typein) / 8;
1371
- format_size = glformat_size(format);
1372
- if (type_size == -1 || format_size == -1)
1373
- return Qnil;
1374
- size = type_size*format_size*heightin*widthin;
1375
- if (RSTRING(arg5)->len < size)
1376
- rb_raise(rb_eArgError, "string length:%d",RSTRING(arg5)->len);
1377
- datain = RSTRING(arg5)->ptr;
1378
- } else
1379
- rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg5));
1380
-
1381
- widthout = (GLint)NUM2INT(arg6);
1382
- heightout = (GLint)NUM2INT(arg7);
1383
- typeout = (GLenum)NUM2INT(arg8);
1384
- type_size = gltype_size(typeout) / 8;
1385
- ret = allocate_buffer_with_string(widthout*heightout*format_size*type_size);
1386
- gluScaleImage(format, widthin, heightin, typein, datain,
1387
- widthout, heightout, typeout, (GLvoid*)RSTRING(ret)->ptr);
1388
- return ret;
1307
+ GLenum format;
1308
+ GLint widthin;
1309
+ GLint heightin;
1310
+ GLenum typein;
1311
+ void* datain;
1312
+ GLint widthout;
1313
+ GLint heightout;
1314
+ GLenum typeout;
1315
+ VALUE ret;
1316
+
1317
+ format = (GLenum)NUM2INT(arg1);
1318
+ widthin = (GLint)NUM2INT(arg2);
1319
+ heightin = (GLint)NUM2INT(arg3);
1320
+ typein = (GLenum)NUM2INT(arg4);
1321
+ Check_Type(arg5,T_STRING);
1322
+ CheckDataSize(typein,format,heightin*widthin,arg5);
1323
+ datain = RSTRING(arg5)->ptr;
1324
+ widthout = (GLint)NUM2INT(arg6);
1325
+ heightout = (GLint)NUM2INT(arg7);
1326
+ typeout = (GLenum)NUM2INT(arg8);
1327
+ ret = allocate_buffer_with_string(GetDataSize(typeout,format,widthout*heightout));
1328
+ gluScaleImage(format, widthin, heightin, typein, datain,
1329
+ widthout, heightout, typeout, (GLvoid*)RSTRING(ret)->ptr);
1330
+ return ret;
1389
1331
  }
1390
1332
 
1391
1333
  static VALUE
1392
1334
  glu_ErrorString(obj, arg1)
1393
1335
  VALUE obj, arg1;
1394
1336
  {
1395
- GLenum errorCode;
1396
- GLubyte* error;
1397
- errorCode = (GLenum)NUM2INT(arg1);
1398
- error = (GLubyte*)gluErrorString(errorCode);
1399
- if (error)
1400
- return rb_str_new2(error);
1401
- else
1402
- return Qnil;
1337
+ GLenum errorCode;
1338
+ GLubyte* error;
1339
+ errorCode = (GLenum)NUM2INT(arg1);
1340
+ error = (GLubyte*)gluErrorString(errorCode);
1341
+ if (error)
1342
+ return rb_str_new2((char *)error);
1343
+ else
1344
+ return Qnil;
1403
1345
  }
1404
- #if defined(GLU_VERSION_1_1)
1405
1346
  static VALUE
1406
1347
  glu_GetString(obj, arg1)
1407
1348
  VALUE obj, arg1;
1408
1349
  {
1409
- GLenum name;
1410
- GLubyte* str;
1411
- name = (GLenum)NUM2INT(arg1);
1412
- str = (GLubyte*)gluGetString(name);
1413
- if (str)
1414
- return rb_str_new2(str);
1415
- else
1416
- return Qnil;
1350
+ GLenum name;
1351
+ GLubyte* str;
1352
+ name = (GLenum)NUM2INT(arg1);
1353
+ str = (GLubyte*)gluGetString(name);
1354
+ if (str)
1355
+ return rb_str_new2((char *)str);
1356
+ else
1357
+ return Qnil;
1417
1358
  }
1418
- #endif
1419
1359
 
1420
1360
  static VALUE module;
1421
1361
 
1422
- #ifndef GLU_BEGIN
1423
- #define GLU_BEGIN 100100
1424
- #endif
1425
- #ifndef GLU_VERTEX
1426
- #define GLU_VERTEX 100101
1427
- #endif
1428
- #ifndef GLU_END
1429
- #define GLU_END 100102
1430
- #endif
1431
- #ifndef GLU_EDGE_FLAG
1432
- #define GLU_EDGE_FLAG 100104
1433
- #endif
1434
- #ifndef GLU_CW
1435
- #define GLU_CW 100120
1436
- #endif
1437
- #ifndef GLU_CCW
1438
- #define GLU_CCW 100121
1439
- #endif
1440
- #ifndef GLU_INTERIOR
1441
- #define GLU_INTERIOR 100122
1442
- #endif
1443
- #ifndef GLU_EXTERIOR
1444
- #define GLU_EXTERIOR 100123
1445
- #endif
1446
- #ifndef GLU_UNKNOWN
1447
- #define GLU_UNKNOWN 100124
1448
- #endif
1449
- #ifndef GLU_ERROR
1450
- #define GLU_ERROR 100103
1451
- #endif
1452
-
1453
1362
  DLLEXPORT void Init_glu()
1454
1363
  {
1455
- callId = rb_intern("call");
1456
- refId = rb_intern("[]");
1457
- module = rb_define_module("Glu");
1458
- rb_define_module_function(module, "gluNewNurbsRenderer", glu_NewNurbsRenderer, 0);
1459
- rb_define_module_function(module, "gluDeleteNurbsRenderer", glu_DeleteNurbsRenderer, 1);
1460
- rb_define_module_function(module, "gluNurbsProperty", glu_NurbsProperty, 3);
1461
- rb_define_module_function(module, "gluGetNurbsProperty", glu_GetNurbsProperty, 2);
1462
- rb_define_module_function(module, "gluBeginCurve", glu_BeginCurve, 1);
1463
- rb_define_module_function(module, "gluEndCurve", glu_EndCurve, 1);
1464
- rb_define_module_function(module, "gluNurbsCurve", glu_NurbsCurve, -1);
1465
- rb_define_module_function(module, "gluBeginSurface", glu_BeginSurface, 1);
1466
- rb_define_module_function(module, "gluEndSurface", glu_EndSurface, 1);
1467
- rb_define_module_function(module, "gluNurbsSurface", glu_NurbsSurface, -1);
1468
- rb_define_module_function(module, "gluBeginTrim", glu_BeginTrim, 1);
1469
- rb_define_module_function(module, "gluEndTrim", glu_EndTrim, 1);
1470
- rb_define_module_function(module, "gluPwlCurve", glu_PwlCurve, -1);
1471
- rb_define_module_function(module, "gluNewTess", glu_NewTess, 0);
1472
- rb_define_module_function(module, "gluDeleteTess", glu_DeleteTess, 1);
1473
- rb_define_module_function(module, "gluTessCallback", glu_TessCallback, 3);
1474
- rb_define_module_function(module, "gluBeginPolygon", glu_BeginPolygon, 1);
1475
- rb_define_module_function(module, "gluTessVertex", glu_TessVertex, 3);
1476
- rb_define_module_function(module, "gluNextContour", glu_NextContour, 2);
1477
- rb_define_module_function(module, "gluEndPolygon", glu_EndPolygon, 1);
1478
- #if defined(GLU_VERSION_1_2)
1479
- rb_define_module_function(module, "gluTessBeginPolygon", glu_TessBeginPolygon, 2);
1480
- rb_define_module_function(module, "gluTessBeginContour", glu_TessBeginContour, 1);
1481
- rb_define_module_function(module, "gluTessEndContour", glu_TessEndContour, 1);
1482
- rb_define_module_function(module, "gluTessEndPolygon", glu_TessEndPolygon, 1);
1483
- rb_define_module_function(module, "gluTessProperty", glu_TessProperty, 3);
1484
- rb_define_module_function(module, "gluTessNormal", glu_TessNormal, 4);
1485
- rb_define_module_function(module, "gluGetTessProperty", glu_GetTessProperty, 2);
1486
- #endif /* GLU_VERSION_1_2 */
1487
- rb_define_module_function(module, "gluNewQuadric", glu_NewQuadric, 0);
1488
- rb_define_module_function(module, "gluDeleteQuadric", glu_DeleteQuadric, 1);
1489
- rb_define_module_function(module, "gluQuadricNormals", glu_QuadricNormals, 2);
1490
- rb_define_module_function(module, "gluQuadricTexture", glu_QuadricTexture, 2);
1491
- rb_define_module_function(module, "gluQuadricOrientation", glu_QuadricOrientation, 2);
1492
- rb_define_module_function(module, "gluQuadricDrawStyle", glu_QuadricDrawStyle, 2);
1493
- rb_define_module_function(module, "gluCylinder", glu_Cylinder, 6);
1494
- rb_define_module_function(module, "gluDisk", glu_Disk, 5);
1495
- rb_define_module_function(module, "gluPartialDisk", glu_PartialDisk, 7);
1496
- rb_define_module_function(module, "gluSphere", glu_Sphere, 4);
1497
-
1498
- rb_define_module_function(module, "gluLookAt", glu_LookAt, 9);
1499
- rb_define_module_function(module, "gluOrtho2D", glu_Ortho2D, 4);
1500
- rb_define_module_function(module, "gluPerspective", glu_Perspective, 4);
1501
- rb_define_module_function(module, "gluPickMatrix", glu_PickMatrix, -1);
1502
- rb_define_module_function(module, "gluProject", glu_Project, -1);
1503
- rb_define_module_function(module, "gluUnProject", glu_UnProject, -1);
1504
- rb_define_module_function(module, "gluBuild2DMipmaps", glu_Build2DMipmaps, 7);
1505
- rb_define_module_function(module, "gluScaleImage", glu_ScaleImage, 8);
1506
- rb_define_module_function(module, "gluErrorString", glu_ErrorString, 1);
1507
- #if defined(GLU_VERSION_1_1)
1508
- rb_define_module_function(module, "gluGetString", glu_GetString, 1);
1509
- #endif
1510
-
1511
- rb_define_const(module, "GLU_SMOOTH", INT2NUM(GLU_SMOOTH));
1512
- rb_define_const(module, "GLU_FLAT", INT2NUM(GLU_FLAT));
1513
- rb_define_const(module, "GLU_NONE", INT2NUM(GLU_NONE));
1514
- rb_define_const(module, "GLU_POINT", INT2NUM(GLU_POINT));
1515
- rb_define_const(module, "GLU_LINE", INT2NUM(GLU_LINE));
1516
- rb_define_const(module, "GLU_FILL", INT2NUM(GLU_FILL));
1517
- rb_define_const(module, "GLU_SILHOUETTE", INT2NUM(GLU_SILHOUETTE));
1518
- rb_define_const(module, "GLU_OUTSIDE", INT2NUM(GLU_OUTSIDE));
1519
- rb_define_const(module, "GLU_INSIDE", INT2NUM(GLU_INSIDE));
1520
- #if defined(GLU_VERSION_1_2)
1521
- rb_define_const(module, "GLU_TESS_BEGIN", INT2NUM(GLU_TESS_BEGIN));
1522
- rb_define_const(module, "GLU_TESS_VERTEX", INT2NUM(GLU_TESS_VERTEX));
1523
- rb_define_const(module, "GLU_TESS_END", INT2NUM(GLU_TESS_END));
1524
- rb_define_const(module, "GLU_TESS_ERROR", INT2NUM(GLU_TESS_ERROR));
1525
- rb_define_const(module, "GLU_TESS_EDGE_FLAG", INT2NUM(GLU_TESS_EDGE_FLAG));
1526
- rb_define_const(module, "GLU_TESS_COMBINE", INT2NUM(GLU_TESS_COMBINE));
1527
-
1528
- rb_define_const(module, "GLU_TESS_BEGIN_DATA", INT2NUM(GLU_TESS_BEGIN_DATA));
1529
- rb_define_const(module, "GLU_TESS_VERTEX_DATA", INT2NUM(GLU_TESS_VERTEX_DATA));
1530
- rb_define_const(module, "GLU_TESS_END_DATA", INT2NUM(GLU_TESS_END_DATA));
1531
- rb_define_const(module, "GLU_TESS_ERROR_DATA", INT2NUM(GLU_TESS_ERROR_DATA));
1532
- rb_define_const(module, "GLU_TESS_EDGE_FLAG_DATA", INT2NUM(GLU_TESS_EDGE_FLAG_DATA));
1533
- rb_define_const(module, "GLU_TESS_COMBINE_DATA", INT2NUM(GLU_TESS_COMBINE_DATA));
1534
-
1535
- /* Winding rules */
1536
- rb_define_const(module, "GLU_TESS_WINDING_ODD", INT2NUM(GLU_TESS_WINDING_ODD));
1537
- rb_define_const(module, "GLU_TESS_WINDING_NONZERO", INT2NUM(GLU_TESS_WINDING_NONZERO));
1538
- rb_define_const(module, "GLU_TESS_WINDING_POSITIVE", INT2NUM(GLU_TESS_WINDING_POSITIVE));
1539
- rb_define_const(module, "GLU_TESS_WINDING_NEGATIVE", INT2NUM(GLU_TESS_WINDING_NEGATIVE));
1540
- rb_define_const(module, "GLU_TESS_WINDING_ABS_GEQ_TWO", INT2NUM(GLU_TESS_WINDING_ABS_GEQ_TWO));
1541
-
1542
- /* Tessellation properties */
1543
- rb_define_const(module, "GLU_TESS_WINDING_RULE", INT2NUM(GLU_TESS_WINDING_RULE));
1544
- rb_define_const(module, "GLU_TESS_BOUNDARY_ONLY", INT2NUM(GLU_TESS_BOUNDARY_ONLY));
1545
- rb_define_const(module, "GLU_TESS_TOLERANCE", INT2NUM(GLU_TESS_TOLERANCE));
1546
- #endif /* GLU_VERSION_1_2 */
1547
-
1548
- rb_define_const(module, "GLU_BEGIN", INT2NUM(GLU_BEGIN));
1549
- rb_define_const(module, "GLU_VERTEX", INT2NUM(GLU_VERTEX));
1550
- rb_define_const(module, "GLU_END", INT2NUM(GLU_END));
1551
- rb_define_const(module, "GLU_ERROR", INT2NUM(GLU_ERROR));
1552
- rb_define_const(module, "GLU_EDGE_FLAG", INT2NUM(GLU_EDGE_FLAG));
1553
- rb_define_const(module, "GLU_CW", INT2NUM(GLU_CW));
1554
- rb_define_const(module, "GLU_CCW", INT2NUM(GLU_CCW));
1555
- rb_define_const(module, "GLU_INTERIOR", INT2NUM(GLU_INTERIOR));
1556
- rb_define_const(module, "GLU_EXTERIOR", INT2NUM(GLU_EXTERIOR));
1557
- rb_define_const(module, "GLU_UNKNOWN", INT2NUM(GLU_UNKNOWN));
1558
- rb_define_const(module, "GLU_TESS_ERROR1", INT2NUM(GLU_TESS_ERROR1));
1559
- rb_define_const(module, "GLU_TESS_ERROR2", INT2NUM(GLU_TESS_ERROR2));
1560
- rb_define_const(module, "GLU_TESS_ERROR3", INT2NUM(GLU_TESS_ERROR3));
1561
- rb_define_const(module, "GLU_TESS_ERROR4", INT2NUM(GLU_TESS_ERROR4));
1562
- rb_define_const(module, "GLU_TESS_ERROR5", INT2NUM(GLU_TESS_ERROR5));
1563
- rb_define_const(module, "GLU_TESS_ERROR6", INT2NUM(GLU_TESS_ERROR6));
1564
- rb_define_const(module, "GLU_TESS_ERROR7", INT2NUM(GLU_TESS_ERROR7));
1565
- rb_define_const(module, "GLU_TESS_ERROR8", INT2NUM(GLU_TESS_ERROR8));
1566
- #if defined(TESS_ERROR9)
1567
- rb_define_const(module, "GLU_TESS_ERROR9", INT2NUM(GLU_TESS_ERROR9));
1568
- #endif
1569
- #if defined(GLU_VERSION_1_3)
1570
- rb_define_const(module, "GLU_AUTO_LOAD_MATRIX", INT2NUM(GLU_AUTO_LOAD_MATRIX));
1571
- rb_define_const(module, "GLU_CULLING", INT2NUM(GLU_CULLING));
1572
- rb_define_const(module, "GLU_SAMPLING_TOLERANCE", INT2NUM(GLU_SAMPLING_TOLERANCE));
1573
- rb_define_const(module, "GLU_DISPLAY_MODE", INT2NUM(GLU_DISPLAY_MODE));
1574
- rb_define_const(module, "GLU_SAMPLING_METHOD", INT2NUM(GLU_SAMPLING_METHOD));
1575
- rb_define_const(module, "GLU_U_STEP", INT2NUM(GLU_U_STEP));
1576
- rb_define_const(module, "GLU_V_STEP", INT2NUM(GLU_V_STEP));
1577
- #endif
1578
- rb_define_const(module, "GLU_PATH_LENGTH", INT2NUM(GLU_PATH_LENGTH));
1579
- rb_define_const(module, "GLU_PARAMETRIC_ERROR", INT2NUM(GLU_PARAMETRIC_ERROR));
1580
- rb_define_const(module, "GLU_DOMAIN_DISTANCE", INT2NUM(GLU_DOMAIN_DISTANCE));
1581
- rb_define_const(module, "GLU_MAP1_TRIM_2", INT2NUM(GLU_MAP1_TRIM_2));
1582
- rb_define_const(module, "GLU_MAP1_TRIM_3", INT2NUM(GLU_MAP1_TRIM_3));
1583
- rb_define_const(module, "GLU_OUTLINE_POLYGON", INT2NUM(GLU_OUTLINE_POLYGON));
1584
- rb_define_const(module, "GLU_OUTLINE_PATCH", INT2NUM(GLU_OUTLINE_PATCH));
1585
- rb_define_const(module, "GLU_NURBS_ERROR1", INT2NUM(GLU_NURBS_ERROR1));
1586
- rb_define_const(module, "GLU_NURBS_ERROR2", INT2NUM(GLU_NURBS_ERROR2));
1587
- rb_define_const(module, "GLU_NURBS_ERROR3", INT2NUM(GLU_NURBS_ERROR3));
1588
- rb_define_const(module, "GLU_NURBS_ERROR4", INT2NUM(GLU_NURBS_ERROR4));
1589
- rb_define_const(module, "GLU_NURBS_ERROR5", INT2NUM(GLU_NURBS_ERROR5));
1590
- rb_define_const(module, "GLU_NURBS_ERROR6", INT2NUM(GLU_NURBS_ERROR6));
1591
- rb_define_const(module, "GLU_NURBS_ERROR7", INT2NUM(GLU_NURBS_ERROR7));
1592
- rb_define_const(module, "GLU_NURBS_ERROR8", INT2NUM(GLU_NURBS_ERROR8));
1593
- rb_define_const(module, "GLU_NURBS_ERROR9", INT2NUM(GLU_NURBS_ERROR9));
1594
- rb_define_const(module, "GLU_NURBS_ERROR10", INT2NUM(GLU_NURBS_ERROR10));
1595
- rb_define_const(module, "GLU_NURBS_ERROR11", INT2NUM(GLU_NURBS_ERROR11));
1596
- rb_define_const(module, "GLU_NURBS_ERROR12", INT2NUM(GLU_NURBS_ERROR12));
1597
- rb_define_const(module, "GLU_NURBS_ERROR13", INT2NUM(GLU_NURBS_ERROR13));
1598
- rb_define_const(module, "GLU_NURBS_ERROR14", INT2NUM(GLU_NURBS_ERROR14));
1599
- rb_define_const(module, "GLU_NURBS_ERROR15", INT2NUM(GLU_NURBS_ERROR15));
1600
- rb_define_const(module, "GLU_NURBS_ERROR16", INT2NUM(GLU_NURBS_ERROR16));
1601
- rb_define_const(module, "GLU_NURBS_ERROR17", INT2NUM(GLU_NURBS_ERROR17));
1602
- rb_define_const(module, "GLU_NURBS_ERROR18", INT2NUM(GLU_NURBS_ERROR18));
1603
- rb_define_const(module, "GLU_NURBS_ERROR19", INT2NUM(GLU_NURBS_ERROR19));
1604
- rb_define_const(module, "GLU_NURBS_ERROR20", INT2NUM(GLU_NURBS_ERROR20));
1605
- rb_define_const(module, "GLU_NURBS_ERROR21", INT2NUM(GLU_NURBS_ERROR21));
1606
- rb_define_const(module, "GLU_NURBS_ERROR22", INT2NUM(GLU_NURBS_ERROR22));
1607
- rb_define_const(module, "GLU_NURBS_ERROR23", INT2NUM(GLU_NURBS_ERROR23));
1608
- rb_define_const(module, "GLU_NURBS_ERROR24", INT2NUM(GLU_NURBS_ERROR24));
1609
- rb_define_const(module, "GLU_NURBS_ERROR25", INT2NUM(GLU_NURBS_ERROR25));
1610
- rb_define_const(module, "GLU_NURBS_ERROR26", INT2NUM(GLU_NURBS_ERROR26));
1611
- rb_define_const(module, "GLU_NURBS_ERROR27", INT2NUM(GLU_NURBS_ERROR27));
1612
- rb_define_const(module, "GLU_NURBS_ERROR28", INT2NUM(GLU_NURBS_ERROR28));
1613
- rb_define_const(module, "GLU_NURBS_ERROR29", INT2NUM(GLU_NURBS_ERROR29));
1614
- rb_define_const(module, "GLU_NURBS_ERROR30", INT2NUM(GLU_NURBS_ERROR30));
1615
- rb_define_const(module, "GLU_NURBS_ERROR31", INT2NUM(GLU_NURBS_ERROR31));
1616
- rb_define_const(module, "GLU_NURBS_ERROR32", INT2NUM(GLU_NURBS_ERROR32));
1617
- rb_define_const(module, "GLU_NURBS_ERROR33", INT2NUM(GLU_NURBS_ERROR33));
1618
- rb_define_const(module, "GLU_NURBS_ERROR34", INT2NUM(GLU_NURBS_ERROR34));
1619
- rb_define_const(module, "GLU_NURBS_ERROR35", INT2NUM(GLU_NURBS_ERROR35));
1620
- rb_define_const(module, "GLU_NURBS_ERROR36", INT2NUM(GLU_NURBS_ERROR36));
1621
- rb_define_const(module, "GLU_NURBS_ERROR37", INT2NUM(GLU_NURBS_ERROR37));
1622
- rb_define_const(module, "GLU_INVALID_ENUM", INT2NUM(GLU_INVALID_ENUM));
1623
- rb_define_const(module, "GLU_INVALID_VALUE", INT2NUM(GLU_INVALID_VALUE));
1624
- rb_define_const(module, "GLU_OUT_OF_MEMORY", INT2NUM(GLU_OUT_OF_MEMORY));
1625
- #ifdef GLU_INCOMPATIBLE_GL_VERSION
1626
- rb_define_const(module, "GLU_INCOMPATIBLE_GL_VERSION", INT2NUM(GLU_INCOMPATIBLE_GL_VERSION));
1627
- #endif
1628
- rb_define_const(module, "GLU_VERSION", INT2NUM(GLU_VERSION));
1629
- rb_define_const(module, "GLU_EXTENSIONS", INT2NUM(GLU_EXTENSIONS));
1630
-
1631
- cNurbs = rb_define_class("Nurbs", rb_cObject);
1632
- cTess = rb_define_class("Tess", rb_cObject);
1633
- cQuad = rb_define_class("Quadric", rb_cObject);
1634
-
1635
- rb_global_variable(&t_current);
1636
- t_current = rb_ary_new();
1364
+ callId = rb_intern("call");
1365
+ refId = rb_intern("[]");
1366
+ module = rb_define_module("Glu");
1367
+
1368
+ glu_init_enums(module);
1369
+
1370
+ rb_define_module_function(module, "gluNewNurbsRenderer", glu_NewNurbsRenderer, 0);
1371
+ rb_define_module_function(module, "gluDeleteNurbsRenderer", glu_DeleteNurbsRenderer, 1);
1372
+ rb_define_module_function(module, "gluNurbsProperty", glu_NurbsProperty, 3);
1373
+ rb_define_module_function(module, "gluGetNurbsProperty", glu_GetNurbsProperty, 2);
1374
+ rb_define_module_function(module, "gluBeginCurve", glu_BeginCurve, 1);
1375
+ rb_define_module_function(module, "gluEndCurve", glu_EndCurve, 1);
1376
+ rb_define_module_function(module, "gluNurbsCurve", glu_NurbsCurve, -1);
1377
+ rb_define_module_function(module, "gluBeginSurface", glu_BeginSurface, 1);
1378
+ rb_define_module_function(module, "gluEndSurface", glu_EndSurface, 1);
1379
+ rb_define_module_function(module, "gluNurbsSurface", glu_NurbsSurface, -1);
1380
+ rb_define_module_function(module, "gluBeginTrim", glu_BeginTrim, 1);
1381
+ rb_define_module_function(module, "gluEndTrim", glu_EndTrim, 1);
1382
+ rb_define_module_function(module, "gluPwlCurve", glu_PwlCurve, -1);
1383
+ rb_define_module_function(module, "gluNewTess", glu_NewTess, 0);
1384
+ rb_define_module_function(module, "gluDeleteTess", glu_DeleteTess, 1);
1385
+ rb_define_module_function(module, "gluTessCallback", glu_TessCallback, 3);
1386
+ rb_define_module_function(module, "gluBeginPolygon", glu_BeginPolygon, 1);
1387
+ rb_define_module_function(module, "gluTessVertex", glu_TessVertex, 3);
1388
+ rb_define_module_function(module, "gluNextContour", glu_NextContour, 2);
1389
+ rb_define_module_function(module, "gluEndPolygon", glu_EndPolygon, 1);
1390
+ rb_define_module_function(module, "gluTessBeginPolygon", glu_TessBeginPolygon, 2);
1391
+ rb_define_module_function(module, "gluTessBeginContour", glu_TessBeginContour, 1);
1392
+ rb_define_module_function(module, "gluTessEndContour", glu_TessEndContour, 1);
1393
+ rb_define_module_function(module, "gluTessEndPolygon", glu_TessEndPolygon, 1);
1394
+ rb_define_module_function(module, "gluTessProperty", glu_TessProperty, 3);
1395
+ rb_define_module_function(module, "gluTessNormal", glu_TessNormal, 4);
1396
+ rb_define_module_function(module, "gluGetTessProperty", glu_GetTessProperty, 2);
1397
+ rb_define_module_function(module, "gluNewQuadric", glu_NewQuadric, 0);
1398
+ rb_define_module_function(module, "gluDeleteQuadric", glu_DeleteQuadric, 1);
1399
+ rb_define_module_function(module, "gluQuadricNormals", glu_QuadricNormals, 2);
1400
+ rb_define_module_function(module, "gluQuadricTexture", glu_QuadricTexture, 2);
1401
+ rb_define_module_function(module, "gluQuadricOrientation", glu_QuadricOrientation, 2);
1402
+ rb_define_module_function(module, "gluQuadricDrawStyle", glu_QuadricDrawStyle, 2);
1403
+ rb_define_module_function(module, "gluCylinder", glu_Cylinder, 6);
1404
+ rb_define_module_function(module, "gluDisk", glu_Disk, 5);
1405
+ rb_define_module_function(module, "gluPartialDisk", glu_PartialDisk, 7);
1406
+ rb_define_module_function(module, "gluSphere", glu_Sphere, 4);
1407
+
1408
+ rb_define_module_function(module, "gluLookAt", glu_LookAt, 9);
1409
+ rb_define_module_function(module, "gluOrtho2D", glu_Ortho2D, 4);
1410
+ rb_define_module_function(module, "gluPerspective", glu_Perspective, 4);
1411
+ rb_define_module_function(module, "gluPickMatrix", glu_PickMatrix, -1);
1412
+ rb_define_module_function(module, "gluProject", glu_Project, -1);
1413
+ rb_define_module_function(module, "gluUnProject", glu_UnProject, -1);
1414
+ rb_define_module_function(module, "gluBuild1DMipmaps", glu_Build1DMipmaps, 6);
1415
+ rb_define_module_function(module, "gluBuild2DMipmaps", glu_Build2DMipmaps, 7);
1416
+ rb_define_module_function(module, "gluScaleImage", glu_ScaleImage, 8);
1417
+ rb_define_module_function(module, "gluErrorString", glu_ErrorString, 1);
1418
+ rb_define_module_function(module, "gluGetString", glu_GetString, 1);
1419
+
1420
+ rb_define_module_function(module, "gluLoadSamplingMatrices",glu_LoadSamplingMatrices,4);
1421
+ rb_define_module_function(module, "gluQuadricCallback", glu_QuadricCallback, 3);
1422
+ rb_define_module_function(module, "gluNurbsCallback", glu_NurbsCallback, 3);
1423
+
1424
+
1425
+ cNurbs = rb_define_class("Nurbs", rb_cObject);
1426
+ cTess = rb_define_class("Tess", rb_cObject);
1427
+ cQuad = rb_define_class("Quadric", rb_cObject);
1428
+
1429
+ rb_global_variable(&t_current); /* current active tesselator, nurbs and quadric, used for callbacks */
1430
+ t_current = rb_ary_new();
1431
+ rb_global_variable(&n_current);
1432
+ n_current = rb_ary_new();
1433
+ rb_global_variable(&q_current);
1434
+ q_current = rb_ary_new();
1637
1435
  }