glu2 8.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 769c11fab55c92ec10a88c9d5cb902a50875fef7189c49cb0bcb34ce1790f65a
4
+ data.tar.gz: b86cbbd8bd26933822f6bbcd5439df7bd2ba03e3eea8640de9ab58bae4150ac2
5
+ SHA512:
6
+ metadata.gz: 2da32f46f3fc2bf32ec077b3652aecdeeebffb0542a607b6622ef73c45290ae3b3fc7126578423aea572abb9fe42ebc6d5aa3d3de460498f272aea3ebb05be8f
7
+ data.tar.gz: af43b67c94f0d9e2d0b245e7f30d5f49bbd63e943072ae24b2e5bf36c4bcff218a60e3f70005c8a79ccc48c1be826416d2d54cabca85b7825f630c16b45b508e
data/.autotest ADDED
@@ -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
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.swp
2
+ /TAGS
3
+ /lib/glu/*.so
4
+ /lib/glu/*.bundle
5
+ /pkg
6
+ /tmp
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ # - "1.9.3"
4
+ - "2.0.0"
5
+ # - jruby-19mode # JRuby in 1.9 mode
6
+ # - rbx-19mode
7
+ before_install:
8
+ - gem install hoe rake-compiler;
9
+ - sudo apt-get install xpra xserver-xorg-video-dummy freeglut3-dev;
10
+ before_script:
11
+ - "xpra --xvfb=\"Xorg +extension GLX -config `pwd`/test/dummy.xorg.conf -logfile ${HOME}/.xpra/xorg.log\" start :9"
12
+ script: "env DISPLAY=:9 rake test"
13
+ after_script:
14
+ - "xpra stop :9"
15
+ - "cat ~/.xpra/*"
data/History.rdoc ADDED
@@ -0,0 +1,25 @@
1
+ === 8.4.0 / 2024-09-08
2
+
3
+ * Support ruby-3.3
4
+
5
+ === 8.3.0 / 2017-06-25
6
+
7
+ * Support ruby-2.0 to 2.4 with binary windows gems.
8
+
9
+ === 8.2.2 / 2016-01-21
10
+
11
+ * Add ruby-2.2 and 2.3 to binary windows gems.
12
+
13
+ === 8.2.1 / 2014-10-06
14
+
15
+ * Add ruby-2.1 to binary windows gems.
16
+ * Fix build on OSX
17
+
18
+ === 8.2.0 / 2014-03-14
19
+
20
+ * Add x64-mingw platform for cross build and add ruby-2.0.0 to binary gems.
21
+ * Don't pollute the global namespace. Use GLU namespace.
22
+
23
+ === 8.1.0 / 2013-03-03
24
+
25
+ Split Glu into a separate gem.
data/MIT-LICENSE ADDED
@@ -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.
data/Manifest.txt ADDED
@@ -0,0 +1,20 @@
1
+ .autotest
2
+ .gemtest
3
+ .gitignore
4
+ .travis.yml
5
+ History.rdoc
6
+ MIT-LICENSE
7
+ Manifest.txt
8
+ README.rdoc
9
+ Rakefile
10
+ ext/glu/common.h
11
+ ext/glu/conv.h
12
+ ext/glu/extconf.rb
13
+ ext/glu/gl-enums.h
14
+ ext/glu/glu-enums.c
15
+ ext/glu/glu-enums.h
16
+ ext/glu/glu.c
17
+ lib/glu.rb
18
+ lib/glu/dummy.rb
19
+ test/dummy.xorg.conf
20
+ test/test_glu.rb
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ = glu2
2
+ main :: https://github.com/vrodic/ruby-glu2
3
+
4
+ == Description
5
+
6
+ Glu bindings for the opengl gem, split into a separate gem because of Glu deprecation.
7
+
8
+ == License
9
+
10
+ (The MIT License)
11
+
12
+ Copyright (c) Vedran Rodic (current maintainer)
13
+ Copyright (c) Blaž Hrastnik (previous maintainer)
14
+ Copyright (c) Eric Hodel (previous maintainer)
15
+ Copyright (c) Alain Hoang (previous maintainer)
16
+ Copyright (c) Jan Dvorak (contributor)
17
+ Copyright (c) Minh Thu Vo (contributor)
18
+ Copyright (c) James Adam (contributor)
19
+
20
+ Permission is hereby granted, free of charge, to any person obtaining
21
+ a copy of this software and associated documentation files (the
22
+ 'Software'), to deal in the Software without restriction, including
23
+ without limitation the rights to use, copy, modify, merge, publish,
24
+ distribute, sublicense, and/or sell copies of the Software, and to
25
+ permit persons to whom the Software is furnished to do so, subject to
26
+ the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be
29
+ included in all copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
32
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
35
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
+
data/Rakefile ADDED
@@ -0,0 +1,69 @@
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 'glu2' do
21
+ developer 'Vedran Rodic', 'vrodic@gmail.com'
22
+ developer 'Eric Hodel', 'drbrain@segment7.net'
23
+ developer 'Lars Kanis', ''
24
+ developer 'Blaž Hrastnik', 'blaz.hrast@gmail.com'
25
+ developer 'Alain Hoang', ''
26
+ developer 'Jan Dvorak', ''
27
+ developer 'Minh Thu Vo', ''
28
+ developer 'James Adam', ''
29
+
30
+ self.readme_file = 'README.rdoc'
31
+ self.history_file = 'History.rdoc'
32
+ self.extra_rdoc_files = FileList['*.rdoc']
33
+
34
+ extra_dev_deps << ['rake-compiler', '~> 1.0']
35
+ extra_dev_deps << ['rake-compiler-dock', '~> 0.6.0']
36
+
37
+ self.spec_extras = {
38
+ extensions: %w[ext/glu/extconf.rb],
39
+ required_ruby_version: '>= 1.9.2'
40
+ }
41
+ end
42
+
43
+ Rake::ExtensionTask.new 'glu', hoe.spec do |ext|
44
+ ext.lib_dir = 'lib/glu'
45
+
46
+ ext.cross_compile = true
47
+ ext.cross_platform = %w[x86-mingw32 x64-mingw32]
48
+ end
49
+
50
+ # To reduce the gem file size strip mingw32 dlls before packaging
51
+ ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
52
+ task "copy:glu:x86-mingw32:#{ruby_version}" do |t|
53
+ sh "i686-w64-mingw32-strip -S tmp/x86-mingw32/stage/lib/glu/#{ruby_version[/^\d+\.\d+/]}/glu.so"
54
+ end
55
+
56
+ task "copy:glu:x64-mingw32:#{ruby_version}" do |t|
57
+ sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/glu/#{ruby_version[/^\d+\.\d+/]}/glu.so"
58
+ end
59
+ end
60
+
61
+ desc 'Build windows binary gems per rake-compiler-dock.'
62
+ task 'gem:windows' do
63
+ require 'rake_compiler_dock'
64
+ RakeCompilerDock.sh <<-SHELL
65
+ rake cross native gem MAKE='nice make -j`nproc`'
66
+ SHELL
67
+ end
68
+
69
+ task test: :compile
data/ext/glu/common.h ADDED
@@ -0,0 +1,227 @@
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_GL_H
29
+ #include <OpenGL/gl.h>
30
+ #endif
31
+
32
+ #ifdef HAVE_GL_GL_H
33
+ #include <GL/gl.h>
34
+ #endif
35
+
36
+ #ifdef HAVE_OPENGL_GLU_H
37
+ #include <OpenGL/glu.h>
38
+ #endif
39
+
40
+ #ifdef HAVE_GL_GLU_H
41
+ #include <GL/glu.h>
42
+ #endif
43
+
44
+ #include "gl-enums.h"
45
+ #include "glu-enums.h"
46
+ #include "conv.h"
47
+
48
+ #ifndef CALLBACK
49
+ #define CALLBACK
50
+ #endif
51
+
52
+ #ifdef HAVE_WINDOWS_H
53
+ #define DLLEXPORT __declspec(dllexport)
54
+ #else
55
+ #define DLLEXPORT
56
+ #endif
57
+
58
+ /* these two macros are cast to a 32 bit type in the places they are used */
59
+ #ifndef RARRAY_LENINT
60
+ #define RARRAY_LENINT RARRAY_LEN
61
+ #endif
62
+
63
+ /* -------------------------------------------------------------------- */
64
+
65
+ /* gets number of components for given format */
66
+ static inline int glformat_size(GLenum format)
67
+ {
68
+ switch(format)
69
+ {
70
+ case GL_COLOR_INDEX:
71
+ case GL_RED:
72
+ case GL_GREEN:
73
+ case GL_BLUE:
74
+ case GL_ALPHA:
75
+ case GL_RED_INTEGER_EXT:
76
+ case GL_GREEN_INTEGER_EXT:
77
+ case GL_BLUE_INTEGER_EXT:
78
+ case GL_ALPHA_INTEGER_EXT:
79
+ case GL_STENCIL_INDEX:
80
+ case GL_DEPTH_COMPONENT:
81
+ case GL_LUMINANCE:
82
+ case GL_LUMINANCE_INTEGER_EXT:
83
+ return 1;
84
+
85
+ case GL_LUMINANCE_ALPHA:
86
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
87
+ case GL_422_EXT:
88
+ case GL_422_REV_EXT:
89
+ case GL_422_AVERAGE_EXT:
90
+ case GL_422_REV_AVERAGE_EXT:
91
+ case GL_YCRCB_422_SGIX:
92
+ case GL_YCBCR_422_APPLE:
93
+ case GL_YCBCR_MESA:
94
+ case GL_DEPTH_STENCIL_NV:
95
+ case GL_HILO_NV:
96
+ case GL_DSDT_NV:
97
+ case GL_DUDV_ATI:
98
+ case GL_DU8DV8_ATI:
99
+ case GL_FORMAT_SUBSAMPLE_24_24_OML:
100
+ return 2;
101
+
102
+ case GL_RGB:
103
+ case GL_RGB_INTEGER_EXT:
104
+ case GL_BGR_EXT:
105
+ case GL_BGR_INTEGER_EXT:
106
+ case GL_YCRCB_444_SGIX:
107
+ case GL_DSDT_MAG_NV:
108
+ case GL_FORMAT_SUBSAMPLE_244_244_OML:
109
+ return 3;
110
+
111
+ case GL_RGBA:
112
+ case GL_RGBA_INTEGER_EXT:
113
+ case GL_BGRA_EXT:
114
+ case GL_BGRA_INTEGER_EXT:
115
+ case GL_ABGR_EXT:
116
+ case GL_CMYK_EXT:
117
+ case GL_DSDT_MAG_VIB_NV:
118
+ return 4;
119
+
120
+ case GL_CMYKA_EXT:
121
+ return 5;
122
+
123
+ /* GL spec permits passing direct format size instead of enum (now obsolete) */
124
+ case 1:
125
+ case 2:
126
+ case 3:
127
+ case 4:
128
+ return format;
129
+
130
+ default:
131
+ rb_raise(rb_eArgError, "Unknown GL format enum %i",format);
132
+ return -1; /* not reached */
133
+ }
134
+ }
135
+
136
+ /* computes unit (pixel) size for given type and format */
137
+ static inline int gltype_glformat_unit_size(GLenum type,GLenum format)
138
+ {
139
+ unsigned int format_size;
140
+
141
+ format_size = glformat_size(format);
142
+
143
+ switch(type)
144
+ {
145
+ case GL_BYTE:
146
+ case GL_UNSIGNED_BYTE:
147
+ case GL_BITMAP:
148
+ return 1*format_size;
149
+
150
+ case GL_SHORT:
151
+ case GL_UNSIGNED_SHORT:
152
+ case GL_HALF_FLOAT_ARB:
153
+ return 2*format_size;
154
+
155
+ case GL_INT:
156
+ case GL_UNSIGNED_INT:
157
+ case GL_FLOAT:
158
+ return 4*format_size;
159
+
160
+ /* in packed formats all components are packed into/unpacked from single datatype,
161
+ so number of components(format_size) doesn't matter for total size calculation */
162
+ case GL_UNSIGNED_BYTE_3_3_2:
163
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
164
+ return 1;
165
+
166
+ case GL_UNSIGNED_SHORT_5_6_5:
167
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
168
+ case GL_UNSIGNED_SHORT_4_4_4_4:
169
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
170
+ case GL_UNSIGNED_SHORT_5_5_5_1:
171
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
172
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
173
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
174
+ return 2;
175
+
176
+ case GL_UNSIGNED_INT_8_8_8_8:
177
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
178
+ case GL_UNSIGNED_INT_10_10_10_2:
179
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
180
+ case GL_UNSIGNED_INT_24_8_NV:
181
+ case GL_UNSIGNED_INT_S8_S8_8_8_NV:
182
+ case GL_UNSIGNED_INT_8_8_S8_S8_REV_NV:
183
+ case GL_UNSIGNED_INT_10F_11F_11F_REV_EXT:
184
+ case GL_UNSIGNED_INT_5_9_9_9_REV_EXT:
185
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV:
186
+ return 4;
187
+
188
+ default:
189
+ rb_raise(rb_eArgError, "Unknown GL type enum %i",type);
190
+ return -1; /* not reached */
191
+ }
192
+ }
193
+
194
+ static inline int GetDataSize(GLenum type,GLenum format,int num)
195
+ {
196
+ int size;
197
+ int unit_size;
198
+
199
+ unit_size = gltype_glformat_unit_size(type,format);
200
+
201
+ if (type==GL_BITMAP)
202
+ size = unit_size*(num/8); /* FIXME account for alignment */
203
+ else
204
+ size = unit_size*num;
205
+
206
+ return size;
207
+ }
208
+
209
+ /* Checks if data size of 'data' string confirms to passed format values */
210
+ /* 'num' is number of elements, each of size 'format' * 'type' */
211
+ static inline void CheckDataSize(GLenum type,GLenum format,int num,VALUE data)
212
+ {
213
+ int size;
214
+
215
+ size = GetDataSize(type,format,num);
216
+
217
+ if (RSTRING_LEN(data) < size)
218
+ rb_raise(rb_eArgError, "Length of specified data doesn't correspond to format and type parameters passed. Calculated length: %i",size);
219
+ }
220
+
221
+ /* -------------------------------------------------------------------- */
222
+ static inline VALUE allocate_buffer_with_string( long size )
223
+ {
224
+ return rb_str_new(NULL, size);
225
+ }
226
+
227
+ #endif
data/ext/glu/conv.h ADDED
@@ -0,0 +1,143 @@
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_F,GLfloat,rb_float_new)
79
+ cond_GLBOOL2RUBY_FUNC(cond_GLBOOL2RUBY_D,GLdouble,rb_float_new)
80
+
81
+
82
+ /* For conversion between ruby array (or object that can be converted to
83
+ * array) and C array.
84
+ *
85
+ * The C array has to be preallocated by calling function. */
86
+ #define ARY2CTYPE(_type_,_convert_) \
87
+ static inline long ary2c##_type_( arg, cary, maxlen ) \
88
+ VALUE arg; \
89
+ GL##_type_ cary[]; \
90
+ long maxlen; \
91
+ { \
92
+ long i; \
93
+ VALUE ary = rb_Array(arg); \
94
+ if (maxlen < 1) \
95
+ maxlen = RARRAY_LEN(ary); \
96
+ else \
97
+ maxlen = maxlen < RARRAY_LEN(ary) ? maxlen : RARRAY_LEN(ary); \
98
+ for (i=0; i < maxlen; i++) \
99
+ cary[i] = (GL##_type_)_convert_(rb_ary_entry(ary,i)); \
100
+ return i; \
101
+ }
102
+
103
+ ARY2CTYPE(int,NUM2INT)
104
+ ARY2CTYPE(uint,NUM2UINT)
105
+ ARY2CTYPE(byte,NUM2INT)
106
+ ARY2CTYPE(ubyte,NUM2INT)
107
+ ARY2CTYPE(short,NUM2INT)
108
+ ARY2CTYPE(ushort,NUM2INT)
109
+ ARY2CTYPE(boolean,GLBOOL2RUBY)
110
+ ARY2CTYPE(float,NUM2DBL)
111
+ ARY2CTYPE(double,NUM2DBL)
112
+
113
+ #define ary2cflt ary2cfloat
114
+ #define ary2cdbl ary2cdouble
115
+
116
+ #undef ARY2CTYPE
117
+
118
+ /* Converts either array or object responding to #to_a to C-style array */
119
+ #define ARY2CMAT(_type_) \
120
+ static inline void ary2cmat##_type_(rary, cary, cols, rows) \
121
+ VALUE rary; \
122
+ _type_ cary[]; \
123
+ int cols,rows; \
124
+ { \
125
+ int i; \
126
+ \
127
+ rary = rb_Array(rary); \
128
+ rary = rb_funcall(rary,rb_intern("flatten"),0); \
129
+ \
130
+ if (RARRAY_LEN(rary) != cols*rows) \
131
+ rb_raise(rb_eArgError, "passed array/matrix must have %i*%i elements",cols,rows); \
132
+ \
133
+ for (i=0; i < cols*rows; i++) \
134
+ cary[i] = (_type_) NUM2DBL(rb_ary_entry(rary,i)); \
135
+ }
136
+
137
+ ARY2CMAT(double)
138
+ ARY2CMAT(float)
139
+ #undef ARY2CMAT
140
+
141
+ #define EMPTY
142
+ #define FREE(_x_) xfree(_x_);
143
+
@@ -0,0 +1,38 @@
1
+ require 'mkmf'
2
+
3
+ def have_framework(fw, &b)
4
+ checking_for fw do
5
+ src = cpp_include("#{fw}/#{fw}.h") << "\n" "int main(void){return 0;}"
6
+ if try_link(src, opt = "-ObjC -framework #{fw}", &b)
7
+ $defs.push(format("-DHAVE_FRAMEWORK_%s", fw.tr_cpp))
8
+ $LDFLAGS << " " << opt
9
+ true
10
+ else
11
+ false
12
+ end
13
+ end
14
+ end unless respond_to? :have_framework
15
+
16
+ if ENV['CROSS_COMPILING']
17
+ dir_config("installed")
18
+ end
19
+
20
+ ok =
21
+ (have_library('opengl32.lib', 'glVertex3d') &&
22
+ have_library('glu32.lib', 'gluLookAt')) ||
23
+ (have_library('opengl32') &&
24
+ have_library('glu32')) ||
25
+ (have_library('GL', 'glVertex3d') &&
26
+ have_library('GLU', 'gluLookAt')) ||
27
+ (have_framework('OpenGL') && have_framework('Cocoa'))
28
+
29
+ ok &&=
30
+ (have_header('GL/gl.h') && have_header('GL/glu.h')) ||
31
+ (have_header('OpenGL/gl.h') && have_header('OpenGL/glu.h')) # OS X
32
+
33
+ have_struct_member 'struct RFloat', 'float_value'
34
+
35
+ if ok then
36
+ create_header
37
+ create_makefile 'glu/glu'
38
+ end