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
@@ -16,7 +16,7 @@
16
16
  if __FILE__ == $0
17
17
  # If we are being called from the command line, e.g., ruby foo.rb, then
18
18
  # fixup the load path so we can find the OpenGL extension libs
19
- $: << File.join(File.dirname(__FILE__), '..', 'ext')
19
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
20
20
  end
21
21
 
22
22
  require 'test/unit'
@@ -1,5 +1,5 @@
1
- #--
2
- # Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
1
+ #
2
+ # Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
3
  #
4
4
  # This program is distributed under the terms of the MIT license.
5
5
  # See the included MIT-LICENSE file for the terms of this license.
@@ -11,30 +11,30 @@
11
11
  # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
12
  # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
13
  # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
- #++
14
+ #
15
15
 
16
16
  if __FILE__ == $0
17
17
  # If we are being called from the command line, e.g., ruby foo.rb, then
18
18
  # fixup the load path so we can find the OpenGL extension libs
19
- $: << File.join(File.dirname(__FILE__), '..', 'ext')
19
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
20
20
  end
21
21
 
22
22
  require 'test/unit'
23
- require 'opengl'
24
-
25
- # Test that a require of the opengl convenience lib requires and includes
26
- # the proper OpenGL, GLU and GLUT namespaces.
27
- class OpenglTest < Test::Unit::TestCase
23
+ require 'gl'
24
+ require 'glut'
25
+ include Gl
26
+ include Glut
28
27
 
29
- def test_gl_constant
30
- assert Gl::VERSION
31
- end
28
+ class Test_misc < Test::Unit::TestCase
29
+ def setup
30
+ return if $glut_initialized
31
+ glut_init()
32
+ $glut_initialized = true
33
+ end
32
34
 
33
- def test_glut_constant
34
- assert Glut::GLUT_API_VERSION
35
- end
36
-
37
- def test_glu_constant
38
- fail "GLU not implemented yet"
39
- end
40
- end
35
+ def test_isavailable
36
+ assert_equal(is_available?("glTexImage3D"),true)
37
+ assert_equal(is_available?("GL_ARB_multitexture"),true)
38
+ assert_equal(is_available?("GL_NON_EXISTENT"),false)
39
+ end
40
+ end
@@ -16,7 +16,7 @@
16
16
  if __FILE__ == $0
17
17
  # If we are being called from the command line, e.g., ruby foo.rb, then
18
18
  # fixup the load path so we can find the OpenGL extension libs
19
- $: << File.join(File.dirname(__FILE__), '..', 'ext')
19
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
20
20
  end
21
21
 
22
22
  require 'test/unit'
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.1
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruby-opengl
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.33.0
7
- date: 2007-02-21 00:00:00 +09:00
6
+ version: 0.40.0
7
+ date: 2007-07-18 00:00:00 +09:00
8
8
  summary: OpenGL Interface for Ruby
9
9
  require_paths:
10
10
  - lib
@@ -27,51 +27,114 @@ signing_key:
27
27
  cert_chain:
28
28
  post_install_message:
29
29
  authors:
30
- - John Gabriele
30
+ - Alain Hoang
31
+ - Jan Dvorak
31
32
  - Minh Thu Vo
32
33
  files:
34
+ - lib/glut_prev.rb
33
35
  - lib/gl_prev.rb
34
36
  - lib/glu_prev.rb
35
- - lib/glut_prev.rb
36
- - ext/common
37
+ - lib/opengl.rb
37
38
  - ext/gl
38
39
  - ext/glu
39
40
  - ext/glut
40
- - ext/common/gl-enums.h
41
- - ext/common/Rakefile
42
- - ext/common/rbogl.c
43
- - ext/common/rbogl.h
41
+ - ext/common
42
+ - ext/gl/gl.c
44
43
  - ext/gl/mkrf_conf.rb
44
+ - ext/gl/gl-2.0.c
45
45
  - ext/gl/gl-1.2.c
46
- - ext/gl/gl.c
46
+ - ext/gl/gl-2.1.c
47
+ - ext/gl/gl-1.3.c
48
+ - ext/gl/gl-1.4.c
49
+ - ext/gl/gl-1.5.c
47
50
  - ext/gl/gl-enums.c
48
51
  - ext/gl/gl-1.0-1.1.c
49
- - ext/glu/mkrf_conf.rb
50
52
  - ext/glu/glu.c
51
- - ext/glut/mkrf_conf.rb
53
+ - ext/glu/mkrf_conf.rb
52
54
  - ext/glut/glut.c
