glu 8.2.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/.autotest +29 -0
- data/.gemtest +0 -0
- data/.gitignore +6 -0
- data/.travis.yml +15 -0
- data/History.rdoc +8 -0
- data/MIT-LICENSE +18 -0
- data/Manifest.txt +20 -0
- data/README.rdoc +36 -0
- data/Rakefile +49 -0
- data/ext/glu/common.h +227 -0
- data/ext/glu/conv.h +143 -0
- data/ext/glu/extconf.rb +37 -0
- data/ext/glu/gl-enums.h +14588 -0
- data/ext/glu/glu-enums.c +164 -0
- data/ext/glu/glu-enums.h +463 -0
- data/ext/glu/glu.c +1538 -0
- data/lib/glu.rb +28 -0
- data/lib/glu/2.0/glu.so +0 -0
- data/lib/glu/2.1/glu.so +0 -0
- data/lib/glu/dummy.rb +2 -0
- data/test/dummy.xorg.conf +131 -0
- data/test/test_glu.rb +310 -0
- metadata +155 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26b3f1156ae3f8eba17e333c7d6870ff0d502bf8
|
4
|
+
data.tar.gz: 2095791768b216b27344d598bcdc6a46deb490c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: feee7510ef93bddbf33837ee2313670dc201850a3a29584041f608b1cf3ac2ce39b036a5d89c71a28064c96fa036c11ac366941b6807db6a95fba364dc2e37f1
|
7
|
+
data.tar.gz: 310f7c5f3dcd5937cafe9bf2f489de8c9f8ea95cbf0bc95e2abae3922a37cafdbab248bb7dc3a4c3c1ffcf35e938bb9cf0a5186bf5496643a9ec6a2b06f715c9
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
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
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
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,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
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#-*-ruby-*-
|
3
|
+
#
|
4
|
+
# Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
|
5
|
+
# Copyright (C) Eric Hodel <drbrain@segment7.net>
|
6
|
+
#
|
7
|
+
# This program is distributed under the terms of the MIT license.
|
8
|
+
# See the included MIT-LICENSE file for the terms of this license.
|
9
|
+
#
|
10
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
11
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
12
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
13
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
14
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
15
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
16
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
|
18
|
+
require 'hoe'
|
19
|
+
require 'rake/extensiontask'
|
20
|
+
|
21
|
+
hoe = Hoe.spec 'glu' do
|
22
|
+
developer 'Eric Hodel', 'drbrain@segment7.net'
|
23
|
+
developer 'Lars Kanis', ''
|
24
|
+
developer 'Blaž Hrastnik', 'speed.the.bboy@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', '~> 0.7', '>= 0.7.9']
|
35
|
+
|
36
|
+
self.spec_extras = {
|
37
|
+
:extensions => %w[ext/glu/extconf.rb],
|
38
|
+
:required_ruby_version => '>= 1.9.2',
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
Rake::ExtensionTask.new 'glu', hoe.spec do |ext|
|
43
|
+
ext.lib_dir = 'lib/glu'
|
44
|
+
|
45
|
+
ext.cross_compile = true
|
46
|
+
ext.cross_platform = ['i386-mingw32', 'x64-mingw32']
|
47
|
+
end
|
48
|
+
|
49
|
+
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
|
+
|