danabr75-opengl 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +29 -0
- data/.gemtest +0 -0
- data/.gitignore +6 -0
- data/.travis.yml +19 -0
- data/Gemfile +8 -0
- data/History.md +101 -0
- data/MIT-LICENSE +18 -0
- data/Manifest.txt +142 -0
- data/README.rdoc +105 -0
- data/Rakefile +170 -0
- data/danabr75-opengl.gemspec +32 -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 +117 -0
- data/examples/NeHe/nehe_lesson03.rb +123 -0
- data/examples/NeHe/nehe_lesson04.rb +132 -0
- data/examples/NeHe/nehe_lesson05.rb +182 -0
- data/examples/NeHe/nehe_lesson06.rb +186 -0
- data/examples/NeHe/nehe_lesson07.rb +240 -0
- data/examples/NeHe/nehe_lesson08.rb +255 -0
- data/examples/NeHe/nehe_lesson09.rb +203 -0
- data/examples/NeHe/nehe_lesson11.rb +176 -0
- data/examples/NeHe/nehe_lesson12.rb +203 -0
- data/examples/NeHe/nehe_lesson16.rb +211 -0
- data/examples/NeHe/nehe_lesson19.rb +209 -0
- data/examples/NeHe/nehe_lesson36.rb +308 -0
- data/examples/NeHe/particle.png +0 -0
- data/examples/NeHe/star.png +0 -0
- data/examples/NeHe/tim.png +0 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +378 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +408 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +16 -0
- data/examples/RedBook/aapoly.rb +143 -0
- data/examples/RedBook/aargb.rb +121 -0
- data/examples/RedBook/accanti.rb +164 -0
- data/examples/RedBook/accpersp.rb +217 -0
- data/examples/RedBook/alpha.rb +125 -0
- data/examples/RedBook/alpha3D.rb +160 -0
- data/examples/RedBook/bezcurve.rb +107 -0
- data/examples/RedBook/bezmesh.rb +139 -0
- data/examples/RedBook/checker.rb +126 -0
- data/examples/RedBook/clip.rb +97 -0
- data/examples/RedBook/colormat.rb +137 -0
- data/examples/RedBook/cube.rb +71 -0
- data/examples/RedBook/depthcue.rb +101 -0
- data/examples/RedBook/dof.rb +206 -0
- data/examples/RedBook/double.rb +107 -0
- data/examples/RedBook/drawf.rb +93 -0
- data/examples/RedBook/feedback.rb +147 -0
- data/examples/RedBook/fog.rb +168 -0
- data/examples/RedBook/font.rb +153 -0
- data/examples/RedBook/hello.rb +81 -0
- data/examples/RedBook/image.rb +139 -0
- data/examples/RedBook/jitter.rb +207 -0
- data/examples/RedBook/light.rb +157 -0
- data/examples/RedBook/lines.rb +130 -0
- data/examples/RedBook/list.rb +113 -0
- data/examples/RedBook/material.rb +276 -0
- data/examples/RedBook/mipmap.rb +158 -0
- data/examples/RedBook/model.rb +115 -0
- data/examples/RedBook/movelight.rb +134 -0
- data/examples/RedBook/pickdepth.rb +181 -0
- data/examples/RedBook/planet.rb +110 -0
- data/examples/RedBook/quadric.rb +160 -0
- data/examples/RedBook/robot.rb +117 -0
- data/examples/RedBook/select.rb +198 -0
- data/examples/RedBook/smooth.rb +97 -0
- data/examples/RedBook/stencil.rb +165 -0
- data/examples/RedBook/stroke.rb +169 -0
- data/examples/RedBook/surface.rb +168 -0
- data/examples/RedBook/teaambient.rb +134 -0
- data/examples/RedBook/teapots.rb +184 -0
- data/examples/RedBook/tess.rb +185 -0
- data/examples/RedBook/texbind.rb +149 -0
- data/examples/RedBook/texgen.rb +171 -0
- data/examples/RedBook/texturesurf.rb +130 -0
- data/examples/RedBook/varray.rb +161 -0
- data/examples/RedBook/wrap.rb +150 -0
- data/examples/misc/OGLBench.rb +338 -0
- data/examples/misc/anisotropic.rb +196 -0
- data/examples/misc/fbo_test.rb +357 -0
- data/examples/misc/font-glut.rb +47 -0
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/plane.rb +161 -0
- data/examples/misc/readpixel.rb +66 -0
- data/examples/misc/sdltest.rb +36 -0
- data/examples/misc/trislam.rb +829 -0
- data/ext/opengl/GL/gl.h +2115 -0
- data/ext/opengl/GL/glext.h +11770 -0
- data/ext/opengl/common.h +372 -0
- data/ext/opengl/conv.h +247 -0
- data/ext/opengl/extconf.rb +19 -0
- data/ext/opengl/fptr_struct.h +912 -0
- data/ext/opengl/funcdef.h +279 -0
- data/ext/opengl/gl-1.0-1.1.c +3345 -0
- data/ext/opengl/gl-1.2.c +155 -0
- data/ext/opengl/gl-1.3.c +447 -0
- data/ext/opengl/gl-1.4.c +346 -0
- data/ext/opengl/gl-1.5.c +225 -0
- data/ext/opengl/gl-2.0.c +665 -0
- data/ext/opengl/gl-2.1.c +57 -0
- data/ext/opengl/gl-3.0.c +502 -0
- data/ext/opengl/gl-enums.c +4853 -0
- data/ext/opengl/gl-enums.h +14528 -0
- data/ext/opengl/gl-error.c +110 -0
- data/ext/opengl/gl-error.h +25 -0
- data/ext/opengl/gl-ext-3dfx.c +27 -0
- data/ext/opengl/gl-ext-arb.c +880 -0
- data/ext/opengl/gl-ext-ati.c +41 -0
- data/ext/opengl/gl-ext-ext.c +885 -0
- data/ext/opengl/gl-ext-gremedy.c +41 -0
- data/ext/opengl/gl-ext-nv.c +679 -0
- data/ext/opengl/gl.c +265 -0
- data/ext/opengl/gl_buffer.c +202 -0
- data/ext/opengl/glimpl.c +187 -0
- data/ext/opengl/glimpl.h +47 -0
- data/ext/opengl/opengl.c +9 -0
- data/lib/gl.rb +1 -0
- data/lib/opengl.rb +79 -0
- data/lib/opengl/bindings_version.rb +4 -0
- data/lib/opengl/implementation.rb +38 -0
- data/lib/opengl/test_case.rb +86 -0
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +45 -0
- data/test/test_gl_10_11.rb +1363 -0
- data/test/test_gl_12.rb +71 -0
- data/test/test_gl_13.rb +221 -0
- data/test/test_gl_14.rb +218 -0
- data/test/test_gl_15.rb +258 -0
- data/test/test_gl_20.rb +417 -0
- data/test/test_gl_21.rb +436 -0
- data/test/test_gl_ext_arb.rb +508 -0
- data/test/test_gl_ext_ati.rb +28 -0
- data/test/test_gl_ext_ext.rb +608 -0
- data/test/test_gl_ext_gremedy.rb +29 -0
- data/test/test_gl_ext_nv.rb +349 -0
- data/test/test_glimpl.rb +23 -0
- data/test/test_opengl_buffer.rb +122 -0
- data/utils/README +6 -0
- data/utils/enumgen.rb +108 -0
- data/utils/extlistgen.rb +90 -0
- metadata +326 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
# This file is used to setup a dummy X server for testing on http://travis-ci.org
|
2
|
+
# See config file ".travis.yml"
|
3
|
+
|
4
|
+
##Xdummy:##
|
5
|
+
Section "ServerFlags"
|
6
|
+
Option "DontVTSwitch" "true"
|
7
|
+
Option "AllowMouseOpenFail" "true"
|
8
|
+
Option "PciForceNone" "true"
|
9
|
+
Option "AutoEnableDevices" "false"
|
10
|
+
Option "AutoAddDevices" "false"
|
11
|
+
EndSection
|
12
|
+
|
13
|
+
Section "Module"
|
14
|
+
Load "/usr/lib/xorg/modules/extensions/libglx.so"
|
15
|
+
EndSection
|
16
|
+
|
17
|
+
Section "Extensions"
|
18
|
+
Option "GLX" "Enable"
|
19
|
+
Option "NV-GLX" "Disable"
|
20
|
+
EndSection
|
21
|
+
|
22
|
+
|
23
|
+
##Xdummy:##
|
24
|
+
Section "InputDevice"
|
25
|
+
Identifier "NoMouse"
|
26
|
+
Option "CorePointer" "true"
|
27
|
+
Driver "void"
|
28
|
+
EndSection
|
29
|
+
|
30
|
+
Section "InputDevice"
|
31
|
+
Identifier "NoKeyboard"
|
32
|
+
Option "CoreKeyboard" "true"
|
33
|
+
Driver "void"
|
34
|
+
EndSection
|
35
|
+
|
36
|
+
##Xdummy:##
|
37
|
+
Section "Device"
|
38
|
+
Identifier "Videocard0"
|
39
|
+
Driver "dummy"
|
40
|
+
#VideoRam 4096000
|
41
|
+
VideoRam 256000
|
42
|
+
EndSection
|
43
|
+
|
44
|
+
##Xdummy:##
|
45
|
+
Section "Monitor"
|
46
|
+
Identifier "Monitor0"
|
47
|
+
HorizSync 10.0 - 300.0
|
48
|
+
VertRefresh 10.0 - 200.0
|
49
|
+
DisplaySize 4335 1084
|
50
|
+
#The following modeline is invalid (calculator overflowed):
|
51
|
+
#Modeline "32000x32000@0" -38917.43 32000 32032 -115848 -115816 32000 32775 32826 33601
|
52
|
+
Modeline "16384x8192@10" 2101.93 16384 16416 24400 24432 8192 8390 8403 8602
|
53
|
+
Modeline "8192x4096@10" 424.46 8192 8224 9832 9864 4096 4195 4202 4301
|
54
|
+
Modeline "5120x3200@10" 199.75 5120 5152 5904 5936 3200 3277 3283 3361
|
55
|
+
Modeline "3840x2880@10" 133.43 3840 3872 4376 4408 2880 2950 2955 3025
|
56
|
+
Modeline "3840x2560@10" 116.93 3840 3872 4312 4344 2560 2622 2627 2689
|
57
|
+
Modeline "3840x2048@10" 91.45 3840 3872 4216 4248 2048 2097 2101 2151
|
58
|
+
Modeline "2048x2048@10" 49.47 2048 2080 2264 2296 2048 2097 2101 2151
|
59
|
+
Modeline "2560x1600@10" 47.12 2560 2592 2768 2800 1600 1639 1642 1681
|
60
|
+
Modeline "1920x1200@10" 26.28 1920 1952 2048 2080 1200 1229 1231 1261
|
61
|
+
Modeline "1920x1080@10" 23.53 1920 1952 2040 2072 1080 1106 1108 1135
|
62
|
+
Modeline "1680x1050@10" 20.08 1680 1712 1784 1816 1050 1075 1077 1103
|
63
|
+
Modeline "1600x900@20" 33.92 1600 1632 1760 1792 900 921 924 946
|
64
|
+
Modeline "1440x900@20" 30.66 1440 1472 1584 1616 900 921 924 946
|
65
|
+
Modeline "1360x768@20" 24.49 1360 1392 1480 1512 768 786 789 807
|
66
|
+
#common resolutions for android devices (both orientations):
|
67
|
+
Modeline "800x1280@20" 25.89 800 832 928 960 1280 1310 1315 1345
|
68
|
+
Modeline "1280x800@20" 24.15 1280 1312 1400 1432 800 819 822 841
|
69
|
+
Modeline "720x1280@25" 30.22 720 752 864 896 1280 1309 1315 1345
|
70
|
+
Modeline "1280x720@25" 27.41 1280 1312 1416 1448 720 737 740 757
|
71
|
+
Modeline "768x1024@25" 24.93 768 800 888 920 1024 1047 1052 1076
|
72
|
+
Modeline "1024x768@25" 23.77 1024 1056 1144 1176 768 785 789 807
|
73
|
+
Modeline "600x1024@25" 19.90 600 632 704 736 1024 1047 1052 1076
|
74
|
+
Modeline "1024x600@25" 18.26 1024 1056 1120 1152 600 614 617 631
|
75
|
+
Modeline "536x960@25" 16.74 536 568 624 656 960 982 986 1009
|
76
|
+
Modeline "960x536@25" 15.23 960 992 1048 1080 536 548 551 563
|
77
|
+
Modeline "600x800@25" 15.17 600 632 688 720 800 818 822 841
|
78
|
+
Modeline "800x600@25" 14.50 800 832 880 912 600 614 617 631
|
79
|
+
Modeline "480x854@25" 13.34 480 512 560 592 854 873 877 897
|
80
|
+
Modeline "848x480@25" 12.09 848 880 920 952 480 491 493 505
|
81
|
+
Modeline "480x800@25" 12.43 480 512 552 584 800 818 822 841
|
82
|
+
Modeline "800x480@25" 11.46 800 832 872 904 480 491 493 505
|
83
|
+
Modeline "320x480@50" 10.73 320 352 392 424 480 490 494 505
|
84
|
+
Modeline "480x320@50" 9.79 480 512 544 576 320 327 330 337
|
85
|
+
Modeline "240x400@50" 6.96 240 272 296 328 400 408 412 421
|
86
|
+
Modeline "400x240@50" 6.17 400 432 448 480 240 245 247 253
|
87
|
+
Modeline "240x320@50" 5.47 240 272 288 320 320 327 330 337
|
88
|
+
Modeline "320x240@50" 5.10 320 352 368 400 240 245 247 253
|
89
|
+
#resolutions for android devices (both orientations)
|
90
|
+
#minus the status bar
|
91
|
+
#38px status bar (and width rounded up)
|
92
|
+
Modeline "800x1242@20" 25.03 800 832 920 952 1242 1271 1275 1305
|
93
|
+
Modeline "1280x762@20" 22.93 1280 1312 1392 1424 762 780 783 801
|
94
|
+
Modeline "720x1242@25" 29.20 720 752 856 888 1242 1271 1276 1305
|
95
|
+
Modeline "1280x682@25" 25.85 1280 1312 1408 1440 682 698 701 717
|
96
|
+
Modeline "768x986@25" 23.90 768 800 888 920 986 1009 1013 1036
|
97
|
+
Modeline "1024x730@25" 22.50 1024 1056 1136 1168 730 747 750 767
|
98
|
+
Modeline "600x986@25" 19.07 600 632 704 736 986 1009 1013 1036
|
99
|
+
Modeline "1024x562@25" 17.03 1024 1056 1120 1152 562 575 578 591
|
100
|
+
Modeline "536x922@25" 16.01 536 568 624 656 922 943 947 969
|
101
|
+
Modeline "960x498@25" 14.09 960 992 1040 1072 498 509 511 523
|
102
|
+
Modeline "600x762@25" 14.39 600 632 680 712 762 779 783 801
|
103
|
+
Modeline "800x562@25" 13.52 800 832 880 912 562 575 578 591
|
104
|
+
Modeline "480x810@25" 12.59 480 512 552 584 810 828 832 851
|
105
|
+
Modeline "848x442@25" 11.09 848 880 920 952 442 452 454 465
|
106
|
+
Modeline "480x762@25" 11.79 480 512 552 584 762 779 783 801
|
107
|
+
Modeline "800x442@25" 10.51 800 832 864 896 442 452 454 465
|
108
|
+
#32px status bar (no need for rounding):
|
109
|
+
Modeline "320x448@50" 9.93 320 352 384 416 448 457 461 471
|
110
|
+
Modeline "480x288@50" 8.75 480 512 544 576 288 294 297 303
|
111
|
+
#24px status bar:
|
112
|
+
Modeline "240x376@50" 6.49 240 272 296 328 376 384 387 395
|
113
|
+
Modeline "400x216@50" 5.50 400 432 448 480 216 220 222 227
|
114
|
+
Modeline "240x296@50" 5.02 240 272 288 320 296 302 305 311
|
115
|
+
Modeline "320x216@50" 4.55 320 352 368 400 216 220 222 227
|
116
|
+
EndSection
|
117
|
+
|
118
|
+
##Xdummy:##
|
119
|
+
Section "Screen"
|
120
|
+
Identifier "Screen0"
|
121
|
+
Device "Videocard0"
|
122
|
+
Monitor "Monitor0"
|
123
|
+
DefaultDepth 24
|
124
|
+
SubSection "Display"
|
125
|
+
Viewport 0 0
|
126
|
+
Depth 24
|
127
|
+
Modes "32000x32000" "16384x8192" "8192x4096" "5120x3200" "3840x2880" "3840x2560" "3840x2048" "2048x2048" "2560x1600" "1920x1440" "1920x1200" "1920x1080" "1600x1200" "1680x1050" "1600x900" "1400x1050" "1440x900" "1280x1024" "1366x768" "1280x800" "1024x768" "1024x600" "800x600" "320x200"
|
128
|
+
#Virtual 32000 32000
|
129
|
+
#Virtual 16384 8192
|
130
|
+
#Virtual 8192 4096
|
131
|
+
Virtual 1920 1440
|
132
|
+
EndSubSection
|
133
|
+
EndSection
|
134
|
+
|
135
|
+
Section "ServerLayout"
|
136
|
+
Identifier "dummy_layout"
|
137
|
+
Screen "screen0"
|
138
|
+
InputDevice "NoMouse"
|
139
|
+
InputDevice "NoKeyboard"
|
140
|
+
EndSection
|
data/test/test_gl.rb
ADDED
@@ -0,0 +1,45 @@
|
|
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 TestGl < OpenGL::TestCase
|
19
|
+
def test_isavailable
|
20
|
+
assert_equal(true, is_available?(1.1))
|
21
|
+
assert_equal(true, is_available?("GL_ARB_multitexture"))
|
22
|
+
assert_equal(false, is_available?("GL_NON_EXISTENT"))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_errorchecking
|
26
|
+
Gl.disable_error_checking
|
27
|
+
assert_equal(false, Gl.is_error_checking_enabled?)
|
28
|
+
Gl.enable_error_checking
|
29
|
+
assert_equal(true, Gl.is_error_checking_enabled?)
|
30
|
+
begin
|
31
|
+
glEnable(0)
|
32
|
+
rescue Gl::Error => err
|
33
|
+
assert_equal(err.id, GL_INVALID_ENUM)
|
34
|
+
else
|
35
|
+
assert(false) # error not detected
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_implementation
|
40
|
+
old_glimpl = Gl.implementation
|
41
|
+
Gl.implementation = Gl::DefaultImplementation.open
|
42
|
+
|
43
|
+
refute_equal old_glimpl, Gl.implementation
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,1363 @@
|
|
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 TestGl10_11 < OpenGL::TestCase
|
19
|
+
def test_glhint
|
20
|
+
glHint(GL_FOG_HINT,GL_NICEST)
|
21
|
+
assert_equal(glGetIntegerv(GL_FOG_HINT), GL_NICEST)
|
22
|
+
glHint(GL_FOG_HINT,GL_FASTEST)
|
23
|
+
assert_equal(glGetIntegerv(GL_FOG_HINT), GL_FASTEST)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_glindex
|
27
|
+
glIndexd(2.0)
|
28
|
+
assert_in_delta(2.0, glGetDoublev(GL_CURRENT_INDEX), 0.001)
|
29
|
+
glIndexdv([3.0])
|
30
|
+
assert_in_delta(3.0, glGetDoublev(GL_CURRENT_INDEX), 0.001)
|
31
|
+
|
32
|
+
glIndexf(4.0)
|
33
|
+
assert_in_delta(4.0, glGetFloatv(GL_CURRENT_INDEX), 0.001)
|
34
|
+
glIndexfv([5.0])
|
35
|
+
assert_in_delta(5.0, glGetFloatv(GL_CURRENT_INDEX), 0.001)
|
36
|
+
|
37
|
+
glIndexi(6)
|
38
|
+
assert_in_delta(6, glGetIntegerv(GL_CURRENT_INDEX), 0.001)
|
39
|
+
glIndexiv([7])
|
40
|
+
assert_in_delta(7, glGetIntegerv(GL_CURRENT_INDEX), 0.001)
|
41
|
+
|
42
|
+
glIndexs(8)
|
43
|
+
assert_in_delta(8, glGetIntegerv(GL_CURRENT_INDEX), 0.001)
|
44
|
+
glIndexsv([9])
|
45
|
+
assert_in_delta(9, glGetIntegerv(GL_CURRENT_INDEX), 0.001)
|
46
|
+
|
47
|
+
glIndexub(10)
|
48
|
+
assert_in_delta(10, glGetIntegerv(GL_CURRENT_INDEX), 0.001)
|
49
|
+
glIndexubv([11])
|
50
|
+
assert_in_delta(11, glGetIntegerv(GL_CURRENT_INDEX), 0.001)
|
51
|
+
|
52
|
+
# index pointer
|
53
|
+
glIndexPointer(GL_INT, 2, "")
|
54
|
+
assert_equal(2, glGetIntegerv(GL_INDEX_ARRAY_STRIDE))
|
55
|
+
assert_equal(GL_INT, glGetIntegerv(GL_INDEX_ARRAY_TYPE))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_glclear
|
59
|
+
glClearColor(1,0,1,0)
|
60
|
+
assert_equal([1,0,1,0], glGetDoublev(GL_COLOR_CLEAR_VALUE))
|
61
|
+
|
62
|
+
glClearIndex(2)
|
63
|
+
assert_equal(2, glGetDoublev(GL_INDEX_CLEAR_VALUE))
|
64
|
+
|
65
|
+
glClearAccum(0.5,0.5,0.5,0.5)
|
66
|
+
assert_equal([0.5,0.5,0.5,0.5], glGetDoublev(GL_ACCUM_CLEAR_VALUE))
|
67
|
+
|
68
|
+
glClearStencil(1)
|
69
|
+
assert_equal(1, glGetIntegerv(GL_STENCIL_CLEAR_VALUE))
|
70
|
+
|
71
|
+
glClearDepth(0.5)
|
72
|
+
assert_equal(0.5, glGetDoublev(GL_DEPTH_CLEAR_VALUE))
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_glclientattrib
|
76
|
+
glPixelStorei(GL_PACK_ALIGNMENT,2)
|
77
|
+
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT)
|
78
|
+
glPixelStorei(GL_PACK_ALIGNMENT,4)
|
79
|
+
assert_equal(4, glGetIntegerv(GL_PACK_ALIGNMENT))
|
80
|
+
glPopClientAttrib()
|
81
|
+
assert_equal(2, glGetIntegerv(GL_PACK_ALIGNMENT))
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_matrix
|
85
|
+
m_a = [[2.0,0.0,0.0,0.0],
|
86
|
+
[0.0,2.0,0.0,0.0],
|
87
|
+
[0.0,0.0,2.0,0.0],
|
88
|
+
[0.0,0.0,0.0,2.0]]
|
89
|
+
|
90
|
+
m_b = [[3.0,0.0,0.0,0.0],
|
91
|
+
[0.0,3.0,0.0,0.0],
|
92
|
+
[0.0,0.0,3.0,0.0],
|
93
|
+
[0.0,0.0,0.0,3.0]]
|
94
|
+
|
95
|
+
m_ident = [[1.0,0.0,0.0,0.0],
|
96
|
+
[0.0,1.0,0.0,0.0],
|
97
|
+
[0.0,0.0,1.0,0.0],
|
98
|
+
[0.0,0.0,0.0,1.0]]
|
99
|
+
|
100
|
+
# 1
|
101
|
+
glMatrixMode(GL_MODELVIEW)
|
102
|
+
glLoadMatrixf(m_a)
|
103
|
+
assert_equal(m_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
104
|
+
glLoadMatrixd(m_b)
|
105
|
+
assert_equal(m_b, glGetDoublev(GL_MODELVIEW_MATRIX))
|
106
|
+
|
107
|
+
glLoadIdentity()
|
108
|
+
assert_equal( m_ident, glGetDoublev(GL_MODELVIEW_MATRIX))
|
109
|
+
|
110
|
+
glMultMatrixf(m_a)
|
111
|
+
assert_equal(m_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
112
|
+
glLoadIdentity()
|
113
|
+
glMultMatrixd(m_b)
|
114
|
+
assert_equal(m_b, glGetDoublev(GL_MODELVIEW_MATRIX))
|
115
|
+
|
116
|
+
# 2
|
117
|
+
glMatrixMode(GL_MODELVIEW)
|
118
|
+
glLoadMatrixf(m_a)
|
119
|
+
glMatrixMode(GL_PROJECTION)
|
120
|
+
glLoadMatrixf(m_b)
|
121
|
+
|
122
|
+
assert_equal(m_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
123
|
+
assert_equal(m_b, glGetDoublev(GL_PROJECTION_MATRIX))
|
124
|
+
|
125
|
+
glMatrixMode(GL_MODELVIEW)
|
126
|
+
glLoadMatrixf(m_a)
|
127
|
+
glPushMatrix()
|
128
|
+
glLoadMatrixf(m_b)
|
129
|
+
assert_equal(m_b, glGetDoublev(GL_MODELVIEW_MATRIX))
|
130
|
+
glPopMatrix()
|
131
|
+
assert_equal(m_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
132
|
+
|
133
|
+
# 3
|
134
|
+
m = Matrix.rows([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
|
135
|
+
glMatrixMode(GL_MODELVIEW)
|
136
|
+
glLoadMatrixf(m)
|
137
|
+
assert_equal(m.to_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
138
|
+
glLoadIdentity()
|
139
|
+
glLoadMatrixd(m)
|
140
|
+
assert_equal(m.to_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
141
|
+
glLoadIdentity()
|
142
|
+
glMultMatrixf(m)
|
143
|
+
assert_equal(m.to_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
144
|
+
glLoadIdentity()
|
145
|
+
glMultMatrixd(m)
|
146
|
+
assert_equal(m.to_a, glGetDoublev(GL_MODELVIEW_MATRIX))
|
147
|
+
|
148
|
+
assert_raises ArgumentError do glLoadMatrixf([1,2,3,4]) end
|
149
|
+
assert_raises ArgumentError do glLoadMatrixd([1,2,3,4]) end
|
150
|
+
assert_raises ArgumentError do glMultMatrixf([1,2,3,4]) end
|
151
|
+
assert_raises ArgumentError do glMultMatrixd([1,2,3,4]) end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_gledge
|
155
|
+
glEdgeFlag(GL_FALSE)
|
156
|
+
assert_equal(false, glGetBooleanv(GL_EDGE_FLAG))
|
157
|
+
|
158
|
+
glEdgeFlag(GL_TRUE)
|
159
|
+
assert_equal(true, glGetBooleanv(GL_EDGE_FLAG))
|
160
|
+
|
161
|
+
glEdgeFlagv([GL_FALSE])
|
162
|
+
assert_equal(false, glGetBooleanv(GL_EDGE_FLAG))
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_clientstate
|
166
|
+
glEnableClientState(GL_COLOR_ARRAY)
|
167
|
+
assert_equal(true, glIsEnabled(GL_COLOR_ARRAY))
|
168
|
+
glDisableClientState(GL_COLOR_ARRAY)
|
169
|
+
assert_equal(false, glIsEnabled(GL_COLOR_ARRAY))
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_glshademodel
|
173
|
+
glShadeModel(GL_FLAT)
|
174
|
+
assert_equal(GL_FLAT, glGetIntegerv(GL_SHADE_MODEL))
|
175
|
+
glShadeModel(GL_SMOOTH)
|
176
|
+
assert_equal(GL_SMOOTH, glGetIntegerv(GL_SHADE_MODEL))
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_glclipplane
|
180
|
+
glClipPlane(GL_CLIP_PLANE0,[1,2,3,4])
|
181
|
+
assert_equal([1,2,3,4], glGetClipPlane(GL_CLIP_PLANE0))
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_polygonoffset
|
185
|
+
glPolygonOffset(2.0,3.0)
|
186
|
+
assert_equal(2.0, glGetDoublev(GL_POLYGON_OFFSET_FACTOR))
|
187
|
+
assert_equal(3.0, glGetDoublev(GL_POLYGON_OFFSET_UNITS))
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_glviewport
|
191
|
+
glViewport(1,2,3,4)
|
192
|
+
assert_equal([1,2,3,4], glGetIntegerv(GL_VIEWPORT))
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_mask
|
196
|
+
glStencilMask(2)
|
197
|
+
assert_equal( 2, glGetIntegerv(GL_STENCIL_WRITEMASK))
|
198
|
+
glStencilMask(1)
|
199
|
+
assert_equal( 1, glGetIntegerv(GL_STENCIL_BACK_WRITEMASK))
|
200
|
+
|
201
|
+
glColorMask(GL_TRUE,GL_FALSE,GL_TRUE,GL_FALSE)
|
202
|
+
assert_equal([true,false,true,false], glGetBooleanv(GL_COLOR_WRITEMASK))
|
203
|
+
|
204
|
+
glDepthMask(GL_TRUE)
|
205
|
+
assert_equal(true, glGetBooleanv(GL_DEPTH_WRITEMASK))
|
206
|
+
glDepthMask(GL_FALSE)
|
207
|
+
assert_equal(false, glGetBooleanv(GL_DEPTH_WRITEMASK))
|
208
|
+
|
209
|
+
glIndexMask(2)
|
210
|
+
assert_equal(2, glGetIntegerv(GL_INDEX_WRITEMASK))
|
211
|
+
glIndexMask(1)
|
212
|
+
assert_equal(1, glGetIntegerv(GL_INDEX_WRITEMASK))
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_glflush
|
216
|
+
begin
|
217
|
+
glBegin(GL_POINTS)
|
218
|
+
glFlush()
|
219
|
+
glEnd
|
220
|
+
rescue Gl::Error => err
|
221
|
+
assert(err.id == GL_INVALID_OPERATION)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_glfinish
|
226
|
+
begin
|
227
|
+
glBegin(GL_POINTS)
|
228
|
+
glFinish()
|
229
|
+
glEnd
|
230
|
+
rescue Gl::Error => err
|
231
|
+
assert(err.id == GL_INVALID_OPERATION)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_glgetstring
|
236
|
+
assert(glGetString(GL_VERSION).size > 0)
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_glscissor
|
240
|
+
glScissor(1,2,3,4)
|
241
|
+
assert_equal([1,2,3,4], glGetIntegerv(GL_SCISSOR_BOX))
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_glstencilfunc
|
245
|
+
glStencilFunc(GL_LEQUAL,2,3)
|
246
|
+
assert_equal(GL_LEQUAL, glGetIntegerv(GL_STENCIL_FUNC))
|
247
|
+
assert_equal(2, glGetIntegerv(GL_STENCIL_REF))
|
248
|
+
assert_equal(3, glGetIntegerv(GL_STENCIL_VALUE_MASK))
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_glstencilop
|
252
|
+
glStencilOp(GL_ZERO,GL_REPLACE,GL_INCR)
|
253
|
+
assert_equal(GL_ZERO, glGetIntegerv(GL_STENCIL_FAIL))
|
254
|
+
assert_equal(GL_REPLACE, glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL))
|
255
|
+
assert_equal(GL_INCR, glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS))
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_gllogicop
|
259
|
+
glLogicOp(GL_NAND)
|
260
|
+
assert_equal(GL_NAND, glGetIntegerv(GL_LOGIC_OP_MODE))
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_glfrustum
|
264
|
+
glMatrixMode(GL_PROJECTION)
|
265
|
+
glLoadIdentity()
|
266
|
+
|
267
|
+
glFrustum(1,2,3,4,5,6)
|
268
|
+
assert_equal([[10.0, 0.0, 0.0, 0.0], [0.0, 10.0, 0.0, 0.0], [3.0, 7.0, -11.0, -1.0], [0.0, 0.0, -60.0, 0.0]], glGetDoublev(GL_PROJECTION_MATRIX))
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_gldepthrange
|
272
|
+
glDepthRange(0.5,0.5)
|
273
|
+
assert_equal([0.5,0.5], glGetDoublev(GL_DEPTH_RANGE))
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_func
|
277
|
+
glAlphaFunc(GL_GREATER, 0.5)
|
278
|
+
assert_equal(GL_GREATER, glGetIntegerv(GL_ALPHA_TEST_FUNC))
|
279
|
+
assert_equal(0.5, glGetDoublev(GL_ALPHA_TEST_REF))
|
280
|
+
|
281
|
+
glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_DST_COLOR)
|
282
|
+
assert_equal(GL_CONSTANT_ALPHA, glGetIntegerv(GL_BLEND_SRC))
|
283
|
+
assert_equal(GL_ONE_MINUS_DST_COLOR, glGetIntegerv(GL_BLEND_DST))
|
284
|
+
|
285
|
+
glDepthFunc(GL_LEQUAL)
|
286
|
+
assert_equal(GL_LEQUAL, glGetIntegerv(GL_DEPTH_FUNC))
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_glpixelzoom
|
290
|
+
glPixelZoom(0.5,0.5)
|
291
|
+
assert_equal(0.5, glGetDoublev(GL_ZOOM_X))
|
292
|
+
assert_equal(0.5, glGetDoublev(GL_ZOOM_Y))
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_glpixelstore
|
296
|
+
glPixelStoref(GL_PACK_IMAGE_HEIGHT,5)
|
297
|
+
assert_equal(5, glGetIntegerv(GL_PACK_IMAGE_HEIGHT))
|
298
|
+
glPixelStorei(GL_PACK_IMAGE_HEIGHT,6)
|
299
|
+
assert_equal(6, glGetIntegerv(GL_PACK_IMAGE_HEIGHT))
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_glpixeltransfer
|
303
|
+
glPixelTransferf(GL_RED_SCALE,2)
|
304
|
+
assert_equal(2, glGetIntegerv(GL_RED_SCALE))
|
305
|
+
glPixelTransferi(GL_RED_SCALE,3)
|
306
|
+
assert_equal(3, glGetIntegerv(GL_RED_SCALE))
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_pixelmap
|
310
|
+
glPixelMapfv(GL_PIXEL_MAP_I_TO_I,[1,2,3,4])
|
311
|
+
assert_equal([1,2,3,4], glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I))
|
312
|
+
|
313
|
+
glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,[5,6,7,8])
|
314
|
+
assert_equal([5,6,7,8], glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I))
|
315
|
+
|
316
|
+
glPixelMapusv(GL_PIXEL_MAP_I_TO_I,[9,10,11,12])
|
317
|
+
assert_equal([9,10,11,12], glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I))
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_buffers
|
321
|
+
glDrawBuffer(GL_FRONT)
|
322
|
+
assert_equal(GL_FRONT, glGetIntegerv(GL_DRAW_BUFFER))
|
323
|
+
glDrawBuffer(GL_BACK)
|
324
|
+
assert_equal(GL_BACK, glGetIntegerv(GL_DRAW_BUFFER))
|
325
|
+
|
326
|
+
glReadBuffer(GL_FRONT)
|
327
|
+
assert_equal(GL_FRONT, glGetIntegerv(GL_READ_BUFFER))
|
328
|
+
glReadBuffer(GL_BACK)
|
329
|
+
assert_equal(GL_BACK, glGetIntegerv(GL_READ_BUFFER))
|
330
|
+
end
|
331
|
+
|
332
|
+
def test__selection_buffer
|
333
|
+
buf = glSelectBuffer(32)
|
334
|
+
|
335
|
+
glRenderMode(GL_SELECT)
|
336
|
+
glInitNames()
|
337
|
+
glPushName(6)
|
338
|
+
glPushName(3)
|
339
|
+
glLoadName(5)
|
340
|
+
glPopName()
|
341
|
+
|
342
|
+
glBegin(GL_QUADS)
|
343
|
+
glVertex2i(-1,-1)
|
344
|
+
glVertex2i( 1,-1)
|
345
|
+
glVertex2i( 1, 1)
|
346
|
+
glVertex2i(-1, 1)
|
347
|
+
glEnd()
|
348
|
+
|
349
|
+
count = glRenderMode(GL_RENDER)
|
350
|
+
data = buf.unpack("i*")
|
351
|
+
assert(count==1) # number of records
|
352
|
+
assert(data[0]==1) # number of hits in this record
|
353
|
+
# assert(data[1]>0) # zbuffer near
|
354
|
+
# assert(data[2]>0) # zbuffer far
|
355
|
+
assert(data[3]==6) # name of hit
|
356
|
+
end
|
357
|
+
|
358
|
+
def test__feedback_buffer
|
359
|
+
buf = glFeedbackBuffer(32,GL_2D)
|
360
|
+
|
361
|
+
glRenderMode(GL_FEEDBACK)
|
362
|
+
|
363
|
+
glBegin(GL_TRIANGLES)
|
364
|
+
glVertex2i(-1,-1)
|
365
|
+
glVertex2i( 1,-1)
|
366
|
+
glVertex2i( 1, 1)
|
367
|
+
glEnd()
|
368
|
+
|
369
|
+
glPassThrough(2.0)
|
370
|
+
|
371
|
+
count = glRenderMode(GL_RENDER)
|
372
|
+
data = buf.unpack("f*")
|
373
|
+
assert_equal(10, count) # (1 + 1 + 3x2) + (1 + 1)
|
374
|
+
assert_equal(GL_POLYGON_TOKEN, data[0])
|
375
|
+
assert_equal(3, data[1]) # 3 vertices
|
376
|
+
# skip rasterized vertex data
|
377
|
+
assert_equal(GL_PASS_THROUGH_TOKEN, data[8])
|
378
|
+
assert_equal(2.0, data[9])
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_glrasterposv
|
382
|
+
glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
|
383
|
+
|
384
|
+
glRasterPos3dv Vector[1, 1, 1]
|
385
|
+
|
386
|
+
assert_each_in_delta [1, 1, 1, 1], glGetDoublev(GL_CURRENT_RASTER_POSITION)
|
387
|
+
end
|
388
|
+
|
389
|
+
def test_glrasterpos_2
|
390
|
+
glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
|
391
|
+
|
392
|
+
glRasterPos2d(1.0,2.0)
|
393
|
+
assert_equal([1.0,2.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
394
|
+
glRasterPos2dv([3.0,4.0])
|
395
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
396
|
+
|
397
|
+
glRasterPos2f(1.0,2.0)
|
398
|
+
assert_equal([1.0,2.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
399
|
+
glRasterPos2fv([3.0,4.0])
|
400
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
401
|
+
|
402
|
+
glRasterPos2i(1,2)
|
403
|
+
assert_equal([1.0,2.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
404
|
+
glRasterPos2iv([3,4])
|
405
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
406
|
+
|
407
|
+
glRasterPos2s(1,2)
|
408
|
+
assert_equal([1.0,2.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
409
|
+
glRasterPos2sv([3,4])
|
410
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
411
|
+
end
|
412
|
+
|
413
|
+
def test_glrasterpos_3
|
414
|
+
glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
|
415
|
+
|
416
|
+
glRasterPos3d(1.0,2.0,1.0)
|
417
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
418
|
+
glRasterPos3dv([3.0,4.0,0.0])
|
419
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
420
|
+
|
421
|
+
glRasterPos3f(1.0,2.0,1.0)
|
422
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
423
|
+
glRasterPos3fv([3.0,4.0,0.0])
|
424
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
425
|
+
|
426
|
+
glRasterPos3i(1,2,1)
|
427
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
428
|
+
glRasterPos3iv([3,4,0])
|
429
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
430
|
+
|
431
|
+
glRasterPos3s(1,2,1)
|
432
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
433
|
+
glRasterPos3sv([3,4,0])
|
434
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
435
|
+
|
436
|
+
# 4
|
437
|
+
glRasterPos4d(1.0,2.0,1.0,1.0)
|
438
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
439
|
+
glRasterPos4dv([3.0,4.0,0.0,1.0])
|
440
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
441
|
+
|
442
|
+
glRasterPos4f(1.0,2.0,1.0,1.0)
|
443
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
444
|
+
glRasterPos4fv([3.0,4.0,0.0,1.0])
|
445
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
446
|
+
|
447
|
+
glRasterPos4i(1,2,1,1)
|
448
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
449
|
+
glRasterPos4iv([3,4,0,1])
|
450
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
451
|
+
|
452
|
+
glRasterPos4s(1,2,1,1)
|
453
|
+
assert_equal([1.0,2.0,1.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
454
|
+
glRasterPos4sv([3,4,0,1])
|
455
|
+
assert_equal([3.0,4.0,0.0,1.0], glGetDoublev(GL_CURRENT_RASTER_POSITION))
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_glbitmap
|
459
|
+
glOrtho(0,WINDOW_SIZE,0,WINDOW_SIZE,0,-1)
|
460
|
+
|
461
|
+
bitmap = [ 0x55 ] * 8 # 64 bits (8x8 bitmap), stipple pattern
|
462
|
+
|
463
|
+
glPixelStorei(GL_PACK_ALIGNMENT,1)
|
464
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT,1)
|
465
|
+
|
466
|
+
glBitmap(8,8,0,0,0,0,bitmap.pack("c*"))
|
467
|
+
data = glReadPixels(0,0,8,8,GL_RED,GL_UNSIGNED_BYTE)
|
468
|
+
assert_equal([0,255] * 32, data.unpack("C*"))
|
469
|
+
end
|
470
|
+
|
471
|
+
def test_glfog
|
472
|
+
glFogfv(GL_FOG_COLOR,[0.0,1.0,0.0,1.0])
|
473
|
+
assert_equal(glGetDoublev(GL_FOG_COLOR),[0.0,1.0,0.0,1.0])
|
474
|
+
glFogf(GL_FOG_DENSITY,0.5)
|
475
|
+
assert_equal(glGetDoublev(GL_FOG_DENSITY),0.5)
|
476
|
+
glFogi(GL_FOG_MODE,GL_LINEAR)
|
477
|
+
assert_equal(glGetIntegerv(GL_FOG_MODE),GL_LINEAR)
|
478
|
+
glFogi(GL_FOG_MODE,GL_EXP)
|
479
|
+
assert_equal(glGetIntegerv(GL_FOG_MODE),GL_EXP)
|
480
|
+
glFogiv(GL_FOG_MODE,[GL_EXP2])
|
481
|
+
assert_equal(GL_EXP2, glGetIntegerv(GL_FOG_MODE))
|
482
|
+
end
|
483
|
+
|
484
|
+
def test_glcolorv
|
485
|
+
glColor3fv Vector[1, 1, 1]
|
486
|
+
|
487
|
+
assert_each_in_delta [1, 1, 1, 1], glGetDoublev(GL_CURRENT_COLOR)
|
488
|
+
end
|
489
|
+
|
490
|
+
def test_glcolor_3
|
491
|
+
glColor3b(2**7-1, 0, 2**7-1)
|
492
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
493
|
+
|
494
|
+
glColor3bv([0, 2**7-1, 0])
|
495
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
496
|
+
|
497
|
+
glColor3d(1.0, 0.0, 1.0)
|
498
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
499
|
+
|
500
|
+
glColor3dv([0.0, 1.0, 0.0])
|
501
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
502
|
+
|
503
|
+
glColor3f(1.0, 0.0, 1.0)
|
504
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
505
|
+
|
506
|
+
glColor3fv([0.0, 1.0, 0.0])
|
507
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
508
|
+
|
509
|
+
glColor3i(2**31-1, 0, 2**31-1)
|
510
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
511
|
+
|
512
|
+
glColor3iv([0, 2**31-1, 0])
|
513
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
514
|
+
|
515
|
+
glColor3s(2**15-1, 0, 2**15-1)
|
516
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
517
|
+
|
518
|
+
glColor3sv([0, 2**15-1, 0])
|
519
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
520
|
+
|
521
|
+
glColor3ub(2**8-1, 0, 2**8-1)
|
522
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
523
|
+
|
524
|
+
glColor3ubv([0, 2**8-1, 0])
|
525
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
526
|
+
|
527
|
+
glColor3ui(2**32-1, 0, 2**32-1)
|
528
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
529
|
+
|
530
|
+
glColor3uiv([0, 2**32-1, 0])
|
531
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
532
|
+
|
533
|
+
glColor3us(2**16-1, 0, 2**16-1)
|
534
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
535
|
+
|
536
|
+
glColor3usv([0, 2**16-1, 0])
|
537
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
538
|
+
end
|
539
|
+
|
540
|
+
def test_glcolor_4
|
541
|
+
glColor4b(2**7-1, 0, 2**7-1, 0)
|
542
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
543
|
+
|
544
|
+
glColor4bv([0, 2**7-1, 0, 2**7-1])
|
545
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
546
|
+
|
547
|
+
glColor4d(1.0, 0.0, 1.0, 0.0)
|
548
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
549
|
+
|
550
|
+
glColor4dv([0.0, 1.0, 0.0, 1.0])
|
551
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
552
|
+
|
553
|
+
glColor4fv([0.0, 1.0, 0.0, 1.0])
|
554
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
555
|
+
|
556
|
+
glColor4i(2**31-1, 0, 2**31-1, 0)
|
557
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
558
|
+
|
559
|
+
glColor4iv([0, 2**31-1, 0, 2**31-1])
|
560
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
561
|
+
|
562
|
+
glColor4s(2**15-1, 0, 2**15-1, 0)
|
563
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
564
|
+
|
565
|
+
glColor4sv([0, 2**15-1, 0, 2**15-1])
|
566
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
567
|
+
|
568
|
+
glColor4ub(2**8-1, 0, 2**8-1, 0)
|
569
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
570
|
+
|
571
|
+
glColor4ubv([0, 2**8-1, 0, 2**8-1])
|
572
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
573
|
+
|
574
|
+
glColor4ui(2**32-1, 0, 2**32-1, 0)
|
575
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
576
|
+
|
577
|
+
glColor4uiv([0, 2**32-1, 0, 2**32-1])
|
578
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
579
|
+
|
580
|
+
glColor4us(2**16-1, 0, 2**16-1, 0)
|
581
|
+
assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
582
|
+
|
583
|
+
glColor4usv([0, 2**16-1, 0, 2**16-1])
|
584
|
+
assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
|
585
|
+
end
|
586
|
+
|
587
|
+
def test_glortho
|
588
|
+
res = [ [2.0/WINDOW_SIZE, 0, 0, 0],
|
589
|
+
[0, 2.0/WINDOW_SIZE, 0, 0],
|
590
|
+
[0, 0, 2, 0],
|
591
|
+
[-1,-1,-1,1] ]
|
592
|
+
|
593
|
+
glMatrixMode(GL_PROJECTION)
|
594
|
+
glLoadIdentity()
|
595
|
+
glOrtho(0,WINDOW_SIZE,0,WINDOW_SIZE,0,-1)
|
596
|
+
assert_equal(res, glGetDoublev(GL_PROJECTION_MATRIX))
|
597
|
+
end
|
598
|
+
|
599
|
+
def test_glnormal
|
600
|
+
glNormal3d(1.0, 2.0, 3.0)
|
601
|
+
assert_equal([1.0, 2.0, 3.0], glGetDoublev(GL_CURRENT_NORMAL))
|
602
|
+
|
603
|
+
glNormal3dv([4.0, 5.0, 6.0])
|
604
|
+
assert_equal([4.0, 5.0, 6.0], glGetDoublev(GL_CURRENT_NORMAL))
|
605
|
+
|
606
|
+
glNormal3f(1.0, 2.0, 3.0)
|
607
|
+
assert_equal([1.0, 2.0, 3.0], glGetDoublev(GL_CURRENT_NORMAL))
|
608
|
+
|
609
|
+
glNormal3fv([4.0, 5.0, 6.0])
|
610
|
+
assert_equal([4.0, 5.0, 6.0], glGetDoublev(GL_CURRENT_NORMAL))
|
611
|
+
|
612
|
+
glNormal3i(1, 2, 3)
|
613
|
+
assert_equal([1, 2, 3], glGetIntegerv(GL_CURRENT_NORMAL))
|
614
|
+
|
615
|
+
glNormal3iv([4, 5, 6])
|
616
|
+
assert_equal([4, 5, 6], glGetIntegerv(GL_CURRENT_NORMAL))
|
617
|
+
|
618
|
+
glNormal3b(2**7-1, 0, 2**7-1)
|
619
|
+
assert_each_in_delta([1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_NORMAL))
|
620
|
+
|
621
|
+
glNormal3bv(0, 2**7-1, 0)
|
622
|
+
assert_each_in_delta([0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_NORMAL))
|
623
|
+
|
624
|
+
glNormal3s(2**15-1, 0, 2**15-1)
|
625
|
+
assert_each_in_delta([1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_NORMAL))
|
626
|
+
|
627
|
+
glNormal3sv(0, 2**15-1, 0)
|
628
|
+
assert_each_in_delta([0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_NORMAL))
|
629
|
+
end
|
630
|
+
|
631
|
+
def test_gllight
|
632
|
+
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,80.0)
|
633
|
+
assert_equal(80.0, glGetLightfv(GL_LIGHT0,GL_SPOT_CUTOFF))
|
634
|
+
glLighti(GL_LIGHT0,GL_SPOT_CUTOFF,75)
|
635
|
+
assert_equal(75, glGetLightiv(GL_LIGHT0,GL_SPOT_CUTOFF))
|
636
|
+
glLightfv(GL_LIGHT0,GL_AMBIENT,[0.5,0.5,0.5,1.0])
|
637
|
+
assert_equal([0.5,0.5,0.5,1.0], glGetLightfv(GL_LIGHT0,GL_AMBIENT))
|
638
|
+
glLightiv(GL_LIGHT0,GL_CONSTANT_ATTENUATION,[32])
|
639
|
+
assert_equal(32, glGetLightiv(GL_LIGHT0,GL_CONSTANT_ATTENUATION))
|
640
|
+
end
|
641
|
+
|
642
|
+
def test_glmaterial
|
643
|
+
glMaterialfv(GL_FRONT,GL_AMBIENT,[0.0,1.0,0.0,1.0])
|
644
|
+
assert_equal([0.0,1.0,0.0,1.0], glGetMaterialfv(GL_FRONT,GL_AMBIENT))
|
645
|
+
|
646
|
+
glMaterialiv(GL_FRONT,GL_SHININESS,[50])
|
647
|
+
assert_equal(50, glGetMaterialiv(GL_FRONT,GL_SHININESS))
|
648
|
+
|
649
|
+
glMaterialf(GL_FRONT,GL_SHININESS,49.0)
|
650
|
+
assert_equal(49.0, glGetMaterialfv(GL_FRONT,GL_SHININESS))
|
651
|
+
|
652
|
+
glMateriali(GL_FRONT,GL_SHININESS,48)
|
653
|
+
assert_equal(48, glGetMaterialiv(GL_FRONT,GL_SHININESS))
|
654
|
+
|
655
|
+
end
|
656
|
+
|
657
|
+
def test_glcolormaterial
|
658
|
+
glColorMaterial(GL_FRONT,GL_EMISSION)
|
659
|
+
assert_equal(GL_FRONT, glGetIntegerv(GL_COLOR_MATERIAL_FACE))
|
660
|
+
assert_equal(GL_EMISSION, glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER))
|
661
|
+
|
662
|
+
glColorMaterial(GL_BACK,GL_SPECULAR)
|
663
|
+
assert_equal(GL_BACK, glGetIntegerv(GL_COLOR_MATERIAL_FACE))
|
664
|
+
assert_equal(GL_SPECULAR, glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER))
|
665
|
+
end
|
666
|
+
|
667
|
+
def test_gllightmodel
|
668
|
+
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1)
|
669
|
+
assert_equal(GL_TRUE, glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE))
|
670
|
+
|
671
|
+
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0)
|
672
|
+
assert_equal(GL_FALSE, glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE))
|
673
|
+
|
674
|
+
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [0.5, 0.5, 0.5, 1.0])
|
675
|
+
assert_equal([0.5, 0.5, 0.5, 1.0], glGetDoublev(GL_LIGHT_MODEL_AMBIENT))
|
676
|
+
|
677
|
+
glLightModeliv(GL_LIGHT_MODEL_AMBIENT, [2, 0, 2, 0])
|
678
|
+
assert_equal([2, 0, 2, 0], glGetIntegerv(GL_LIGHT_MODEL_AMBIENT))
|
679
|
+
end
|
680
|
+
|
681
|
+
def test_gltexcoordv
|
682
|
+
glTexCoord2dv [1, 1]
|
683
|
+
|
684
|
+
assert_each_in_delta [1, 1, 0, 1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS)
|
685
|
+
end
|
686
|
+
|
687
|
+
def test_gltexcoord_1
|
688
|
+
glTexCoord1d(1.5)
|
689
|
+
assert_equal([1.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
690
|
+
glTexCoord1dv([0.5])
|
691
|
+
assert_equal([0.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
692
|
+
glTexCoord1f(1.5)
|
693
|
+
assert_equal([1.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
694
|
+
glTexCoord1fv([0.5])
|
695
|
+
assert_equal([0.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
696
|
+
glTexCoord1i(1)
|
697
|
+
assert_equal([1,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
698
|
+
glTexCoord1iv([0])
|
699
|
+
assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
700
|
+
glTexCoord1s(1)
|
701
|
+
assert_equal([1,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
702
|
+
glTexCoord1sv([0])
|
703
|
+
assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
704
|
+
end
|
705
|
+
|
706
|
+
def test_gltexcoord_2
|
707
|
+
glTexCoord2d(1.5,1.5)
|
708
|
+
assert_equal([1.5,1.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
709
|
+
glTexCoord2dv([0.5,0.5])
|
710
|
+
assert_equal([0.5,0.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
711
|
+
glTexCoord2f(1.5,1.5)
|
712
|
+
assert_equal([1.5,1.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
713
|
+
glTexCoord2fv([0.5,0.5])
|
714
|
+
assert_equal([0.5,0.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
715
|
+
glTexCoord2i(1,1)
|
716
|
+
assert_equal([1,1,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
717
|
+
glTexCoord2iv([0,0])
|
718
|
+
assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
719
|
+
glTexCoord2s(1,1)
|
720
|
+
assert_equal([1,1,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
721
|
+
glTexCoord2sv([0,0])
|
722
|
+
assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
723
|
+
end
|
724
|
+
|
725
|
+
def test_gltexcoord_3
|
726
|
+
glTexCoord3d(1.5,1.5,1.5)
|
727
|
+
assert_equal([1.5,1.5,1.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
728
|
+
glTexCoord3dv([0.5,0.5,0.5])
|
729
|
+
assert_equal([0.5,0.5,0.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
730
|
+
glTexCoord3f(1.5,1.5,1.5)
|
731
|
+
assert_equal([1.5,1.5,1.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
732
|
+
glTexCoord3fv([0.5,0.5,0.5])
|
733
|
+
assert_equal([0.5,0.5,0.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
734
|
+
glTexCoord3i(1,1,1)
|
735
|
+
assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
736
|
+
glTexCoord3iv([0,0,0])
|
737
|
+
assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
738
|
+
glTexCoord3s(1,1,1)
|
739
|
+
assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
740
|
+
glTexCoord3sv([0,0,0])
|
741
|
+
assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
742
|
+
end
|
743
|
+
|
744
|
+
def test_gltexcoord_4
|
745
|
+
glTexCoord4d(1.5,1.5,1.5,1.5)
|
746
|
+
assert_equal([1.5,1.5,1.5,1.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
747
|
+
glTexCoord4dv([0.5,0.5,0.5,0.5])
|
748
|
+
assert_equal([0.5,0.5,0.5,0.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
749
|
+
glTexCoord4f(1.5,1.5,1.5,1.5)
|
750
|
+
assert_equal([1.5,1.5,1.5,1.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
751
|
+
glTexCoord4fv([0.5,0.5,0.5,0.5])
|
752
|
+
assert_equal([0.5,0.5,0.5,0.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
753
|
+
glTexCoord4i(1,1,1,1)
|
754
|
+
assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
755
|
+
glTexCoord4iv([0,0,0,0])
|
756
|
+
assert_equal([0,0,0,0], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
757
|
+
glTexCoord4s(1,1,1,1)
|
758
|
+
assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
759
|
+
glTexCoord4sv([0,0,0,0])
|
760
|
+
assert_equal([0,0,0,0], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
761
|
+
end
|
762
|
+
|
763
|
+
def test_glenable_disable
|
764
|
+
glEnable(GL_FOG)
|
765
|
+
assert_equal(true, glIsEnabled(GL_FOG))
|
766
|
+
glDisable(GL_FOG)
|
767
|
+
assert_equal(false, glIsEnabled(GL_FOG))
|
768
|
+
end
|
769
|
+
|
770
|
+
def test_gltexparameter
|
771
|
+
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP)
|
772
|
+
assert_equal(GL_CLAMP, glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S))
|
773
|
+
|
774
|
+
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_MIRRORED_REPEAT)
|
775
|
+
assert_equal(GL_MIRRORED_REPEAT, glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S))
|
776
|
+
|
777
|
+
glTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,[GL_CLAMP])
|
778
|
+
assert_equal(GL_CLAMP, glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S))
|
779
|
+
|
780
|
+
glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,[GL_MIRRORED_REPEAT])
|
781
|
+
assert_equal(GL_MIRRORED_REPEAT, glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S))
|
782
|
+
|
783
|
+
assert_equal(0.0, glGetTexLevelParameterfv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH))
|
784
|
+
assert_equal(0, glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH))
|
785
|
+
end
|
786
|
+
|
787
|
+
def test_glcullface
|
788
|
+
glCullFace(GL_FRONT)
|
789
|
+
assert_equal(GL_FRONT, glGetIntegerv(GL_CULL_FACE_MODE))
|
790
|
+
glCullFace(GL_BACK)
|
791
|
+
assert_equal(GL_BACK, glGetIntegerv(GL_CULL_FACE_MODE))
|
792
|
+
end
|
793
|
+
|
794
|
+
def test_glfrontface
|
795
|
+
glFrontFace(GL_CW)
|
796
|
+
assert_equal(GL_CW, glGetIntegerv(GL_FRONT_FACE))
|
797
|
+
glFrontFace(GL_CCW)
|
798
|
+
assert_equal(GL_CCW, glGetIntegerv(GL_FRONT_FACE))
|
799
|
+
end
|
800
|
+
|
801
|
+
def test_glpointsize
|
802
|
+
glPointSize(2.0)
|
803
|
+
assert_equal(2.0, glGetDoublev(GL_POINT_SIZE))
|
804
|
+
glPointSize(3.0)
|
805
|
+
assert_equal(3.0, glGetDoublev(GL_POINT_SIZE))
|
806
|
+
end
|
807
|
+
|
808
|
+
def test_glpolygonmode
|
809
|
+
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE)
|
810
|
+
assert_equal([GL_LINE,GL_LINE], glGetIntegerv(GL_POLYGON_MODE))
|
811
|
+
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
|
812
|
+
assert_equal([GL_FILL,GL_FILL], glGetIntegerv(GL_POLYGON_MODE))
|
813
|
+
end
|
814
|
+
|
815
|
+
def test_gllinewidth
|
816
|
+
glLineWidth(2.0)
|
817
|
+
assert_equal(2.0, glGetDoublev(GL_LINE_WIDTH))
|
818
|
+
glLineWidth(3.0)
|
819
|
+
assert_equal(3.0, glGetDoublev(GL_LINE_WIDTH))
|
820
|
+
end
|
821
|
+
|
822
|
+
def test_gllinestipple
|
823
|
+
glLineStipple(3,0x1234)
|
824
|
+
assert_equal(3, glGetIntegerv(GL_LINE_STIPPLE_REPEAT))
|
825
|
+
assert_equal(0x1234, glGetIntegerv(GL_LINE_STIPPLE_PATTERN))
|
826
|
+
end
|
827
|
+
|
828
|
+
def test_glpolygonstipple
|
829
|
+
stipple = [0x12] * 128
|
830
|
+
glPolygonStipple(stipple.pack("c*"))
|
831
|
+
assert_equal(stipple.pack("c*"), glGetPolygonStipple())
|
832
|
+
end
|
833
|
+
|
834
|
+
def parse_feedback_data(data,count)
|
835
|
+
c = count / 11
|
836
|
+
ret = []
|
837
|
+
(0...c).each do |x|
|
838
|
+
i = x * 11
|
839
|
+
type = data[0+i]
|
840
|
+
|
841
|
+
v1 = [data[2+i], data[3+i], data[4+i]]
|
842
|
+
v2 = [data[5+i], data[6+i], data[7+i]]
|
843
|
+
v3 = [data[8+i], data[9+i], data[10+i]]
|
844
|
+
vertex = [v1,v2,v3].sort
|
845
|
+
ret << [type,vertex]
|
846
|
+
end
|
847
|
+
ret
|
848
|
+
end
|
849
|
+
|
850
|
+
def test_glvertex
|
851
|
+
glMatrixMode(GL_PROJECTION)
|
852
|
+
glOrtho(0,WINDOW_SIZE,0,WINDOW_SIZE,0,-1)
|
853
|
+
|
854
|
+
buf = glFeedbackBuffer(256,GL_3D)
|
855
|
+
|
856
|
+
glRenderMode(GL_FEEDBACK)
|
857
|
+
|
858
|
+
glBegin(GL_TRIANGLES)
|
859
|
+
glVertex2d( 1, 0)
|
860
|
+
glVertex2dv([0,0])
|
861
|
+
glVertex2f( 1,1)
|
862
|
+
|
863
|
+
glVertex2fv([ 1, 0])
|
864
|
+
glVertex2i( 0,0)
|
865
|
+
glVertex2iv([1,1])
|
866
|
+
|
867
|
+
glVertex2s( 1, 0)
|
868
|
+
glVertex2sv([0,0])
|
869
|
+
glVertex3d( 1,1,0)
|
870
|
+
|
871
|
+
glVertex3dv([ 1, 0,0])
|
872
|
+
glVertex3f( 0,0,0)
|
873
|
+
glVertex3fv([1,1,0])
|
874
|
+
|
875
|
+
glVertex3i( 1, 0,0)
|
876
|
+
glVertex3iv([0,0,0])
|
877
|
+
glVertex3s( 1,1,0)
|
878
|
+
|
879
|
+
glVertex3sv([ 1, 0,0])
|
880
|
+
glVertex4d( 0,0,0,1)
|
881
|
+
glVertex4dv([1,1,0,1])
|
882
|
+
|
883
|
+
glVertex4f( 1, 0,0,1)
|
884
|
+
glVertex4fv([0,0,0,1])
|
885
|
+
glVertex4i( 1,1,0,1)
|
886
|
+
|
887
|
+
glVertex4iv([ 1, 0,0,1])
|
888
|
+
glVertex4s( 0,0,0,1)
|
889
|
+
glVertex4sv([1,1,0,1])
|
890
|
+
|
891
|
+
glEnd()
|
892
|
+
|
893
|
+
count = glRenderMode(GL_RENDER)
|
894
|
+
data = buf.unpack("f*")
|
895
|
+
|
896
|
+
ref = [[GL_POLYGON_TOKEN,[[0,0,0],[1,0,0],[1,1,0]]]] * 8
|
897
|
+
|
898
|
+
assert_equal(ref, parse_feedback_data(data,count))
|
899
|
+
end
|
900
|
+
|
901
|
+
def test_glrect
|
902
|
+
glMatrixMode GL_PROJECTION
|
903
|
+
glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
|
904
|
+
|
905
|
+
buf = glFeedbackBuffer 256, GL_3D
|
906
|
+
|
907
|
+
glRenderMode GL_FEEDBACK
|
908
|
+
|
909
|
+
glRectd(0, 0, 1, 1)
|
910
|
+
glRectdv([0, 0], [1, 1])
|
911
|
+
|
912
|
+
glRectf(0, 0, 1, 1)
|
913
|
+
glRectfv([0, 0], [1, 1])
|
914
|
+
|
915
|
+
glRecti(0, 0, 1, 1)
|
916
|
+
glRectiv([0, 0], [1, 1])
|
917
|
+
|
918
|
+
glRects(0, 0, 1, 1)
|
919
|
+
glRectsv([0, 0], [1, 1])
|
920
|
+
|
921
|
+
count = glRenderMode GL_RENDER
|
922
|
+
data = buf.unpack("f*")[0, count]
|
923
|
+
|
924
|
+
# eight 3d polygons with four points
|
925
|
+
assert_equal 16 * (3 * 3 + 2), count
|
926
|
+
end
|
927
|
+
|
928
|
+
def test_glrectv
|
929
|
+
glMatrixMode GL_PROJECTION
|
930
|
+
glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
|
931
|
+
|
932
|
+
buf = glFeedbackBuffer 256, GL_3D
|
933
|
+
|
934
|
+
glRenderMode GL_FEEDBACK
|
935
|
+
|
936
|
+
glRectdv Vector[0, 0], Vector[1, 1]
|
937
|
+
|
938
|
+
refute_equal 0, glRenderMode(GL_RENDER)
|
939
|
+
end
|
940
|
+
|
941
|
+
def test_glclear
|
942
|
+
glClearColor(1.0,1.0,1.0,1.0)
|
943
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
944
|
+
|
945
|
+
data = glReadPixels(0,0,1,1,GL_RGB,GL_FLOAT)
|
946
|
+
assert_equal([1.0,1.0, 1.0], data.unpack("f*"))
|
947
|
+
|
948
|
+
glClearColor(0.0,0.0,0.0,0.0)
|
949
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
950
|
+
|
951
|
+
data = glReadPixels(0,0,1,1,GL_RGB,GL_FLOAT)
|
952
|
+
assert_equal([0.0,0.0,0.0], data.unpack("f*"))
|
953
|
+
end
|
954
|
+
|
955
|
+
def test_gltexenv
|
956
|
+
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)
|
957
|
+
assert_equal(GL_ADD, glGetTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE))
|
958
|
+
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)
|
959
|
+
assert_equal(GL_MODULATE, glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE))
|
960
|
+
|
961
|
+
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[GL_ADD])
|
962
|
+
assert_equal(GL_ADD, glGetTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE))
|
963
|
+
glTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[GL_MODULATE])
|
964
|
+
assert_equal(GL_MODULATE, glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE))
|
965
|
+
end
|
966
|
+
|
967
|
+
def test_gltexgen
|
968
|
+
glTexGend(GL_S,GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP)
|
969
|
+
assert_equal(GL_REFLECTION_MAP, glGetTexGendv(GL_S,GL_TEXTURE_GEN_MODE))
|
970
|
+
glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR)
|
971
|
+
assert_equal(GL_EYE_LINEAR, glGetTexGenfv(GL_S,GL_TEXTURE_GEN_MODE))
|
972
|
+
glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP)
|
973
|
+
assert_equal(GL_SPHERE_MAP, glGetTexGeniv(GL_S,GL_TEXTURE_GEN_MODE))
|
974
|
+
|
975
|
+
glTexGendv(GL_S,GL_TEXTURE_GEN_MODE,[GL_REFLECTION_MAP])
|
976
|
+
assert_equal(GL_REFLECTION_MAP, glGetTexGendv(GL_S,GL_TEXTURE_GEN_MODE))
|
977
|
+
glTexGenfv(GL_S,GL_TEXTURE_GEN_MODE,[GL_EYE_LINEAR])
|
978
|
+
assert_equal(GL_EYE_LINEAR, glGetTexGenfv(GL_S,GL_TEXTURE_GEN_MODE))
|
979
|
+
glTexGeniv(GL_S,GL_TEXTURE_GEN_MODE,[GL_SPHERE_MAP])
|
980
|
+
assert_equal(GL_SPHERE_MAP, glGetTexGeniv(GL_S,GL_TEXTURE_GEN_MODE))
|
981
|
+
end
|
982
|
+
|
983
|
+
def test_textures
|
984
|
+
textures = glGenTextures(2)
|
985
|
+
assert_equal(2, textures.size)
|
986
|
+
assert_equal(false, glIsTexture(textures[0]))
|
987
|
+
glBindTexture(GL_TEXTURE_2D,textures[0])
|
988
|
+
assert_equal(true, glIsTexture(textures[0]))
|
989
|
+
|
990
|
+
image = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
|
991
|
+
|
992
|
+
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, image)
|
993
|
+
assert_equal(image, glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT))
|
994
|
+
|
995
|
+
glBindTexture(GL_TEXTURE_1D,textures[1])
|
996
|
+
|
997
|
+
glTexImage1D(GL_TEXTURE_1D,0,GL_RGB8, 16, 0, GL_RGB, GL_FLOAT, image)
|
998
|
+
assert_equal(image, glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT))
|
999
|
+
|
1000
|
+
glDeleteTextures(textures)
|
1001
|
+
assert_equal(false, glIsTexture(textures[0]))
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
def test_pixels
|
1005
|
+
glClearColor(0,0,0,0)
|
1006
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
1007
|
+
|
1008
|
+
data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
|
1009
|
+
assert_equal([0] * 3 * 16, data.unpack("f*"))
|
1010
|
+
|
1011
|
+
image = ([1.0] * 3 * 16).pack("f*")
|
1012
|
+
glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
|
1013
|
+
|
1014
|
+
data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
|
1015
|
+
assert_equal(image, data)
|
1016
|
+
|
1017
|
+
#
|
1018
|
+
glClearColor(0,0,0,0)
|
1019
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
1020
|
+
|
1021
|
+
image = (([0.0] * 3 * 8) + ([1.0] * 3 * 8)).pack("f*")
|
1022
|
+
glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
|
1023
|
+
|
1024
|
+
data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
|
1025
|
+
assert_equal(image, data)
|
1026
|
+
|
1027
|
+
glCopyPixels(0,2,4,2,GL_COLOR)
|
1028
|
+
|
1029
|
+
data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
|
1030
|
+
assert_equal(([1.0] * 3 * 16).pack("f*"), data)
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
def test_gltranslate
|
1034
|
+
m = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[1,2,3,1]]
|
1035
|
+
glMatrixMode(GL_MODELVIEW)
|
1036
|
+
glLoadIdentity()
|
1037
|
+
glTranslated(1.0,2.0,3.0)
|
1038
|
+
assert_equal(m, glGetDoublev(GL_MODELVIEW_MATRIX))
|
1039
|
+
glLoadIdentity()
|
1040
|
+
glTranslatef(1.0,2.0,3.0)
|
1041
|
+
assert_equal(m, glGetDoublev(GL_MODELVIEW_MATRIX))
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
def test_glscale
|
1045
|
+
m = [[1,0,0,0],[0,2,0,0],[0,0,3,0],[0,0,0,1]]
|
1046
|
+
glMatrixMode(GL_MODELVIEW)
|
1047
|
+
glLoadIdentity()
|
1048
|
+
glScaled(1.0,2.0,3.0)
|
1049
|
+
assert_equal(m, glGetDoublev(GL_MODELVIEW_MATRIX))
|
1050
|
+
glLoadIdentity()
|
1051
|
+
glScalef(1.0,2.0,3.0)
|
1052
|
+
assert_equal(m, glGetDoublev(GL_MODELVIEW_MATRIX))
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
def test_glrotate
|
1056
|
+
m1 = [[0, 0, -1, 0], [0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1]]
|
1057
|
+
m2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
|
1058
|
+
glMatrixMode(GL_MODELVIEW)
|
1059
|
+
glLoadIdentity()
|
1060
|
+
glRotated(90, 0, 1, 0)
|
1061
|
+
|
1062
|
+
assert_each_in_delta m1, glGetDoublev(GL_MODELVIEW_MATRIX)
|
1063
|
+
|
1064
|
+
glRotated(-90, 0, 1, 0)
|
1065
|
+
|
1066
|
+
assert_each_in_delta m2, glGetDoublev(GL_MODELVIEW_MATRIX)
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
def test_textures_2
|
1070
|
+
textures = glGenTextures(2)
|
1071
|
+
glBindTexture(GL_TEXTURE_1D,textures[0])
|
1072
|
+
glBindTexture(GL_TEXTURE_2D,textures[1])
|
1073
|
+
assert_equal(2, glAreTexturesResident(textures).size)
|
1074
|
+
glPrioritizeTextures(textures,[0.5,1.0])
|
1075
|
+
assert_equal(0.5, glGetTexParameterfv(GL_TEXTURE_1D,GL_TEXTURE_PRIORITY))
|
1076
|
+
assert_equal(1.0, glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY))
|
1077
|
+
|
1078
|
+
tex = ([0,0,0,1,1,1] * 2).pack("f*")
|
1079
|
+
tex2 = ([1] * 3 * 4).pack("f*")
|
1080
|
+
|
1081
|
+
# 1d
|
1082
|
+
glDrawPixels(4,1,GL_RGB,GL_FLOAT,tex)
|
1083
|
+
glCopyTexImage1D(GL_TEXTURE_1D,0,GL_RGB8,0,0,4,0)
|
1084
|
+
assert_equal(tex, glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT))
|
1085
|
+
|
1086
|
+
glDrawPixels(4,1,GL_RGB,GL_FLOAT,tex2)
|
1087
|
+
glCopyTexSubImage1D(GL_TEXTURE_1D,0,0,0,0,4)
|
1088
|
+
assert_equal(tex2, glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT))
|
1089
|
+
|
1090
|
+
glTexSubImage1D(GL_TEXTURE_1D,0,0,4,GL_RGB,GL_FLOAT,tex)
|
1091
|
+
assert_equal(tex, glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT))
|
1092
|
+
|
1093
|
+
# 2d
|
1094
|
+
glDrawPixels(2,2,GL_RGB,GL_FLOAT,tex)
|
1095
|
+
glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,0,0,2,2,0)
|
1096
|
+
assert_equal(tex, glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT))
|
1097
|
+
|
1098
|
+
glDrawPixels(2,2,GL_RGB,GL_FLOAT,tex2)
|
1099
|
+
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,2,2)
|
1100
|
+
assert_equal(tex2, glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT))
|
1101
|
+
|
1102
|
+
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,2,2,GL_RGB,GL_FLOAT,tex)
|
1103
|
+
assert_equal(tex, glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT))
|
1104
|
+
|
1105
|
+
glDeleteTextures(textures)
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
def test_glmap
|
1109
|
+
control_points = [
|
1110
|
+
0.25, 0.5, 0.0,
|
1111
|
+
1.0, 1.0, 0.0
|
1112
|
+
]
|
1113
|
+
|
1114
|
+
control_points_2 = [
|
1115
|
+
1.25, 1.5, 1.0,
|
1116
|
+
0.0, 0.0, 1.0
|
1117
|
+
]
|
1118
|
+
|
1119
|
+
glMap1f(GL_MAP1_VERTEX_3,0,100,3,2,control_points)
|
1120
|
+
assert_equal(control_points, glGetMapfv(GL_MAP1_VERTEX_3,GL_COEFF))
|
1121
|
+
|
1122
|
+
glMap1d(GL_MAP1_VERTEX_3,0,100,3,2,control_points_2)
|
1123
|
+
assert_equal(control_points_2, glGetMapdv(GL_MAP1_VERTEX_3,GL_COEFF))
|
1124
|
+
|
1125
|
+
assert_equal(2, glGetMapiv(GL_MAP1_VERTEX_3,GL_ORDER))
|
1126
|
+
|
1127
|
+
glMap2f(GL_MAP2_VERTEX_3,0,100,3,1,0,100,3,2,control_points)
|
1128
|
+
assert_equal(control_points,glGetMapfv(GL_MAP2_VERTEX_3,GL_COEFF))
|
1129
|
+
|
1130
|
+
glMap2d(GL_MAP2_VERTEX_3,0,100,3,1,0,100,3,2,control_points_2)
|
1131
|
+
assert_equal(control_points_2, glGetMapdv(GL_MAP2_VERTEX_3,GL_COEFF))
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
def test_glmapgrid
|
1135
|
+
glMapGrid1d(2,1,100)
|
1136
|
+
assert_equal(2, glGetIntegerv(GL_MAP1_GRID_SEGMENTS))
|
1137
|
+
assert_equal([1,100], glGetIntegerv(GL_MAP1_GRID_DOMAIN))
|
1138
|
+
glMapGrid1f(3,2,99)
|
1139
|
+
assert_equal(3, glGetIntegerv(GL_MAP1_GRID_SEGMENTS))
|
1140
|
+
assert_equal([2,99], glGetIntegerv(GL_MAP1_GRID_DOMAIN))
|
1141
|
+
#
|
1142
|
+
glMapGrid2d(2,1,100,3,2,99)
|
1143
|
+
assert_equal([2,3], glGetIntegerv(GL_MAP2_GRID_SEGMENTS))
|
1144
|
+
assert_equal([1,100,2,99], glGetIntegerv(GL_MAP2_GRID_DOMAIN))
|
1145
|
+
|
1146
|
+
glMapGrid2f(3,2,99,4,3,98)
|
1147
|
+
assert_equal([3,4], glGetIntegerv(GL_MAP2_GRID_SEGMENTS))
|
1148
|
+
assert_equal([2,99,3,98], glGetIntegerv(GL_MAP2_GRID_DOMAIN))
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
def test_gleval
|
1152
|
+
control_points = [0,0,0,1,1,1]
|
1153
|
+
glMap1f(GL_MAP1_VERTEX_3,0,1,3,2,control_points)
|
1154
|
+
glMap2f(GL_MAP2_VERTEX_3,0,1,3,1,0,1,3,2,control_points)
|
1155
|
+
glEnable(GL_MAP1_VERTEX_3)
|
1156
|
+
glEnable(GL_MAP2_VERTEX_3)
|
1157
|
+
|
1158
|
+
buf = glFeedbackBuffer(256,GL_3D)
|
1159
|
+
glRenderMode(GL_FEEDBACK)
|
1160
|
+
|
1161
|
+
glBegin(GL_TRIANGLES)
|
1162
|
+
glEvalCoord1d(1.0)
|
1163
|
+
glEvalCoord1dv([1.0])
|
1164
|
+
glEvalCoord1f(1.0)
|
1165
|
+
|
1166
|
+
glEvalCoord1fv([1.0])
|
1167
|
+
glEvalCoord1fv([1.0])
|
1168
|
+
glEvalCoord1fv([1.0])
|
1169
|
+
|
1170
|
+
glEvalCoord2d(1.0,1.0)
|
1171
|
+
glEvalCoord2dv([1.0,1.0])
|
1172
|
+
glEvalCoord2f(1.0,1.0)
|
1173
|
+
|
1174
|
+
glEvalCoord2fv([1.0,1.0])
|
1175
|
+
glEvalCoord2fv([1.0,1.0])
|
1176
|
+
glEvalCoord2fv([1.0,1.0])
|
1177
|
+
|
1178
|
+
glEvalPoint1(0.0)
|
1179
|
+
glEvalPoint1(0.0)
|
1180
|
+
glEvalPoint1(0.0)
|
1181
|
+
|
1182
|
+
glEvalPoint2(0.0,1.0)
|
1183
|
+
glEvalPoint2(0.0,1.0)
|
1184
|
+
glEvalPoint2(0.0,1.0)
|
1185
|
+
|
1186
|
+
glEnd
|
1187
|
+
|
1188
|
+
count = glRenderMode(GL_RENDER)
|
1189
|
+
assert_equal(count,(3*3+2)*6)
|
1190
|
+
|
1191
|
+
glDisable(GL_MAP2_VERTEX_3)
|
1192
|
+
glDisable(GL_MAP1_VERTEX_3)
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
def test_glevalmesh
|
1196
|
+
control_points = [0,0,0,1,1,1]
|
1197
|
+
glMap1f(GL_MAP1_VERTEX_3,0,1,3,2,control_points)
|
1198
|
+
glMap2f(GL_MAP2_VERTEX_3,0,1,3,1,0,1,3,2,control_points)
|
1199
|
+
glEnable(GL_MAP1_VERTEX_3)
|
1200
|
+
glEnable(GL_MAP2_VERTEX_3)
|
1201
|
+
|
1202
|
+
buf = glFeedbackBuffer(256,GL_3D)
|
1203
|
+
glRenderMode(GL_FEEDBACK)
|
1204
|
+
|
1205
|
+
glEvalMesh1(GL_POINT,0,1)
|
1206
|
+
glEvalMesh2(GL_POINT,0,1,0,1)
|
1207
|
+
|
1208
|
+
count = glRenderMode(GL_RENDER)
|
1209
|
+
assert_equal(count,((3+1)*(2+2*2)))
|
1210
|
+
|
1211
|
+
glDisable(GL_MAP2_VERTEX_3)
|
1212
|
+
glDisable(GL_MAP1_VERTEX_3)
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
def test_glaccum
|
1216
|
+
return if glGetIntegerv(GL_ACCUM_RED_BITS) <= 0 # no accumulation buffer ?
|
1217
|
+
|
1218
|
+
i1 = ([0.0] * 3 + [1.0] * 3 ).pack("f*")
|
1219
|
+
i2 = ([1.0] * 3 + [0.0] * 3 ).pack("f*")
|
1220
|
+
|
1221
|
+
# init
|
1222
|
+
glClearColor(0,0,0,0)
|
1223
|
+
glClear(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
|
1224
|
+
# left
|
1225
|
+
glDrawPixels(2,1,GL_RGB,GL_FLOAT,i1)
|
1226
|
+
glAccum(GL_ACCUM,1.0)
|
1227
|
+
# right
|
1228
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
1229
|
+
glDrawPixels(2,1,GL_RGB,GL_FLOAT,i2)
|
1230
|
+
glAccum(GL_ACCUM,1.0)
|
1231
|
+
# combine
|
1232
|
+
glAccum(GL_RETURN,1.0)
|
1233
|
+
|
1234
|
+
data = glReadPixels(0,0,2,1,GL_RGB,GL_FLOAT)
|
1235
|
+
assert_each_in_delta [1.0] * 2 * 3, data.unpack("f*"), 0.01
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
def test_displaylists
|
1239
|
+
base = glGenLists(2)
|
1240
|
+
assert(base>0)
|
1241
|
+
glListBase(1)
|
1242
|
+
assert_equal(1, glGetIntegerv(GL_LIST_BASE))
|
1243
|
+
glListBase(0)
|
1244
|
+
assert_equal(0, glGetIntegerv(GL_LIST_BASE))
|
1245
|
+
|
1246
|
+
glNewList(base+0, GL_COMPILE)
|
1247
|
+
glBegin(GL_TRIANGLES)
|
1248
|
+
glVertex2f(0,0)
|
1249
|
+
glVertex2f(1,0)
|
1250
|
+
glVertex2f(1,1)
|
1251
|
+
glEnd()
|
1252
|
+
glEndList()
|
1253
|
+
|
1254
|
+
glNewList(base+1, GL_COMPILE)
|
1255
|
+
glBegin(GL_TRIANGLES)
|
1256
|
+
glVertex2f(0,0)
|
1257
|
+
glVertex2f(1,0)
|
1258
|
+
glVertex2f(1,1)
|
1259
|
+
glEnd()
|
1260
|
+
glEndList()
|
1261
|
+
|
1262
|
+
assert_equal(true, glIsList(base+0))
|
1263
|
+
assert_equal(true, glIsList(base+1))
|
1264
|
+
assert_equal(false, glIsList(base+2))
|
1265
|
+
|
1266
|
+
#
|
1267
|
+
buf = glFeedbackBuffer(256,GL_3D)
|
1268
|
+
glRenderMode(GL_FEEDBACK)
|
1269
|
+
|
1270
|
+
glCallList(base+0)
|
1271
|
+
glCallLists(GL_INT,[base+0,base+1])
|
1272
|
+
|
1273
|
+
count = glRenderMode(GL_RENDER)
|
1274
|
+
assert_equal((3*3+2) * 3, count) # 3 triangles
|
1275
|
+
#
|
1276
|
+
|
1277
|
+
glDeleteLists(base,2)
|
1278
|
+
|
1279
|
+
assert_equal(false, glIsList(base+0))
|
1280
|
+
assert_equal(false, glIsList(base+1))
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
def test_arrays
|
1284
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
1285
|
+
|
1286
|
+
va = [0, 0, 0, 1, 1, 1].pack("f*")
|
1287
|
+
|
1288
|
+
glVertexPointer 2, GL_FLOAT, 8, va
|
1289
|
+
assert_equal va, glGetPointerv(GL_VERTEX_ARRAY_POINTER)
|
1290
|
+
assert_equal 2, glGetIntegerv(GL_VERTEX_ARRAY_SIZE)
|
1291
|
+
assert_equal GL_FLOAT, glGetIntegerv(GL_VERTEX_ARRAY_TYPE)
|
1292
|
+
assert_equal 8, glGetIntegerv(GL_VERTEX_ARRAY_STRIDE)
|
1293
|
+
|
1294
|
+
buf = glFeedbackBuffer(256, GL_3D)
|
1295
|
+
glRenderMode(GL_FEEDBACK)
|
1296
|
+
|
1297
|
+
glDrawArrays(GL_TRIANGLES, 0, 3)
|
1298
|
+
|
1299
|
+
glBegin(GL_TRIANGLES)
|
1300
|
+
glArrayElement(0)
|
1301
|
+
glArrayElement(1)
|
1302
|
+
glArrayElement(2)
|
1303
|
+
glEnd
|
1304
|
+
|
1305
|
+
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, [0, 1, 2].pack("C*"))
|
1306
|
+
|
1307
|
+
glInterleavedArrays(GL_V2F, 0, va)
|
1308
|
+
|
1309
|
+
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, [0, 1, 2].pack("C*"))
|
1310
|
+
|
1311
|
+
count = glRenderMode(GL_RENDER)
|
1312
|
+
assert_equal(44, count)
|
1313
|
+
|
1314
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
def test_arrays_2
|
1318
|
+
na = [0, 1, 0].pack("f*")
|
1319
|
+
ta = [1, 0, 1, 0].pack("f*")
|
1320
|
+
ea = [0].pack("C*")
|
1321
|
+
ca = [1, 0, 1, 0].pack("f*")
|
1322
|
+
|
1323
|
+
glNormalPointer(GL_FLOAT, 12, na)
|
1324
|
+
assert_equal(GL_FLOAT, glGetIntegerv(GL_NORMAL_ARRAY_TYPE))
|
1325
|
+
assert_equal(12, glGetIntegerv(GL_NORMAL_ARRAY_STRIDE))
|
1326
|
+
assert_equal(na, glGetPointerv(GL_NORMAL_ARRAY_POINTER))
|
1327
|
+
|
1328
|
+
glTexCoordPointer(4, GL_FLOAT, 16, ta)
|
1329
|
+
assert_equal(4, glGetIntegerv(GL_TEXTURE_COORD_ARRAY_SIZE))
|
1330
|
+
assert_equal(GL_FLOAT, glGetIntegerv(GL_TEXTURE_COORD_ARRAY_TYPE))
|
1331
|
+
assert_equal(16, glGetIntegerv(GL_TEXTURE_COORD_ARRAY_STRIDE))
|
1332
|
+
assert_equal(ta, glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER))
|
1333
|
+
|
1334
|
+
glEdgeFlagPointer(1, ea)
|
1335
|
+
assert_equal(1, glGetIntegerv(GL_EDGE_FLAG_ARRAY_STRIDE))
|
1336
|
+
assert_equal(ea, glGetPointerv(GL_EDGE_FLAG_ARRAY_POINTER))
|
1337
|
+
|
1338
|
+
glColorPointer(4, GL_FLOAT, 16, ca)
|
1339
|
+
assert_equal(4, glGetIntegerv(GL_COLOR_ARRAY_SIZE))
|
1340
|
+
assert_equal(GL_FLOAT, glGetIntegerv(GL_COLOR_ARRAY_TYPE))
|
1341
|
+
assert_equal(16, glGetIntegerv(GL_COLOR_ARRAY_STRIDE))
|
1342
|
+
assert_equal(ca, glGetPointerv(GL_COLOR_ARRAY_POINTER))
|
1343
|
+
|
1344
|
+
glEnableClientState(GL_COLOR_ARRAY)
|
1345
|
+
glEnableClientState(GL_NORMAL_ARRAY)
|
1346
|
+
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
|
1347
|
+
glEnableClientState(GL_EDGE_FLAG_ARRAY)
|
1348
|
+
|
1349
|
+
glBegin(GL_TRIANGLES)
|
1350
|
+
glArrayElement(0)
|
1351
|
+
glEnd
|
1352
|
+
|
1353
|
+
assert_each_in_delta([1, 0, 1, 0], glGetDoublev(GL_CURRENT_COLOR))
|
1354
|
+
assert_equal([0, 1, 0], glGetDoublev(GL_CURRENT_NORMAL))
|
1355
|
+
assert_equal([1, 0, 1, 0], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
|
1356
|
+
assert_equal(false, glGetBooleanv(GL_EDGE_FLAG))
|
1357
|
+
|
1358
|
+
glDisableClientState(GL_EDGE_FLAG_ARRAY)
|
1359
|
+
glDisableClientState(GL_TEXTURE_COORD_ARRAY)
|
1360
|
+
glDisableClientState(GL_NORMAL_ARRAY)
|
1361
|
+
glDisableClientState(GL_COLOR_ARRAY)
|
1362
|
+
end
|
1363
|
+
end
|