55
+ - ext/glut/mkrf_conf.rb
56
+ - ext/common/gl-enums.h
57
+ - ext/common/common.h
53
58
  - doc/supplies
54
- - doc/requirements_and_design.txt
55
- - doc/build_install.txt
56
- - doc/history.txt
57
- - doc/scientific_use.txt
58
- - doc/roadmap.txt
59
59
  - doc/thanks.txt
60
+ - doc/roadmap.txt
61
+ - doc/scientific_use.txt
62
+ - doc/history.txt
60
63
  - doc/tutorial.txt
64
+ - doc/requirements_and_design.txt
65
+ - doc/screenshots.txt
66
+ - doc/build_install.txt
61
67
  - doc/supplies/page_template.html
62
- - examples/aaindex.rb
63
- - examples/README
64
- - examples/smooth_prev.rb
65
- - examples/all_tests.rb
66
68
  - examples/plane.rb
67
- - examples/smooth.rb
68
69
  - examples/test.rb
69
- - test/tc_gl_vertex.rb
70
- - test/README
71
- - test/tc_opengl_namespace.rb
70
+ - examples/smooth.rb
71
+ - examples/nehe_lesson02.rb
72
+ - examples/nehe_lesson03.rb
73
+ - examples/nehe_lesson04.rb
74
+ - examples/nehe_lesson05.rb
75
+ - examples/legacy
76
+ - examples/README
77
+ - examples/legacy/aaindex.rb
78
+ - examples/legacy/COPYRIGHT
79
+ - examples/legacy/jitter.rb
80
+ - examples/legacy/lines.rb
81
+ - examples/legacy/list.rb
82
+ - examples/legacy/material.rb
83
+ - examples/legacy/mipmap.rb
84
+ - examples/legacy/model.rb
85
+ - examples/legacy/movelight.rb
86
+ - examples/legacy/pickdepth.rb
87
+ - examples/legacy/planet.rb
88
+ - examples/legacy/quadric.rb
89
+ - examples/legacy/readpixel.rb
90
+ - examples/legacy/robot.rb
91
+ - examples/legacy/select.rb
92
+ - examples/legacy/smooth.rb
93
+ - examples/legacy/stencil.rb
94
+ - examples/legacy/stroke.rb
95
+ - examples/legacy/surface.rb
96
+ - examples/legacy/teaambient.rb
97
+ - examples/legacy/teapots.rb
98
+ - examples/legacy/texbind.rb
99
+ - examples/legacy/texgen.rb
100
+ - examples/legacy/texturesurf.rb
101
+ - examples/legacy/varray.rb
102
+ - examples/legacy/wrap.rb
103
+ - examples/legacy/aapoly.rb
104
+ - examples/legacy/accanti.rb
105
+ - examples/legacy/accpersp.rb
106
+ - examples/legacy/alpha3D.rb
107
+ - examples/legacy/alpha.rb
108
+ - examples/legacy/aargb.rb
109
+ - examples/legacy/bezcurve.rb
110
+ - examples/legacy/bezmesh.rb
111
+ - examples/legacy/checker.rb
112
+ - examples/legacy/clip.rb
113
+ - examples/legacy/colormat.rb
114
+ - examples/legacy/cube.rb
115
+ - examples/legacy/depthcue.rb
116
+ - examples/legacy/dof.rb
117
+ - examples/legacy/double.rb
118
+ - examples/legacy/drawf.rb
119
+ - examples/legacy/feedback.rb
120
+ - examples/legacy/fog.rb
121
+ - examples/legacy/font-glut.rb
122
+ - examples/legacy/font.rb
123
+ - examples/legacy/hello.rb
124
+ - examples/legacy/image.rb
125
+ - examples/legacy/tess.rb
72
126
  - test/tc_include_gl.rb
127
+ - test/README
73
128
  - test/tc_require_gl.rb
74
- - test/runtests.sh
129
+ - test/tc_common.rb
130
+ - test/tc_misc.rb
131
+ - test/tc_func_10_11.rb
132
+ - test/tc_func_20.rb
133
+ - test/tc_func_12.rb
134
+ - test/tc_func_21.rb
135
+ - test/tc_func_13.rb
136
+ - test/tc_func_14.rb
137
+ - test/tc_func_15.rb
75
138
  test_files: []
76
139
 
77
140
  rdoc_options: []
@@ -94,3 +157,12 @@ dependencies:
94
157
  - !ruby/object:Gem::Version
95
158
  version: 0.2.0
96
159
  version:
