glu 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b3da7761fa955e769b6300af459d27e5b5f0457
4
+ data.tar.gz: 3f5a02de19bf9d2e82efa73233f1b49dc94b8f4f
5
+ SHA512:
6
+ metadata.gz: ef209e8f452de58fa14982d4fa910dd3cb08b1740ef4671e991b8dc4d0ac72b98dc9172842cf273ce05d99dd910474c52632e5ab43914e25c4ca6d3c54c60b54
7
+ data.tar.gz: d173734ada37fa4ebbae1a2a94c093a7fb5592b25803edaeebcaf158128395a51d2a362aab19200ad249f444e990d7ca51ddf8b9f2164359505346a579afc743
@@ -0,0 +1,29 @@
1
+ require 'autotest/restart'
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.add_exception /\.git/
5
+ at.add_exception /doc/
6
+ at.add_exception /examples/
7
+ at.add_exception /utils/
8
+ at.add_exception /website/
9
+
10
+ at.add_mapping(/^lib\/.*(\.bundle|so|dll)$/) do |filename, match|
11
+ possible = File.basename(filename, match[1])
12
+ at.files_matching %r%^test/test_#{possible}%
13
+ end
14
+
15
+ def at.path_to_classname s
16
+ sep = File::SEPARATOR
17
+ n = s.sub(/^test#{sep}test_(.*)\.rb/, '\1')
18
+ c = if n =~ /^(glu?)_?(.*)/ then
19
+ "#{$1.capitalize}#{$2.split(/_|(\d+)/).map { |seg| seg.capitalize }.join}"
20
+ end
21
+
22
+ "Test#{c}"
23
+ end
24
+ end
25
+
26
+ Autotest.add_hook :run_command do |at|
27
+ at.unit_diff = 'cat'
28
+ system Gem.ruby, Gem.bin_path('rake', 'rake'), 'compile'
29
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ *.swp
2
+ /TAGS
3
+ /lib/glu/*.so
4
+ /lib/glu/*.bundle
5
+ /pkg
6
+ /tmp
@@ -0,0 +1,3 @@
1
+ == 8.1.0
2
+
3
+ Split Glu into a separate gem.
@@ -0,0 +1,18 @@
1
+
2
+ Permission is hereby granted, free of charge, to any person obtaining a
3
+ copy of this software and associated documentation files (the "Software"),
4
+ to deal in the Software without restriction, including without limitation
5
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
6
+ and/or sell copies of the Software, and to permit persons to whom the
7
+ Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in
10
+ all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ .autotest
2
+ .gemtest
3
+ .gitignore
4
+ History.rdoc
5
+ MIT-LICENSE
6
+ Manifest.txt
7
+ README.rdoc
8
+ Rakefile
9
+ ext/glu/common.h
10
+ ext/glu/conv.h
11
+ ext/glu/extconf.rb
12
+ ext/glu/glu-enums.c
13
+ ext/glu/glu-enums.h
14
+ ext/glu/glu.c
15
+ lib/glu.rb
16
+ lib/glu/dummy.rb
17
+ test/test_glu.rb
@@ -0,0 +1,36 @@
1
+ = glu
2
+
3
+ == Description
4
+
5
+ Glu bindings for the opengl gem, split into a separate gem because of Glu deprecation.
6
+
7
+ == License
8
+
9
+ (The MIT License)
10
+
11
+ Copyright (c) Blaž Hrastnik (current maintainer)
12
+ Copyright (c) Eric Hodel (current maintainer)
13
+ Copyright (c) Alain Hoang (previous maintainer)
14
+ Copyright (c) Jan Dvorak (contributor)
15
+ Copyright (c) Minh Thu Vo (contributor)
16
+ Copyright (c) James Adam (contributor)
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining
19
+ a copy of this software and associated documentation files (the
20
+ 'Software'), to deal in the Software without restriction, including
21
+ without limitation the rights to use, copy, modify, merge, publish,
22
+ distribute, sublicense, and/or sell copies of the Software, and to
23
+ permit persons to whom the Software is furnished to do so, subject to
24
+ the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be
27
+ included in all copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
30
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
33
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
34
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
35
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36
+
@@ -0,0 +1,48 @@
1
+ #-*-ruby-*-
2
+ #
3
+ # Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
+ # Copyright (C) Eric Hodel <drbrain@segment7.net>
5
+ #
6
+ # This program is distributed under the terms of the MIT license.
7
+ # See the included MIT-LICENSE file for the terms of this license.
8
+ #
9
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
12
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
13
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+
17
+ require 'hoe'
18
+ require 'rake/extensiontask'
19
+
20
+ hoe = Hoe.spec 'glu' do
21
+ developer 'Eric Hodel', 'drbrain@segment7.net'
22
+ developer 'Lars Kanis', ''
23
+ developer 'Blaž Hrastnik', 'speed.the.bboy@gmail.com'
24
+ developer 'Alain Hoang', ''
25
+ developer 'Jan Dvorak', ''
26
+ developer 'Minh Thu Vo', ''
27
+ developer 'James Adam', ''
28
+
29
+ self.readme_file = 'README.rdoc'
30
+ self.history_file = 'History.rdoc'
31
+ self.extra_rdoc_files = FileList['*.rdoc']
32
+
33
+ extra_dev_deps << ['rake-compiler', '~> 0.7', '>= 0.7.9']
34
+
35
+ self.spec_extras = {
36
+ :extensions => %w[ext/glu/extconf.rb],
37
+ :required_ruby_version => '>= 1.9.2',
38
+ }
39
+ end
40
+
41
+ Rake::ExtensionTask.new 'glu', hoe.spec do |ext|
42
+ ext.lib_dir = 'lib/glu'
43
+
44
+ ext.cross_compile = true
45
+ ext.cross_platform = ['i386-mingw32']
46
+ end
47
+
48
+ task :test => :compile
@@ -0,0 +1,218 @@
1
+ /*
2
+ * Last edit by previous maintainer:
3
+ * 2000/01/06 16:37:43, kusano
4
+ *
5
+ * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
6
+ * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
7
+ * Copyright (C) 2007 James Adam <james@lazyatom.com>
8
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
9
+ *
10
+ * This program is distributed under the terms of the MIT license.
11
+ * See the included MIT-LICENSE file for the terms of this license.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ */
21
+
22
+ #ifndef _COMMON_H_
23
+ #define _COMMON_H_
24
+
25
+ #include <ruby.h>
26
+ #include "extconf.h"
27
+
28
+ #ifdef HAVE_OPENGL_GLU_H
29
+ #include <OpenGL/glu.h>
30
+ #endif
31
+
32
+ #ifdef HAVE_GL_GLU_H
33
+ #include <GL/glu.h>
34
+ #endif
35
+
36
+ #include "glu-enums.h"
37
+ #include "conv.h"
38
+
39
+ #ifndef CALLBACK
40
+ #define CALLBACK
41
+ #endif
42
+
43
+ #ifdef HAVE_WINDOWS_H
44
+ #define DLLEXPORT __declspec(dllexport)
45
+ #else
46
+ #define DLLEXPORT
47
+ #endif
48
+
49
+ /* these two macros are cast to a 32 bit type in the places they are used */
50
+ #ifndef RARRAY_LENINT
51
+ #define RARRAY_LENINT RARRAY_LEN
52
+ #endif
53
+
54
+ /* -------------------------------------------------------------------- */
55
+
56
+ /* gets number of components for given format */
57
+ static inline int glformat_size(GLenum format)
58
+ {
59
+ switch(format)
60
+ {
61
+ case GL_COLOR_INDEX:
62
+ case GL_RED:
63
+ case GL_GREEN:
64
+ case GL_BLUE:
65
+ case GL_ALPHA:
66
+ case GL_RED_INTEGER_EXT:
67
+ case GL_GREEN_INTEGER_EXT:
68
+ case GL_BLUE_INTEGER_EXT:
69
+ case GL_ALPHA_INTEGER_EXT:
70
+ case GL_STENCIL_INDEX:
71
+ case GL_DEPTH_COMPONENT:
72
+ case GL_LUMINANCE:
73
+ case GL_LUMINANCE_INTEGER_EXT:
74
+ return 1;
75
+
76
+ case GL_LUMINANCE_ALPHA:
77
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
78
+ case GL_422_EXT:
79
+ case GL_422_REV_EXT:
80
+ case GL_422_AVERAGE_EXT:
81
+ case GL_422_REV_AVERAGE_EXT:
82
+ case GL_YCRCB_422_SGIX:
83
+ case GL_YCBCR_422_APPLE:
84
+ case GL_YCBCR_MESA:
85
+ case GL_DEPTH_STENCIL_NV:
86
+ case GL_HILO_NV:
87
+ case GL_DSDT_NV:
88
+ case GL_DUDV_ATI:
89
+ case GL_DU8DV8_ATI:
90
+ case GL_FORMAT_SUBSAMPLE_24_24_OML:
91
+ return 2;
92
+
93
+ case GL_RGB:
94
+ case GL_RGB_INTEGER_EXT:
95
+ case GL_BGR_EXT:
96
+ case GL_BGR_INTEGER_EXT:
97
+ case GL_YCRCB_444_SGIX:
98
+ case GL_DSDT_MAG_NV:
99
+ case GL_FORMAT_SUBSAMPLE_244_244_OML:
100
+ return 3;
101
+
102
+ case GL_RGBA:
103
+ case GL_RGBA_INTEGER_EXT:
104
+ case GL_BGRA_EXT:
105
+ case GL_BGRA_INTEGER_EXT:
106
+ case GL_ABGR_EXT:
107
+ case GL_CMYK_EXT:
108
+ case GL_DSDT_MAG_VIB_NV:
109
+ return 4;
110
+
111
+ case GL_CMYKA_EXT:
112
+ return 5;
113
+
114
+ /* GL spec permits passing direct format size instead of enum (now obsolete) */
115
+ case 1:
116
+ case 2:
117
+ case 3:
118
+ case 4:
119
+ return format;
120
+
121
+ default:
122
+ rb_raise(rb_eArgError, "Unknown GL format enum %i",format);
123
+ return -1; /* not reached */
124
+ }
125
+ }
126
+
127
+ /* computes unit (pixel) size for given type and format */
128
+ static inline int gltype_glformat_unit_size(GLenum type,GLenum format)
129
+ {
130
+ unsigned int format_size;
131
+
132
+ format_size = glformat_size(format);
133
+
134
+ switch(type)
135
+ {
136
+ case GL_BYTE:
137
+ case GL_UNSIGNED_BYTE:
138
+ case GL_BITMAP:
139
+ return 1*format_size;
140
+
141
+ case GL_SHORT:
142
+ case GL_UNSIGNED_SHORT:
143
+ case GL_HALF_FLOAT_ARB:
144
+ return 2*format_size;
145
+
146
+ case GL_INT:
147
+ case GL_UNSIGNED_INT:
148
+ case GL_FLOAT:
149
+ return 4*format_size;
150
+
151
+ /* in packed formats all components are packed into/unpacked from single datatype,
152
+ so number of components(format_size) doesn't matter for total size calculation */
153
+ case GL_UNSIGNED_BYTE_3_3_2:
154
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
155
+ return 1;
156
+
157
+ case GL_UNSIGNED_SHORT_5_6_5:
158
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
159
+ case GL_UNSIGNED_SHORT_4_4_4_4:
160
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
161
+ case GL_UNSIGNED_SHORT_5_5_5_1:
162
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
163
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
164
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
165
+ return 2;
166
+
167
+ case GL_UNSIGNED_INT_8_8_8_8:
168
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
169
+ case GL_UNSIGNED_INT_10_10_10_2:
170
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
171
+ case GL_UNSIGNED_INT_24_8_NV:
172
+ case GL_UNSIGNED_INT_S8_S8_8_8_NV:
173
+ case GL_UNSIGNED_INT_8_8_S8_S8_REV_NV:
174
+ case GL_UNSIGNED_INT_10F_11F_11F_REV_EXT:
175
+ case GL_UNSIGNED_INT_5_9_9_9_REV_EXT:
176
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV:
177
+ return 4;
178
+
179
+ default:
180
+ rb_raise(rb_eArgError, "Unknown GL type enum %i",type);
181
+ return -1; /* not reached */
182
+ }
183
+ }
184
+
185
+ static inline int GetDataSize(GLenum type,GLenum format,int num)
186
+ {
187
+ int size;
188
+ int unit_size;
189
+
190
+ unit_size = gltype_glformat_unit_size(type,format);
191
+
192
+ if (type==GL_BITMAP)
193
+ size = unit_size*(num/8); /* FIXME account for alignment */
194
+ else
195
+ size = unit_size*num;
196
+
197
+ return size;
198
+ }
199
+
200
+ /* Checks if data size of 'data' string confirms to passed format values */
201
+ /* 'num' is number of elements, each of size 'format' * 'type' */
202
+ static inline void CheckDataSize(GLenum type,GLenum format,int num,VALUE data)
203
+ {
204
+ int size;
205
+
206
+ size = GetDataSize(type,format,num);
207
+
208
+ if (RSTRING_LEN(data) < size)
209
+ rb_raise(rb_eArgError, "Length of specified data doesn't correspond to format and type parameters passed. Calculated length: %i",size);
210
+ }
211
+
212
+ /* -------------------------------------------------------------------- */
213
+ static inline VALUE allocate_buffer_with_string( long size )
214
+ {
215
+ return rb_str_new(NULL, size);
216
+ }
217
+
218
+ #endif
@@ -0,0 +1,145 @@
1
+ /*
2
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
+ *
4
+ * This program is distributed under the terms of the MIT license.
5
+ * See the included MIT-LICENSE file for the terms of this license.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+
16
+ /* Functions and macros for datatype conversion between Ruby and C */
17
+
18
+ /*
19
+ Fast inline conversion functions as a replacement for the ones in libruby.
20
+ FIXNUM_P is simple logical AND check so it comes first, TYPE() is simple function,
21
+ and specified in header file so it can be inlined. For conversion, FIX2LONG is
22
+ simple right shift, and RFLOAT()-> just pointer dereference. For converting
23
+ Fixnum and Float types (which accounts for 99.9% of things you would want to pass
24
+ to OpenGL), there is large performance boost as result.
25
+
26
+ Also ruby 'true' and 'false' are converted to GL_TRUE/GL_FALSE for compatibility, and
27
+ finally, we fallback to library functions for any other data types (and error handling).
28
+ */
29
+
30
+ #if HAVE_STRUCT_RFLOAT_FLOAT_VALUE
31
+ #define FLOAT_VAL_ACCESS(val) RFLOAT(val)->float_value
32
+ #else
33
+ #define FLOAT_VAL_ACCESS(val) RFLOAT(val)->value
34
+ #endif
35
+
36
+ /* For conversion between ruby and GL boolean values */
37
+ #define GLBOOL2RUBY(x) \
38
+ (x) == GL_TRUE ? Qtrue : ((x)==GL_FALSE ? Qfalse : INT2NUM((x)))
39
+
40
+ #define RUBYBOOL2GL(x) \
41
+ (x) == Qtrue ? GL_TRUE : GL_FALSE
42
+
43
+ #define cond_GLBOOL2RUBY_FUNC(_name_,_type_,_conv_) \
44
+ static inline VALUE _name_(GLenum pname,_type_ value) \
45
+ { \
46
+ switch (pname) { \
47
+ case GL_DELETE_STATUS: \
48
+ case GL_LINK_STATUS: \
49
+ case GL_VALIDATE_STATUS: \
50
+ case GL_COMPILE_STATUS: \
51
+ case GL_MINMAX_SINK: \
52
+ case GL_HISTOGRAM_SINK: \
53
+ case GL_COORD_REPLACE: \
54
+ case GL_TEXTURE_COMPRESSED: \
55
+ case GL_GENERATE_MIPMAP: \
56
+ case GL_TEXTURE_RESIDENT: \
57
+ case GL_BUFFER_MAPPED: \
58
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: \
59
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED: \
60
+ case GL_QUERY_RESULT_AVAILABLE: \
61
+ case GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB: \
62
+ case GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT: \
63
+ case GL_FENCE_STATUS_NV: \
64
+ case GL_TEXTURE_FLOAT_COMPONENTS_NV: \
65
+ case GL_SHADER_CONSISTENT_NV: \
66
+ case GL_TEXTURE_COMPARE_SGIX: \
67
+ case GLU_TESS_BOUNDARY_ONLY: \
68
+ case GLU_CULLING: \
69
+ case GLU_AUTO_LOAD_MATRIX: \
70
+ return GLBOOL2RUBY(value); \
71
+ default: \
72
+ return _conv_(value); \
73
+ } \
74
+ }
75
+
76
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY,GLint,INT2NUM)
77
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY_U,GLuint,UINT2NUM)
78
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY_LL,GLint64EXT,LL2NUM)
79
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY_ULL,GLuint64EXT,ULL2NUM)
80
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY_F,GLfloat,rb_float_new)
81
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY_D,GLdouble,rb_float_new)
82
+
83
+
84
+ /* For conversion between ruby array (or object that can be converted to
85
+ * array) and C array.
86
+ *
87
+ * The C array has to be preallocated by calling function. */
88
+ #define ARY2CTYPE(_type_,_convert_) \
89
+ static inline long ary2c##_type_( arg, cary, maxlen ) \
90
+ VALUE arg; \
91
+ GL##_type_ cary[]; \
92
+ long maxlen; \
93
+ { \
94
+ long i; \
95
+ VALUE ary = rb_Array(arg); \
96
+ if (maxlen < 1) \
97
+ maxlen = RARRAY_LEN(ary); \
98
+ else \
99
+ maxlen = maxlen < RARRAY_LEN(ary) ? maxlen : RARRAY_LEN(ary); \
100
+ for (i=0; i < maxlen; i++) \
101
+ cary[i] = (GL##_type_)_convert_(rb_ary_entry(ary,i)); \
102
+ return i; \
103
+ }
104
+
105
+ ARY2CTYPE(int,NUM2INT)
106
+ ARY2CTYPE(uint,NUM2UINT)
107
+ ARY2CTYPE(byte,NUM2INT)
108
+ ARY2CTYPE(ubyte,NUM2INT)
109
+ ARY2CTYPE(short,NUM2INT)
110
+ ARY2CTYPE(ushort,NUM2INT)
111
+ ARY2CTYPE(boolean,GLBOOL2RUBY)
112
+ ARY2CTYPE(float,NUM2DBL)
113
+ ARY2CTYPE(double,NUM2DBL)
114
+
115
+ #define ary2cflt ary2cfloat
116
+ #define ary2cdbl ary2cdouble
117
+
118
+ #undef ARY2CTYPE
119
+
120
+ /* Converts either array or object responding to #to_a to C-style array */
121
+ #define ARY2CMAT(_type_) \
122
+ static inline void ary2cmat##_type_(rary, cary, cols, rows) \
123
+ VALUE rary; \
124
+ _type_ cary[]; \
125
+ int cols,rows; \
126
+ { \
127
+ int i; \
128
+ \
129
+ rary = rb_Array(rary); \
130
+ rary = rb_funcall(rary,rb_intern("flatten"),0); \
131
+ \
132
+ if (RARRAY_LEN(rary) != cols*rows) \
133
+ rb_raise(rb_eArgError, "passed array/matrix must have %i*%i elements",cols,rows); \
134
+ \
135
+ for (i=0; i < cols*rows; i++) \
136
+ cary[i] = (_type_) NUM2DBL(rb_ary_entry(rary,i)); \
137
+ }
138
+
139
+ ARY2CMAT(double)
140
+ ARY2CMAT(float)
141
+ #undef ARY2CMAT
142
+
143
+ #define EMPTY
144
+ #define FREE(_x_) xfree(_x_);
145
+