opengl 0.7.0.pre1 → 0.7.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +29 -0
- data/.gitignore +5 -8
- data/History.rdoc +33 -0
- data/Manifest.txt +72 -57
- data/README.rdoc +72 -25
- data/Rakefile +60 -72
- data/Rakefile.cross +5 -2
- data/{doc → docs}/build_install.txt +0 -0
- data/{doc → docs}/extensions.txt.in +0 -0
- data/{doc → docs}/history.txt +0 -0
- data/{doc → docs}/requirements_and_design.txt +0 -0
- data/{doc → docs}/roadmap.txt +0 -0
- data/{doc → docs}/scientific_use.txt +0 -0
- data/{doc → docs}/supplies/page_template.html +0 -0
- data/{doc → docs}/thanks.txt +0 -0
- data/{doc → docs}/tutorial.txt +0 -0
- data/examples/NeHe/NeHe.png +0 -0
- data/examples/NeHe/crate.png +0 -0
- data/examples/NeHe/glass.png +0 -0
- data/examples/NeHe/nehe_lesson02.rb +82 -83
- data/examples/NeHe/nehe_lesson03.rb +88 -88
- data/examples/NeHe/nehe_lesson04.rb +93 -96
- data/examples/NeHe/nehe_lesson05.rb +137 -144
- data/examples/NeHe/nehe_lesson06.rb +183 -0
- data/examples/NeHe/nehe_lesson07.rb +237 -0
- data/examples/NeHe/nehe_lesson08.rb +252 -0
- data/examples/NeHe/nehe_lesson09.rb +199 -0
- data/examples/NeHe/nehe_lesson11.rb +173 -0
- data/examples/NeHe/nehe_lesson12.rb +200 -0
- data/examples/NeHe/nehe_lesson16.rb +208 -0
- data/examples/NeHe/nehe_lesson19.rb +206 -0
- data/examples/NeHe/particle.png +0 -0
- data/examples/NeHe/star.png +0 -0
- data/examples/NeHe/tim.png +0 -0
- data/examples/RedBook/light.rb +154 -0
- data/examples/misc/OGLBench.rb +2 -2
- data/examples/misc/trislam.rb +2 -2
- data/ext/{common → opengl}/common.h +2 -11
- data/ext/{common → opengl}/conv.h +43 -31
- data/ext/{glut → opengl}/extconf.rb +14 -7
- data/ext/{common → opengl}/funcdef.h +155 -125
- data/ext/{gl → opengl}/gl-1.0-1.1.c +426 -162
- data/ext/{gl → opengl}/gl-1.2.c +70 -66
- data/ext/{gl → opengl}/gl-1.3.c +19 -19
- data/ext/{gl → opengl}/gl-1.4.c +23 -23
- data/ext/{gl → opengl}/gl-1.5.c +46 -47
- data/ext/{gl → opengl}/gl-2.0.c +66 -60
- data/ext/{gl → opengl}/gl-2.1.c +4 -4
- data/ext/{gl → opengl}/gl-enums.c +2 -1
- data/ext/{common → opengl}/gl-enums.h +0 -0
- data/ext/{gl → opengl}/gl-error.c +12 -4
- data/ext/{common → opengl}/gl-error.h +7 -2
- data/ext/{gl → opengl}/gl-ext-3dfx.c +1 -1
- data/ext/{gl → opengl}/gl-ext-arb.c +75 -70
- data/ext/{gl → opengl}/gl-ext-ati.c +3 -3
- data/ext/{gl → opengl}/gl-ext-ext.c +54 -54
- data/ext/{gl → opengl}/gl-ext-gremedy.c +3 -3
- data/ext/{gl → opengl}/gl-ext-nv.c +49 -48
- data/ext/{common → opengl}/gl-types.h +0 -0
- data/ext/{gl → opengl}/gl.c +8 -10
- data/ext/{glu → opengl}/glu-enums.c +1 -1
- data/ext/{common → opengl}/glu-enums.h +0 -0
- data/ext/{glu → opengl}/glu.c +7 -3
- data/ext/{glut → opengl}/glut.c +98 -48
- data/ext/opengl/opengl.c +11 -0
- data/lib/gl.rb +1 -0
- data/lib/glu.rb +1 -0
- data/lib/glut.rb +1 -0
- data/lib/opengl.rb +13 -14
- data/lib/opengl/test_case.rb +87 -0
- data/test/{tc_misc.rb → test_gl.rb} +2 -14
- data/test/test_gl_10_11.rb +1363 -0
- data/test/test_gl_12.rb +182 -0
- data/test/{tc_func_13.rb → test_gl_13.rb} +14 -14
- data/test/test_gl_14.rb +221 -0
- data/test/test_gl_15.rb +260 -0
- data/test/test_gl_20.rb +430 -0
- data/test/test_gl_21.rb +553 -0
- data/test/test_gl_ext_arb.rb +526 -0
- data/test/{tc_ext_ati.rb → test_gl_ext_ati.rb} +11 -14
- data/test/test_gl_ext_ext.rb +608 -0
- data/test/{tc_ext_gremedy.rb → test_gl_ext_gremedy.rb} +6 -6
- data/test/test_gl_ext_nv.rb +352 -0
- data/test/test_glu.rb +309 -0
- metadata +159 -99
- data/History.txt +0 -36
- data/ext/gl/extconf.rb +0 -43
- data/ext/glu/extconf.rb +0 -51
- data/test/README +0 -10
- data/test/tc_common.rb +0 -98
- data/test/tc_ext_arb.rb +0 -467
- data/test/tc_ext_ext.rb +0 -551
- data/test/tc_ext_nv.rb +0 -357
- data/test/tc_func_10_11.rb +0 -1281
- data/test/tc_func_12.rb +0 -186
- data/test/tc_func_14.rb +0 -197
- data/test/tc_func_15.rb +0 -270
- data/test/tc_func_20.rb +0 -346
- data/test/tc_func_21.rb +0 -541
- data/test/tc_glu.rb +0 -310
- data/test/tc_include_gl.rb +0 -35
- data/test/tc_require_gl.rb +0 -34
@@ -13,24 +13,24 @@
|
|
13
13
|
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
14
|
#
|
15
15
|
|
16
|
-
require '
|
16
|
+
require 'opengl/test_case'
|
17
17
|
|
18
|
-
class
|
18
|
+
class TestGlExtGremedy < OpenGL::TestCase
|
19
19
|
def setup
|
20
|
-
|
20
|
+
super()
|
21
21
|
end
|
22
22
|
|
23
23
|
def teardown
|
24
|
-
|
24
|
+
super()
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_gl_gremedy_string_marker
|
28
|
-
|
28
|
+
supported?("GL_GREMEDY_string_marker")
|
29
29
|
glStringMarkerGREMEDY("test")
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_gl_gremedy_frame_terminator
|
33
|
-
|
33
|
+
supported?("GL_GREMEDY_frame_terminator")
|
34
34
|
glFrameTerminatorGREMEDY()
|
35
35
|
end
|
36
36
|
end
|
@@ -0,0 +1,352 @@
|
|
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
|
+
|
18
|
+
class TestGlExtNv < OpenGL::TestCase
|
19
|
+
|
20
|
+
def test_gl_nv_vertex_program
|
21
|
+
supported?("GL_NV_vertex_program")
|
22
|
+
|
23
|
+
assert_equal(glIsProgramNV(0),false)
|
24
|
+
programs = glGenProgramsNV(2)
|
25
|
+
assert_equal(programs.size,2)
|
26
|
+
|
27
|
+
program = "!!VSP1.0\nEND"
|
28
|
+
|
29
|
+
glBindProgramNV(GL_VERTEX_PROGRAM_NV, programs[1])
|
30
|
+
glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, programs[0], program)
|
31
|
+
assert_equal(glGetProgramStringNV(programs[0], GL_PROGRAM_STRING_NV), program)
|
32
|
+
assert_equal(glIsProgramNV(programs[0]),true)
|
33
|
+
|
34
|
+
assert_equal(glGetProgramivNV(programs[0],GL_PROGRAM_LENGTH_NV),program.size)
|
35
|
+
|
36
|
+
glVertexAttribPointerNV(1,2,GL_FLOAT,0,[1,1].pack("f*"))
|
37
|
+
assert_equal(glGetVertexAttribPointervNV(1),[1,1].pack("f*"))
|
38
|
+
|
39
|
+
glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV,programs[0],[1,1,1,1])
|
40
|
+
|
41
|
+
glProgramParameter4dNV(GL_VERTEX_PROGRAM_NV,1, 1,2,3,4)
|
42
|
+
assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[1,2,3,4])
|
43
|
+
glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV,1, 5,6,7,8)
|
44
|
+
assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[5,6,7,8])
|
45
|
+
glProgramParameter4dvNV(GL_VERTEX_PROGRAM_NV,1, [1,2,3,4])
|
46
|
+
assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[1,2,3,4])
|
47
|
+
glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV,1, [5,6,7,8])
|
48
|
+
assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[5,6,7,8])
|
49
|
+
|
50
|
+
glProgramParameters4fvNV(GL_VERTEX_PROGRAM_NV,1, [1,2,3,4,5,6,7,8])
|
51
|
+
assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[1,2,3,4])
|
52
|
+
assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,2,GL_PROGRAM_PARAMETER_NV),[5,6,7,8])
|
53
|
+
|
54
|
+
glProgramParameters4dvNV(GL_VERTEX_PROGRAM_NV,1, [8,7,6,5,4,3,2,1])
|
55
|
+
assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[8,7,6,5])
|
56
|
+
assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,2,GL_PROGRAM_PARAMETER_NV),[4,3,2,1])
|
57
|
+
|
58
|
+
|
59
|
+
glVertexAttrib1dNV(1,1)
|
60
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],1)
|
61
|
+
glVertexAttrib1fNV(1,2)
|
62
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0],2)
|
63
|
+
glVertexAttrib1sNV(1,3)
|
64
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0],3)
|
65
|
+
glVertexAttrib1dvNV(1,[1])
|
66
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],1)
|
67
|
+
glVertexAttrib1fvNV(1,[2])
|
68
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0],2)
|
69
|
+
glVertexAttrib1svNV(1,[3])
|
70
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0],3)
|
71
|
+
|
72
|
+
glVertexAttrib2dNV(1,1,2)
|
73
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[1,2])
|
74
|
+
glVertexAttrib2fNV(1,2,3)
|
75
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[2,3])
|
76
|
+
glVertexAttrib2sNV(1,3,4)
|
77
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
|
78
|
+
glVertexAttrib2dvNV(1,[1,2])
|
79
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[1,2])
|
80
|
+
glVertexAttrib2fvNV(1,[2,3])
|
81
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[2,3])
|
82
|
+
glVertexAttrib2svNV(1,[3,4])
|
83
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
|
84
|
+
|
85
|
+
glVertexAttrib3dNV(1,1,2,3)
|
86
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[1,2,3])
|
87
|
+
glVertexAttrib3fNV(1,2,3,4)
|
88
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[2,3,4])
|
89
|
+
glVertexAttrib3sNV(1,3,4,5)
|
90
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[3,4,5])
|
91
|
+
glVertexAttrib3dvNV(1,[1,2,3])
|
92
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[1,2,3])
|
93
|
+
glVertexAttrib3fvNV(1,[2,3,4])
|
94
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[2,3,4])
|
95
|
+
glVertexAttrib3svNV(1,[3,4,5])
|
96
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[3,4,5])
|
97
|
+
|
98
|
+
glVertexAttrib4dNV(1,1,2,3,4)
|
99
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,2,3,4])
|
100
|
+
glVertexAttrib4fNV(1,2,3,4,5)
|
101
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[2,3,4,5])
|
102
|
+
glVertexAttrib4sNV(1,3,4,5,6)
|
103
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[3,4,5,6])
|
104
|
+
glVertexAttrib4dvNV(1,[1,2,3,4])
|
105
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,2,3,4])
|
106
|
+
glVertexAttrib4fvNV(1,[2,3,4,5])
|
107
|
+
assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[2,3,4,5])
|
108
|
+
glVertexAttrib4svNV(1,[3,4,5,6])
|
109
|
+
assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[3,4,5,6])
|
110
|
+
|
111
|
+
glVertexAttrib4ubNV(1,2**8-1,0,2**8-1,0)
|
112
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,0,1,0])
|
113
|
+
glVertexAttrib4ubvNV(1,[0,2**8-1,0,2**8-1])
|
114
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[0,1,0,1])
|
115
|
+
|
116
|
+
glVertexAttribs1dvNV(1,[1,2])
|
117
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],1)
|
118
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0],2)
|
119
|
+
glVertexAttribs1fvNV(1,[3,4])
|
120
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],3)
|
121
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0],4)
|
122
|
+
glVertexAttribs1svNV(1,[5,6])
|
123
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],5)
|
124
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0],6)
|
125
|
+
|
126
|
+
glVertexAttribs2dvNV(1,[1,2,3,4])
|
127
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[1,2])
|
128
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
|
129
|
+
glVertexAttribs2fvNV(1,[3,4,5,6])
|
130
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
|
131
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,2],[5,6])
|
132
|
+
glVertexAttribs2svNV(1,[5,6,7,8])
|
133
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[5,6])
|
134
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,2],[7,8])
|
135
|
+
|
136
|
+
glVertexAttribs3dvNV(1,[1,2,3,4,5,6])
|
137
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[1,2,3])
|
138
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,3],[4,5,6])
|
139
|
+
glVertexAttribs3fvNV(1,[3,4,5,6,7,8])
|
140
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[3,4,5])
|
141
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,3],[6,7,8])
|
142
|
+
glVertexAttribs3svNV(1,[5,6,7,8,9,10])
|
143
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[5,6,7])
|
144
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,3],[8,9,10])
|
145
|
+
|
146
|
+
glVertexAttribs4dvNV(1,[1,2,3,4,5,6,7,8])
|
147
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,2,3,4])
|
148
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[5,6,7,8])
|
149
|
+
glVertexAttribs4fvNV(1,[3,4,5,6,7,8,9,10])
|
150
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[3,4,5,6])
|
151
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[7,8,9,10])
|
152
|
+
glVertexAttribs4svNV(1,[5,6,7,8,9,10,11,12])
|
153
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[5,6,7,8])
|
154
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[9,10,11,12])
|
155
|
+
glVertexAttribs4ubvNV(1,[2**8-1,0,2**8-1,0,2**8-1,0,2**8-1,0])
|
156
|
+
assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,0,1,0])
|
157
|
+
assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[1,0,1,0])
|
158
|
+
|
159
|
+
glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MATRIX0_NV, GL_IDENTITY_NV);
|
160
|
+
assert_equal(glGetTrackMatrixivNV(GL_VERTEX_PROGRAM_NV, 4, GL_TRACK_MATRIX_NV),GL_MATRIX0_NV)
|
161
|
+
|
162
|
+
glRequestResidentProgramsNV(programs[0])
|
163
|
+
res = glAreProgramsResidentNV(programs[0])
|
164
|
+
assert_equal(res.size,1)
|
165
|
+
|
166
|
+
glDeleteProgramsNV(programs)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_gl_nv_fragment_program
|
170
|
+
supported?("GL_NV_fragment_program")
|
171
|
+
programs = glGenProgramsNV(1)
|
172
|
+
program = "!!FP1.0\nDECLARE test = {0,0,0,0};\nEND"
|
173
|
+
glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, programs[0])
|
174
|
+
glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, programs[0], program)
|
175
|
+
|
176
|
+
glProgramNamedParameter4fNV(programs[0],"test",1,2,3,4)
|
177
|
+
assert_equal(glGetProgramNamedParameterfvNV(programs[0],"test"),[1,2,3,4])
|
178
|
+
glProgramNamedParameter4dNV(programs[0],"test",5,6,7,8)
|
179
|
+
assert_equal(glGetProgramNamedParameterdvNV(programs[0],"test"),[5,6,7,8])
|
180
|
+
glProgramNamedParameter4fvNV(programs[0],"test",[1,2,3,4])
|
181
|
+
assert_equal(glGetProgramNamedParameterfvNV(programs[0],"test"),[1,2,3,4])
|
182
|
+
glProgramNamedParameter4dvNV(programs[0],"test",[5,6,7,8])
|
183
|
+
assert_equal(glGetProgramNamedParameterdvNV(programs[0],"test"),[5,6,7,8])
|
184
|
+
|
185
|
+
glDeleteProgramsNV(programs)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_gl_nv_framebuffer_multisample_coverage
|
189
|
+
supported?("GL_NV_framebuffer_multisample_coverage")
|
190
|
+
rb = glGenRenderbuffersEXT(1)[0]
|
191
|
+
|
192
|
+
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,rb)
|
193
|
+
glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER_EXT,4,4, GL_RGBA,2,2)
|
194
|
+
samples = glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,GL_RENDERBUFFER_COVERAGE_SAMPLES_NV)
|
195
|
+
assert_equal(samples,4)
|
196
|
+
samples = glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,GL_RENDERBUFFER_COLOR_SAMPLES_NV)
|
197
|
+
assert_equal(samples,4)
|
198
|
+
|
199
|
+
glDeleteRenderbuffersEXT(rb)
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_gl_nv_fence
|
203
|
+
supported?("GL_NV_fence")
|
204
|
+
fences = glGenFencesNV(2)
|
205
|
+
assert_equal(fences.size,2)
|
206
|
+
|
207
|
+
glSetFenceNV(fences[0],GL_ALL_COMPLETED_NV)
|
208
|
+
assert_equal(glGetFenceivNV(fences[0],GL_FENCE_CONDITION_NV),GL_ALL_COMPLETED_NV)
|
209
|
+
assert_equal(glIsFenceNV(fences[0]),true)
|
210
|
+
|
211
|
+
glFinishFenceNV(fences[0])
|
212
|
+
assert_equal(glTestFenceNV(fences[0]),true)
|
213
|
+
|
214
|
+
glDeleteFencesNV(fences)
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_gl_nv_depth_buffer_float
|
218
|
+
supported?("GL_NV_depth_buffer_float")
|
219
|
+
glDepthRangedNV(0.1,0.2)
|
220
|
+
assert(assert_in_delta(glGetFloatv(GL_DEPTH_RANGE),[0.1,0.2]))
|
221
|
+
glDepthBoundsdNV(0.1,0.2)
|
222
|
+
assert(assert_in_delta(glGetFloatv(GL_DEPTH_BOUNDS_EXT),[0.1,0.2]))
|
223
|
+
glClearDepthdNV(0.3)
|
224
|
+
assert(assert_in_delta([glGetDoublev(GL_DEPTH_CLEAR_VALUE)],[0.3]))
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_gl_nv_occlusion_query
|
228
|
+
supported?("GL_NV_occlusion_query")
|
229
|
+
|
230
|
+
queries = glGenOcclusionQueriesNV(2)
|
231
|
+
assert_equal(queries.size,2)
|
232
|
+
|
233
|
+
glBeginOcclusionQueryNV(queries[0])
|
234
|
+
assert_equal(glIsOcclusionQueryNV(queries[0]),true)
|
235
|
+
|
236
|
+
glEndOcclusionQueryNV()
|
237
|
+
r = glGetOcclusionQueryivNV(queries[0],GL_PIXEL_COUNT_AVAILABLE_NV)
|
238
|
+
assert(r==GL_TRUE || r==GL_FALSE)
|
239
|
+
assert(glGetOcclusionQueryuivNV(queries[0],GL_PIXEL_COUNT_NV)>=0)
|
240
|
+
|
241
|
+
glDeleteOcclusionQueriesNV(queries)
|
242
|
+
assert_equal(glIsOcclusionQueryNV(queries[1]),false)
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_gl_nv_gpu_program4
|
246
|
+
supported?(["GL_NV_gpu_program4","GL_ARB_vertex_program"])
|
247
|
+
|
248
|
+
programs = glGenProgramsARB(1)
|
249
|
+
program = "!!ARBvp1.0\nTEMP vv;\nEND"
|
250
|
+
|
251
|
+
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, programs[0])
|
252
|
+
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, program)
|
253
|
+
|
254
|
+
glProgramLocalParameterI4iNV(GL_VERTEX_PROGRAM_ARB,1, 1,2,3,4)
|
255
|
+
assert_equal(glGetProgramLocalParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
|
256
|
+
glProgramLocalParameterI4uiNV(GL_VERTEX_PROGRAM_ARB,1, 5,6,7,8)
|
257
|
+
assert_equal(glGetProgramLocalParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
|
258
|
+
glProgramLocalParameterI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
|
259
|
+
assert_equal(glGetProgramLocalParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
|
260
|
+
glProgramLocalParameterI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
|
261
|
+
assert_equal(glGetProgramLocalParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
|
262
|
+
glProgramLocalParametersI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
|
263
|
+
assert_equal(glGetProgramLocalParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
|
264
|
+
glProgramLocalParametersI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
|
265
|
+
assert_equal(glGetProgramLocalParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
|
266
|
+
|
267
|
+
glProgramEnvParameterI4iNV(GL_VERTEX_PROGRAM_ARB,1, 1,2,3,4)
|
268
|
+
assert_equal(glGetProgramEnvParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
|
269
|
+
glProgramEnvParameterI4uiNV(GL_VERTEX_PROGRAM_ARB,1, 5,6,7,8)
|
270
|
+
assert_equal(glGetProgramEnvParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
|
271
|
+
glProgramEnvParameterI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
|
272
|
+
assert_equal(glGetProgramEnvParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
|
273
|
+
glProgramEnvParameterI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
|
274
|
+
assert_equal(glGetProgramEnvParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
|
275
|
+
glProgramEnvParametersI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
|
276
|
+
assert_equal(glGetProgramEnvParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
|
277
|
+
glProgramEnvParametersI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
|
278
|
+
assert_equal(glGetProgramEnvParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
|
279
|
+
|
280
|
+
glDeleteProgramsARB(programs)
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_gl_nv_gpu_program4
|
284
|
+
supported?(["GL_NV_gpu_program4","GL_EXT_framebuffer_object"])
|
285
|
+
geometry_program = <<-EOP
|
286
|
+
!!NVgp4.0
|
287
|
+
PRIMITIVE_IN TRIANGLES;
|
288
|
+
PRIMITIVE_OUT TRIANGLE_STRIP;
|
289
|
+
VERTICES_OUT 1;
|
290
|
+
END
|
291
|
+
EOP
|
292
|
+
|
293
|
+
program_id = glGenProgramsARB(1)[0]
|
294
|
+
glBindProgramARB(GL_GEOMETRY_PROGRAM_NV, program_id)
|
295
|
+
glProgramStringARB(GL_GEOMETRY_PROGRAM_NV, GL_PROGRAM_FORMAT_ASCII_ARB, geometry_program);
|
296
|
+
|
297
|
+
assert_equal(glGetProgramivARB(GL_GEOMETRY_PROGRAM_NV,GL_GEOMETRY_VERTICES_OUT_EXT),1)
|
298
|
+
glProgramVertexLimitNV(GL_GEOMETRY_PROGRAM_NV, 2)
|
299
|
+
assert_equal(glGetProgramivARB(GL_GEOMETRY_PROGRAM_NV,GL_GEOMETRY_VERTICES_OUT_EXT),2)
|
300
|
+
|
301
|
+
#
|
302
|
+
|
303
|
+
fbo = glGenFramebuffersEXT(1)[0]
|
304
|
+
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo)
|
305
|
+
|
306
|
+
texture2d,texture3d,texture_cube = glGenTextures(3)
|
307
|
+
glBindTexture(GL_TEXTURE_2D, texture2d)
|
308
|
+
glBindTexture(GL_TEXTURE_3D, texture3d)
|
309
|
+
glBindTexture(GL_TEXTURE_CUBE_MAP, texture_cube)
|
310
|
+
|
311
|
+
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,texture2d,0)
|
312
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT),texture2d)
|
313
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT),0)
|
314
|
+
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,texture3d,0,1)
|
315
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT),texture3d)
|
316
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT),0)
|
317
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT),1)
|
318
|
+
|
319
|
+
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,texture_cube,0,GL_TEXTURE_CUBE_MAP_POSITIVE_X)
|
320
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT),texture_cube)
|
321
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT),0)
|
322
|
+
assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT),GL_TEXTURE_CUBE_MAP_POSITIVE_X)
|
323
|
+
|
324
|
+
glDeleteTextures([texture2d,texture3d])
|
325
|
+
glDeleteFramebuffersEXT(fbo)
|
326
|
+
glDeleteProgramsARB(program_id)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_gl_nv_primitive_restart
|
330
|
+
supported?("GL_NV_primitive_restart")
|
331
|
+
glBegin(GL_TRIANGLES)
|
332
|
+
glPrimitiveRestartNV()
|
333
|
+
glEnd
|
334
|
+
glPrimitiveRestartIndexNV(2)
|
335
|
+
assert_equal(glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX_NV),2)
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_gl_nv_point_sprite
|
339
|
+
supported?("GL_NV_point_sprite")
|
340
|
+
glPointParameteriNV(GL_POINT_SPRITE_R_MODE_NV, GL_ZERO)
|
341
|
+
assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_ZERO)
|
342
|
+
glPointParameteriNV(GL_POINT_SPRITE_R_MODE_NV, GL_S)
|
343
|
+
assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_S)
|
344
|
+
|
345
|
+
glPointParameterivNV(GL_POINT_SPRITE_R_MODE_NV, [GL_ZERO])
|
346
|
+
assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_ZERO)
|
347
|
+
glPointParameterivNV(GL_POINT_SPRITE_R_MODE_NV, [GL_S])
|
348
|
+
assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_S)
|
349
|
+
end
|
350
|
+
|
351
|
+
end
|
352
|
+
|
data/test/test_glu.rb
ADDED
@@ -0,0 +1,309 @@
|
|
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
|
+
|
18
|
+
class TestGlu < OpenGL::TestCase
|
19
|
+
|
20
|
+
def test_gluortho
|
21
|
+
res = [ [2.0/WINDOW_SIZE, 0, 0, 0],
|
22
|
+
[0, 2.0/WINDOW_SIZE, 0, 0],
|
23
|
+
[0, 0, -1, 0],
|
24
|
+
[-1, -1, 0, 1] ]
|
25
|
+
|
26
|
+
glMatrixMode(GL_PROJECTION)
|
27
|
+
glLoadIdentity()
|
28
|
+
gluOrtho2D(0, WINDOW_SIZE, 0, WINDOW_SIZE)
|
29
|
+
assert_equal res, glGetDoublev(GL_PROJECTION_MATRIX)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_glugetstring
|
33
|
+
refute_empty gluGetString GLU_VERSION
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_gluerrorstring
|
37
|
+
refute_empty gluErrorString GL_INVALID_VALUE
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_glubuild2dmipmaps
|
41
|
+
textures = glGenTextures(1)
|
42
|
+
glBindTexture(GL_TEXTURE_2D, textures[0])
|
43
|
+
|
44
|
+
image = ([0, 0, 0, 1, 1, 1] * 8).pack("f*") # 16 RGB pixels
|
45
|
+
|
46
|
+
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB8, 4, 4, GL_RGB, GL_FLOAT, image)
|
47
|
+
im = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT)
|
48
|
+
|
49
|
+
assert_equal image, im
|
50
|
+
assert_equal 4*4*3, im.unpack("f*").size
|
51
|
+
|
52
|
+
im = glGetTexImage(GL_TEXTURE_2D, 1, GL_RGB, GL_FLOAT)
|
53
|
+
assert_equal 2*2*3, im.unpack("f*").size
|
54
|
+
|
55
|
+
im = glGetTexImage(GL_TEXTURE_2D, 2, GL_RGB, GL_FLOAT)
|
56
|
+
assert_equal 1*1*3, im.unpack("f*").size
|
57
|
+
|
58
|
+
glDeleteTextures(textures)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_glubuild1dmipmaps
|
62
|
+
textures = glGenTextures(1)
|
63
|
+
glBindTexture(GL_TEXTURE_1D, textures[0])
|
64
|
+
|
65
|
+
image = ([0, 0, 0, 1, 1, 1] * 2).pack("f*") # 4 RGB pixels
|
66
|
+
|
67
|
+
gluBuild1DMipmaps(GL_TEXTURE_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT, image)
|
68
|
+
|
69
|
+
im = glGetTexImage(GL_TEXTURE_1D, 0, GL_RGB, GL_FLOAT)
|
70
|
+
assert_equal image, im
|
71
|
+
assert_equal 4*3, im.unpack("f*").size
|
72
|
+
im = glGetTexImage(GL_TEXTURE_1D, 1, GL_RGB, GL_FLOAT)
|
73
|
+
assert_equal 2*3, im.unpack("f*").size
|
74
|
+
im = glGetTexImage(GL_TEXTURE_1D, 2, GL_RGB, GL_FLOAT)
|
75
|
+
assert_equal 1*3, im.unpack("f*").size
|
76
|
+
|
77
|
+
glDeleteTextures(textures)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_glulookat
|
81
|
+
m = [[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, -1, 1]]
|
82
|
+
gluLookAt(1, 0, 0, 0, 0, 0, 0, 1, 0)
|
83
|
+
assert_equal m, glGetDoublev(GL_PROJECTION_MATRIX)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_gluproject
|
87
|
+
pos = gluProject(1, 1, 1)
|
88
|
+
assert_equal [WINDOW_SIZE, WINDOW_SIZE, 1], pos
|
89
|
+
|
90
|
+
mp = glGetDoublev(GL_PROJECTION_MATRIX)
|
91
|
+
mm = Matrix.rows(glGetDoublev(GL_MODELVIEW_MATRIX))
|
92
|
+
view = glGetDoublev(GL_VIEWPORT)
|
93
|
+
pos = gluProject(1, 1, 1, mp, mm, view)
|
94
|
+
assert_equal(pos, [WINDOW_SIZE, WINDOW_SIZE, 1])
|
95
|
+
|
96
|
+
assert_raises ArgumentError do pos = gluProject(1, 1, 1, mp, [1, 2, 3, 4], view) end
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_gluunproject
|
100
|
+
pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1)
|
101
|
+
assert_equal(pos, [1, 1, 1])
|
102
|
+
|
103
|
+
mp = glGetDoublev(GL_PROJECTION_MATRIX)
|
104
|
+
mm = Matrix.rows(glGetDoublev(GL_MODELVIEW_MATRIX))
|
105
|
+
view = glGetDoublev(GL_VIEWPORT)
|
106
|
+
pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1, mp, mm, view)
|
107
|
+
assert_equal(pos, [1, 1, 1])
|
108
|
+
assert_raises ArgumentError do pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1, mp, [1, 2, 3, 4], view) end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_glupickmatrix
|
112
|
+
t = WINDOW_SIZE / 5.0
|
113
|
+
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]]
|
114
|
+
glMatrixMode(GL_PROJECTION)
|
115
|
+
|
116
|
+
glLoadIdentity()
|
117
|
+
gluPickMatrix(0, 0)
|
118
|
+
assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
|
119
|
+
|
120
|
+
glLoadIdentity()
|
121
|
+
gluPickMatrix(0, 0, 5, 5)
|
122
|
+
assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
|
123
|
+
|
124
|
+
glLoadIdentity()
|
125
|
+
gluPickMatrix(0, 0, 5, 5, glGetDoublev(GL_VIEWPORT))
|
126
|
+
assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_gluperspective
|
130
|
+
m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -3, -1], [0, 0, -4, 0]]
|
131
|
+
gluPerspective(90, 1, 1, 2)
|
132
|
+
assert_equal m, glGetDoublev(GL_PROJECTION_MATRIX)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_gluscaleimage
|
136
|
+
image = ([0, 0, 0, 1, 1, 1] * 8).pack("f*") # 16 RGB pixels
|
137
|
+
scaled = gluScaleImage(GL_RGB, 4, 4, GL_FLOAT, image, 2, 2, GL_FLOAT)
|
138
|
+
assert_equal(scaled.unpack("f*").length, 2*2*3)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_gluquadrics
|
142
|
+
ecount = 0
|
143
|
+
error_func = lambda do |error|
|
144
|
+
ecount+=1
|
145
|
+
end
|
146
|
+
|
147
|
+
q = gluNewQuadric()
|
148
|
+
gluQuadricDrawStyle(q, GL_LINE)
|
149
|
+
gluQuadricNormals(q, GL_SMOOTH)
|
150
|
+
gluQuadricOrientation(q, GLU_OUTSIDE)
|
151
|
+
gluQuadricTexture(q, GL_FALSE)
|
152
|
+
gluQuadricCallback(q, GLU_ERROR, error_func)
|
153
|
+
|
154
|
+
buf = glFeedbackBuffer(1024, GL_3D)
|
155
|
+
glRenderMode(GL_FEEDBACK)
|
156
|
+
gluSphere(q, 1.0, 4, 3)
|
157
|
+
count = glRenderMode(GL_RENDER)
|
158
|
+
refute_equal 0, count
|
159
|
+
|
160
|
+
glRenderMode(GL_FEEDBACK)
|
161
|
+
gluCylinder(q, 1.0, 1.0, 1.0, 4, 3)
|
162
|
+
count = glRenderMode(GL_RENDER)
|
163
|
+
refute_equal 0, count
|
164
|
+
|
165
|
+
glRenderMode(GL_FEEDBACK)
|
166
|
+
gluDisk(q, 1.0, 2.0, 4, 3)
|
167
|
+
count = glRenderMode(GL_RENDER)
|
168
|
+
refute_equal 0, count
|
169
|
+
|
170
|
+
glRenderMode(GL_FEEDBACK)
|
171
|
+
gluPartialDisk(q, 1.0, 2.0, 4, 3, 0, 360)
|
172
|
+
count = glRenderMode(GL_RENDER)
|
173
|
+
refute_equal 0, count
|
174
|
+
|
175
|
+
assert_equal 0, ecount
|
176
|
+
gluSphere(q, 0.0, 0, 0)
|
177
|
+
assert_equal 1, ecount
|
178
|
+
gluDeleteQuadric(q)
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_glunurbs
|
182
|
+
ecount = 0
|
183
|
+
|
184
|
+
glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE)
|
185
|
+
glMatrixMode(GL_PROJECTION)
|
186
|
+
glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1)
|
187
|
+
|
188
|
+
n_error = lambda do |error|
|
189
|
+
ecount += 1
|
190
|
+
end
|
191
|
+
|
192
|
+
m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
|
193
|
+
m2 = Matrix.rows(m)
|
194
|
+
|
195
|
+
n = gluNewNurbsRenderer()
|
196
|
+
gluNurbsCallback(n, GLU_ERROR, n_error)
|
197
|
+
gluNurbsProperty(n, GLU_SAMPLING_TOLERANCE, 40)
|
198
|
+
assert_equal 40, gluGetNurbsProperty(n, GLU_SAMPLING_TOLERANCE)
|
199
|
+
|
200
|
+
gluLoadSamplingMatrices(n, m, m2, glGetIntegerv(GL_VIEWPORT))
|
201
|
+
assert_raises ArgumentError do gluLoadSamplingMatrices(n, m, [1, 2, 3, 4], glGetIntegerv(GL_VIEWPORT)) end
|
202
|
+
|
203
|
+
knots = [0, 0, 0, 0, 1, 1, 1, 1]
|
204
|
+
ctlpoints_curve = [[50, 50, 0], [400, 50, 0], [400, 400, 0], [50, 400, 0]]
|
205
|
+
|
206
|
+
# generate surface control points
|
207
|
+
ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
|
208
|
+
0.upto(3) do |u|
|
209
|
+
0.upto(3) do |v|
|
210
|
+
ctlpoints[u][v][0]=2.0*(u-1.5)
|
211
|
+
ctlpoints[u][v][1]=2.0*(v-1.5)
|
212
|
+
|
213
|
+
if ((u==1 || u==2) && (v==1 || v==2))
|
214
|
+
ctlpoints[u][v][2]=6.0
|
215
|
+
else
|
216
|
+
ctlpoints[u][v][2]=0.0
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
buf = glFeedbackBuffer(1024*1024*8, GL_3D) # large enough buffer for tesselated surface
|
222
|
+
glRenderMode(GL_FEEDBACK)
|
223
|
+
gluBeginCurve(n)
|
224
|
+
gluNurbsCurve(n, knots, ctlpoints_curve, 4, GL_MAP1_VERTEX_3)
|
225
|
+
gluEndCurve(n)
|
226
|
+
|
227
|
+
gluBeginSurface(n)
|
228
|
+
gluNurbsSurface(n, knots, knots, ctlpoints, 4, 4, GL_MAP2_VERTEX_3)
|
229
|
+
gluEndSurface(n)
|
230
|
+
|
231
|
+
count = glRenderMode(GL_RENDER)
|
232
|
+
refute_equal 1, count
|
233
|
+
|
234
|
+
assert_equal 0, ecount
|
235
|
+
gluBeginTrim(n)
|
236
|
+
gluPwlCurve(n, [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]], GLU_MAP1_TRIM_2)
|
237
|
+
gluEndTrim(n)
|
238
|
+
|
239
|
+
gluDeleteNurbsRenderer(n)
|
240
|
+
assert_equal 1, ecount
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_glutess
|
244
|
+
glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE)
|
245
|
+
glMatrixMode(GL_PROJECTION)
|
246
|
+
glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1)
|
247
|
+
vcount, bcount, ecount = 0, 0, 0
|
248
|
+
|
249
|
+
cb_begin = lambda do |type|
|
250
|
+
bcount += 1
|
251
|
+
end
|
252
|
+
cb_end = lambda do
|
253
|
+
ecount += 1
|
254
|
+
end
|
255
|
+
cb_vertex = lambda do |data|
|
256
|
+
vcount += 1
|
257
|
+
end
|
258
|
+
cb_error = lambda do |error|
|
259
|
+
p gluErrorString(error)
|
260
|
+
end
|
261
|
+
|
262
|
+
t = gluNewTess()
|
263
|
+
gluTessCallback(t, GLU_TESS_BEGIN, cb_begin)
|
264
|
+
gluTessCallback(t, GLU_TESS_END, cb_end)
|
265
|
+
gluTessCallback(t, GLU_TESS_ERROR, cb_error)
|
266
|
+
gluTessCallback(t, GLU_TESS_VERTEX, cb_vertex)
|
267
|
+
gluTessProperty(t, GLU_TESS_BOUNDARY_ONLY, GL_TRUE)
|
268
|
+
assert_equal GL_TRUE, gluGetTessProperty(t, GLU_TESS_BOUNDARY_ONLY)
|
269
|
+
gluTessProperty(t, GLU_TESS_BOUNDARY_ONLY, GL_FALSE)
|
270
|
+
assert_equal GL_FALSE, gluGetTessProperty(t, GLU_TESS_BOUNDARY_ONLY)
|
271
|
+
|
272
|
+
gluTessNormal(t, 0.0, 0.0, 0.0)
|
273
|
+
|
274
|
+
rect = [[50.0, 50.0, 0.0],
|
275
|
+
[200.0, 50.0, 0.0],
|
276
|
+
[200.0, 200.0, 0.0],
|
277
|
+
[50.0, 200.0, 0.0]]
|
278
|
+
tri = [[75.0, 75.0, 0.0],
|
279
|
+
[125.0, 175.0, 0.0],
|
280
|
+
[175.0, 75.0, 0.0]]
|
281
|
+
|
282
|
+
gluTessBeginPolygon(t, nil)
|
283
|
+
gluTessBeginContour(t)
|
284
|
+
gluTessVertex(t, rect[0], rect[0])
|
285
|
+
gluTessVertex(t, rect[1], rect[1])
|
286
|
+
gluTessVertex(t, rect[2], rect[2])
|
287
|
+
gluTessVertex(t, rect[3], rect[3])
|
288
|
+
gluTessEndContour(t)
|
289
|
+
gluTessBeginContour(t)
|
290
|
+
gluTessVertex(t, tri[0], tri[0])
|
291
|
+
gluTessVertex(t, tri[1], tri[1])
|
292
|
+
gluTessVertex(t, tri[2], tri[2])
|
293
|
+
gluTessEndContour(t)
|
294
|
+
gluTessEndPolygon(t)
|
295
|
+
|
296
|
+
gluTessCallback(t, GLU_TESS_BEGIN, nil)
|
297
|
+
gluTessCallback(t, GLU_TESS_END, nil)
|
298
|
+
gluTessCallback(t, GLU_TESS_ERROR, nil)
|
299
|
+
gluTessCallback(t, GLU_TESS_VERTEX, nil)
|
300
|
+
|
301
|
+
gluDeleteTess(t)
|
302
|
+
|
303
|
+
assert_equal 1, bcount
|
304
|
+
assert_equal 1, ecount
|
305
|
+
assert_equal 9, vcount
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
309
|
+
|