opengl-bindings2 2.0.0.rc1 → 2.0.0rc2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/glu.rb CHANGED
@@ -1,366 +1,366 @@
1
- # -*- coding: utf-8 -*-
2
- require 'fiddle/import'
3
- require_relative 'opengl_platform'
4
-
5
- module GLU
6
-
7
- extend Fiddle::Importer
8
-
9
- # defines
10
-
11
- # Extensions
12
- GLU_EXT_object_space_tess = 1
13
- GLU_EXT_nurbs_tessellator = 1
14
-
15
- # Boolean
16
- GLU_FALSE = 0
17
- GLU_TRUE = 1
18
-
19
- # Version
20
- GLU_VERSION_1_1 = 1
21
- GLU_VERSION_1_2 = 1
22
- GLU_VERSION_1_3 = 1
23
-
24
- # StringName
25
- GLU_VERSION = 100800
26
- GLU_EXTENSIONS = 100801
27
-
28
- # ErrorCode
29
- GLU_INVALID_ENUM = 100900
30
- GLU_INVALID_VALUE = 100901
31
- GLU_OUT_OF_MEMORY = 100902
32
- GLU_INCOMPATIBLE_GL_VERSION = 100903
33
- GLU_INVALID_OPERATION = 100904
34
-
35
-
36
- # NurbsDisplay
37
- # GLU_FILL
38
- GLU_OUTLINE_POLYGON = 100240
39
- GLU_OUTLINE_PATCH = 100241
40
-
41
- # NurbsCallback
42
- GLU_NURBS_ERROR = 100103
43
- GLU_ERROR = 100103
44
- GLU_NURBS_BEGIN = 100164
45
- GLU_NURBS_BEGIN_EXT = 100164
46
- GLU_NURBS_VERTEX = 100165
47
- GLU_NURBS_VERTEX_EXT = 100165
48
- GLU_NURBS_NORMAL = 100166
49
- GLU_NURBS_NORMAL_EXT = 100166
50
- GLU_NURBS_COLOR = 100167
51
- GLU_NURBS_COLOR_EXT = 100167
52
- GLU_NURBS_TEXTURE_COORD = 100168
53
- GLU_NURBS_TEX_COORD_EXT = 100168
54
- GLU_NURBS_END = 100169
55
- GLU_NURBS_END_EXT = 100169
56
- GLU_NURBS_BEGIN_DATA = 100170
57
- GLU_NURBS_BEGIN_DATA_EXT = 100170
58
- GLU_NURBS_VERTEX_DATA = 100171
59
- GLU_NURBS_VERTEX_DATA_EXT = 100171
60
- GLU_NURBS_NORMAL_DATA = 100172
61
- GLU_NURBS_NORMAL_DATA_EXT = 100172
62
- GLU_NURBS_COLOR_DATA = 100173
63
- GLU_NURBS_COLOR_DATA_EXT = 100173
64
- GLU_NURBS_TEXTURE_COORD_DATA = 100174
65
- GLU_NURBS_TEX_COORD_DATA_EXT = 100174
66
- GLU_NURBS_END_DATA = 100175
67
- GLU_NURBS_END_DATA_EXT = 100175
68
-
69
- # NurbsError
70
- GLU_NURBS_ERROR1 = 100251 # spline order un-supported
71
- GLU_NURBS_ERROR2 = 100252 # too few knots
72
- GLU_NURBS_ERROR3 = 100253 # valid knot range is empty
73
- GLU_NURBS_ERROR4 = 100254 # decreasing knot sequence
74
- GLU_NURBS_ERROR5 = 100255 # knot multiplicity > spline order
75
- GLU_NURBS_ERROR6 = 100256 # endcurve() must follow bgncurve()
76
- GLU_NURBS_ERROR7 = 100257 # bgncurve() must precede endcurve()
77
- GLU_NURBS_ERROR8 = 100258 # ctrlarray or knot vector is NULL
78
- GLU_NURBS_ERROR9 = 100259 # can't draw pwlcurves
79
- GLU_NURBS_ERROR10 = 100260 # missing gluNurbsCurve()
80
- GLU_NURBS_ERROR11 = 100261 # missing gluNurbsSurface()
81
- GLU_NURBS_ERROR12 = 100262 # endtrim() must precede endsurface()
82
- GLU_NURBS_ERROR13 = 100263 # bgnsurface() must precede endsurface()
83
- GLU_NURBS_ERROR14 = 100264 # curve of improper type passed as trim curve
84
- GLU_NURBS_ERROR15 = 100265 # bgnsurface() must precede bgntrim()
85
- GLU_NURBS_ERROR16 = 100266 # endtrim() must follow bgntrim()
86
- GLU_NURBS_ERROR17 = 100267 # bgntrim() must precede endtrim()
87
- GLU_NURBS_ERROR18 = 100268 # invalid or missing trim curve
88
- GLU_NURBS_ERROR19 = 100269 # bgntrim() must precede pwlcurve()
89
- GLU_NURBS_ERROR20 = 100270 # pwlcurve referenced twice
90
- GLU_NURBS_ERROR21 = 100271 # pwlcurve and nurbscurve mixed
91
- GLU_NURBS_ERROR22 = 100272 # improper usage of trim data type
92
- GLU_NURBS_ERROR23 = 100273 # nurbscurve referenced twice
93
- GLU_NURBS_ERROR24 = 100274 # nurbscurve and pwlcurve mixed
94
- GLU_NURBS_ERROR25 = 100275 # nurbssurface referenced twice
95
- GLU_NURBS_ERROR26 = 100276 # invalid property
96
- GLU_NURBS_ERROR27 = 100277 # endsurface() must follow bgnsurface()
97
- GLU_NURBS_ERROR28 = 100278 # intersecting or misoriented trim curves
98
- GLU_NURBS_ERROR29 = 100279 # intersecting trim curves
99
- GLU_NURBS_ERROR30 = 100280 # UNUSED
100
- GLU_NURBS_ERROR31 = 100281 # unconnected trim curves
101
- GLU_NURBS_ERROR32 = 100282 # unknown knot error
102
- GLU_NURBS_ERROR33 = 100283 # negative vertex count encountered
103
- GLU_NURBS_ERROR34 = 100284 # negative byte-stride
104
- GLU_NURBS_ERROR35 = 100285 # unknown type descriptor
105
- GLU_NURBS_ERROR36 = 100286 # null control point reference
106
- GLU_NURBS_ERROR37 = 100287 # duplicate point on pwlcurve
107
-
108
- # NurbsProperty
109
- GLU_AUTO_LOAD_MATRIX = 100200
110
- GLU_CULLING = 100201
111
- GLU_SAMPLING_TOLERANCE = 100203
112
- GLU_DISPLAY_MODE = 100204
113
- GLU_PARAMETRIC_TOLERANCE = 100202
114
- GLU_SAMPLING_METHOD = 100205
115
- GLU_U_STEP = 100206
116
- GLU_V_STEP = 100207
117
- GLU_NURBS_MODE = 100160
118
- GLU_NURBS_MODE_EXT = 100160
119
- GLU_NURBS_TESSELLATOR = 100161
120
- GLU_NURBS_TESSELLATOR_EXT = 100161
121
- GLU_NURBS_RENDERER = 100162
122
- GLU_NURBS_RENDERER_EXT = 100162
123
-
124
- # NurbsSampling
125
- GLU_OBJECT_PARAMETRIC_ERROR = 100208
126
- GLU_OBJECT_PARAMETRIC_ERROR_EXT = 100208
127
- GLU_OBJECT_PATH_LENGTH = 100209
128
- GLU_OBJECT_PATH_LENGTH_EXT = 100209
129
- GLU_PATH_LENGTH = 100215
130
- GLU_PARAMETRIC_ERROR = 100216
131
- GLU_DOMAIN_DISTANCE = 100217
132
-
133
- # NurbsTrim
134
- GLU_MAP1_TRIM_2 = 100210
135
- GLU_MAP1_TRIM_3 = 100211
136
-
137
- # QuadricDrawStyle
138
- GLU_POINT = 100010
139
- GLU_LINE = 100011
140
- GLU_FILL = 100012
141
- GLU_SILHOUETTE = 100013
142
-
143
- # QuadricCallback
144
- # GLU_ERROR
145
-
146
- # QuadricNormal
147
- GLU_SMOOTH = 100000
148
- GLU_FLAT = 100001
149
- GLU_NONE = 100002
150
-
151
- # QuadricOrientation
152
- GLU_OUTSIDE = 100020
153
- GLU_INSIDE = 100021
154
-
155
- # TessCallback
156
- GLU_TESS_BEGIN = 100100
157
- GLU_BEGIN = 100100
158
- GLU_TESS_VERTEX = 100101
159
- GLU_VERTEX = 100101
160
- GLU_TESS_END = 100102
161
- GLU_END = 100102
162
- GLU_TESS_ERROR = 100103
163
- GLU_TESS_EDGE_FLAG = 100104
164
- GLU_EDGE_FLAG = 100104
165
- GLU_TESS_COMBINE = 100105
166
- GLU_TESS_BEGIN_DATA = 100106
167
- GLU_TESS_VERTEX_DATA = 100107
168
- GLU_TESS_END_DATA = 100108
169
- GLU_TESS_ERROR_DATA = 100109
170
- GLU_TESS_EDGE_FLAG_DATA = 100110
171
- GLU_TESS_COMBINE_DATA = 100111
172
-
173
- # TessContour
174
- GLU_CW = 100120
175
- GLU_CCW = 100121
176
- GLU_INTERIOR = 100122
177
- GLU_EXTERIOR = 100123
178
- GLU_UNKNOWN = 100124
179
-
180
- # TessProperty
181
- GLU_TESS_WINDING_RULE = 100140
182
- GLU_TESS_BOUNDARY_ONLY = 100141
183
- GLU_TESS_TOLERANCE = 100142
184
-
185
- # TessError
186
- GLU_TESS_ERROR1 = 100151
187
- GLU_TESS_ERROR2 = 100152
188
- GLU_TESS_ERROR3 = 100153
189
- GLU_TESS_ERROR4 = 100154
190
- GLU_TESS_ERROR5 = 100155
191
- GLU_TESS_ERROR6 = 100156
192
- GLU_TESS_ERROR7 = 100157
193
- GLU_TESS_ERROR8 = 100158
194
- GLU_TESS_MISSING_BEGIN_POLYGON = 100151
195
- GLU_TESS_MISSING_BEGIN_CONTOUR = 100152
196
- GLU_TESS_MISSING_END_POLYGON = 100153
197
- GLU_TESS_MISSING_END_CONTOUR = 100154
198
- GLU_TESS_COORD_TOO_LARGE = 100155
199
- GLU_TESS_NEED_COMBINE_CALLBACK = 100156
200
-
201
- # TessWinding
202
- GLU_TESS_WINDING_ODD = 100130
203
- GLU_TESS_WINDING_NONZERO = 100131
204
- GLU_TESS_WINDING_POSITIVE = 100132
205
- GLU_TESS_WINDING_NEGATIVE = 100133
206
- GLU_TESS_WINDING_ABS_GEQ_TWO = 100134
207
-
208
- GLU_TESS_MAX_COORD = 1.0e150
209
-
210
- # typedefs
211
- @@glu_cb_signature = {
212
- :NurbsCallback => "void CallBackFunc()",
213
- :QuadricCallback => "void CallBackFunc()",
214
- :TessCallback => "void CallBackFunc()",
215
- }
216
- def self.create_callback( sym, *opts, &blk )
217
- return bind( @@glu_cb_signature[sym], opts, &blk )
218
- end
219
-
220
- # struct
221
-
222
- @@glu_import_done = false
223
-
224
- # Load native library.
225
- def self.load_lib(lib_path = nil, output_error = false)
226
- if lib_path == nil
227
- lib_path = case GL.get_platform
228
- when :OPENGL_PLATFORM_WINDOWS
229
- 'C:/Windows/System32/GLU32.dll'
230
- when :OPENGL_PLATFORM_MACOSX
231
- '/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib'
232
- else
233
- 'libGLU.so' # not tested
234
- end
235
- end
236
-
237
- dlload(lib_path)
238
-
239
- import_symbols(output_error) unless @@glu_import_done
240
- end
241
-
242
- @@lib_signature = [
243
- 'void gluBeginCurve (void*)',
244
- 'void gluBeginPolygon (void*)',
245
- 'void gluBeginSurface (void*)',
246
- 'void gluBeginTrim (void*)',
247
- 'int32_t gluBuild1DMipmapLevels (uint32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*)', # Unavailable on Windows
248
- 'int32_t gluBuild1DMipmaps (uint32_t, int32_t, int32_t, uint32_t, uint32_t, void*)',
249
- 'int32_t gluBuild2DMipmapLevels (uint32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*)', # Unavailable on Windows
250
- 'int32_t gluBuild2DMipmaps (uint32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, void*)',
251
- 'int32_t gluBuild3DMipmapLevels (uint32_t, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*)', # Unavailable on Windows
252
- 'int32_t gluBuild3DMipmaps (uint32_t, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, void*)', # Unavailable on Windows
253
- 'uint8_t gluCheckExtension (uint8_t*, uint8_t*)', # Unavailable on Windows
254
- 'void gluCylinder (void*, double, double, double, int32_t, int32_t)',
255
- 'void gluDeleteNurbsRenderer (void*)',
256
- 'void gluDeleteQuadric (void*)',
257
- 'void gluDeleteTess (void*)',
258
- 'void gluDisk (void*, double, double, int32_t, int32_t)',
259
- 'void gluEndCurve (void*)',
260
- 'void gluEndPolygon (void*)',
261
- 'void gluEndSurface (void*)',
262
- 'void gluEndTrim (void*)',
263
- 'uint8_t* gluErrorString (uint32_t)',
264
- 'void gluGetNurbsProperty (void*, uint32_t, float*)',
265
- 'uint8_t* gluGetString (uint32_t)',
266
- 'void gluGetTessProperty (void*, uint32_t, double*)',
267
- 'void gluLoadSamplingMatrices (void*, float*, float*, int32_t*)',
268
- 'void gluLookAt (double, double, double, double, double, double, double, double, double)',
269
- 'void* gluNewNurbsRenderer ()',
270
- 'void* gluNewQuadric ()',
271
- 'void* gluNewTess ()',
272
- 'void gluNextContour (void*, uint32_t)',
273
- 'void gluNurbsCallback (void*, uint32_t, void*)',
274
- 'void gluNurbsCallbackData (void*, void*)', # Unavailable on Windows
275
- 'void gluNurbsCallbackDataEXT (void*, void*)', # Unavailable on Windows
276
- 'void gluNurbsCurve (void*, int32_t, float*, int32_t, float*, int32_t, uint32_t)',
277
- 'void gluNurbsProperty (void*, uint32_t, float)',
278
- 'void gluNurbsSurface (void*, int32_t, float*, int32_t, float*, int32_t, int32_t, float*, int32_t, int32_t, uint32_t)',
279
- 'void gluOrtho2D (double, double, double, double)',
280
- 'void gluPartialDisk (void*, double, double, int32_t, int32_t, double, double)',
281
- 'void gluPerspective (double, double, double, double)',
282
- 'void gluPickMatrix (double, double, double, double, int32_t*)',
283
- 'int32_t gluProject (double, double, double, double*, double*, int32_t*, double*, double*, double*)',
284
- 'void gluPwlCurve (void*, int32_t, float*, int32_t, uint32_t)',
285
- 'void gluQuadricCallback (void*, uint32_t, void*)',
286
- 'void gluQuadricDrawStyle (void*, uint32_t)',
287
- 'void gluQuadricNormals (void*, uint32_t)',
288
- 'void gluQuadricOrientation (void*, uint32_t)',
289
- 'void gluQuadricTexture (void*, uint8_t)',
290
- 'int32_t gluScaleImage (uint32_t, int32_t, int32_t, uint32_t, void*, int32_t, int32_t, uint32_t, void*)',
291
- 'void gluSphere (void*, double, int32_t, int32_t)',
292
- 'void gluTessBeginContour (void*)',
293
- 'void gluTessBeginPolygon (void*, void*)',
294
- 'void gluTessCallback (void*, uint32_t, void*)',
295
- 'void gluTessEndContour (void*)',
296
- 'void gluTessEndPolygon (void*)',
297
- 'void gluTessNormal (void*, double, double, double)',
298
- 'void gluTessProperty (void*, uint32_t, double)',
299
- 'void gluTessVertex (void*, double*, void*)',
300
- 'int32_t gluUnProject (double, double, double, double*, double*, int32_t*, double*, double*, double*)',
301
- 'int32_t gluUnProject4 (double, double, double, double, double*, double*, int32_t*, double, double, double*, double*, double*, double*)', # Unavailable on Windows
302
- ]
303
-
304
- def self.import_symbols(output_error = false)
305
-
306
- # function
307
- @@lib_signature.each do |sig|
308
- begin
309
- extern sig
310
- rescue
311
- $stderr.puts("[Warning] Failed to import #{sig}.") if output_error
312
- end
313
- end
314
-
315
- # Convert method names (e.g.: GLU.gluBeginCurve -> GLU.BeginCurve)
316
- self.singleton_methods(false).each do |method_name|
317
- m = singleton_method(method_name)
318
- if m.name.to_s.start_with? 'glu'
319
- modified_api = m.name.to_s[3..-1] # omit prefix "glu"
320
- define_singleton_method(modified_api, m) # define alias
321
- end
322
- end
323
-
324
- # Convert constant names (e.g.: GLU::GLU_TRUE -> GLU::TRUE)
325
- self.constants.each do |constant|
326
- cs = constant.to_s
327
- if cs[0..3] == "GLU_"
328
- if cs[4] =~ /\d/
329
- # We have to abandon name conversion like 'GL_2D, GL_3D_COLOR, GL_4_BYTES, etc.
330
- # Because constants can't start with a digit or underscore.
331
- # [Note] This rule has been inherited from Yoshi's very original ruby-opengl (confirmed with opengl-0.32g, 2004-07-17).
332
- else
333
- # Convert by omitting the 'GLU_' prefix
334
- const_set(cs[4..-1], GLU.const_get(constant))
335
- end
336
- end
337
- end
338
-
339
- @@glu_import_done = true
340
- end
341
-
342
- end
343
-
344
- =begin
345
- Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
346
- Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
347
-
348
- This software is provided 'as-is', without any express or implied
349
- warranty. In no event will the authors be held liable for any damages
350
- arising from the use of this software.
351
-
352
- Permission is granted to anyone to use this software for any purpose,
353
- including commercial applications, and to alter it and redistribute it
354
- freely, subject to the following restrictions:
355
-
356
- 1. The origin of this software must not be misrepresented; you must not
357
- claim that you wrote the original software. If you use this software
358
- in a product, an acknowledgment in the product documentation would be
359
- appreciated but is not required.
360
-
361
- 2. Altered source versions must be plainly marked as such, and must not be
362
- misrepresented as being the original software.
363
-
364
- 3. This notice may not be removed or altered from any source
365
- distribution.
366
- =end
1
+ # -*- coding: utf-8 -*-
2
+ require 'fiddle/import'
3
+ require_relative 'opengl_platform'
4
+
5
+ module GLU
6
+
7
+ extend Fiddle::Importer
8
+
9
+ # defines
10
+
11
+ # Extensions
12
+ GLU_EXT_object_space_tess = 1
13
+ GLU_EXT_nurbs_tessellator = 1
14
+
15
+ # Boolean
16
+ GLU_FALSE = 0
17
+ GLU_TRUE = 1
18
+
19
+ # Version
20
+ GLU_VERSION_1_1 = 1
21
+ GLU_VERSION_1_2 = 1
22
+ GLU_VERSION_1_3 = 1
23
+
24
+ # StringName
25
+ GLU_VERSION = 100800
26
+ GLU_EXTENSIONS = 100801
27
+
28
+ # ErrorCode
29
+ GLU_INVALID_ENUM = 100900
30
+ GLU_INVALID_VALUE = 100901
31
+ GLU_OUT_OF_MEMORY = 100902
32
+ GLU_INCOMPATIBLE_GL_VERSION = 100903
33
+ GLU_INVALID_OPERATION = 100904
34
+
35
+
36
+ # NurbsDisplay
37
+ # GLU_FILL
38
+ GLU_OUTLINE_POLYGON = 100240
39
+ GLU_OUTLINE_PATCH = 100241
40
+
41
+ # NurbsCallback
42
+ GLU_NURBS_ERROR = 100103
43
+ GLU_ERROR = 100103
44
+ GLU_NURBS_BEGIN = 100164
45
+ GLU_NURBS_BEGIN_EXT = 100164
46
+ GLU_NURBS_VERTEX = 100165
47
+ GLU_NURBS_VERTEX_EXT = 100165
48
+ GLU_NURBS_NORMAL = 100166
49
+ GLU_NURBS_NORMAL_EXT = 100166
50
+ GLU_NURBS_COLOR = 100167
51
+ GLU_NURBS_COLOR_EXT = 100167
52
+ GLU_NURBS_TEXTURE_COORD = 100168
53
+ GLU_NURBS_TEX_COORD_EXT = 100168
54
+ GLU_NURBS_END = 100169
55
+ GLU_NURBS_END_EXT = 100169
56
+ GLU_NURBS_BEGIN_DATA = 100170
57
+ GLU_NURBS_BEGIN_DATA_EXT = 100170
58
+ GLU_NURBS_VERTEX_DATA = 100171
59
+ GLU_NURBS_VERTEX_DATA_EXT = 100171
60
+ GLU_NURBS_NORMAL_DATA = 100172
61
+ GLU_NURBS_NORMAL_DATA_EXT = 100172
62
+ GLU_NURBS_COLOR_DATA = 100173
63
+ GLU_NURBS_COLOR_DATA_EXT = 100173
64
+ GLU_NURBS_TEXTURE_COORD_DATA = 100174
65
+ GLU_NURBS_TEX_COORD_DATA_EXT = 100174
66
+ GLU_NURBS_END_DATA = 100175
67
+ GLU_NURBS_END_DATA_EXT = 100175
68
+
69
+ # NurbsError
70
+ GLU_NURBS_ERROR1 = 100251 # spline order un-supported
71
+ GLU_NURBS_ERROR2 = 100252 # too few knots
72
+ GLU_NURBS_ERROR3 = 100253 # valid knot range is empty
73
+ GLU_NURBS_ERROR4 = 100254 # decreasing knot sequence
74
+ GLU_NURBS_ERROR5 = 100255 # knot multiplicity > spline order
75
+ GLU_NURBS_ERROR6 = 100256 # endcurve() must follow bgncurve()
76
+ GLU_NURBS_ERROR7 = 100257 # bgncurve() must precede endcurve()
77
+ GLU_NURBS_ERROR8 = 100258 # ctrlarray or knot vector is NULL
78
+ GLU_NURBS_ERROR9 = 100259 # can't draw pwlcurves
79
+ GLU_NURBS_ERROR10 = 100260 # missing gluNurbsCurve()
80
+ GLU_NURBS_ERROR11 = 100261 # missing gluNurbsSurface()
81
+ GLU_NURBS_ERROR12 = 100262 # endtrim() must precede endsurface()
82
+ GLU_NURBS_ERROR13 = 100263 # bgnsurface() must precede endsurface()
83
+ GLU_NURBS_ERROR14 = 100264 # curve of improper type passed as trim curve
84
+ GLU_NURBS_ERROR15 = 100265 # bgnsurface() must precede bgntrim()
85
+ GLU_NURBS_ERROR16 = 100266 # endtrim() must follow bgntrim()
86
+ GLU_NURBS_ERROR17 = 100267 # bgntrim() must precede endtrim()
87
+ GLU_NURBS_ERROR18 = 100268 # invalid or missing trim curve
88
+ GLU_NURBS_ERROR19 = 100269 # bgntrim() must precede pwlcurve()
89
+ GLU_NURBS_ERROR20 = 100270 # pwlcurve referenced twice
90
+ GLU_NURBS_ERROR21 = 100271 # pwlcurve and nurbscurve mixed
91
+ GLU_NURBS_ERROR22 = 100272 # improper usage of trim data type
92
+ GLU_NURBS_ERROR23 = 100273 # nurbscurve referenced twice
93
+ GLU_NURBS_ERROR24 = 100274 # nurbscurve and pwlcurve mixed
94
+ GLU_NURBS_ERROR25 = 100275 # nurbssurface referenced twice
95
+ GLU_NURBS_ERROR26 = 100276 # invalid property
96
+ GLU_NURBS_ERROR27 = 100277 # endsurface() must follow bgnsurface()
97
+ GLU_NURBS_ERROR28 = 100278 # intersecting or misoriented trim curves
98
+ GLU_NURBS_ERROR29 = 100279 # intersecting trim curves
99
+ GLU_NURBS_ERROR30 = 100280 # UNUSED
100
+ GLU_NURBS_ERROR31 = 100281 # unconnected trim curves
101
+ GLU_NURBS_ERROR32 = 100282 # unknown knot error
102
+ GLU_NURBS_ERROR33 = 100283 # negative vertex count encountered
103
+ GLU_NURBS_ERROR34 = 100284 # negative byte-stride
104
+ GLU_NURBS_ERROR35 = 100285 # unknown type descriptor
105
+ GLU_NURBS_ERROR36 = 100286 # null control point reference
106
+ GLU_NURBS_ERROR37 = 100287 # duplicate point on pwlcurve
107
+
108
+ # NurbsProperty
109
+ GLU_AUTO_LOAD_MATRIX = 100200
110
+ GLU_CULLING = 100201
111
+ GLU_SAMPLING_TOLERANCE = 100203
112
+ GLU_DISPLAY_MODE = 100204
113
+ GLU_PARAMETRIC_TOLERANCE = 100202
114
+ GLU_SAMPLING_METHOD = 100205
115
+ GLU_U_STEP = 100206
116
+ GLU_V_STEP = 100207
117
+ GLU_NURBS_MODE = 100160
118
+ GLU_NURBS_MODE_EXT = 100160
119
+ GLU_NURBS_TESSELLATOR = 100161
120
+ GLU_NURBS_TESSELLATOR_EXT = 100161
121
+ GLU_NURBS_RENDERER = 100162
122
+ GLU_NURBS_RENDERER_EXT = 100162
123
+
124
+ # NurbsSampling
125
+ GLU_OBJECT_PARAMETRIC_ERROR = 100208
126
+ GLU_OBJECT_PARAMETRIC_ERROR_EXT = 100208
127
+ GLU_OBJECT_PATH_LENGTH = 100209
128
+ GLU_OBJECT_PATH_LENGTH_EXT = 100209
129
+ GLU_PATH_LENGTH = 100215
130
+ GLU_PARAMETRIC_ERROR = 100216
131
+ GLU_DOMAIN_DISTANCE = 100217
132
+
133
+ # NurbsTrim
134
+ GLU_MAP1_TRIM_2 = 100210
135
+ GLU_MAP1_TRIM_3 = 100211
136
+
137
+ # QuadricDrawStyle
138
+ GLU_POINT = 100010
139
+ GLU_LINE = 100011
140
+ GLU_FILL = 100012
141
+ GLU_SILHOUETTE = 100013
142
+
143
+ # QuadricCallback
144
+ # GLU_ERROR
145
+
146
+ # QuadricNormal
147
+ GLU_SMOOTH = 100000
148
+ GLU_FLAT = 100001
149
+ GLU_NONE = 100002
150
+
151
+ # QuadricOrientation
152
+ GLU_OUTSIDE = 100020
153
+ GLU_INSIDE = 100021
154
+
155
+ # TessCallback
156
+ GLU_TESS_BEGIN = 100100
157
+ GLU_BEGIN = 100100
158
+ GLU_TESS_VERTEX = 100101
159
+ GLU_VERTEX = 100101
160
+ GLU_TESS_END = 100102
161
+ GLU_END = 100102
162
+ GLU_TESS_ERROR = 100103
163
+ GLU_TESS_EDGE_FLAG = 100104
164
+ GLU_EDGE_FLAG = 100104
165
+ GLU_TESS_COMBINE = 100105
166
+ GLU_TESS_BEGIN_DATA = 100106
167
+ GLU_TESS_VERTEX_DATA = 100107
168
+ GLU_TESS_END_DATA = 100108
169
+ GLU_TESS_ERROR_DATA = 100109
170
+ GLU_TESS_EDGE_FLAG_DATA = 100110
171
+ GLU_TESS_COMBINE_DATA = 100111
172
+
173
+ # TessContour
174
+ GLU_CW = 100120
175
+ GLU_CCW = 100121
176
+ GLU_INTERIOR = 100122
177
+ GLU_EXTERIOR = 100123
178
+ GLU_UNKNOWN = 100124
179
+
180
+ # TessProperty
181
+ GLU_TESS_WINDING_RULE = 100140
182
+ GLU_TESS_BOUNDARY_ONLY = 100141
183
+ GLU_TESS_TOLERANCE = 100142
184
+
185
+ # TessError
186
+ GLU_TESS_ERROR1 = 100151
187
+ GLU_TESS_ERROR2 = 100152
188
+ GLU_TESS_ERROR3 = 100153
189
+ GLU_TESS_ERROR4 = 100154
190
+ GLU_TESS_ERROR5 = 100155
191
+ GLU_TESS_ERROR6 = 100156
192
+ GLU_TESS_ERROR7 = 100157
193
+ GLU_TESS_ERROR8 = 100158
194
+ GLU_TESS_MISSING_BEGIN_POLYGON = 100151
195
+ GLU_TESS_MISSING_BEGIN_CONTOUR = 100152
196
+ GLU_TESS_MISSING_END_POLYGON = 100153
197
+ GLU_TESS_MISSING_END_CONTOUR = 100154
198
+ GLU_TESS_COORD_TOO_LARGE = 100155
199
+ GLU_TESS_NEED_COMBINE_CALLBACK = 100156
200
+
201
+ # TessWinding
202
+ GLU_TESS_WINDING_ODD = 100130
203
+ GLU_TESS_WINDING_NONZERO = 100131
204
+ GLU_TESS_WINDING_POSITIVE = 100132
205
+ GLU_TESS_WINDING_NEGATIVE = 100133
206
+ GLU_TESS_WINDING_ABS_GEQ_TWO = 100134
207
+
208
+ GLU_TESS_MAX_COORD = 1.0e150
209
+
210
+ # typedefs
211
+ @@glu_cb_signature = {
212
+ :NurbsCallback => "void CallBackFunc()",
213
+ :QuadricCallback => "void CallBackFunc()",
214
+ :TessCallback => "void CallBackFunc()",
215
+ }
216
+ def self.create_callback(sym, *opts, &blk)
217
+ return bind(@@glu_cb_signature[sym], opts, &blk)
218
+ end
219
+
220
+ # struct
221
+
222
+ @@glu_import_done = false
223
+
224
+ # Load native library.
225
+ def self.load_lib(lib_path = nil, output_error = false)
226
+ if lib_path == nil
227
+ lib_path = case GL.get_platform
228
+ when :OPENGL_PLATFORM_WINDOWS
229
+ 'C:/Windows/System32/GLU32.dll'
230
+ when :OPENGL_PLATFORM_MACOSX
231
+ '/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib'
232
+ else
233
+ 'libGLU.so' # not tested
234
+ end
235
+ end
236
+
237
+ dlload(lib_path)
238
+
239
+ import_symbols(output_error) unless @@glu_import_done
240
+ end
241
+
242
+ @@lib_signature = [
243
+ 'void gluBeginCurve (void*)',
244
+ 'void gluBeginPolygon (void*)',
245
+ 'void gluBeginSurface (void*)',
246
+ 'void gluBeginTrim (void*)',
247
+ 'int32_t gluBuild1DMipmapLevels (uint32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*)', # Unavailable on Windows
248
+ 'int32_t gluBuild1DMipmaps (uint32_t, int32_t, int32_t, uint32_t, uint32_t, void*)',
249
+ 'int32_t gluBuild2DMipmapLevels (uint32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*)', # Unavailable on Windows
250
+ 'int32_t gluBuild2DMipmaps (uint32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, void*)',
251
+ 'int32_t gluBuild3DMipmapLevels (uint32_t, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*)', # Unavailable on Windows
252
+ 'int32_t gluBuild3DMipmaps (uint32_t, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, void*)', # Unavailable on Windows
253
+ 'uint8_t gluCheckExtension (uint8_t*, uint8_t*)', # Unavailable on Windows
254
+ 'void gluCylinder (void*, double, double, double, int32_t, int32_t)',
255
+ 'void gluDeleteNurbsRenderer (void*)',
256
+ 'void gluDeleteQuadric (void*)',
257
+ 'void gluDeleteTess (void*)',
258
+ 'void gluDisk (void*, double, double, int32_t, int32_t)',
259
+ 'void gluEndCurve (void*)',
260
+ 'void gluEndPolygon (void*)',
261
+ 'void gluEndSurface (void*)',
262
+ 'void gluEndTrim (void*)',
263
+ 'uint8_t* gluErrorString (uint32_t)',
264
+ 'void gluGetNurbsProperty (void*, uint32_t, float*)',
265
+ 'uint8_t* gluGetString (uint32_t)',
266
+ 'void gluGetTessProperty (void*, uint32_t, double*)',
267
+ 'void gluLoadSamplingMatrices (void*, float*, float*, int32_t*)',
268
+ 'void gluLookAt (double, double, double, double, double, double, double, double, double)',
269
+ 'void* gluNewNurbsRenderer ()',
270
+ 'void* gluNewQuadric ()',
271
+ 'void* gluNewTess ()',
272
+ 'void gluNextContour (void*, uint32_t)',
273
+ 'void gluNurbsCallback (void*, uint32_t, void*)',
274
+ 'void gluNurbsCallbackData (void*, void*)', # Unavailable on Windows
275
+ 'void gluNurbsCallbackDataEXT (void*, void*)', # Unavailable on Windows
276
+ 'void gluNurbsCurve (void*, int32_t, float*, int32_t, float*, int32_t, uint32_t)',
277
+ 'void gluNurbsProperty (void*, uint32_t, float)',
278
+ 'void gluNurbsSurface (void*, int32_t, float*, int32_t, float*, int32_t, int32_t, float*, int32_t, int32_t, uint32_t)',
279
+ 'void gluOrtho2D (double, double, double, double)',
280
+ 'void gluPartialDisk (void*, double, double, int32_t, int32_t, double, double)',
281
+ 'void gluPerspective (double, double, double, double)',
282
+ 'void gluPickMatrix (double, double, double, double, int32_t*)',
283
+ 'int32_t gluProject (double, double, double, double*, double*, int32_t*, double*, double*, double*)',
284
+ 'void gluPwlCurve (void*, int32_t, float*, int32_t, uint32_t)',
285
+ 'void gluQuadricCallback (void*, uint32_t, void*)',
286
+ 'void gluQuadricDrawStyle (void*, uint32_t)',
287
+ 'void gluQuadricNormals (void*, uint32_t)',
288
+ 'void gluQuadricOrientation (void*, uint32_t)',
289
+ 'void gluQuadricTexture (void*, uint8_t)',
290
+ 'int32_t gluScaleImage (uint32_t, int32_t, int32_t, uint32_t, void*, int32_t, int32_t, uint32_t, void*)',
291
+ 'void gluSphere (void*, double, int32_t, int32_t)',
292
+ 'void gluTessBeginContour (void*)',
293
+ 'void gluTessBeginPolygon (void*, void*)',
294
+ 'void gluTessCallback (void*, uint32_t, void*)',
295
+ 'void gluTessEndContour (void*)',
296
+ 'void gluTessEndPolygon (void*)',
297
+ 'void gluTessNormal (void*, double, double, double)',
298
+ 'void gluTessProperty (void*, uint32_t, double)',
299
+ 'void gluTessVertex (void*, double*, void*)',
300
+ 'int32_t gluUnProject (double, double, double, double*, double*, int32_t*, double*, double*, double*)',
301
+ 'int32_t gluUnProject4 (double, double, double, double, double*, double*, int32_t*, double, double, double*, double*, double*, double*)', # Unavailable on Windows
302
+ ]
303
+
304
+ def self.import_symbols(output_error = false)
305
+
306
+ # function
307
+ @@lib_signature.each do |sig|
308
+ begin
309
+ extern sig
310
+ rescue
311
+ $stderr.puts("[Warning] Failed to import #{sig}.") if output_error
312
+ end
313
+ end
314
+
315
+ # Convert method names (e.g.: GLU.gluBeginCurve -> GLU.BeginCurve)
316
+ self.singleton_methods(false).each do |method_name|
317
+ m = singleton_method(method_name)
318
+ if m.name.to_s.start_with? 'glu'
319
+ modified_api = m.name.to_s[3..-1] # omit prefix "glu"
320
+ define_singleton_method(modified_api, m) # define alias
321
+ end
322
+ end
323
+
324
+ # Convert constant names (e.g.: GLU::GLU_TRUE -> GLU::TRUE)
325
+ self.constants.each do |constant|
326
+ cs = constant.to_s
327
+ if cs[0..3] == "GLU_"
328
+ if cs[4] =~ /\d/
329
+ # We have to abandon name conversion like 'GL_2D, GL_3D_COLOR, GL_4_BYTES, etc.
330
+ # Because constants can't start with a digit or underscore.
331
+ # [Note] This rule has been inherited from Yoshi's very original ruby-opengl (confirmed with opengl-0.32g, 2004-07-17).
332
+ else
333
+ # Convert by omitting the 'GLU_' prefix
334
+ const_set(cs[4..-1], GLU.const_get(constant))
335
+ end
336
+ end
337
+ end
338
+
339
+ @@glu_import_done = true
340
+ end
341
+
342
+ end
343
+
344
+ =begin
345
+ Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
346
+ Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
347
+
348
+ This software is provided 'as-is', without any express or implied
349
+ warranty. In no event will the authors be held liable for any damages
350
+ arising from the use of this software.
351
+
352
+ Permission is granted to anyone to use this software for any purpose,
353
+ including commercial applications, and to alter it and redistribute it
354
+ freely, subject to the following restrictions:
355
+
356
+ 1. The origin of this software must not be misrepresented; you must not
357
+ claim that you wrote the original software. If you use this software
358
+ in a product, an acknowledgment in the product documentation would be
359
+ appreciated but is not required.
360
+
361
+ 2. Altered source versions must be plainly marked as such, and must not be
362
+ misrepresented as being the original software.
363
+
364
+ 3. This notice may not be removed or altered from any source
365
+ distribution.
366
+ =end