opengl 0.7.0.pre1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +8 -0
  3. data/History.txt +36 -0
  4. data/MIT-LICENSE +18 -0
  5. data/Manifest.txt +140 -0
  6. data/README.rdoc +51 -0
  7. data/Rakefile +129 -0
  8. data/Rakefile.cross +104 -0
  9. data/doc/build_install.txt +119 -0
  10. data/doc/extensions.txt.in +348 -0
  11. data/doc/history.txt +66 -0
  12. data/doc/requirements_and_design.txt +117 -0
  13. data/doc/roadmap.txt +28 -0
  14. data/doc/scientific_use.txt +35 -0
  15. data/doc/supplies/page_template.html +71 -0
  16. data/doc/thanks.txt +29 -0
  17. data/doc/tutorial.txt +469 -0
  18. data/examples/NeHe/nehe_lesson02.rb +117 -0
  19. data/examples/NeHe/nehe_lesson03.rb +122 -0
  20. data/examples/NeHe/nehe_lesson04.rb +133 -0
  21. data/examples/NeHe/nehe_lesson05.rb +186 -0
  22. data/examples/NeHe/nehe_lesson36.rb +303 -0
  23. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  24. data/examples/OrangeBook/brick.frag +36 -0
  25. data/examples/OrangeBook/brick.rb +376 -0
  26. data/examples/OrangeBook/brick.vert +41 -0
  27. data/examples/OrangeBook/particle.frag +17 -0
  28. data/examples/OrangeBook/particle.rb +406 -0
  29. data/examples/OrangeBook/particle.vert +38 -0
  30. data/examples/README +16 -0
  31. data/examples/RedBook/aapoly.rb +142 -0
  32. data/examples/RedBook/aargb.rb +119 -0
  33. data/examples/RedBook/accanti.rb +162 -0
  34. data/examples/RedBook/accpersp.rb +215 -0
  35. data/examples/RedBook/alpha.rb +123 -0
  36. data/examples/RedBook/alpha3D.rb +158 -0
  37. data/examples/RedBook/bezcurve.rb +105 -0
  38. data/examples/RedBook/bezmesh.rb +137 -0
  39. data/examples/RedBook/checker.rb +124 -0
  40. data/examples/RedBook/clip.rb +95 -0
  41. data/examples/RedBook/colormat.rb +135 -0
  42. data/examples/RedBook/cube.rb +69 -0
  43. data/examples/RedBook/depthcue.rb +99 -0
  44. data/examples/RedBook/dof.rb +205 -0
  45. data/examples/RedBook/double.rb +105 -0
  46. data/examples/RedBook/drawf.rb +91 -0
  47. data/examples/RedBook/feedback.rb +145 -0
  48. data/examples/RedBook/fog.rb +167 -0
  49. data/examples/RedBook/font.rb +151 -0
  50. data/examples/RedBook/hello.rb +79 -0
  51. data/examples/RedBook/image.rb +137 -0
  52. data/examples/RedBook/jitter.rb +207 -0
  53. data/examples/RedBook/lines.rb +128 -0
  54. data/examples/RedBook/list.rb +111 -0
  55. data/examples/RedBook/material.rb +275 -0
  56. data/examples/RedBook/mipmap.rb +156 -0
  57. data/examples/RedBook/model.rb +113 -0
  58. data/examples/RedBook/movelight.rb +132 -0
  59. data/examples/RedBook/pickdepth.rb +179 -0
  60. data/examples/RedBook/planet.rb +108 -0
  61. data/examples/RedBook/quadric.rb +158 -0
  62. data/examples/RedBook/robot.rb +115 -0
  63. data/examples/RedBook/select.rb +196 -0
  64. data/examples/RedBook/smooth.rb +95 -0
  65. data/examples/RedBook/stencil.rb +163 -0
  66. data/examples/RedBook/stroke.rb +167 -0
  67. data/examples/RedBook/surface.rb +166 -0
  68. data/examples/RedBook/teaambient.rb +132 -0
  69. data/examples/RedBook/teapots.rb +182 -0
  70. data/examples/RedBook/tess.rb +183 -0
  71. data/examples/RedBook/texbind.rb +147 -0
  72. data/examples/RedBook/texgen.rb +169 -0
  73. data/examples/RedBook/texturesurf.rb +128 -0
  74. data/examples/RedBook/varray.rb +159 -0
  75. data/examples/RedBook/wrap.rb +148 -0
  76. data/examples/misc/OGLBench.rb +337 -0
  77. data/examples/misc/anisotropic.rb +194 -0
  78. data/examples/misc/fbo_test.rb +356 -0
  79. data/examples/misc/font-glut.rb +46 -0
  80. data/examples/misc/glfwtest.rb +30 -0
  81. data/examples/misc/plane.rb +161 -0
  82. data/examples/misc/readpixel.rb +65 -0
  83. data/examples/misc/sdltest.rb +34 -0
  84. data/examples/misc/trislam.rb +828 -0
  85. data/ext/common/common.h +448 -0
  86. data/ext/common/conv.h +234 -0
  87. data/ext/common/funcdef.h +280 -0
  88. data/ext/common/gl-enums.h +10031 -0
  89. data/ext/common/gl-error.h +23 -0
  90. data/ext/common/gl-types.h +67 -0
  91. data/ext/common/glu-enums.h +463 -0
  92. data/ext/gl/extconf.rb +43 -0
  93. data/ext/gl/gl-1.0-1.1.c +2811 -0
  94. data/ext/gl/gl-1.2.c +814 -0
  95. data/ext/gl/gl-1.3.c +443 -0
  96. data/ext/gl/gl-1.4.c +348 -0
  97. data/ext/gl/gl-1.5.c +225 -0
  98. data/ext/gl/gl-2.0.c +657 -0
  99. data/ext/gl/gl-2.1.c +57 -0
  100. data/ext/gl/gl-enums.c +3354 -0
  101. data/ext/gl/gl-error.c +104 -0
  102. data/ext/gl/gl-ext-3dfx.c +27 -0
  103. data/ext/gl/gl-ext-arb.c +866 -0
  104. data/ext/gl/gl-ext-ati.c +41 -0
  105. data/ext/gl/gl-ext-ext.c +889 -0
  106. data/ext/gl/gl-ext-gremedy.c +41 -0
  107. data/ext/gl/gl-ext-nv.c +679 -0
  108. data/ext/gl/gl.c +216 -0
  109. data/ext/glu/extconf.rb +51 -0
  110. data/ext/glu/glu-enums.c +164 -0
  111. data/ext/glu/glu.c +1530 -0
  112. data/ext/glut/extconf.rb +67 -0
  113. data/ext/glut/glut.c +1624 -0
  114. data/lib/opengl.rb +89 -0
  115. data/test/README +10 -0
  116. data/test/tc_common.rb +98 -0
  117. data/test/tc_ext_arb.rb +467 -0
  118. data/test/tc_ext_ati.rb +33 -0
  119. data/test/tc_ext_ext.rb +551 -0
  120. data/test/tc_ext_gremedy.rb +36 -0
  121. data/test/tc_ext_nv.rb +357 -0
  122. data/test/tc_func_10_11.rb +1281 -0
  123. data/test/tc_func_12.rb +186 -0
  124. data/test/tc_func_13.rb +229 -0
  125. data/test/tc_func_14.rb +197 -0
  126. data/test/tc_func_15.rb +270 -0
  127. data/test/tc_func_20.rb +346 -0
  128. data/test/tc_func_21.rb +541 -0
  129. data/test/tc_glu.rb +310 -0
  130. data/test/tc_include_gl.rb +35 -0
  131. data/test/tc_misc.rb +54 -0
  132. data/test/tc_require_gl.rb +34 -0
  133. data/utils/README +11 -0
  134. data/utils/enumgen.rb +112 -0
  135. data/utils/extlistgen.rb +90 -0
  136. data/utils/mkdn2html.rb +59 -0
  137. data/utils/post-mkdn2html.rb +91 -0
  138. data/website/images/ogl.jpg +0 -0
  139. data/website/images/tab_bottom.gif +0 -0
  140. data/website/style.css +198 -0
  141. metadata +274 -0
