ruby-opengl 0.33.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/Rakefile +42 -15
  2. data/doc/build_install.txt +70 -25
  3. data/doc/history.txt +4 -0
  4. data/doc/requirements_and_design.txt +2 -3
  5. data/doc/roadmap.txt +15 -2
  6. data/doc/screenshots.txt +23 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +3 -0
  9. data/doc/tutorial.txt +5 -3
  10. data/examples/README +57 -7
  11. data/examples/legacy/COPYRIGHT +8 -0
  12. data/examples/{aaindex.rb → legacy/aaindex.rb} +6 -5
  13. data/examples/legacy/aapoly.rb +153 -0
  14. data/examples/legacy/aargb.rb +139 -0
  15. data/examples/legacy/accanti.rb +159 -0
  16. data/examples/legacy/accpersp.rb +216 -0
  17. data/examples/legacy/alpha.rb +133 -0
  18. data/examples/legacy/alpha3D.rb +165 -0
  19. data/examples/legacy/bezcurve.rb +107 -0
  20. data/examples/legacy/bezmesh.rb +131 -0
  21. data/examples/legacy/checker.rb +121 -0
  22. data/examples/legacy/clip.rb +104 -0
  23. data/examples/legacy/colormat.rb +145 -0
  24. data/examples/legacy/cube.rb +73 -0
  25. data/examples/legacy/depthcue.rb +101 -0
  26. data/examples/legacy/dof.rb +212 -0
  27. data/examples/legacy/double.rb +104 -0
  28. data/examples/legacy/drawf.rb +98 -0
  29. data/examples/legacy/feedback.rb +152 -0
  30. data/examples/legacy/fog.rb +172 -0
  31. data/examples/legacy/font-glut.rb +41 -0
  32. data/examples/legacy/font.rb +158 -0
  33. data/examples/legacy/hello.rb +75 -0
  34. data/examples/legacy/image.rb +145 -0
  35. data/examples/legacy/jitter.rb +209 -0
  36. data/examples/legacy/lines.rb +135 -0
  37. data/examples/legacy/list.rb +120 -0
  38. data/examples/legacy/material.rb +290 -0
  39. data/examples/legacy/mipmap.rb +159 -0
  40. data/examples/legacy/model.rb +119 -0
  41. data/examples/legacy/movelight.rb +140 -0
  42. data/examples/legacy/pickdepth.rb +180 -0
  43. data/examples/legacy/planet.rb +112 -0
  44. data/examples/legacy/quadric.rb +180 -0
  45. data/examples/legacy/readpixel.rb +59 -0
  46. data/examples/legacy/robot.rb +120 -0
  47. data/examples/legacy/select.rb +207 -0
  48. data/examples/{smooth_prev.rb → legacy/smooth.rb} +3 -2
  49. data/examples/legacy/stencil.rb +154 -0
  50. data/examples/legacy/stroke.rb +170 -0
  51. data/examples/legacy/surface.rb +170 -0
  52. data/examples/legacy/teaambient.rb +132 -0
  53. data/examples/legacy/teapots.rb +188 -0
  54. data/examples/legacy/tess.rb +222 -0
  55. data/examples/legacy/texbind.rb +157 -0
  56. data/examples/legacy/texgen.rb +171 -0
  57. data/examples/legacy/texturesurf.rb +128 -0
  58. data/examples/legacy/varray.rb +167 -0
  59. data/examples/legacy/wrap.rb +158 -0
  60. data/examples/nehe_lesson02.rb +117 -0
  61. data/examples/nehe_lesson03.rb +122 -0
  62. data/examples/nehe_lesson04.rb +133 -0
  63. data/examples/nehe_lesson05.rb +186 -0
  64. data/examples/plane.rb +1 -1
  65. data/examples/smooth.rb +4 -2
  66. data/examples/test.rb +3 -2
  67. data/ext/common/{rbogl.c → common.h} +99 -32
  68. data/ext/common/gl-enums.h +39 -1
  69. data/ext/gl/gl-1.0-1.1.c +350 -305
  70. data/ext/gl/gl-1.2.c +933 -38
  71. data/ext/gl/gl-1.3.c +725 -0
  72. data/ext/gl/gl-1.4.c +647 -0
  73. data/ext/gl/gl-1.5.c +362 -0
  74. data/ext/gl/gl-2.0.c +1632 -0
  75. data/ext/gl/gl-2.1.c +154 -0
  76. data/ext/gl/gl-enums.c +1 -2
  77. data/ext/gl/gl.c +58 -2
  78. data/ext/gl/mkrf_conf.rb +4 -1
  79. data/ext/glu/glu.c +5 -4
  80. data/ext/glu/mkrf_conf.rb +4 -1
  81. data/ext/glut/glut.c +7 -1
  82. data/ext/glut/mkrf_conf.rb +5 -0
  83. data/lib/gl_prev.rb +4 -3
  84. data/lib/glu_prev.rb +4 -3
  85. data/lib/glut_prev.rb +3 -3
  86. data/{examples/all_tests.rb → lib/opengl.rb} +9 -12
  87. data/test/README +5 -18
  88. data/test/tc_common.rb +79 -0
  89. data/test/tc_func_10_11.rb +1255 -0
  90. data/test/tc_func_12.rb +186 -0
  91. data/test/tc_func_13.rb +203 -0
  92. data/test/tc_func_14.rb +197 -0
  93. data/test/tc_func_15.rb +82 -0
  94. data/test/tc_func_20.rb +320 -0
  95. data/test/tc_func_21.rb +67 -0
  96. data/test/tc_include_gl.rb +1 -1
  97. data/test/{tc_opengl_namespace.rb → tc_misc.rb} +20 -20
  98. data/test/tc_require_gl.rb +1 -1
  99. metadata +99 -27
  100. data/ext/common/Rakefile +0 -39
  101. data/ext/common/rbogl.h +0 -52
  102. data/test/runtests.sh +0 -7
  103. data/test/tc_gl_vertex.rb +0 -180