160
+ - !ruby/object:Gem::Dependency
161
+ name: rake
162
+ version_requirement:
163
+ version_requirements: !ruby/object:Gem::Version::Requirement
164
+ requirements:
165
+ - - ">"
166
+ - !ruby/object:Gem::Version
167
+ version: 0.0.0
168
+ version:
data/ext/common/Rakefile DELETED
@@ -1,39 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- # Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
- #
5
- # This program is distributed under the terms of the MIT license.
6
- # See the included COPYRIGHT file for the terms of this license.
7
- #
8
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
12
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
13
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
-
16
- # Simple Rakefile for building rbogl.c.
17
-
18
- require 'rake/clean'
19
- require 'rbconfig'
20
-
21
- INCLUDES = "-I#{Config::CONFIG['archdir']}"
22
- CFLAGS = "#{Config::CONFIG['CFLAGS']}"
23
-
24
- case RUBY_PLATFORM
25
- when /darwin/
26
- INCLUDES << ' -F/System/Library/Frameworks'
27
- end
28
-
29
- CLEAN.include( '*.o' )
30
-
31
- SRC = FileList[ '*.c' ]
32
- OBJ = SRC.ext( 'o' )
33
-
34
- task :default => OBJ
35
- file 'rbogl.c' => [ 'rbogl.h' ]
36
-
37
- rule '.o' => '.c' do |t|
38
- sh "cc -c #{CFLAGS} #{INCLUDES} -o #{t.name} #{t.source}"
39
- end
data/ext/common/rbogl.h DELETED
@@ -1,52 +0,0 @@
1
- /*
2
- * Last edit by previous maintainer:
3
- * 2000/01/06 16:37:43, kusano
4
- *
5
- * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
6
- * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
7
- *
8
- * This program is distributed under the terms of the MIT license.
9
- * See the included MIT-LICENSE file for the terms of this license.
10
- *
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
15
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
16
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
- */
19
-
20
- #ifndef _RBOGL_H_
21
- #define _RBOGL_H_
22
-
23
- #include <ruby.h>
24
-
25
- typedef struct RArray RArray;
26
-
27
- extern VALUE cProc;
28
-
29
- int ary2cint( VALUE, GLint[], int );
30
- int ary2cuint( VALUE, GLuint[], int );
31
- int ary2cshort( VALUE, GLshort[], int );
32
- int ary2cushort( VALUE, GLushort[], int );
33
- int ary2cbyte( VALUE, GLbyte[], int );
34
- int ary2cubyte( VALUE, GLubyte[], int );
35
- int ary2cboolean( VALUE, GLboolean[], int );
36
- int ary2cdbl( VALUE, double[], int );
37
- int ary2cflt( VALUE, float[], int );
38
- void mary2ary( VALUE, VALUE );
39
- void ary2cmat4x4dbl( VALUE, double[] );
40
- void ary2cmat4x4flt( VALUE, float[] );
41
- VALUE allocate_buffer_with_string( int );
42
-
43
- #ifndef NUM2DBL
44
- double num2double( VALUE );
45
- #define _NO_NUM2DBL_
46
- #define NUM2DBL(_val) num2double(_val)
47
- #endif /* NUM2DBL */
48
-
49
- int gltype_size(GLenum type);
50
- int glformat_size(GLenum format);
51
-
52
- #endif /* _RBOGL_H_ */
data/test/runtests.sh DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
- # A quick hack to run all the tests in the test/ directory
3
-
4
- for i in *.rb
5
- do
6
- ruby -rubygems $i
7
- done
data/test/tc_gl_vertex.rb DELETED
@@ -1,180 +0,0 @@
1
- #--
2
- # Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
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
- if __FILE__ == $0
17
- # If we are being called from the command line, e.g., ruby foo.rb, then
18
- # fixup the load path so we can find the OpenGL extension libs
19
- $: << File.join(File.dirname(__FILE__), '..', 'ext')
20
- end
21
-
22
- require 'test/unit'
23
- require 'gl'
24
- require 'glut'
25
- include Gl
26
- include Glut
27
-
28
-
29
- # Yet to test
30
-
31
- # glVertex2dv
32
- # glVertex2fv
33
- # glVertex2iv
34
- # glVertex2sv
35
-
36
- # glVertex3dv
37
- # glVertex3fv
38
- # glVertex3iv
39
- # glVertex3sv
40
-
41
- # glVertex4dv
42
- # glVertex4fv
43
- # glVertex4iv
44
- # glVertex4sv
45
-
46
- class GlVertexTest < Test::Unit::TestCase
47
-
48
-
49
- # Test the existence of
50
- # glVertex2d
51
- # glVertex2f
52
- # glVertex2i
53
- # glVertex2s
54
- def test_gl_vertex2x
55
- one_time_glut_init
56
- # These parameters define a small box
57
- params = [
58
- [-1.5, -1.5],
59
- [-1.5, 1.5],
60
- [ 1.5, 1.5],
61
- [ 1.5, -1.5]
62
- ]
63
- run_with(%w( glVertex2d glVertex2f glVertex2i glVertex2s ), params)
64
- end
65
-
66
- # Test the existence of
67
- # glVertex3d
68
- # glVertex3f
69
- # glVertex3i
70
- # glVertex3s
71
- def test_gl_vertex3x
72
- one_time_glut_init
73
- # These parameters define a small box
74
- params = [
75
- [-1.5, -1.5, 0],
76
- [-1.5, 1.5, 0],
77
- [ 1.5, 1.5, 0],
78
- [ 1.5, -1.5, 0]
79
- ]
80
- run_with(%w( glVertex3d glVertex3f glVertex3i glVertex3s ), params)
81
- end
82
-
83
- # Test the existence of
84
- # glVertex4d
85
- # glVertex4f
86
- # glVertex4i
87
- # glVertex4s
88
- def test_gl_vertex4x
89
- one_time_glut_init
90
- # These parameters define a small box
91
- params = [
92
- [-1.5, -1.5, 0, 1],
93
- [-1.5, 1.5, 0, 1],
94
- [ 1.5, 1.5, 0, 1],
95
- [ 1.5, -1.5, 0, 1]
96
- ]
97
- run_with(%w( glVertex4d glVertex4f glVertex4i glVertex4s ), params)
98
- end
99
-
100
- def one_time_glut_init
101
- puts "=== one_time_glut_init"
102
- glutInit
103
- glutInitWindowSize(600, 600)
104
- end
105
-
106
- def init
107
- puts "=== init"
108
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
109
- glMatrixMode(GL_PROJECTION)
110
- glLoadIdentity
111
- # Give us a 20x20x20 cube to display in centered on the origin
112
- glOrtho(-10, 10, -10, 10, -10, 10)
113
- end
114
-
115
- # Run several related tests. gl_vertex_methods, is an array of method
116
- # names that are appropriate to run against the arity of params. E.g.,
117
- # if gl_vertex_methods was ["glVertex2f", "glVertex2d", ... ] and
118
- # params was [ [-1.5, -1.5], [-1.5, 1.5], [ 1.5, 1.5], [ 1.5, -1.5] ],
119
- # then calling run_with(gl_vertex_methods, params) would be equivalent
120
- # to running the following test cases:
121
- #
122
- # glBegin(GL_POLYGON)
123
- # glVertex2f(-1.5, -1.5)
124
- # glVertex2f(-1.5, 1.5)
125
- # glVertex2f( 1.5, 1.5)
126
- # glVertex2f( 1.5, -1.5)
127
- # glEnd
128
- # ...
129
- # glBegin(GL_POLYGON)
130
- # glVertex2d(-1.5, -1.5)
131
- # glVertex2d(-1.5, 1.5)
132
- # glVertex2d( 1.5, 1.5)
133
- # glVertex2d( 1.5, -1.5)
134
- # glEnd
135
- #
136
- def run_with(gl_vertex_methods, params)
137
- gl_vertex_methods.each do |mn|
138
- display = lambda do
139
- glColor3f( 1.0, 1.0, 1.0 )
140
-
141
- glBegin(GL_POLYGON)
142
- # The send(...) basically do something like:
143
- # glVertex2d( -1.5, -1.5 )
144
- # or
145
- # glVertex3d( -1.5, -1.5, 0 )
146
- # or
147
- # glVertex4f( -1.5, -1.5, 0, 1 )
148
- #
149
- params.each {|p| send(mn, *p)}
150
- glEnd
151
- glFlush
152
- end
153
-
154
- keyboard = lambda do |key, x, y|
155
- case(key)
156
- when 27
157
- raise StopGlutMain.new
158
- end
159
- end
160
- glutCreateWindow("#{__FILE__} : #{mn}");
161
- init
162
- glutDisplayFunc(display);
163
- glutKeyboardFunc(keyboard)
164
- begin
165
- glutMainLoop;
166
- rescue StopGlutMain
167
- # Ignore
168
- end
169
- end
170
- end
171
- end
172
-
173
- class StopGlutMain < RuntimeError
174
- # This Exception is just used to break out of the glutMainLoop.
175
- #
176
- # The Mac OS X version of glut has the glutCheckLoop/glutWMCloseFunc
177
- # pair, but in general, we can't rely on something beyond the really
178
- # old 98 version of GLUT being installed.
179
- end
180
-