@@ -0,0 +1,36 @@
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 'test/unit'
17
+
18
+ class Test_EXT_GREMEDY < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_gl_gremedy_string_marker
28
+ return if not supported?("GL_GREMEDY_string_marker")
29
+ glStringMarkerGREMEDY("test")
30
+ end
31
+
32
+ def test_gl_gremedy_frame_terminator
33
+ return if not supported?("GL_GREMEDY_frame_terminator")
34
+ glFrameTerminatorGREMEDY()
35
+ end
36
+ end
data/test/tc_ext_nv.rb ADDED
@@ -0,0 +1,357 @@
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 'test/unit'
17
+
18
+ class Test_EXT_NV < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_gl_nv_vertex_program
28
+ return if not supported?("GL_NV_vertex_program")
29
+
30
+ assert_equal(glIsProgramNV(0),false)
31
+ programs = glGenProgramsNV(2)
32
+ assert_equal(programs.size,2)
33
+
34
+ program = "!!VSP1.0\nEND"
35
+
36
+ glBindProgramNV(GL_VERTEX_PROGRAM_NV, programs[1])
37
+ glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, programs[0], program)
38
+ assert_equal(glGetProgramStringNV(programs[0], GL_PROGRAM_STRING_NV), program)
39
+ assert_equal(glIsProgramNV(programs[0]),true)
40
+
41
+ assert_equal(glGetProgramivNV(programs[0],GL_PROGRAM_LENGTH_NV),program.size)
42
+
43
+ glVertexAttribPointerNV(1,2,GL_FLOAT,0,[1,1].pack("f*"))
44
+ assert_equal(glGetVertexAttribPointervNV(1),[1,1].pack("f*"))
45
+
46
+ glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV,programs[0],[1,1,1,1])
47
+
48
+ glProgramParameter4dNV(GL_VERTEX_PROGRAM_NV,1, 1,2,3,4)
49
+ assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[1,2,3,4])
50
+ glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV,1, 5,6,7,8)
51
+ assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[5,6,7,8])
52
+ glProgramParameter4dvNV(GL_VERTEX_PROGRAM_NV,1, [1,2,3,4])
53
+ assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[1,2,3,4])
54
+ glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV,1, [5,6,7,8])
55
+ assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[5,6,7,8])
56
+
57
+ glProgramParameters4fvNV(GL_VERTEX_PROGRAM_NV,1, [1,2,3,4,5,6,7,8])
58
+ assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[1,2,3,4])
59
+ assert_equal(glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV,2,GL_PROGRAM_PARAMETER_NV),[5,6,7,8])
60
+
61
+ glProgramParameters4dvNV(GL_VERTEX_PROGRAM_NV,1, [8,7,6,5,4,3,2,1])
62
+ assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,1,GL_PROGRAM_PARAMETER_NV),[8,7,6,5])
63
+ assert_equal(glGetProgramParameterdvNV(GL_VERTEX_PROGRAM_NV,2,GL_PROGRAM_PARAMETER_NV),[4,3,2,1])
64
+
65
+
66
+ glVertexAttrib1dNV(1,1)
67
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],1)
68
+ glVertexAttrib1fNV(1,2)
69
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0],2)
70
+ glVertexAttrib1sNV(1,3)
71
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0],3)
72
+ glVertexAttrib1dvNV(1,[1])
73
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],1)
74
+ glVertexAttrib1fvNV(1,[2])
75
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0],2)
76
+ glVertexAttrib1svNV(1,[3])
77
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0],3)
78
+
79
+ glVertexAttrib2dNV(1,1,2)
80
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[1,2])
81
+ glVertexAttrib2fNV(1,2,3)
82
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[2,3])
83
+ glVertexAttrib2sNV(1,3,4)
84
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
85
+ glVertexAttrib2dvNV(1,[1,2])
86
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[1,2])
87
+ glVertexAttrib2fvNV(1,[2,3])
88
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[2,3])
89
+ glVertexAttrib2svNV(1,[3,4])
90
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
91
+
92
+ glVertexAttrib3dNV(1,1,2,3)
93
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[1,2,3])
94
+ glVertexAttrib3fNV(1,2,3,4)
95
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[2,3,4])
96
+ glVertexAttrib3sNV(1,3,4,5)
97
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[3,4,5])
98
+ glVertexAttrib3dvNV(1,[1,2,3])
99
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[1,2,3])
100
+ glVertexAttrib3fvNV(1,[2,3,4])
101
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[2,3,4])
102
+ glVertexAttrib3svNV(1,[3,4,5])
103
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[3,4,5])
104
+
105
+ glVertexAttrib4dNV(1,1,2,3,4)
106
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,2,3,4])
107
+ glVertexAttrib4fNV(1,2,3,4,5)
108
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[2,3,4,5])
109
+ glVertexAttrib4sNV(1,3,4,5,6)
110
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[3,4,5,6])
111
+ glVertexAttrib4dvNV(1,[1,2,3,4])
112
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,2,3,4])
113
+ glVertexAttrib4fvNV(1,[2,3,4,5])
114
+ assert_equal(glGetVertexAttribfvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[2,3,4,5])
115
+ glVertexAttrib4svNV(1,[3,4,5,6])
116
+ assert_equal(glGetVertexAttribivNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[3,4,5,6])
117
+
118
+ glVertexAttrib4ubNV(1,2**8-1,0,2**8-1,0)
119
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,0,1,0])
120
+ glVertexAttrib4ubvNV(1,[0,2**8-1,0,2**8-1])
121
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[0,1,0,1])
122
+
123
+ glVertexAttribs1dvNV(1,[1,2])
124
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],1)
125
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0],2)
126
+ glVertexAttribs1fvNV(1,[3,4])
127
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],3)
128
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0],4)
129
+ glVertexAttribs1svNV(1,[5,6])
130
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0],5)
131
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0],6)
132
+
133
+ glVertexAttribs2dvNV(1,[1,2,3,4])
134
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[1,2])
135
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
136
+ glVertexAttribs2fvNV(1,[3,4,5,6])
137
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[3,4])
138
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,2],[5,6])
139
+ glVertexAttribs2svNV(1,[5,6,7,8])
140
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,2],[5,6])
141
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,2],[7,8])
142
+
143
+ glVertexAttribs3dvNV(1,[1,2,3,4,5,6])
144
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[1,2,3])
145
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,3],[4,5,6])
146
+ glVertexAttribs3fvNV(1,[3,4,5,6,7,8])
147
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[3,4,5])
148
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,3],[6,7,8])
149
+ glVertexAttribs3svNV(1,[5,6,7,8,9,10])
150
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,3],[5,6,7])
151
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,3],[8,9,10])
152
+
153
+ glVertexAttribs4dvNV(1,[1,2,3,4,5,6,7,8])
154
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,2,3,4])
155
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[5,6,7,8])
156
+ glVertexAttribs4fvNV(1,[3,4,5,6,7,8,9,10])
157
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[3,4,5,6])
158
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[7,8,9,10])
159
+ glVertexAttribs4svNV(1,[5,6,7,8,9,10,11,12])
160
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[5,6,7,8])
161
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[9,10,11,12])
162
+ glVertexAttribs4ubvNV(1,[2**8-1,0,2**8-1,0,2**8-1,0,2**8-1,0])
163
+ assert_equal(glGetVertexAttribdvNV(1,GL_CURRENT_ATTRIB_NV)[0,4],[1,0,1,0])
164
+ assert_equal(glGetVertexAttribdvNV(2,GL_CURRENT_ATTRIB_NV)[0,4],[1,0,1,0])
165
+
166
+ glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MATRIX0_NV, GL_IDENTITY_NV);
167
+ assert_equal(glGetTrackMatrixivNV(GL_VERTEX_PROGRAM_NV, 4, GL_TRACK_MATRIX_NV),GL_MATRIX0_NV)
168
+
169
+ glRequestResidentProgramsNV(programs[0])
170
+ res = glAreProgramsResidentNV(programs[0])
171
+ assert_equal(res.size,1)
172
+
173
+ glDeleteProgramsNV(programs)
174
+ end
175
+
176
+ def test_gl_nv_fragment_program
177
+ return if not supported?("GL_NV_fragment_program")
178
+ programs = glGenProgramsNV(1)
179
+ program = "!!FP1.0\nDECLARE test = {0,0,0,0};\nEND"
180
+ glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, programs[0])
181
+ glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, programs[0], program)
182
+
183
+ glProgramNamedParameter4fNV(programs[0],"test",1,2,3,4)
184
+ assert_equal(glGetProgramNamedParameterfvNV(programs[0],"test"),[1,2,3,4])
185
+ glProgramNamedParameter4dNV(programs[0],"test",5,6,7,8)
186
+ assert_equal(glGetProgramNamedParameterdvNV(programs[0],"test"),[5,6,7,8])
187
+ glProgramNamedParameter4fvNV(programs[0],"test",[1,2,3,4])
188
+ assert_equal(glGetProgramNamedParameterfvNV(programs[0],"test"),[1,2,3,4])
189
+ glProgramNamedParameter4dvNV(programs[0],"test",[5,6,7,8])
190
+ assert_equal(glGetProgramNamedParameterdvNV(programs[0],"test"),[5,6,7,8])
191
+
192
+ glDeleteProgramsNV(programs)
193
+ end
194
+
195
+ def test_gl_nv_framebuffer_multisample_coverage
196
+ return if not supported?("GL_NV_framebuffer_multisample_coverage")
197
+ rb = glGenRenderbuffersEXT(1)[0]
198
+
199
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,rb)
200
+ glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER_EXT,4,4, GL_RGBA,2,2)
201
+ samples = glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,GL_RENDERBUFFER_COVERAGE_SAMPLES_NV)
202
+ assert_equal(samples,4)
203
+ samples = glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,GL_RENDERBUFFER_COLOR_SAMPLES_NV)
204
+ assert_equal(samples,4)
205
+
206
+ glDeleteRenderbuffersEXT(rb)
207
+ end
208
+
209
+ def test_gl_nv_fence
210
+ return if not supported?("GL_NV_fence")
211
+ fences = glGenFencesNV(2)
212
+ assert_equal(fences.size,2)
213
+
214
+ glSetFenceNV(fences[0],GL_ALL_COMPLETED_NV)
215
+ assert_equal(glGetFenceivNV(fences[0],GL_FENCE_CONDITION_NV),GL_ALL_COMPLETED_NV)
216
+ assert_equal(glIsFenceNV(fences[0]),true)
217
+
218
+ glFinishFenceNV(fences[0])
219
+ assert_equal(glTestFenceNV(fences[0]),true)
220
+
221
+ glDeleteFencesNV(fences)
222
+ end
223
+
224
+ def test_gl_nv_depth_buffer_float
225
+ return if not supported?("GL_NV_depth_buffer_float")
226
+ glDepthRangedNV(0.1,0.2)
227
+ assert(approx_equal(glGetFloatv(GL_DEPTH_RANGE),[0.1,0.2]))
228
+ glDepthBoundsdNV(0.1,0.2)
229
+ assert(approx_equal(glGetFloatv(GL_DEPTH_BOUNDS_EXT),[0.1,0.2]))
230
+ glClearDepthdNV(0.3)
231
+ assert(approx_equal([glGetDoublev(GL_DEPTH_CLEAR_VALUE)],[0.3]))
232
+ end
233
+
234
+ def test_gl_nv_occlusion_query
235
+ return if not supported?("GL_NV_occlusion_query")
236
+
237
+ queries = glGenOcclusionQueriesNV(2)
238
+ assert_equal(queries.size,2)
239
+
240
+ glBeginOcclusionQueryNV(queries[0])
241
+ assert_equal(glIsOcclusionQueryNV(queries[0]),true)
242
+
243
+ glEndOcclusionQueryNV()
244
+ r = glGetOcclusionQueryivNV(queries[0],GL_PIXEL_COUNT_AVAILABLE_NV)
245
+ assert(r==GL_TRUE || r==GL_FALSE)
246
+ assert(glGetOcclusionQueryuivNV(queries[0],GL_PIXEL_COUNT_NV)>=0)
247
+
248
+ glDeleteOcclusionQueriesNV(queries)
249
+ assert_equal(glIsOcclusionQueryNV(queries[1]),false)
250
+ end
251
+
252
+ def test_gl_nv_gpu_program4
253
+ return if not supported?(["GL_NV_gpu_program4","GL_ARB_vertex_program"])
254
+
255
+ programs = glGenProgramsARB(1)
256
+ program = "!!ARBvp1.0\nTEMP vv;\nEND"
257
+
258
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, programs[0])
259
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, program)
260
+
261
+ glProgramLocalParameterI4iNV(GL_VERTEX_PROGRAM_ARB,1, 1,2,3,4)
262
+ assert_equal(glGetProgramLocalParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
263
+ glProgramLocalParameterI4uiNV(GL_VERTEX_PROGRAM_ARB,1, 5,6,7,8)
264
+ assert_equal(glGetProgramLocalParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
265
+ glProgramLocalParameterI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
266
+ assert_equal(glGetProgramLocalParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
267
+ glProgramLocalParameterI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
268
+ assert_equal(glGetProgramLocalParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
269
+ glProgramLocalParametersI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
270
+ assert_equal(glGetProgramLocalParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
271
+ glProgramLocalParametersI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
272
+ assert_equal(glGetProgramLocalParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
273
+
274
+ glProgramEnvParameterI4iNV(GL_VERTEX_PROGRAM_ARB,1, 1,2,3,4)
275
+ assert_equal(glGetProgramEnvParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
276
+ glProgramEnvParameterI4uiNV(GL_VERTEX_PROGRAM_ARB,1, 5,6,7,8)
277
+ assert_equal(glGetProgramEnvParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
278
+ glProgramEnvParameterI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
279
+ assert_equal(glGetProgramEnvParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
280
+ glProgramEnvParameterI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
281
+ assert_equal(glGetProgramEnvParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
282
+ glProgramEnvParametersI4ivNV(GL_VERTEX_PROGRAM_ARB,1, [1,2,3,4])
283
+ assert_equal(glGetProgramEnvParameterIivNV(GL_VERTEX_PROGRAM_ARB,1),[1,2,3,4])
284
+ glProgramEnvParametersI4uivNV(GL_VERTEX_PROGRAM_ARB,1, [5,6,7,8])
285
+ assert_equal(glGetProgramEnvParameterIuivNV(GL_VERTEX_PROGRAM_ARB,1),[5,6,7,8])
286
+
287
+ glDeleteProgramsARB(programs)
288
+ end
289
+
290
+ def test_gl_nv_gpu_program4
291
+ return if not supported?(["GL_NV_gpu_program4","GL_EXT_framebuffer_object"])
292
+ geometry_program = <<-EOP
293
+ !!NVgp4.0
294
+ PRIMITIVE_IN TRIANGLES;
295
+ PRIMITIVE_OUT TRIANGLE_STRIP;
296
+ VERTICES_OUT 1;
297
+ END
298
+ EOP
299
+
300
+ program_id = glGenProgramsARB(1)[0]
301
+ glBindProgramARB(GL_GEOMETRY_PROGRAM_NV, program_id)
302
+ glProgramStringARB(GL_GEOMETRY_PROGRAM_NV, GL_PROGRAM_FORMAT_ASCII_ARB, geometry_program);
303
+
304
+ assert_equal(glGetProgramivARB(GL_GEOMETRY_PROGRAM_NV,GL_GEOMETRY_VERTICES_OUT_EXT),1)
305
+ glProgramVertexLimitNV(GL_GEOMETRY_PROGRAM_NV, 2)
306
+ assert_equal(glGetProgramivARB(GL_GEOMETRY_PROGRAM_NV,GL_GEOMETRY_VERTICES_OUT_EXT),2)
307
+
308
+ #
309
+
310
+ fbo = glGenFramebuffersEXT(1)[0]
311
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo)
312
+
313
+ texture2d,texture3d,texture_cube = glGenTextures(3)
314
+ glBindTexture(GL_TEXTURE_2D, texture2d)
315
+ glBindTexture(GL_TEXTURE_3D, texture3d)
316
+ glBindTexture(GL_TEXTURE_CUBE_MAP, texture_cube)
317
+
318
+ glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,texture2d,0)
319
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT),texture2d)
320
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT),0)
321
+ glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,texture3d,0,1)
322
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT),texture3d)
323
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT),0)
324
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT),1)
325
+
326
+ glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,texture_cube,0,GL_TEXTURE_CUBE_MAP_POSITIVE_X)
327
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT),texture_cube)
328
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT),0)
329
+ assert_equal(glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT),GL_TEXTURE_CUBE_MAP_POSITIVE_X)
330
+
331
+ glDeleteTextures([texture2d,texture3d])
332
+ glDeleteFramebuffersEXT(fbo)
333
+ glDeleteProgramsARB(program_id)
334
+ end
335
+
336
+ def test_gl_nv_primitive_restart
337
+ return if not supported?("GL_NV_primitive_restart")
338
+ glBegin(GL_TRIANGLES)
339
+ glPrimitiveRestartNV()
340
+ glEnd
341
+ glPrimitiveRestartIndexNV(2)
342
+ assert_equal(glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX_NV),2)
343
+ end
344
+
345
+ def test_gl_nv_point_sprite
346
+ return if not supported?("GL_NV_point_sprite")
347
+ glPointParameteriNV(GL_POINT_SPRITE_R_MODE_NV, GL_ZERO)
348
+ assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_ZERO)
349
+ glPointParameteriNV(GL_POINT_SPRITE_R_MODE_NV, GL_S)
350
+ assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_S)
351
+
352
+ glPointParameterivNV(GL_POINT_SPRITE_R_MODE_NV, [GL_ZERO])
353
+ assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_ZERO)
354
+ glPointParameterivNV(GL_POINT_SPRITE_R_MODE_NV, [GL_S])
355
+ assert_equal(glGetIntegerv(GL_POINT_SPRITE_R_MODE_NV),GL_S)
356
+ end
357
+ end
@@ -0,0 +1,1281 @@
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 'test/unit'
17
+
18
+ class Test_10_11 < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_glhint
28
+ glHint(GL_FOG_HINT,GL_NICEST)
29
+ assert_equal(glGetIntegerv(GL_FOG_HINT), GL_NICEST)
30
+ glHint(GL_FOG_HINT,GL_FASTEST)
31
+ assert_equal(glGetIntegerv(GL_FOG_HINT), GL_FASTEST)
32
+ end
33
+
34
+ def test_glindex
35
+ glIndexd(2.0)
36
+ assert_in_delta(glGetDoublev(GL_CURRENT_INDEX),2.0,0.001)
37
+ glIndexdv([3.0])
38
+ assert_in_delta(glGetDoublev(GL_CURRENT_INDEX),3.0,0.001)
39
+
40
+ glIndexf(4.0)
41
+ assert_in_delta(glGetFloatv(GL_CURRENT_INDEX),4.0,0.001)
42
+ glIndexfv([5.0])
43
+ assert_in_delta(glGetFloatv(GL_CURRENT_INDEX),5.0,0.001)
44
+
45
+ glIndexi(6)
46
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),6,0.001)
47
+ glIndexiv([7])
48
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),7,0.001)
49
+
50
+ glIndexs(8)
51
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),8,0.001)
52
+ glIndexsv([9])
53
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),9,0.001)
54
+
55
+ glIndexub(10)
56
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),10,0.001)
57
+ glIndexubv([11])
58
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),11,0.001)
59
+
60
+ # index pointer
61
+ glIndexPointer(GL_INT,2,"")
62
+ assert_equal(glGetIntegerv(GL_INDEX_ARRAY_STRIDE),2)
63
+ assert_equal(glGetIntegerv(GL_INDEX_ARRAY_TYPE),GL_INT)
64
+ end
65
+
66
+ def test_glclear
67
+ glClearColor(1,0,1,0)
68
+ assert_equal(glGetDoublev(GL_COLOR_CLEAR_VALUE),[1,0,1,0])
69
+
70
+ glClearIndex(2)
71
+ assert_equal(glGetDoublev(GL_INDEX_CLEAR_VALUE),2)
72
+
73
+ glClearAccum(0.5,0.5,0.5,0.5)
74
+ assert_equal(glGetDoublev(GL_ACCUM_CLEAR_VALUE),[0.5,0.5,0.5,0.5])
75
+
76
+ glClearStencil(1)
77
+ assert_equal(glGetIntegerv(GL_STENCIL_CLEAR_VALUE),1)
78
+
79
+ glClearDepth(0.5)
80
+ assert_equal(glGetDoublev(GL_DEPTH_CLEAR_VALUE),0.5)
81
+ end
82
+
83
+ def test_glclientattrib
84
+ glPixelStorei(GL_PACK_ALIGNMENT,2)
85
+ glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT)
86
+ glPixelStorei(GL_PACK_ALIGNMENT,4)
87
+ assert_equal(glGetIntegerv(GL_PACK_ALIGNMENT),4)
88
+ glPopClientAttrib()
89
+ assert_equal(glGetIntegerv(GL_PACK_ALIGNMENT),2)
90
+ end
91
+
92
+ def test_matrix
93
+ m_a = [[2.0,0.0,0.0,0.0],
94
+ [0.0,2.0,0.0,0.0],
95
+ [0.0,0.0,2.0,0.0],
96
+ [0.0,0.0,0.0,2.0]]
97
+
98
+ m_b = [[3.0,0.0,0.0,0.0],
99
+ [0.0,3.0,0.0,0.0],
100
+ [0.0,0.0,3.0,0.0],
101
+ [0.0,0.0,0.0,3.0]]
102
+
103
+ m_ident = [[1.0,0.0,0.0,0.0],
104
+ [0.0,1.0,0.0,0.0],
105
+ [0.0,0.0,1.0,0.0],
106
+ [0.0,0.0,0.0,1.0]]
107
+
108
+ # 1
109
+ glMatrixMode(GL_MODELVIEW)
110
+ glLoadMatrixf(m_a)
111
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
112
+ glLoadMatrixd(m_b)
113
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_b)
114
+
115
+ glLoadIdentity()
116
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_ident)
117
+
118
+ glMultMatrixf(m_a)
119
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
120
+ glLoadIdentity()
121
+ glMultMatrixd(m_b)
122
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_b)
123
+
124
+ # 2
125
+ glMatrixMode(GL_MODELVIEW)
126
+ glLoadMatrixf(m_a)
127
+ glMatrixMode(GL_PROJECTION)
128
+ glLoadMatrixf(m_b)
129
+
130
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
131
+ assert_equal(glGetDoublev(GL_PROJECTION_MATRIX), m_b)
132
+
133
+ glMatrixMode(GL_MODELVIEW)
134
+ glLoadMatrixf(m_a)
135
+ glPushMatrix()
136
+ glLoadMatrixf(m_b)
137
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_b)
138
+ glPopMatrix()
139
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
140
+
141
+ # 3
142
+ m = Matrix.rows([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
143
+ glMatrixMode(GL_MODELVIEW)
144
+ glLoadMatrixf(m)
145
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
146
+ glLoadIdentity()
147
+ glLoadMatrixd(m)
148
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
149
+ glLoadIdentity()
150
+ glMultMatrixf(m)
151
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
152
+ glLoadIdentity()
153
+ glMultMatrixd(m)
154
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
155
+
156
+ assert_raise ArgumentError do glLoadMatrixf([1,2,3,4]) end
157
+ assert_raise ArgumentError do glLoadMatrixd([1,2,3,4]) end
158
+ assert_raise ArgumentError do glMultMatrixf([1,2,3,4]) end
159
+ assert_raise ArgumentError do glMultMatrixd([1,2,3,4]) end
160
+ end
161
+
162
+ def test_gledge
163
+ glEdgeFlag(GL_FALSE)
164
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),false)
165
+ glEdgeFlag(GL_TRUE)
166
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),true)
167
+ glEdgeFlagv([GL_FALSE])
168
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),false)
169
+ end
170
+
171
+ def test_clientstate
172
+ glEnableClientState(GL_COLOR_ARRAY)
173
+ assert_equal(glIsEnabled(GL_COLOR_ARRAY),true)
174
+ glDisableClientState(GL_COLOR_ARRAY)
175
+ assert_equal(glIsEnabled(GL_COLOR_ARRAY),false)
176
+ end
177
+
178
+ def test_glshademodel
179
+ glShadeModel(GL_FLAT)
180
+ assert_equal(glGetIntegerv(GL_SHADE_MODEL),GL_FLAT)
181
+ glShadeModel(GL_SMOOTH)
182
+ assert_equal(glGetIntegerv(GL_SHADE_MODEL),GL_SMOOTH)
183
+ end
184
+
185
+ def test_glclipplane
186
+ glClipPlane(GL_CLIP_PLANE0,[1,2,3,4])
187
+ assert_equal(glGetClipPlane(GL_CLIP_PLANE0),[1,2,3,4])
188
+ end
189
+
190
+ def test_polygonoffset
191
+ glPolygonOffset(2.0,3.0)
192
+ assert_equal(glGetDoublev(GL_POLYGON_OFFSET_FACTOR),2.0)
193
+ assert_equal(glGetDoublev(GL_POLYGON_OFFSET_UNITS),3.0)
194
+ end
195
+
196
+ def test_glviewport
197
+ glViewport(1,2,3,4)
198
+ assert_equal(glGetIntegerv(GL_VIEWPORT), [1,2,3,4])
199
+ end
200
+
201
+ def test_mask
202
+ glStencilMask(2)
203
+ assert_equal(glGetIntegerv(GL_STENCIL_WRITEMASK), 2)
204
+ glStencilMask(1)
205
+ assert_equal(glGetIntegerv(GL_STENCIL_BACK_WRITEMASK), 1)
206
+
207
+ glColorMask(GL_TRUE,GL_FALSE,GL_TRUE,GL_FALSE)
208
+ assert_equal(glGetBooleanv(GL_COLOR_WRITEMASK),[true,false,true,false])
209
+
210
+ glDepthMask(GL_TRUE)
211
+ assert_equal(glGetBooleanv(GL_DEPTH_WRITEMASK),true)
212
+ glDepthMask(GL_FALSE)
213
+ assert_equal(glGetBooleanv(GL_DEPTH_WRITEMASK),false)
214
+
215
+ glIndexMask(2)
216
+ assert_equal(glGetIntegerv(GL_INDEX_WRITEMASK), 2)
217
+ glIndexMask(1)
218
+ assert_equal(glGetIntegerv(GL_INDEX_WRITEMASK), 1)
219
+ end
220
+
221
+ def test_glflush
222
+ begin
223
+ glBegin(GL_POINTS)
224
+ glFlush()
225
+ glEnd
226
+ rescue Gl::Error => err
227
+ assert(err.id == GL_INVALID_OPERATION)
228
+ end
229
+ end
230
+
231
+ def test_glfinish
232
+ begin
233
+ glBegin(GL_POINTS)
234
+ glFinish()
235
+ glEnd
236
+ rescue Gl::Error => err
237
+ assert(err.id == GL_INVALID_OPERATION)
238
+ end
239
+ end
240
+
241
+ def test_glgetstring
242
+ assert(glGetString(GL_VERSION).size > 0)
243
+ end
244
+
245
+ def test_glscissor
246
+ glScissor(1,2,3,4)
247
+ assert_equal(glGetIntegerv(GL_SCISSOR_BOX),[1,2,3,4])
248
+ end
249
+
250
+ def test_glstencilfunc
251
+ glStencilFunc(GL_LEQUAL,2,3)
252
+ assert_equal(glGetIntegerv(GL_STENCIL_FUNC),GL_LEQUAL)
253
+ assert_equal(glGetIntegerv(GL_STENCIL_REF),2)
254
+ assert_equal(glGetIntegerv(GL_STENCIL_VALUE_MASK),3)
255
+ end
256
+
257
+ def test_glstencilop
258
+ glStencilOp(GL_ZERO,GL_REPLACE,GL_INCR)
259
+ assert_equal(glGetIntegerv(GL_STENCIL_FAIL),GL_ZERO)
260
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL),GL_REPLACE)
261
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS),GL_INCR)
262
+ end
263
+
264
+ def test_gllogicop
265
+ glLogicOp(GL_NAND)
266
+ assert_equal(glGetIntegerv(GL_LOGIC_OP_MODE),GL_NAND)
267
+ end
268
+
269
+ def test_glfrustum
270
+ glMatrixMode(GL_PROJECTION)
271
+ glLoadIdentity()
272
+
273
+ glFrustum(1,2,3,4,5,6)
274
+ assert_equal(glGetDoublev(GL_PROJECTION_MATRIX),[[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]])
275
+ end
276
+
277
+ def test_gldepthrange
278
+ glDepthRange(0.5,0.5)
279
+ assert_equal(glGetDoublev(GL_DEPTH_RANGE),[0.5,0.5])
280
+ end
281
+
282
+ def test_func
283
+ glAlphaFunc(GL_GREATER,0.5)
284
+ assert_equal(glGetIntegerv(GL_ALPHA_TEST_FUNC),GL_GREATER)
285
+ assert_equal(glGetDoublev(GL_ALPHA_TEST_REF),0.5)
286
+
287
+ glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_DST_COLOR)
288
+ assert_equal(glGetIntegerv(GL_BLEND_SRC),GL_CONSTANT_ALPHA)
289
+ assert_equal(glGetIntegerv(GL_BLEND_DST),GL_ONE_MINUS_DST_COLOR)
290
+
291
+ glDepthFunc(GL_LEQUAL)
292
+ assert_equal(glGetIntegerv(GL_DEPTH_FUNC),GL_LEQUAL)
293
+ end
294
+
295
+ def test_glpixelzoom
296
+ glPixelZoom(0.5,0.5)
297
+ assert_equal(glGetDoublev(GL_ZOOM_X),0.5)
298
+ assert_equal(glGetDoublev(GL_ZOOM_Y),0.5)
299
+ end
300
+
301
+ def test_glpixelstore
302
+ glPixelStoref(GL_PACK_IMAGE_HEIGHT,5)
303
+ assert_equal(glGetIntegerv(GL_PACK_IMAGE_HEIGHT),5)
304
+ glPixelStorei(GL_PACK_IMAGE_HEIGHT,6)
305
+ assert_equal(glGetIntegerv(GL_PACK_IMAGE_HEIGHT),6)
306
+ end
307
+
308
+ def test_glpixeltransfer
309
+ glPixelTransferf(GL_RED_SCALE,2)
310
+ assert_equal(glGetIntegerv(GL_RED_SCALE),2)
311
+ glPixelTransferi(GL_RED_SCALE,3)
312
+ assert_equal(glGetIntegerv(GL_RED_SCALE),3)
313
+ end
314
+
315
+ def test_pixelmap
316
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_I,[1,2,3,4])
317
+ assert_equal(glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I), [1,2,3,4])
318
+
319
+ glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,[5,6,7,8])
320
+ assert_equal(glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I),[5,6,7,8])
321
+
322
+ glPixelMapusv(GL_PIXEL_MAP_I_TO_I,[9,10,11,12])
323
+ assert_equal(glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I),[9,10,11,12])
324
+ end
325
+
326
+ def test_buffers
327
+ glDrawBuffer(GL_FRONT)
328
+ assert_equal(glGetIntegerv(GL_DRAW_BUFFER),GL_FRONT)
329
+ glDrawBuffer(GL_BACK)
330
+ assert_equal(glGetIntegerv(GL_DRAW_BUFFER),GL_BACK)
331
+
332
+ glReadBuffer(GL_FRONT)
333
+ assert_equal(glGetIntegerv(GL_READ_BUFFER),GL_FRONT)
334
+ glReadBuffer(GL_BACK)
335
+ assert_equal(glGetIntegerv(GL_READ_BUFFER),GL_BACK)
336
+ end
337
+
338
+ def test__selection_buffer
339
+ buf = glSelectBuffer(32)
340
+
341
+ glRenderMode(GL_SELECT)
342
+ glInitNames()
343
+ glPushName(6)
344
+ glPushName(3)
345
+ glLoadName(5)
346
+ glPopName()
347
+
348
+ glBegin(GL_QUADS)
349
+ glVertex2i(-1,-1)
350
+ glVertex2i( 1,-1)
351
+ glVertex2i( 1, 1)
352
+ glVertex2i(-1, 1)
353
+ glEnd()
354
+
355
+ count = glRenderMode(GL_RENDER)
356
+ data = buf.unpack("i*")
357
+ assert(count==1) # number of records
358
+ assert(data[0]==1) # number of hits in this record
359
+ # assert(data[1]>0) # zbuffer near
360
+ # assert(data[2]>0) # zbuffer far
361
+ assert(data[3]==6) # name of hit
362
+ end
363
+
364
+ def test__feedback_buffer
365
+ buf = glFeedbackBuffer(32,GL_2D)
366
+
367
+ glRenderMode(GL_FEEDBACK)
368
+
369
+ glBegin(GL_TRIANGLES)
370
+ glVertex2i(-1,-1)
371
+ glVertex2i( 1,-1)
372
+ glVertex2i( 1, 1)
373
+ glEnd()
374
+
375
+ glPassThrough(2.0)
376
+
377
+ count = glRenderMode(GL_RENDER)
378
+ data = buf.unpack("f*")
379
+ assert_equal(count,10) # (1 + 1 + 3x2) + (1 + 1)
380
+ assert_equal(data[0],GL_POLYGON_TOKEN)
381
+ assert_equal(data[1],3) # 3 vertices
382
+ # skip rasterized vertex data
383
+ assert_equal(data[8],GL_PASS_THROUGH_TOKEN)
384
+ assert_equal(data[9],2.0)
385
+ end
386
+
387
+ def test_glrasterpos
388
+ glOrtho(0,$window_size,0,$window_size,0,-1)
389
+
390
+ # 2
391
+ glRasterPos2d(1.0,2.0)
392
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
393
+ glRasterPos2dv([3.0,4.0])
394
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
395
+
396
+ glRasterPos2f(1.0,2.0)
397
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
398
+ glRasterPos2fv([3.0,4.0])
399
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
400
+
401
+ glRasterPos2i(1,2)
402
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
403
+ glRasterPos2iv([3,4])
404
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
405
+
406
+ glRasterPos2s(1,2)
407
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
408
+ glRasterPos2sv([3,4])
409
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
410
+
411
+ # 3
412
+ glRasterPos3d(1.0,2.0,1.0)
413
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
414
+ glRasterPos3dv([3.0,4.0,0.0])
415
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
416
+
417
+ glRasterPos3f(1.0,2.0,1.0)
418
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
419
+ glRasterPos3fv([3.0,4.0,0.0])
420
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
421
+
422
+ glRasterPos3i(1,2,1)
423
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
424
+ glRasterPos3iv([3,4,0])
425
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
426
+
427
+ glRasterPos3s(1,2,1)
428
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
429
+ glRasterPos3sv([3,4,0])
430
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
431
+
432
+ # 4
433
+ glRasterPos4d(1.0,2.0,1.0,1.0)
434
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
435
+ glRasterPos4dv([3.0,4.0,0.0,1.0])
436
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
437
+
438
+ glRasterPos4f(1.0,2.0,1.0,1.0)
439
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
440
+ glRasterPos4fv([3.0,4.0,0.0,1.0])
441
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
442
+
443
+ glRasterPos4i(1,2,1,1)
444
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
445
+ glRasterPos4iv([3,4,0,1])
446
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
447
+
448
+ glRasterPos4s(1,2,1,1)
449
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
450
+ glRasterPos4sv([3,4,0,1])
451
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
452
+ end
453
+
454
+ def test_glbitmap
455
+ glOrtho(0,$window_size,0,$window_size,0,-1)
456
+
457
+ bitmap = [ 0x55 ] * 8 # 64 bits (8x8 bitmap), stipple pattern
458
+
459
+ glPixelStorei(GL_PACK_ALIGNMENT,1)
460
+ glPixelStorei(GL_UNPACK_ALIGNMENT,1)
461
+
462
+ glBitmap(8,8,0,0,0,0,bitmap.pack("c*"))
463
+ data = glReadPixels(0,0,8,8,GL_RED,GL_UNSIGNED_BYTE)
464
+ assert_equal(data.unpack("C*"),[0,255] * 32)
465
+ end
466
+
467
+ def test_glfog
468
+ glFogfv(GL_FOG_COLOR,[0.0,1.0,0.0,1.0])
469
+ assert_equal(glGetDoublev(GL_FOG_COLOR),[0.0,1.0,0.0,1.0])
470
+ glFogf(GL_FOG_DENSITY,0.5)
471
+ assert_equal(glGetDoublev(GL_FOG_DENSITY),0.5)
472
+ glFogi(GL_FOG_MODE,GL_LINEAR)
473
+ assert_equal(glGetIntegerv(GL_FOG_MODE),GL_LINEAR)
474
+ glFogi(GL_FOG_MODE,GL_EXP)
475
+ assert_equal(glGetIntegerv(GL_FOG_MODE),GL_EXP)
476
+ glFogiv(GL_FOG_MODE,[GL_EXP2])
477
+ assert_equal(glGetIntegerv(GL_FOG_MODE),GL_EXP2)
478
+ end
479
+
480
+ def test_glcolor
481
+ # 3
482
+ glColor3b(2**7-1,0,2**7-1)
483
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
484
+ glColor3bv([0,2**7-1,0])
485
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
486
+ glColor3d(1.0,0.0,1.0)
487
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
488
+ glColor3dv([0.0,1.0,0.0])
489
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
490
+ glColor3f(1.0,0.0,1.0)
491
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
492
+ glColor3fv([0.0,1.0,0.0])
493
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
494
+ glColor3i(2**31-1,0,2**31-1)
495
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
496
+ glColor3iv([0,2**31-1,0])
497
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
498
+ glColor3s(2**15-1,0,2**15-1)
499
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
500
+ glColor3sv([0,2**15-1,0])
501
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
502
+ glColor3ub(2**8-1,0,2**8-1)
503
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
504
+ glColor3ubv([0,2**8-1,0])
505
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
506
+ glColor3ui(2**32-1,0,2**32-1)
507
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
508
+ glColor3uiv([0,2**32-1,0])
509
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
510
+ glColor3us(2**16-1,0,2**16-1)
511
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,1.0]))
512
+ glColor3usv([0,2**16-1,0])
513
+ # 4
514
+ glColor4b(2**7-1,0,2**7-1,0)
515
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
516
+ glColor4bv([0,2**7-1,0,2**7-1])
517
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
518
+ glColor4d(1.0,0.0,1.0,0.0)
519
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
520
+ glColor4dv([0.0,1.0,0.0,1.0])
521
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
522
+ glColor4f(1.0,0.0,1.0,0.0)
523
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
524
+ glColor4fv([0.0,1.0,0.0,1.0])
525
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
526
+ glColor4i(2**31-1,0,2**31-1,0)
527
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
528
+ glColor4iv([0,2**31-1,0,2**31-1])
529
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
530
+ glColor4s(2**15-1,0,2**15-1,0)
531
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
532
+ glColor4sv([0,2**15-1,0,2**15-1])
533
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
534
+ glColor4ub(2**8-1,0,2**8-1,0)
535
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
536
+ glColor4ubv([0,2**8-1,0,2**8-1])
537
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
538
+ glColor4ui(2**32-1,0,2**32-1,0)
539
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
540
+ glColor4uiv([0,2**32-1,0,2**32-1])
541
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
542
+ glColor4us(2**16-1,0,2**16-1,0)
543
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[1.0,0.0,1.0,0.0]))
544
+ glColor4usv([0,2**16-1,0,2**16-1])
545
+ assert(approx_equal(glGetDoublev(GL_CURRENT_COLOR),[0.0,1.0,0.0,1.0]))
546
+ end
547
+
548
+ def test_glortho
549
+ res = [ [2.0/$window_size, 0, 0, 0],
550
+ [0, 2.0/$window_size, 0, 0],
551
+ [0, 0, 2, 0],
552
+ [-1,-1,-1,1] ]
553
+
554
+ glMatrixMode(GL_PROJECTION)
555
+ glLoadIdentity()
556
+ glOrtho(0,$window_size,0,$window_size,0,-1)
557
+ assert_equal(glGetDoublev(GL_PROJECTION_MATRIX),res)
558
+ end
559
+
560
+ def test_glnormal
561
+ glNormal3d(1.0,2.0,3.0)
562
+ assert_equal(glGetDoublev(GL_CURRENT_NORMAL),[1.0,2.0,3.0])
563
+ glNormal3dv([4.0,5.0,6.0])
564
+ assert_equal(glGetDoublev(GL_CURRENT_NORMAL),[4.0,5.0,6.0])
565
+
566
+ glNormal3f(1.0,2.0,3.0)
567
+ assert_equal(glGetDoublev(GL_CURRENT_NORMAL),[1.0,2.0,3.0])
568
+ glNormal3fv([4.0,5.0,6.0])
569
+ assert_equal(glGetDoublev(GL_CURRENT_NORMAL),[4.0,5.0,6.0])
570
+
571
+ glNormal3i(1,2,3)
572
+ assert_equal(glGetIntegerv(GL_CURRENT_NORMAL),[1,2,3])
573
+ glNormal3iv([4,5,6])
574
+ assert_equal(glGetIntegerv(GL_CURRENT_NORMAL),[4,5,6])
575
+
576
+ glNormal3b(2**7-1,0,2**7-1)
577
+ assert(approx_equal(glGetDoublev(GL_CURRENT_NORMAL),[1.0,0.0,1.0]))
578
+ glNormal3bv(0,2**7-1,0)
579
+ assert(approx_equal(glGetDoublev(GL_CURRENT_NORMAL),[0.0,1.0,0.0]))
580
+
581
+ glNormal3s(2**15-1,0,2**15-1)
582
+ assert(approx_equal(glGetDoublev(GL_CURRENT_NORMAL),[1.0,0.0,1.0]))
583
+ glNormal3sv(0,2**15-1,0)
584
+ assert(approx_equal(glGetDoublev(GL_CURRENT_NORMAL),[0.0,1.0,0.0]))
585
+ end
586
+
587
+
588
+ def test_gllight
589
+ glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,80.0)
590
+ assert_equal(glGetLightfv(GL_LIGHT0,GL_SPOT_CUTOFF),80.0)
591
+ glLighti(GL_LIGHT0,GL_SPOT_CUTOFF,75)
592
+ assert_equal(glGetLightiv(GL_LIGHT0,GL_SPOT_CUTOFF),75)
593
+ glLightfv(GL_LIGHT0,GL_AMBIENT,[0.5,0.5,0.5,1.0])
594
+ assert_equal(glGetLightfv(GL_LIGHT0,GL_AMBIENT), [0.5,0.5,0.5,1.0])
595
+ glLightiv(GL_LIGHT0,GL_CONSTANT_ATTENUATION,[32])
596
+ assert_equal(glGetLightiv(GL_LIGHT0,GL_CONSTANT_ATTENUATION),32)
597
+ end
598
+
599
+ def test_glmaterial
600
+ glMaterialfv(GL_FRONT,GL_AMBIENT,[0.0,1.0,0.0,1.0])
601
+ assert_equal(glGetMaterialfv(GL_FRONT,GL_AMBIENT),[0.0,1.0,0.0,1.0])
602
+
603
+ glMaterialiv(GL_FRONT,GL_SHININESS,[50])
604
+ assert_equal(glGetMaterialiv(GL_FRONT,GL_SHININESS),50)
605
+
606
+ glMaterialf(GL_FRONT,GL_SHININESS,49.0)
607
+ assert_equal(glGetMaterialfv(GL_FRONT,GL_SHININESS),49.0)
608
+
609
+ glMateriali(GL_FRONT,GL_SHININESS,48)
610
+ assert_equal(glGetMaterialiv(GL_FRONT,GL_SHININESS),48)
611
+
612
+ end
613
+
614
+ def test_glcolormaterial
615
+ glColorMaterial(GL_FRONT,GL_EMISSION)
616
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_FACE),GL_FRONT)
617
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER),GL_EMISSION)
618
+
619
+ glColorMaterial(GL_BACK,GL_SPECULAR)
620
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_FACE),GL_BACK)
621
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER),GL_SPECULAR)
622
+ end
623
+
624
+ def test_gllightmodel
625
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE)
626
+ assert_equal(glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE),GL_TRUE)
627
+ glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE)
628
+ assert_equal(glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE),GL_FALSE)
629
+
630
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT,[0.5,0.5,0.5,1.0])
631
+ assert_equal(glGetDoublev(GL_LIGHT_MODEL_AMBIENT),[0.5,0.5,0.5,1.0])
632
+ glLightModeliv(GL_LIGHT_MODEL_AMBIENT,[1,0,1,0])
633
+ assert_equal(glGetIntegerv(GL_LIGHT_MODEL_AMBIENT),[1,0,1,0])
634
+ end
635
+
636
+ def test_gltexcoord
637
+ # 1
638
+ glTexCoord1d(1.5)
639
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,0,0,1])
640
+ glTexCoord1dv([0.5])
641
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0,0,1])
642
+ glTexCoord1f(1.5)
643
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,0,0,1])
644
+ glTexCoord1fv([0.5])
645
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0,0,1])
646
+ glTexCoord1i(1)
647
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,0,0,1])
648
+ glTexCoord1iv([0])
649
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,1])
650
+ glTexCoord1s(1)
651
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,0,0,1])
652
+ glTexCoord1sv([0])
653
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,1])
654
+ # 2
655
+ glTexCoord2d(1.5,1.5)
656
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,1.5,0,1])
657
+ glTexCoord2dv([0.5,0.5])
658
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0.5,0,1])
659
+ glTexCoord2f(1.5,1.5)
660
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,1.5,0,1])
661
+ glTexCoord2fv([0.5,0.5])
662
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0.5,0,1])
663
+ glTexCoord2i(1,1)
664
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,1,0,1])
665
+ glTexCoord2iv([0,0])
666
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,1])
667
+ glTexCoord2s(1,1)
668
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,1,0,1])
669
+ glTexCoord2sv([0,0])
670
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,1])
671
+ # 3
672
+ glTexCoord3d(1.5,1.5,1.5)
673
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,1.5,1.5,1])
674
+ glTexCoord3dv([0.5,0.5,0.5])
675
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0.5,0.5,1])
676
+ glTexCoord3f(1.5,1.5,1.5)
677
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,1.5,1.5,1])
678
+ glTexCoord3fv([0.5,0.5,0.5])
679
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0.5,0.5,1])
680
+ glTexCoord3i(1,1,1)
681
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,1,1,1])
682
+ glTexCoord3iv([0,0,0])
683
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,1])
684
+ glTexCoord3s(1,1,1)
685
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,1,1,1])
686
+ glTexCoord3sv([0,0,0])
687
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,1])
688
+ # 4
689
+ glTexCoord4d(1.5,1.5,1.5,1.5)
690
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,1.5,1.5,1.5])
691
+ glTexCoord4dv([0.5,0.5,0.5,0.5])
692
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0.5,0.5,0.5])
693
+ glTexCoord4f(1.5,1.5,1.5,1.5)
694
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1.5,1.5,1.5,1.5])
695
+ glTexCoord4fv([0.5,0.5,0.5,0.5])
696
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0.5,0.5,0.5,0.5])
697
+ glTexCoord4i(1,1,1,1)
698
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,1,1,1])
699
+ glTexCoord4iv([0,0,0,0])
700
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,0])
701
+ glTexCoord4s(1,1,1,1)
702
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,1,1,1])
703
+ glTexCoord4sv([0,0,0,0])
704
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[0,0,0,0])
705
+ end
706
+
707
+ def test_glenable_disable
708
+ glEnable(GL_FOG)
709
+ assert_equal(glIsEnabled(GL_FOG),true)
710
+ glDisable(GL_FOG)
711
+ assert_equal(glIsEnabled(GL_FOG),false)
712
+ end
713
+
714
+ def test_gltexparameter
715
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP)
716
+ assert_equal(glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_CLAMP)
717
+ glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_MIRRORED_REPEAT)
718
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_MIRRORED_REPEAT)
719
+ glTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,[GL_CLAMP])
720
+ assert_equal(glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_CLAMP)
721
+ glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,[GL_MIRRORED_REPEAT])
722
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_MIRRORED_REPEAT)
723
+
724
+ assert_equal(glGetTexLevelParameterfv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH),0.0)
725
+ assert_equal(glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH),0)
726
+ end
727
+
728
+ def test_glcullface
729
+ glCullFace(GL_FRONT)
730
+ assert_equal(glGetIntegerv(GL_CULL_FACE_MODE),GL_FRONT)
731
+ glCullFace(GL_BACK)
732
+ assert_equal(glGetIntegerv(GL_CULL_FACE_MODE),GL_BACK)
733
+ end
734
+
735
+ def test_glfrontface
736
+ glFrontFace(GL_CW)
737
+ assert_equal(glGetIntegerv(GL_FRONT_FACE),GL_CW)
738
+ glFrontFace(GL_CCW)
739
+ assert_equal(glGetIntegerv(GL_FRONT_FACE),GL_CCW)
740
+ end
741
+
742
+ def test_glpointsize
743
+ glPointSize(2.0)
744
+ assert_equal(glGetDoublev(GL_POINT_SIZE),2.0)
745
+ glPointSize(3.0)
746
+ assert_equal(glGetDoublev(GL_POINT_SIZE),3.0)
747
+ end
748
+
749
+ def test_glpolygonmode
750
+ glPolygonMode(GL_FRONT_AND_BACK,GL_LINE)
751
+ assert_equal(glGetIntegerv(GL_POLYGON_MODE),[GL_LINE,GL_LINE])
752
+ glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
753
+ assert_equal(glGetIntegerv(GL_POLYGON_MODE),[GL_FILL,GL_FILL])
754
+ end
755
+
756
+ def test_gllinewidth
757
+ glLineWidth(2.0)
758
+ assert_equal(glGetDoublev(GL_LINE_WIDTH),2.0)
759
+ glLineWidth(3.0)
760
+ assert_equal(glGetDoublev(GL_LINE_WIDTH),3.0)
761
+ end
762
+
763
+ def test_gllinestipple
764
+ glLineStipple(3,0x1234)
765
+ assert_equal(glGetIntegerv(GL_LINE_STIPPLE_REPEAT),3)
766
+ assert_equal(glGetIntegerv(GL_LINE_STIPPLE_PATTERN),0x1234)
767
+ end
768
+
769
+ def test_glpolygonstipple
770
+ stipple = [0x12] * 128
771
+ glPolygonStipple(stipple.pack("c*"))
772
+ assert_equal(glGetPolygonStipple(),stipple.pack("c*"))
773
+ end
774
+
775
+ def parse_feedback_data(data,count)
776
+ c = count / 11
777
+ ret = []
778
+ (0...c).each do |x|
779
+ i = x *11
780
+ type = data[0+i]
781
+
782
+ v1 = [data[2+i], data[3+i], data[4+i]]
783
+ v2 = [data[5+i], data[6+i], data[7+i]]
784
+ v3 = [data[8+i], data[9+i], data[10+i]]
785
+ vertex = [v1,v2,v3].sort
786
+ ret << [type,vertex]
787
+ end
788
+ ret
789
+ end
790
+
791
+ def test_glvertex
792
+ glMatrixMode(GL_PROJECTION)
793
+ glOrtho(0,$window_size,0,$window_size,0,-1)
794
+
795
+ buf = glFeedbackBuffer(256,GL_3D)
796
+
797
+ glRenderMode(GL_FEEDBACK)
798
+
799
+ glBegin(GL_TRIANGLES)
800
+ glVertex2d( 1, 0)
801
+ glVertex2dv([0,0])
802
+ glVertex2f( 1,1)
803
+
804
+ glVertex2fv([ 1, 0])
805
+ glVertex2i( 0,0)
806
+ glVertex2iv([1,1])
807
+
808
+ glVertex2s( 1, 0)
809
+ glVertex2sv([0,0])
810
+ glVertex3d( 1,1,0)
811
+
812
+ glVertex3dv([ 1, 0,0])
813
+ glVertex3f( 0,0,0)
814
+ glVertex3fv([1,1,0])
815
+
816
+ glVertex3i( 1, 0,0)
817
+ glVertex3iv([0,0,0])
818
+ glVertex3s( 1,1,0)
819
+
820
+ glVertex3sv([ 1, 0,0])
821
+ glVertex4d( 0,0,0,1)
822
+ glVertex4dv([1,1,0,1])
823
+
824
+ glVertex4f( 1, 0,0,1)
825
+ glVertex4fv([0,0,0,1])
826
+ glVertex4i( 1,1,0,1)
827
+
828
+ glVertex4iv([ 1, 0,0,1])
829
+ glVertex4s( 0,0,0,1)
830
+ glVertex4sv([1,1,0,1])
831
+
832
+ glEnd()
833
+
834
+ count = glRenderMode(GL_RENDER)
835
+ data = buf.unpack("f*")
836
+
837
+ ref = [[GL_POLYGON_TOKEN,[[0,0,0],[1,0,0],[1,1,0]]]] * 8
838
+
839
+ assert_equal(parse_feedback_data(data,count),ref)
840
+ end
841
+
842
+ def test_glrect
843
+ glMatrixMode(GL_PROJECTION)
844
+ glOrtho(0,$window_size,0,$window_size,0,-1)
845
+
846
+ buf = glFeedbackBuffer(256,GL_3D)
847
+
848
+ glRenderMode(GL_FEEDBACK)
849
+
850
+ glRectd(0,0,1,1)
851
+ glRectdv([0,0],[1,1])
852
+ glRectf(0,0,1,1)
853
+ glRectfv([0,0],[1,1])
854
+ glRecti(0,0,1,1)
855
+ glRectiv([0,0],[1,1])
856
+ glRects(0,0,1,1)
857
+ glRectsv([0,0],[1,1])
858
+
859
+ count = glRenderMode(GL_RENDER)
860
+ data = buf.unpack("f*")
861
+
862
+ assert_equal(count, (3*3+2)*2*8)
863
+ end
864
+
865
+ def test_glclear
866
+ glClearColor(1.0,1.0,1.0,1.0)
867
+ glClear(GL_COLOR_BUFFER_BIT)
868
+
869
+ data = glReadPixels(0,0,1,1,GL_RGB,GL_FLOAT)
870
+ assert_equal(data.unpack("f*"),[1.0,1.0,1.0])
871
+
872
+ glClearColor(0.0,0.0,0.0,0.0)
873
+ glClear(GL_COLOR_BUFFER_BIT)
874
+
875
+ data = glReadPixels(0,0,1,1,GL_RGB,GL_FLOAT)
876
+ assert_equal(data.unpack("f*"),[0.0,0.0,0.0])
877
+ end
878
+
879
+ def test_gltexenv
880
+ glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)
881
+ assert_equal(glGetTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_ADD)
882
+ glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)
883
+ assert_equal(glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_MODULATE)
884
+
885
+ glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[GL_ADD])
886
+ assert_equal(glGetTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_ADD)
887
+ glTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[GL_MODULATE])
888
+ assert_equal(glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_MODULATE)
889
+ end
890
+
891
+ def test_gltexgen
892
+ glTexGend(GL_S,GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP)
893
+ assert_equal(glGetTexGendv(GL_S,GL_TEXTURE_GEN_MODE),GL_REFLECTION_MAP)
894
+ glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR)
895
+ assert_equal(glGetTexGenfv(GL_S,GL_TEXTURE_GEN_MODE),GL_EYE_LINEAR)
896
+ glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP)
897
+ assert_equal(glGetTexGeniv(GL_S,GL_TEXTURE_GEN_MODE),GL_SPHERE_MAP)
898
+
899
+ glTexGendv(GL_S,GL_TEXTURE_GEN_MODE,[GL_REFLECTION_MAP])
900
+ assert_equal(glGetTexGendv(GL_S,GL_TEXTURE_GEN_MODE),GL_REFLECTION_MAP)
901
+ glTexGenfv(GL_S,GL_TEXTURE_GEN_MODE,[GL_EYE_LINEAR])
902
+ assert_equal(glGetTexGenfv(GL_S,GL_TEXTURE_GEN_MODE),GL_EYE_LINEAR)
903
+ glTexGeniv(GL_S,GL_TEXTURE_GEN_MODE,[GL_SPHERE_MAP])
904
+ assert_equal(glGetTexGeniv(GL_S,GL_TEXTURE_GEN_MODE),GL_SPHERE_MAP)
905
+ end
906
+
907
+ def test_textures
908
+ textures = glGenTextures(2)
909
+ assert_equal(textures.size, 2)
910
+ assert_equal(glIsTexture(textures[0]),false)
911
+ glBindTexture(GL_TEXTURE_2D,textures[0])
912
+ assert_equal(glIsTexture(textures[0]),true)
913
+
914
+ image = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
915
+
916
+ glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, image)
917
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT), image)
918
+
919
+ glBindTexture(GL_TEXTURE_1D,textures[1])
920
+
921
+ glTexImage1D(GL_TEXTURE_1D,0,GL_RGB8, 16, 0, GL_RGB, GL_FLOAT, image)
922
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT), image)
923
+
924
+ glDeleteTextures(textures)
925
+ assert_equal(glIsTexture(textures[0]),false)
926
+ end
927
+
928
+ def test_pixels
929
+ glClearColor(0,0,0,0)
930
+ glClear(GL_COLOR_BUFFER_BIT)
931
+
932
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
933
+ assert_equal(data.unpack("f*"), [0] * 3 * 16)
934
+
935
+ image = ([1.0] * 3 * 16).pack("f*")
936
+ glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
937
+
938
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
939
+ assert_equal(data,image)
940
+
941
+ #
942
+ glClearColor(0,0,0,0)
943
+ glClear(GL_COLOR_BUFFER_BIT)
944
+
945
+ image = (([0.0] * 3 * 8) + ([1.0] * 3 * 8)).pack("f*")
946
+ glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
947
+
948
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
949
+ assert_equal(data,image)
950
+
951
+ glCopyPixels(0,2,4,2,GL_COLOR)
952
+
953
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
954
+ assert_equal(data,([1.0] * 3 * 16).pack("f*"))
955
+ end
956
+
957
+ def test_gltranslate
958
+ m = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[1,2,3,1]]
959
+ glMatrixMode(GL_MODELVIEW)
960
+ glLoadIdentity()
961
+ glTranslated(1.0,2.0,3.0)
962
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
963
+ glLoadIdentity()
964
+ glTranslatef(1.0,2.0,3.0)
965
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
966
+ end
967
+
968
+ def test_glscale
969
+ m = [[1,0,0,0],[0,2,0,0],[0,0,3,0],[0,0,0,1]]
970
+ glMatrixMode(GL_MODELVIEW)
971
+ glLoadIdentity()
972
+ glScaled(1.0,2.0,3.0)
973
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
974
+ glLoadIdentity()
975
+ glScalef(1.0,2.0,3.0)
976
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
977
+ end
978
+
979
+ def test_glrotate
980
+ m1 = [[0,0,-1,0],[0,1,0,0],[1,0,0,0],[0,0,0,1]]
981
+ m2 = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
982
+ glMatrixMode(GL_MODELVIEW)
983
+ glLoadIdentity()
984
+ glRotated(90,0,1,0)
985
+ assert(approx_equal(glGetDoublev(GL_MODELVIEW_MATRIX).flatten,m1.flatten))
986
+ glRotated(-90,0,1,0)
987
+ assert(approx_equal(glGetDoublev(GL_MODELVIEW_MATRIX).flatten,m2.flatten))
988
+ end
989
+
990
+ def test_textures_2
991
+ textures = glGenTextures(2)
992
+ glBindTexture(GL_TEXTURE_1D,textures[0])
993
+ glBindTexture(GL_TEXTURE_2D,textures[1])
994
+ assert_equal(glAreTexturesResident(textures).size,2)
995
+ glPrioritizeTextures(textures,[0.5,1.0])
996
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_1D,GL_TEXTURE_PRIORITY),0.5)
997
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY),1.0)
998
+
999
+ tex = ([0,0,0,1,1,1] * 2).pack("f*")
1000
+ tex2 = ([1] * 3 * 4).pack("f*")
1001
+
1002
+ # 1d
1003
+ glDrawPixels(4,1,GL_RGB,GL_FLOAT,tex)
1004
+ glCopyTexImage1D(GL_TEXTURE_1D,0,GL_RGB8,0,0,4,0)
1005
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),tex)
1006
+
1007
+ glDrawPixels(4,1,GL_RGB,GL_FLOAT,tex2)
1008
+ glCopyTexSubImage1D(GL_TEXTURE_1D,0,0,0,0,4)
1009
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),tex2)
1010
+
1011
+ glTexSubImage1D(GL_TEXTURE_1D,0,0,4,GL_RGB,GL_FLOAT,tex)
1012
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),tex)
1013
+
1014
+ # 2d
1015
+ glDrawPixels(2,2,GL_RGB,GL_FLOAT,tex)
1016
+ glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,0,0,2,2,0)
1017
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),tex)
1018
+
1019
+ glDrawPixels(2,2,GL_RGB,GL_FLOAT,tex2)
1020
+ glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,2,2)
1021
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),tex2)
1022
+
1023
+ glTexSubImage2D(GL_TEXTURE_2D,0,0,0,2,2,GL_RGB,GL_FLOAT,tex)
1024
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),tex)
1025
+
1026
+ glDeleteTextures(textures)
1027
+ end
1028
+
1029
+ def test_glmap
1030
+ control_points = [
1031
+ 0.25, 0.5, 0.0,
1032
+ 1.0, 1.0, 0.0
1033
+ ]
1034
+
1035
+ control_points_2 = [
1036
+ 1.25, 1.5, 1.0,
1037
+ 0.0, 0.0, 1.0
1038
+ ]
1039
+
1040
+ glMap1f(GL_MAP1_VERTEX_3,0,100,3,2,control_points)
1041
+ assert_equal(glGetMapfv(GL_MAP1_VERTEX_3,GL_COEFF),control_points)
1042
+
1043
+ glMap1d(GL_MAP1_VERTEX_3,0,100,3,2,control_points_2)
1044
+ assert_equal(glGetMapdv(GL_MAP1_VERTEX_3,GL_COEFF),control_points_2)
1045
+
1046
+ assert_equal(glGetMapiv(GL_MAP1_VERTEX_3,GL_ORDER),2)
1047
+
1048
+ glMap2f(GL_MAP2_VERTEX_3,0,100,3,1,0,100,3,2,control_points)
1049
+ assert_equal(glGetMapfv(GL_MAP2_VERTEX_3,GL_COEFF),control_points)
1050
+
1051
+ glMap2d(GL_MAP2_VERTEX_3,0,100,3,1,0,100,3,2,control_points_2)
1052
+ assert_equal(glGetMapdv(GL_MAP2_VERTEX_3,GL_COEFF),control_points_2)
1053
+ end
1054
+
1055
+ def test_glmapgrid
1056
+ glMapGrid1d(2,1,100)
1057
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_SEGMENTS),2)
1058
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_DOMAIN),[1,100])
1059
+ glMapGrid1f(3,2,99)
1060
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_SEGMENTS),3)
1061
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_DOMAIN),[2,99])
1062
+ #
1063
+ glMapGrid2d(2,1,100,3,2,99)
1064
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_SEGMENTS),[2,3])
1065
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_DOMAIN),[1,100,2,99])
1066
+
1067
+ glMapGrid2f(3,2,99,4,3,98)
1068
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_SEGMENTS),[3,4])
1069
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_DOMAIN),[2,99,3,98])
1070
+ end
1071
+
1072
+ def test_gleval
1073
+ control_points = [0,0,0,1,1,1]
1074
+ glMap1f(GL_MAP1_VERTEX_3,0,1,3,2,control_points)
1075
+ glMap2f(GL_MAP2_VERTEX_3,0,1,3,1,0,1,3,2,control_points)
1076
+ glEnable(GL_MAP1_VERTEX_3)
1077
+ glEnable(GL_MAP2_VERTEX_3)
1078
+
1079
+ buf = glFeedbackBuffer(256,GL_3D)
1080
+ glRenderMode(GL_FEEDBACK)
1081
+
1082
+ glBegin(GL_TRIANGLES)
1083
+ glEvalCoord1d(1.0)
1084
+ glEvalCoord1dv([1.0])
1085
+ glEvalCoord1f(1.0)
1086
+
1087
+ glEvalCoord1fv([1.0])
1088
+ glEvalCoord1fv([1.0])
1089
+ glEvalCoord1fv([1.0])
1090
+
1091
+ glEvalCoord2d(1.0,1.0)
1092
+ glEvalCoord2dv([1.0,1.0])
1093
+ glEvalCoord2f(1.0,1.0)
1094
+
1095
+ glEvalCoord2fv([1.0,1.0])
1096
+ glEvalCoord2fv([1.0,1.0])
1097
+ glEvalCoord2fv([1.0,1.0])
1098
+
1099
+ glEvalPoint1(0.0)
1100
+ glEvalPoint1(0.0)
1101
+ glEvalPoint1(0.0)
1102
+
1103
+ glEvalPoint2(0.0,1.0)
1104
+ glEvalPoint2(0.0,1.0)
1105
+ glEvalPoint2(0.0,1.0)
1106
+
1107
+ glEnd
1108
+
1109
+ count = glRenderMode(GL_RENDER)
1110
+ assert_equal(count,(3*3+2)*6)
1111
+
1112
+ glDisable(GL_MAP2_VERTEX_3)
1113
+ glDisable(GL_MAP1_VERTEX_3)
1114
+ end
1115
+
1116
+ def test_glevalmesh
1117
+ control_points = [0,0,0,1,1,1]
1118
+ glMap1f(GL_MAP1_VERTEX_3,0,1,3,2,control_points)
1119
+ glMap2f(GL_MAP2_VERTEX_3,0,1,3,1,0,1,3,2,control_points)
1120
+ glEnable(GL_MAP1_VERTEX_3)
1121
+ glEnable(GL_MAP2_VERTEX_3)
1122
+
1123
+ buf = glFeedbackBuffer(256,GL_3D)
1124
+ glRenderMode(GL_FEEDBACK)
1125
+
1126
+ glEvalMesh1(GL_POINT,0,1)
1127
+ glEvalMesh2(GL_POINT,0,1,0,1)
1128
+
1129
+ count = glRenderMode(GL_RENDER)
1130
+ assert_equal(count,((3+1)*(2+2*2)))
1131
+
1132
+ glDisable(GL_MAP2_VERTEX_3)
1133
+ glDisable(GL_MAP1_VERTEX_3)
1134
+ end
1135
+
1136
+ def test_glaccum
1137
+ return if glGetIntegerv(GL_ACCUM_RED_BITS) <= 0 # no accumulation buffer ?
1138
+
1139
+ i1 = ([0.0] * 3 + [1.0] * 3 ).pack("f*")
1140
+ i2 = ([1.0] * 3 + [0.0] * 3 ).pack("f*")
1141
+
1142
+ # init
1143
+ glClearColor(0,0,0,0)
1144
+ glClear(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
1145
+ # left
1146
+ glDrawPixels(2,1,GL_RGB,GL_FLOAT,i1)
1147
+ glAccum(GL_ACCUM,1.0)
1148
+ # right
1149
+ glClear(GL_COLOR_BUFFER_BIT)
1150
+ glDrawPixels(2,1,GL_RGB,GL_FLOAT,i2)
1151
+ glAccum(GL_ACCUM,1.0)
1152
+ # combine
1153
+ glAccum(GL_RETURN,1.0)
1154
+
1155
+ data = glReadPixels(0,0,2,1,GL_RGB,GL_FLOAT)
1156
+ assert_equal(data.unpack("f*"),[1.0] * 2 * 3)
1157
+ end
1158
+
1159
+ def test_displaylists
1160
+ base = glGenLists(2)
1161
+ assert(base>0)
1162
+ glListBase(1)
1163
+ assert_equal(glGetIntegerv(GL_LIST_BASE),1)
1164
+ glListBase(0)
1165
+ assert_equal(glGetIntegerv(GL_LIST_BASE),0)
1166
+
1167
+ glNewList(base+0, GL_COMPILE)
1168
+ glBegin(GL_TRIANGLES)
1169
+ glVertex2f(0,0)
1170
+ glVertex2f(1,0)
1171
+ glVertex2f(1,1)
1172
+ glEnd()
1173
+ glEndList()
1174
+
1175
+ glNewList(base+1, GL_COMPILE)
1176
+ glBegin(GL_TRIANGLES)
1177
+ glVertex2f(0,0)
1178
+ glVertex2f(1,0)
1179
+ glVertex2f(1,1)
1180
+ glEnd()
1181
+ glEndList()
1182
+
1183
+ assert_equal(glIsList(base+0),true)
1184
+ assert_equal(glIsList(base+1),true)
1185
+ assert_equal(glIsList(base+2),false)
1186
+
1187
+ #
1188
+ buf = glFeedbackBuffer(256,GL_3D)
1189
+ glRenderMode(GL_FEEDBACK)
1190
+
1191
+ glCallList(base+0)
1192
+ glCallLists(GL_INT,[base+0,base+1])
1193
+
1194
+ count = glRenderMode(GL_RENDER)
1195
+ assert_equal(count,(3*3+2) * 3) # 3 triangles
1196
+ #
1197
+
1198
+ glDeleteLists(base,2)
1199
+
1200
+ assert_equal(glIsList(base+0),false)
1201
+ assert_equal(glIsList(base+1),false)
1202
+ end
1203
+
1204
+ def test_arrays
1205
+ glEnableClientState(GL_VERTEX_ARRAY)
1206
+
1207
+ va = [0,0, 0,1, 1,1].pack("f*")
1208
+ glVertexPointer(2,GL_FLOAT,0,va)
1209
+ assert_equal(glGetPointerv(GL_VERTEX_ARRAY_POINTER),va)
1210
+ assert_equal(glGetIntegerv(GL_VERTEX_ARRAY_SIZE),2)
1211
+ assert_equal(glGetIntegerv(GL_VERTEX_ARRAY_TYPE),GL_FLOAT)
1212
+ assert_equal(glGetIntegerv(GL_VERTEX_ARRAY_STRIDE),0)
1213
+ #
1214
+ buf = glFeedbackBuffer(256,GL_3D)
1215
+ glRenderMode(GL_FEEDBACK)
1216
+
1217
+ glDrawArrays(GL_TRIANGLES,0,3)
1218
+
1219
+ glBegin(GL_TRIANGLES)
1220
+ glArrayElement(0)
1221
+ glArrayElement(1)
1222
+ glArrayElement(2)
1223
+ glEnd()
1224
+
1225
+ glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_BYTE,[0,1,2].pack("C*"))
1226
+
1227
+ glInterleavedArrays(GL_V2F,0, va)
1228
+
1229
+ glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_BYTE,[0,1,2].pack("C*"))
1230
+
1231
+ #
1232
+ count = glRenderMode(GL_RENDER)
1233
+ assert_equal(count,44)
1234
+
1235
+ glDisableClientState(GL_VERTEX_ARRAY)
1236
+ end
1237
+
1238
+ def test_arrays_2
1239
+ na = [0,1,0].pack("f*")
1240
+ ta = [1,0,1,0].pack("f*")
1241
+ ea = [0].pack("C*")
1242
+ ca = [1,0,1,0].pack("f*")
1243
+
1244
+ glNormalPointer(GL_FLOAT,0,na)
1245
+ assert_equal(glGetIntegerv(GL_NORMAL_ARRAY_TYPE),GL_FLOAT)
1246
+ assert_equal(glGetIntegerv(GL_NORMAL_ARRAY_STRIDE),0)
1247
+ assert_equal(glGetPointerv(GL_NORMAL_ARRAY_POINTER),na)
1248
+ glTexCoordPointer(4,GL_FLOAT,0,ta)
1249
+ assert_equal(glGetIntegerv(GL_TEXTURE_COORD_ARRAY_SIZE),4)
1250
+ assert_equal(glGetIntegerv(GL_TEXTURE_COORD_ARRAY_TYPE),GL_FLOAT)
1251
+ assert_equal(glGetIntegerv(GL_TEXTURE_COORD_ARRAY_STRIDE),0)
1252
+ assert_equal(glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER),ta)
1253
+ glEdgeFlagPointer(0,ea)
1254
+ assert_equal(glGetIntegerv(GL_EDGE_FLAG_ARRAY_STRIDE),0)
1255
+ assert_equal(glGetPointerv(GL_EDGE_FLAG_ARRAY_POINTER),ea)
1256
+ glColorPointer(4,GL_FLOAT,0,ca)
1257
+ assert_equal(glGetIntegerv(GL_COLOR_ARRAY_SIZE),4)
1258
+ assert_equal(glGetIntegerv(GL_COLOR_ARRAY_TYPE),GL_FLOAT)
1259
+ assert_equal(glGetIntegerv(GL_COLOR_ARRAY_STRIDE),0)
1260
+ assert_equal(glGetPointerv(GL_COLOR_ARRAY_POINTER),ca)
1261
+ #
1262
+ glEnable(GL_COLOR_ARRAY)
1263
+ glEnable(GL_NORMAL_ARRAY)
1264
+ glEnable(GL_TEXTURE_COORD_ARRAY)
1265
+ glEnable(GL_EDGE_FLAG_ARRAY)
1266
+
1267
+ glBegin(GL_TRIANGLES)
1268
+ glArrayElement(0)
1269
+ glEnd()
1270
+
1271
+ assert_equal(glGetDoublev(GL_CURRENT_COLOR),[1,0,1,0])
1272
+ assert_equal(glGetDoublev(GL_CURRENT_NORMAL),[0,1,0])
1273
+ assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,0,1,0])
1274
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),false)
1275
+
1276
+ glDisable(GL_EDGE_FLAG_ARRAY)
1277
+ glDisable(GL_TEXTURE_COORD_ARRAY)
1278
+ glDisable(GL_NORMAL_ARRAY)
1279
+ glDisable(GL_COLOR_ARRAY)
1280
+ end
1281
+ end