@@ -0,0 +1,82 @@
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_15 < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_query
28
+ return if not supported?(["glGenQueries","glDeleteQueries","glIsQuery","glBeginQuery","glGetQueryiv","glGetQueryObjectiv","glGetQueryObjectuiv"])
29
+ queries = glGenQueries(2)
30
+ assert_equal(queries.size,2)
31
+
32
+ glBeginQuery(GL_SAMPLES_PASSED,queries[1])
33
+ assert_equal(glIsQuery(queries[1]),GL_TRUE)
34
+
35
+ glBegin(GL_TRIANGLES)
36
+ glVertex2i(0,0)
37
+ glVertex2i(1,0)
38
+ glVertex2i(1,1)
39
+ glEnd()
40
+
41
+ assert_equal(glGetQueryiv(GL_SAMPLES_PASSED,GL_CURRENT_QUERY),[queries[1]])
42
+
43
+ glEndQuery(GL_SAMPLES_PASSED)
44
+
45
+ r = glGetQueryObjectiv(queries[1],GL_QUERY_RESULT_AVAILABLE)
46
+ assert((r==[GL_TRUE] || r==[GL_FALSE]))
47
+
48
+ if (r==[GL_TRUE])
49
+ assert(glGetQueryObjectiv(queries[1],GL_QUERY_RESULT)[0] > 0)
50
+ assert(glGetQueryObjectuiv(queries[1],GL_QUERY_RESULT)[0] > 0)
51
+ end
52
+
53
+ glDeleteQueries(queries)
54
+ assert_equal(glIsQuery(queries[1]),GL_FALSE)
55
+ end
56
+
57
+ def test_buffers
58
+ return if not supported?(["glGenBuffers","glDeleteBuffers","glIsBuffer","glBindBuffer","glBufferData","glBufferSubData","glGetBufferSubData","glMapBuffer","glUnmapBuffer","glGetBufferParameteriv","glGetBufferPointerv"])
59
+ buffers = glGenBuffers(2)
60
+ glBindBuffer(GL_ARRAY_BUFFER,buffers[0])
61
+ assert_equal(glIsBuffer(buffers[0]),GL_TRUE)
62
+
63
+ data = [0,1,2,3].pack("C*")
64
+ data2 = [4,5,6,7].pack("C*")
65
+
66
+ glBufferData(GL_ARRAY_BUFFER,4,data,GL_STREAM_READ)
67
+ assert_equal(glGetBufferSubData(GL_ARRAY_BUFFER,0,4),data)
68
+
69
+ assert_equal(glGetBufferParameteriv(GL_ARRAY_BUFFER,GL_BUFFER_USAGE),[GL_STREAM_READ])
70
+
71
+ glBufferSubData(GL_ARRAY_BUFFER,0,4,data2)
72
+ assert_equal(glGetBufferSubData(GL_ARRAY_BUFFER,0,4),data2)
73
+
74
+ assert_equal(glMapBuffer(GL_ARRAY_BUFFER,GL_READ_ONLY),data2)
75
+ r = glUnmapBuffer(GL_ARRAY_BUFFER)
76
+ assert(r == GL_TRUE || r == GL_FALSE)
77
+ glDeleteBuffers(buffers)
78
+ assert_equal(glIsBuffer(buffers[0]),GL_FALSE)
79
+
80
+ # FIXME: GetBufferPointerv not yet implemented
81
+ end
82
+ end
@@ -0,0 +1,320 @@
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_20 < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_glblendequationseparate
28
+ return if not supported?("glBlendEquationSeparate")
29
+ glBlendEquationSeparate(GL_MIN,GL_MAX)
30
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB),GL_MIN)
31
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA),GL_MAX)
32
+ glBlendEquationSeparate(GL_MAX,GL_MIN)
33
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB),GL_MAX)
34
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA),GL_MIN)
35
+ end
36
+
37
+ def test_stencilops
38
+ return if not supported?(["glStencilOpSeparate","glStencilFuncSeparate","glStencilMaskSeparate"])
39
+
40
+ glStencilOpSeparate(GL_FRONT, GL_ZERO, GL_INCR, GL_DECR)
41
+ assert_equal(glGetIntegerv(GL_STENCIL_FAIL), GL_ZERO)
42
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL), GL_INCR)
43
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS), GL_DECR)
44
+ glStencilOpSeparate(GL_FRONT, GL_INCR, GL_DECR, GL_ZERO)
45
+ assert_equal(glGetIntegerv(GL_STENCIL_FAIL), GL_INCR)
46
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL), GL_DECR)
47
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS), GL_ZERO)
48
+
49
+ glStencilFuncSeparate(GL_FRONT, GL_LEQUAL, 1, 0)
50
+ assert_equal(glGetIntegerv(GL_STENCIL_FUNC),GL_LEQUAL)
51
+ assert_equal(glGetIntegerv(GL_STENCIL_REF),1)
52
+ assert_equal(glGetIntegerv(GL_STENCIL_VALUE_MASK),0)
53
+ glStencilFuncSeparate(GL_FRONT, GL_GEQUAL, 0, 1)
54
+ assert_equal(glGetIntegerv(GL_STENCIL_FUNC),GL_GEQUAL)
55
+ assert_equal(glGetIntegerv(GL_STENCIL_REF),0)
56
+ assert_equal(glGetIntegerv(GL_STENCIL_VALUE_MASK),1)
57
+
58
+ glStencilMaskSeparate(GL_FRONT,1)
59
+ assert_equal(glGetIntegerv( GL_STENCIL_WRITEMASK),1)
60
+ glStencilMaskSeparate(GL_FRONT,0)
61
+ assert_equal(glGetIntegerv(GL_STENCIL_WRITEMASK),0)
62
+ end
63
+
64
+ def test_gldrawbuf
65
+ return if not supported?("glDrawBuffers")
66
+ glDrawBuffers([GL_NONE])
67
+ assert_equal(glGetIntegerv(GL_DRAW_BUFFER0),GL_NONE)
68
+ end
69
+
70
+ def test_glvertexattrib
71
+ return if not supported?(["glVertexAttrib1f","glGetVertexAttribdv"])
72
+ # 1
73
+ glVertexAttrib1d(1,2.0)
74
+ assert_equal(glGetVertexAttribdv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,0.0,0.0,1.0])
75
+ glVertexAttrib1dv(1,[3.0])
76
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,0.0,0.0,1.0])
77
+ glVertexAttrib1f(1,2.0)
78
+ assert_equal(glGetVertexAttribiv(1,GL_CURRENT_VERTEX_ATTRIB), [2,0,0,1])
79
+ glVertexAttrib1fv(1,[3.0])
80
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,0.0,0.0,1.0])
81
+ glVertexAttrib1s(1,2)
82
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,0.0,0.0,1.0])
83
+ glVertexAttrib1sv(1,[3])
84
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,0.0,0.0,1.0])
85
+ # 2
86
+ glVertexAttrib2d(1,2.0,2.0)
87
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,0.0,1.0])
88
+ glVertexAttrib2dv(1,[3.0,3.0])
89
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,0.0,1.0])
90
+ glVertexAttrib2f(1,2.0,2.0)
91
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,0.0,1.0])
92
+ glVertexAttrib2fv(1,[3.0,3.0])
93
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,0.0,1.0])
94
+ glVertexAttrib2s(1,2,2)
95
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,0.0,1.0])
96
+ glVertexAttrib2sv(1,[3,3])
97
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,0.0,1.0])
98
+ # 3
99
+ glVertexAttrib3d(1,2.0,2.0,2.0)
100
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,2.0,1.0])
101
+ glVertexAttrib3dv(1,[3.0,3.0,3.0])
102
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,3.0,1.0])
103
+ glVertexAttrib3f(1,2.0,2.0,2.0)
104
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,2.0,1.0])
105
+ glVertexAttrib3fv(1,[3.0,3.0,3.0])
106
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,3.0,1.0])
107
+ glVertexAttrib3s(1,2,2,2)
108
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,2.0,1.0])
109
+ glVertexAttrib3sv(1,[3,3,3])
110
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,3.0,1.0])
111
+ # 4N
112
+ glVertexAttrib4Nbv(1,[2**7-1,2**7-1,2**7-1,2**7-1])
113
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
114
+ glVertexAttrib4Niv(1,[0,0,0,0])
115
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
116
+ glVertexAttrib4Nsv(1,[2**15-1,2**15-1,2**15-1,2**15-1])
117
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
118
+ glVertexAttrib4Nub(1,0,0,0,0)
119
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
120
+ glVertexAttrib4Nubv(1,[2**8-1,2**8-1,2**8-1,2**8-1])
121
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
122
+ glVertexAttrib4Nuiv(1,[0,0,0,0])
123
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
124
+ glVertexAttrib4Nusv(1,[2**16-1,2**16-1,2**16-1,2**16-1])
125
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
126
+ # 4
127
+ glVertexAttrib4bv(1,[0,0,0,0])
128
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
129
+ glVertexAttrib4d(1,1,1,1,1)
130
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
131
+ glVertexAttrib4dv(1,[0,0,0,0])
132
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
133
+ glVertexAttrib4f(1,1,1,1,1)
134
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
135
+ glVertexAttrib4fv(1,[0,0,0,0])
136
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
137
+ glVertexAttrib4iv(1,[1,1,1,1])
138
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
139
+ glVertexAttrib4s(1,0,0,0,0)
140
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
141
+ glVertexAttrib4sv(1,[1,1,1,1])
142
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
143
+ glVertexAttrib4ubv(1,[0,0,0,0])
144
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
145
+ glVertexAttrib4uiv(1,[1,1,1,1])
146
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
147
+ glVertexAttrib4usv(1,[0,0,0,0])
148
+ assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
149
+ end
150
+
151
+ def test_vertexattribpointer
152
+ return if not supported?(["glVertexAttribPointer","glGetVertexAttribPointerv","glEnableVertexAttribArray","glDisableVertexAttribArray"])
153
+
154
+ vaa = [1,1,1,1, 2,2,2,2].pack("f*")
155
+ glVertexAttribPointer(1,4,GL_FLOAT,GL_FALSE,0,vaa)
156
+ assert_equal(glGetVertexAttribPointerv(1),vaa)
157
+
158
+ glEnableVertexAttribArray(1)
159
+
160
+ glBegin(GL_POINTS)
161
+ glArrayElement(1)
162
+ glEnd()
163
+ assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB),[2,2,2,2])
164
+
165
+ glDisableVertexAttribArray(1)
166
+ end
167
+
168
+ def test_shaders
169
+ return if not supported?(["glCreateProgram","glIsProgram","glDeleteProgram","glCreateShader","glIsShader","glDeleteShader","glShaderSource","glGetShaderSource","glGetShaderiv","glGetProgramiv","glGetShaderInfoLog","glGetProgramInfoLog","glAttachShader","glDetachShader","glGetAttachedShaders","glValidateProgram","glUseProgram","glLinkProgram"])
170
+
171
+ vertex_shader_source = "void main() { gl_Position = ftransform();}"
172
+
173
+ program = glCreateProgram()
174
+ assert_equal(glIsProgram(program),GL_TRUE)
175
+
176
+ vs = glCreateShader(GL_VERTEX_SHADER)
177
+ assert_equal(glIsShader(vs),GL_TRUE)
178
+
179
+ glShaderSource(vs,vertex_shader_source)
180
+ assert_equal(glGetShaderSource(vs),vertex_shader_source)
181
+
182
+ assert_equal(glGetShaderiv(vs, GL_SHADER_TYPE),GL_VERTEX_SHADER)
183
+ glCompileShader(vs)
184
+ assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
185
+
186
+ vslog = glGetShaderInfoLog(vs)
187
+ assert_equal(vslog.class,String)
188
+
189
+ glAttachShader(program,vs)
190
+ assert_equal(glGetAttachedShaders(program),[vs])
191
+ glDetachShader(program,vs)
192
+ assert_equal(glGetAttachedShaders(program),nil)
193
+ glAttachShader(program,vs)
194
+
195
+ glValidateProgram(program)
196
+ assert_equal(glGetProgramiv(program,GL_VALIDATE_STATUS),GL_TRUE)
197
+ prlog = glGetProgramInfoLog(program)
198
+ assert_equal(prlog.class,String)
199
+
200
+ glLinkProgram(program)
201
+ assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
202
+
203
+ glUseProgram(program)
204
+ assert_equal(glGetIntegerv(GL_CURRENT_PROGRAM),program)
205
+
206
+ glUseProgram(0)
207
+
208
+ glDetachShader(program,vs)
209
+ glDeleteShader(vs)
210
+ assert_equal(glIsShader(vs),GL_FALSE)
211
+
212
+ glDeleteProgram(program)
213
+ assert_equal(glIsProgram(program),GL_FALSE)
214
+ end
215
+
216
+ def test_shaders_2
217
+ return if not supported?(["glCreateProgram","glBindAttribLocation","glGetAttribLocation"])
218
+
219
+ vertex_shader_source = "attribute vec4 test; uniform float testvec1; uniform vec2 testvec2; uniform vec3 testvec3; uniform vec4 testvec4; uniform int testivec1; uniform ivec2 testivec2; uniform ivec3 testivec3; uniform ivec4 testivec4; void main() { gl_Position = testvec1 * test * testvec2.x * testvec3.x * testivec1 * testivec2.x * testivec3.x * testivec4.x + testvec4;}"
220
+ program = glCreateProgram()
221
+ vs = glCreateShader(GL_VERTEX_SHADER)
222
+
223
+ glShaderSource(vs,vertex_shader_source)
224
+ glCompileShader(vs)
225
+
226
+ assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
227
+ glAttachShader(program,vs)
228
+
229
+ glBindAttribLocation(program,2,"test")
230
+ glLinkProgram(program)
231
+ assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
232
+ glUseProgram(program)
233
+
234
+ assert_equal(glGetAttribLocation(program,"test"),2)
235
+ assert((tv1l = glGetUniformLocation(program,"testvec1"))>=0)
236
+ assert((tv2l = glGetUniformLocation(program,"testvec2"))>=0)
237
+ assert((tv3l = glGetUniformLocation(program,"testvec3"))>=0)
238
+ assert((tv4l = glGetUniformLocation(program,"testvec4"))>=0)
239
+ assert((tv1il = glGetUniformLocation(program,"testivec1"))>=0)
240
+ assert((tv2il = glGetUniformLocation(program,"testivec2"))>=0)
241
+ assert((tv3il = glGetUniformLocation(program,"testivec3"))>=0)
242
+ assert((tv4il = glGetUniformLocation(program,"testivec4"))>=0)
243
+
244
+ ##
245
+ assert_equal(glGetActiveAttrib(program,0),[1,GL_FLOAT_VEC4,"test"])
246
+ assert_equal(glGetActiveUniform(program,tv1il),[1,GL_INT,"testivec1"])
247
+
248
+ # f
249
+ glUniform1f(tv1l,2.0)
250
+ assert_equal(glGetUniformfv(program,tv1l),[2.0])
251
+ glUniform2f(tv2l,2.0,2.0)
252
+ assert_equal(glGetUniformfv(program,tv2l),[2.0,2.0])
253
+ glUniform3f(tv3l,2.0,2.0,2.0)
254
+ assert_equal(glGetUniformfv(program,tv3l),[2.0,2.0,2.0])
255
+ glUniform4f(tv4l,2.0,2.0,2.0,2.0)
256
+ assert_equal(glGetUniformfv(program,tv4l),[2.0,2.0,2.0,2.0])
257
+ # i
258
+ glUniform1i(tv1il,3)
259
+ assert_equal(glGetUniformiv(program,tv1il),[3])
260
+ glUniform2i(tv2il,3,3)
261
+ assert_equal(glGetUniformiv(program,tv2il),[3,3])
262
+ glUniform3i(tv3il,3,3,3)
263
+ assert_equal(glGetUniformiv(program,tv3il),[3,3,3])
264
+ glUniform4i(tv4il,3,3,3,3)
265
+ assert_equal(glGetUniformiv(program,tv4il),[3,3,3,3])
266
+ # fv
267
+ glUniform1fv(tv1l,1,[3.0])
268
+ assert_equal(glGetUniformfv(program,tv1l),[3.0])
269
+ glUniform2fv(tv2l,1,[3.0,3.0])
270
+ assert_equal(glGetUniformfv(program,tv2l),[3.0,3.0])
271
+ glUniform3fv(tv3l,1,[3.0,3.0,3.0])
272
+ assert_equal(glGetUniformfv(program,tv3l),[3.0,3.0,3.0])
273
+ glUniform4fv(tv4l,1,[3.0,3.0,3.0,3.0])
274
+ assert_equal(glGetUniformfv(program,tv4l),[3.0,3.0,3.0,3.0])
275
+ # iv
276
+ glUniform1iv(tv1il,1,[2])
277
+ assert_equal(glGetUniformiv(program,tv1il),[2])
278
+ glUniform2iv(tv2il,1,[2,2])
279
+ assert_equal(glGetUniformiv(program,tv2il),[2,2])
280
+ glUniform3iv(tv3il,1,[2,2,2])
281
+ assert_equal(glGetUniformiv(program,tv3il),[2,2,2])
282
+ glUniform4iv(tv4il,1,[2,2,2,2])
283
+ assert_equal(glGetUniformiv(program,tv4il),[2,2,2,2])
284
+
285
+ glDeleteShader(vs)
286
+ glDeleteProgram(program)
287
+ end
288
+
289
+ def test_shaders_3
290
+ return if not supported?(["glCreateProgram","glUniformMatrix2fv"])
291
+
292
+ vertex_shader_source = "uniform mat2 testmat2; uniform mat3 testmat3; uniform mat4 testmat4; void main() { gl_Position = gl_Vertex * testmat4[0].x * testmat3[0].x * testmat2[0].x;}"
293
+
294
+ program = glCreateProgram()
295
+ vs = glCreateShader(GL_VERTEX_SHADER)
296
+
297
+ glShaderSource(vs,vertex_shader_source)
298
+ glCompileShader(vs)
299
+
300
+ assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
301
+ glAttachShader(program,vs)
302
+
303
+ glLinkProgram(program)
304
+ assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
305
+ glUseProgram(program)
306
+ #
307
+ assert((tm2l = glGetUniformLocation(program,"testmat2"))>=0)
308
+ assert((tm3l = glGetUniformLocation(program,"testmat3"))>=0)
309
+ assert((tm4l = glGetUniformLocation(program,"testmat4"))>=0)
310
+
311
+ glUniformMatrix2fv(tm2l, 1, GL_TRUE, [0,1, 1,0])
312
+ assert_equal(glGetUniformfv(program,tm2l),[0,1,1,0])
313
+
314
+ glUniformMatrix3fv(tm3l, 1, GL_TRUE, [0,1,0, 1,0,1, 0,1,0])
315
+ assert_equal(glGetUniformfv(program,tm3l),[0,1,0, 1,0,1, 0,1,0])
316
+
317
+ glUniformMatrix4fv(tm4l, 1, GL_TRUE, [0,1,0,1, 1,0,1,0, 0,1,0,1, 1,0,1,0])
318
+ assert_equal(glGetUniformfv(program,tm4l),[0,1,0,1, 1,0,1,0, 0,1,0,1, 1,0,1,0])
319
+ end
320
+ end
@@ -0,0 +1,67 @@
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_21 < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_gluniformmatrix21
28
+ return if not supported?(["glCreateProgram","glUniformMatrix2x3fv"])
29
+
30
+ vertex_shader_source = "#version 120\n uniform mat2x3 testmat23; uniform mat3x2 testmat32; uniform mat2x4 testmat24; uniform mat4x2 testmat42; uniform mat3x4 testmat34; uniform mat4x3 testmat43; void main() { gl_Position = gl_Vertex * testmat23[0].x * testmat32[0].x * testmat24[0].x * testmat42[0].x * testmat34[0].x * testmat43[0].x;}"
31
+
32
+ program = glCreateProgram()
33
+ vs = glCreateShader(GL_VERTEX_SHADER)
34
+
35
+ glShaderSource(vs,vertex_shader_source)
36
+ glCompileShader(vs)
37
+
38
+ assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
39
+ glAttachShader(program,vs)
40
+
41
+ glLinkProgram(program)
42
+ assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
43
+ glUseProgram(program)
44
+
45
+ assert((tm23l = glGetUniformLocation(program,"testmat23"))>=0)
46
+ assert((tm32l = glGetUniformLocation(program,"testmat32"))>=0)
47
+ assert((tm24l = glGetUniformLocation(program,"testmat24"))>=0)
48
+ assert((tm42l = glGetUniformLocation(program,"testmat42"))>=0)
49
+ assert((tm34l = glGetUniformLocation(program,"testmat34"))>=0)
50
+ assert((tm43l = glGetUniformLocation(program,"testmat43"))>=0)
51
+
52
+ glUniformMatrix2x3fv(tm23l, 1, GL_FALSE, [0,1, 1,0, 0,1])
53
+ assert_equal(glGetUniformfv(program,tm23l),[0,1, 1,0, 0,1])
54
+ glUniformMatrix3x2fv(tm32l, 1, GL_FALSE, [1,0, 0,1, 1,0])
55
+ assert_equal(glGetUniformfv(program,tm32l),[1,0, 0,1, 1,0])
56
+
57
+ glUniformMatrix2x4fv(tm24l, 1, GL_FALSE, [0,1, 1,0, 0,1, 1,0])
58
+ assert_equal(glGetUniformfv(program,tm24l),[0,1, 1,0, 0,1, 1,0])
59
+ glUniformMatrix4x2fv(tm42l, 1, GL_FALSE, [1,0, 0,1, 1,0, 0,1])
60
+ assert_equal(glGetUniformfv(program,tm42l),[1,0, 0,1, 1,0, 0,1])
61
+
62
+ glUniformMatrix3x4fv(tm34l, 1, GL_FALSE, [0,1,1, 1,0,1, 0,1,1, 1,0,1])
63
+ assert_equal(glGetUniformfv(program,tm34l),[0,1,1, 1,0,1, 0,1,1, 1,0,1])
64
+ glUniformMatrix4x3fv(tm43l, 1, GL_FALSE, [1,0,0, 0,1,0, 1,0,0, 0,1,0])
65
+ assert_equal(glGetUniformfv(program,tm43l),[1,0,0, 0,1,0, 1,0,0, 0,1,0])
66
+ end
67
+ end