glu 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ require 'glu/glu'
2
+
3
+ include Glu
4
+
5
+ # (Glu.)gluSphere -> GLU.Sphere
6
+ # (Glu::)GLU_INSIDE -> GLU::INSIDE
7
+ module GLU
8
+ extend self
9
+ include Glu
10
+
11
+ Glu.constants.each do |cn|
12
+ n = cn.to_s.sub(/^GLU_/,'')
13
+ const_set( n, Glu.const_get( cn ) )
14
+ end
15
+
16
+ Glu.methods( false ).each do |mn|
17
+ n = mn.to_s.sub(/^glu/,'')
18
+ alias_method( n, mn )
19
+ public( n )
20
+ end
21
+ end
22
+
23
+ module Glu
24
+ VERSION = "8.1.0"
25
+ end
@@ -0,0 +1,2 @@
1
+ # Unless this file exists, rake-compiler/hoe won't create this folder
2
+ # and the extension won't build.
@@ -0,0 +1,310 @@
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
+ require 'opengl/test_case'
17
+ require 'glu'
18
+
19
+ include Glu
20
+
21
+ class TestGlu < OpenGL::TestCase
22
+
23
+ def test_gluortho
24
+ res = [ [2.0/WINDOW_SIZE, 0, 0, 0],
25
+ [0, 2.0/WINDOW_SIZE, 0, 0],
26
+ [0, 0, -1, 0],
27
+ [-1, -1, 0, 1] ]
28
+
29
+ glMatrixMode(GL_PROJECTION)
30
+ glLoadIdentity()
31
+ gluOrtho2D(0, WINDOW_SIZE, 0, WINDOW_SIZE)
32
+ assert_equal res, glGetDoublev(GL_PROJECTION_MATRIX)
33
+ end
34
+
35
+ def test_glugetstring
36
+ refute_empty gluGetString GLU_VERSION
37
+ end
38
+
39
+ def test_gluerrorstring
40
+ refute_empty gluErrorString GL_INVALID_VALUE
41
+ end
42
+
43
+ def test_glubuild2dmipmaps
44
+ textures = glGenTextures(1)
45
+ glBindTexture(GL_TEXTURE_2D, textures[0])
46
+
47
+ image = ([0, 0, 0, 1, 1, 1] * 8).pack("f*") # 16 RGB pixels
48
+
49
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB8, 4, 4, GL_RGB, GL_FLOAT, image)
50
+ im = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT)
51
+
52
+ assert_equal image, im
53
+ assert_equal 4*4*3, im.unpack("f*").size
54
+
55
+ im = glGetTexImage(GL_TEXTURE_2D, 1, GL_RGB, GL_FLOAT)
56
+ assert_equal 2*2*3, im.unpack("f*").size
57
+
58
+ im = glGetTexImage(GL_TEXTURE_2D, 2, GL_RGB, GL_FLOAT)
59
+ assert_equal 1*1*3, im.unpack("f*").size
60
+
61
+ glDeleteTextures(textures)
62
+ end
63
+
64
+ def test_glubuild1dmipmaps
65
+ textures = glGenTextures(1)
66
+ glBindTexture(GL_TEXTURE_1D, textures[0])
67
+
68
+ image = ([0, 0, 0, 1, 1, 1] * 2).pack("f*") # 4 RGB pixels
69
+
70
+ gluBuild1DMipmaps(GL_TEXTURE_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT, image)
71
+
72
+ im = glGetTexImage(GL_TEXTURE_1D, 0, GL_RGB, GL_FLOAT)
73
+ assert_equal image, im
74
+ assert_equal 4*3, im.unpack("f*").size
75
+ im = glGetTexImage(GL_TEXTURE_1D, 1, GL_RGB, GL_FLOAT)
76
+ assert_equal 2*3, im.unpack("f*").size
77
+ im = glGetTexImage(GL_TEXTURE_1D, 2, GL_RGB, GL_FLOAT)
78
+ assert_equal 1*3, im.unpack("f*").size
79
+
80
+ glDeleteTextures(textures)
81
+ end
82
+
83
+ def test_glulookat
84
+ m = [[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, -1, 1]]
85
+ gluLookAt(1, 0, 0, 0, 0, 0, 0, 1, 0)
86
+ assert_equal m, glGetDoublev(GL_PROJECTION_MATRIX)
87
+ end
88
+
89
+ def test_gluproject
90
+ pos = gluProject(1, 1, 1)
91
+ assert_equal pos, [WINDOW_SIZE, WINDOW_SIZE, 1]
92
+
93
+ mp = glGetDoublev(GL_PROJECTION_MATRIX)
94
+ mm = Matrix.rows(glGetDoublev(GL_MODELVIEW_MATRIX))
95
+ view = glGetDoublev(GL_VIEWPORT)
96
+ pos = gluProject(1, 1, 1, mp, mm, view)
97
+ assert_equal([WINDOW_SIZE, WINDOW_SIZE, 1], pos)
98
+
99
+ assert_raises ArgumentError do pos = gluProject(1, 1, 1, mp, [1, 2, 3, 4], view) end
100
+ end
101
+
102
+ def test_gluunproject
103
+ pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1)
104
+ assert_equal([1, 1, 1], pos)
105
+
106
+ mp = glGetDoublev(GL_PROJECTION_MATRIX)
107
+ mm = Matrix.rows(glGetDoublev(GL_MODELVIEW_MATRIX))
108
+ view = glGetDoublev(GL_VIEWPORT)
109
+ pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1, mp, mm, view)
110
+ assert_equal([1, 1, 1], pos)
111
+ assert_raises ArgumentError do pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1, mp, [1, 2, 3, 4], view) end
112
+ end
113
+
114
+ def test_glupickmatrix
115
+ t = WINDOW_SIZE / 5.0
116
+ m = [[t, 0.0, 0.0, 0.0], [0.0, t, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [t, t, 0.0, 1.0]]
117
+ glMatrixMode(GL_PROJECTION)
118
+
119
+ glLoadIdentity()
120
+ gluPickMatrix(0, 0)
121
+ assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
122
+
123
+ glLoadIdentity()
124
+ gluPickMatrix(0, 0, 5, 5)
125
+ assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
126
+
127
+ glLoadIdentity()
128
+ gluPickMatrix(0, 0, 5, 5, glGetDoublev(GL_VIEWPORT))
129
+ assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
130
+ end
131
+
132
+ def test_gluperspective
133
+ m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -3, -1], [0, 0, -4, 0]]
134
+ gluPerspective(90, 1, 1, 2)
135
+ assert_equal m, glGetDoublev(GL_PROJECTION_MATRIX)
136
+ end
137
+
138
+ def test_gluscaleimage
139
+ image = ([0, 0, 0, 1, 1, 1] * 8).pack("f*") # 16 RGB pixels
140
+ scaled = gluScaleImage(GL_RGB, 4, 4, GL_FLOAT, image, 2, 2, GL_FLOAT)
141
+ assert_equal(2*2*3, scaled.unpack("f*").length)
142
+ end
143
+
144
+ def test_gluquadrics
145
+ ecount = 0
146
+ error_func = lambda do |error|
147
+ ecount+=1
148
+ end
149
+
150
+ q = gluNewQuadric()
151
+ gluQuadricDrawStyle(q, GL_LINE)
152
+ gluQuadricNormals(q, GL_SMOOTH)
153
+ gluQuadricOrientation(q, GLU_OUTSIDE)
154
+ gluQuadricTexture(q, GL_FALSE)
155
+ gluQuadricCallback(q, GLU_ERROR, error_func)
156
+
157
+ buf = glFeedbackBuffer(1024, GL_3D)
158
+ glRenderMode(GL_FEEDBACK)
159
+ gluSphere(q, 1.0, 4, 3)
160
+ count = glRenderMode(GL_RENDER)
161
+ refute_equal 0, count
162
+
163
+ glRenderMode(GL_FEEDBACK)
164
+ gluCylinder(q, 1.0, 1.0, 1.0, 4, 3)
165
+ count = glRenderMode(GL_RENDER)
166
+ refute_equal 0, count
167
+
168
+ glRenderMode(GL_FEEDBACK)
169
+ gluDisk(q, 1.0, 2.0, 4, 3)
170
+ count = glRenderMode(GL_RENDER)
171
+ refute_equal 0, count
172
+
173
+ glRenderMode(GL_FEEDBACK)
174
+ gluPartialDisk(q, 1.0, 2.0, 4, 3, 0, 360)
175
+ count = glRenderMode(GL_RENDER)
176
+ refute_equal 0, count
177
+
178
+ assert_equal 0, ecount
179
+ gluSphere(q, 0.0, 0, 0)
180
+ assert_equal 1, ecount
181
+ gluDeleteQuadric(q)
182
+ end
183
+
184
+ def test_glunurbs
185
+ ecount = 0
186
+
187
+ glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE)
188
+ glMatrixMode(GL_PROJECTION)
189
+ glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1)
190
+
191
+ n_error = lambda do |error|
192
+ ecount += 1
193
+ end
194
+
195
+ m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
196
+ m2 = Matrix.rows(m)
197
+
198
+ n = gluNewNurbsRenderer()
199
+ gluNurbsCallback(n, GLU_ERROR, n_error)
200
+ gluNurbsProperty(n, GLU_SAMPLING_TOLERANCE, 40)
201
+ assert_equal 40, gluGetNurbsProperty(n, GLU_SAMPLING_TOLERANCE)
202
+
203
+ gluLoadSamplingMatrices(n, m, m2, glGetIntegerv(GL_VIEWPORT))
204
+ assert_raises ArgumentError do gluLoadSamplingMatrices(n, m, [1, 2, 3, 4], glGetIntegerv(GL_VIEWPORT)) end
205
+
206
+ knots = [0, 0, 0, 0, 1, 1, 1, 1]
207
+ ctlpoints_curve = [[50, 50, 0], [400, 50, 0], [400, 400, 0], [50, 400, 0]]
208
+
209
+ # generate surface control points
210
+ ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
211
+ 0.upto(3) do |u|
212
+ 0.upto(3) do |v|
213
+ ctlpoints[u][v][0]=2.0*(u-1.5)
214
+ ctlpoints[u][v][1]=2.0*(v-1.5)
215
+
216
+ if ((u==1 || u==2) && (v==1 || v==2))
217
+ ctlpoints[u][v][2]=6.0
218
+ else
219
+ ctlpoints[u][v][2]=0.0
220
+ end
221
+ end
222
+ end
223
+
224
+ buf = glFeedbackBuffer(1024*1024*8, GL_3D) # large enough buffer for tesselated surface
225
+ glRenderMode(GL_FEEDBACK)
226
+ gluBeginCurve(n)
227
+ gluNurbsCurve(n, knots, ctlpoints_curve, 4, GL_MAP1_VERTEX_3)
228
+ gluEndCurve(n)
229
+
230
+ gluBeginSurface(n)
231
+ gluNurbsSurface(n, knots, knots, ctlpoints, 4, 4, GL_MAP2_VERTEX_3)
232
+ gluEndSurface(n)
233
+
234
+ count = glRenderMode(GL_RENDER)
235
+ refute_equal 1, count
236
+
237
+ assert_equal 0, ecount
238
+ gluBeginTrim(n)
239
+ gluPwlCurve(n, [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]], GLU_MAP1_TRIM_2)
240
+ gluEndTrim(n)
241
+
242
+ gluDeleteNurbsRenderer(n)
243
+ assert_equal 1, ecount
244
+ end
245
+
246
+ def test_glutess
247
+ glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE)
248
+ glMatrixMode(GL_PROJECTION)
249
+ glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1)
250
+ vcount, bcount, ecount = 0, 0, 0
251
+
252
+ cb_begin = lambda do |type|
253
+ bcount += 1
254
+ end
255
+ cb_end = lambda do
256
+ ecount += 1
257
+ end
258
+ cb_vertex = lambda do |data|
259
+ vcount += 1
260
+ end
261
+ cb_error = lambda do |error|
262
+ p gluErrorString(error)
263
+ end
264
+
265
+ t = gluNewTess()
266
+ gluTessCallback(t, GLU_TESS_BEGIN, cb_begin)
267
+ gluTessCallback(t, GLU_TESS_END, cb_end)
268
+ gluTessCallback(t, GLU_TESS_ERROR, cb_error)
269
+ gluTessCallback(t, GLU_TESS_VERTEX, cb_vertex)
270
+ gluTessProperty(t, GLU_TESS_BOUNDARY_ONLY, GL_TRUE)
271
+ assert_equal GL_TRUE, gluGetTessProperty(t, GLU_TESS_BOUNDARY_ONLY)
272
+ gluTessProperty(t, GLU_TESS_BOUNDARY_ONLY, GL_FALSE)
273
+ assert_equal GL_FALSE, gluGetTessProperty(t, GLU_TESS_BOUNDARY_ONLY)
274
+
275
+ gluTessNormal(t, 0.0, 0.0, 0.0)
276
+
277
+ rect = [[50.0, 50.0, 0.0],
278
+ [200.0, 50.0, 0.0],
279
+ [200.0, 200.0, 0.0],
280
+ [50.0, 200.0, 0.0]]
281
+ tri = [[75.0, 75.0, 0.0],
282
+ [125.0, 175.0, 0.0],
283
+ [175.0, 75.0, 0.0]]
284
+
285
+ gluTessBeginPolygon(t, nil)
286
+ gluTessBeginContour(t)
287
+ gluTessVertex(t, rect[0], rect[0])
288
+ gluTessVertex(t, rect[1], rect[1])
289
+ gluTessVertex(t, rect[2], rect[2])
290
+ gluTessVertex(t, rect[3], rect[3])
291
+ gluTessEndContour(t)
292
+ gluTessBeginContour(t)
293
+ gluTessVertex(t, tri[0], tri[0])
294
+ gluTessVertex(t, tri[1], tri[1])
295
+ gluTessVertex(t, tri[2], tri[2])
296
+ gluTessEndContour(t)
297
+ gluTessEndPolygon(t)
298
+
299
+ gluTessCallback(t, GLU_TESS_BEGIN, nil)
300
+ gluTessCallback(t, GLU_TESS_END, nil)
301
+ gluTessCallback(t, GLU_TESS_ERROR, nil)
302
+ gluTessCallback(t, GLU_TESS_VERTEX, nil)
303
+
304
+ gluDeleteTess(t)
305
+
306
+ assert_equal 1, bcount
307
+ assert_equal 1, ecount
308
+ assert_equal 9, vcount
309
+ end
310
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: glu
3
+ version: !ruby/object:Gem::Version
4
+ version: 8.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Hodel
8
+ - Lars Kanis
9
+ - Blaž Hrastnik
10
+ - Alain Hoang
11
+ - Jan Dvorak
12
+ - Minh Thu Vo
13
+ - James Adam
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+ date: 2013-03-03 00:00:00.000000000 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: rdoc
21
+ requirement: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ version: '3.10'
26
+ type: :development
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.10'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake-compiler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '0.7'
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.7.9
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '0.7'
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 0.7.9
53
+ - !ruby/object:Gem::Dependency
54
+ name: hoe
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '3.5'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: '3.5'
67
+ description: Glu bindings for the opengl gem, split into a separate gem because of
68
+ Glu deprecation.
69
+ email:
70
+ - drbrain@segment7.net
71
+ - ''
72
+ - speed.the.bboy@gmail.com
73
+ - ''
74
+ - ''
75
+ - ''
76
+ - ''
77
+ executables: []
78
+ extensions:
79
+ - ext/glu/extconf.rb
80
+ extra_rdoc_files:
81
+ - History.rdoc
82
+ - Manifest.txt
83
+ - README.rdoc
84
+ files:
85
+ - .autotest
86
+ - .gemtest
87
+ - .gitignore
88
+ - History.rdoc
89
+ - MIT-LICENSE
90
+ - Manifest.txt
91
+ - README.rdoc
92
+ - Rakefile
93
+ - ext/glu/common.h
94
+ - ext/glu/conv.h
95
+ - ext/glu/extconf.rb
96
+ - ext/glu/glu-enums.c
97
+ - ext/glu/glu-enums.h
98
+ - ext/glu/glu.c
99
+ - lib/glu.rb
100
+ - lib/glu/dummy.rb
101
+ - test/test_glu.rb
102
+ homepage:
103
+ licenses: []
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options:
107
+ - --main
108
+ - README.rdoc
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: 1.9.2
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project: glu
123
+ rubygems_version: 2.0.0
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Glu bindings for the opengl gem, split into a separate gem because of Glu
127
+ deprecation.
128
+ test_files:
129
+ - test/test_glu.rb