sgl 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/ChangeLog +254 -234
  2. data/History.txt +6 -0
  3. data/Manifest.txt +10 -0
  4. data/Rakefile +27 -7
  5. data/examples/cocoa1-basic.rb +14 -14
  6. data/examples/cocoa10-transparent.rb +26 -26
  7. data/examples/cocoa11-application.rb +13 -13
  8. data/examples/cocoa2-draw.rb +23 -23
  9. data/examples/cocoa3-affine.rb +29 -29
  10. data/examples/cocoa4-font.rb +24 -24
  11. data/examples/cocoa5-image.rb +22 -22
  12. data/examples/cocoa6-sound.rb +24 -24
  13. data/examples/cocoa7-movie.rb +40 -40
  14. data/examples/cocoa8-movieoverlay.rb +42 -42
  15. data/examples/cocoa9-streaming.rb +40 -40
  16. data/examples/opengl1-basic.rb +14 -14
  17. data/examples/opengl11-application.rb +13 -13
  18. data/examples/opengl2-draw.rb +23 -23
  19. data/examples/opengl3-affine.rb +29 -29
  20. data/examples/sample1.rb +11 -11
  21. data/examples/sample10.rb +16 -16
  22. data/examples/sample11.rb +22 -22
  23. data/examples/sample11a.rb +33 -33
  24. data/examples/sample12.rb +30 -30
  25. data/examples/sample12a.rb +35 -35
  26. data/examples/sample13.rb +116 -116
  27. data/examples/sample15.rb +24 -24
  28. data/examples/sample16.rb +31 -31
  29. data/examples/sample16a.rb +35 -35
  30. data/examples/sample6.rb +18 -18
  31. data/examples/sample7.rb +16 -16
  32. data/examples/sample9.rb +20 -20
  33. data/examples/testgl.rb +169 -169
  34. data/lib/sgl/bass.rb +46 -46
  35. data/lib/sgl/cocoa-app.rb +43 -43
  36. data/lib/sgl/cocoa-color.rb +65 -65
  37. data/lib/sgl/cocoa-draw.rb +72 -72
  38. data/lib/sgl/cocoa-event.rb +229 -229
  39. data/lib/sgl/cocoa-media.rb +144 -144
  40. data/lib/sgl/cocoa-notuse.rb +493 -493
  41. data/lib/sgl/cocoa-window.rb +203 -203
  42. data/lib/sgl/cocoa.rb +8 -8
  43. data/lib/sgl/opengl-app.rb +38 -38
  44. data/lib/sgl/opengl-color.rb +44 -44
  45. data/lib/sgl/opengl-draw.rb +260 -260
  46. data/lib/sgl/opengl-event.rb +325 -325
  47. data/lib/sgl/opengl-modules.rb +22 -22
  48. data/lib/sgl/opengl-window.rb +224 -224
  49. data/lib/sgl/opengl.rb +7 -7
  50. data/lib/sgl/sgl-button.rb +135 -135
  51. data/lib/sgl/sgl-client.rb +21 -21
  52. data/lib/sgl/sgl-color.rb +68 -82
  53. data/lib/sgl/sgl-connect.rb +9 -9
  54. data/lib/sgl/sgl-server.rb +58 -58
  55. data/lib/sgl/sgl-spring.rb +216 -216
  56. data/lib/sgl/version.rb +2 -2
  57. data/scripts/lib-txt2html.rb +130 -0
  58. data/scripts/txt2html +2 -63
  59. data/spec/sgl_spec.rb +13 -0
  60. data/spec/spec.opts +1 -0
  61. data/spec/spec_helper.rb +1 -0
  62. data/test/test_cocoa_app.rb +291 -291
  63. data/test/test_module_ruby16.rb +30 -30
  64. data/test/test_opengl_app.rb +147 -147
  65. data/test/test_opengl_basic.rb +22 -22
  66. data/test/test_opengl_fullscreen.rb +23 -23
  67. data/test/test_opengl_novice.rb +35 -35
  68. data/website/challenge1.html +91 -91
  69. data/website/challenge1.txt +3 -3
  70. data/website/challenge2.html +143 -144
  71. data/website/challenge2.txt +13 -14
  72. data/website/challenge3.html +66 -63
  73. data/website/challenge3.txt +7 -7
  74. data/website/cocoa.html +85 -88
  75. data/website/cocoa.txt +2 -4
  76. data/website/description.html +138 -138
  77. data/website/description.txt +1 -1
  78. data/website/exercise1.html +262 -264
  79. data/website/exercise1.txt +58 -53
  80. data/website/exercise2.html +241 -683
  81. data/website/exercise2.txt +11 -427
  82. data/website/exercise3.html +206 -0
  83. data/website/exercise3.txt +155 -0
  84. data/website/exercise4.html +198 -0
  85. data/website/exercise4.txt +151 -0
  86. data/website/exercise5.html +162 -0
  87. data/website/exercise5.txt +113 -0
  88. data/website/exhibition.html +84 -84
  89. data/website/howto.html +146 -134
  90. data/website/howto.txt +9 -0
  91. data/website/index.html +178 -178
  92. data/website/index.txt +20 -19
  93. data/website/sound.html +141 -141
  94. metadata +16 -3
@@ -1,30 +1,30 @@
1
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
2
- # License: Ruby License
3
-
4
- # only for Ruby 1.6
5
- if /\A1\.6/ =~ RUBY_VERSION
6
- class Array
7
- def fetch(n)
8
- a = self[n]
9
- if a.nil?
10
- a = yield
11
- end
12
- a
13
- end
14
- end
15
-
16
- module Enumerable
17
- def sort_by
18
- self.collect {|i| [yield(i), i]}.
19
- sort {|a,b| a[0] <=> b[0]}.
20
- collect! {|i| i[1]}
21
- end
22
- end
23
-
24
- alias org_exit exit
25
- def exit(n)
26
- n = 0 if n == true
27
- n = 1 if n == false
28
- org_exit(n)
29
- end
30
- end
1
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
2
+ # License: Ruby License
3
+
4
+ # only for Ruby 1.6
5
+ if /\A1\.6/ =~ RUBY_VERSION
6
+ class Array
7
+ def fetch(n)
8
+ a = self[n]
9
+ if a.nil?
10
+ a = yield
11
+ end
12
+ a
13
+ end
14
+ end
15
+
16
+ module Enumerable
17
+ def sort_by
18
+ self.collect {|i| [yield(i), i]}.
19
+ sort {|a,b| a[0] <=> b[0]}.
20
+ collect! {|i| i[1]}
21
+ end
22
+ end
23
+
24
+ alias org_exit exit
25
+ def exit(n)
26
+ n = 0 if n == true
27
+ n = 1 if n == false
28
+ org_exit(n)
29
+ end
30
+ end
@@ -1,147 +1,147 @@
1
- #!/usr/bin/env ruby -w
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
- # License: Ruby License
4
-
5
- require File.dirname(__FILE__) + '/test_helper.rb'
6
-
7
- class TestOpenglBasic < Test::Unit::TestCase
8
- def test_basic
9
- app = SGL::Application.new
10
- app.set_setup {
11
- app.window(100, 100)
12
- app.runtime = 0.1
13
- }
14
- i = 0
15
- app.set_display {
16
- app.line(0, 0, 100, i*5)
17
- i += 2
18
- i = 0 if 20 < i
19
- }
20
- app.mainloop
21
- end
22
-
23
- def test_window
24
- app = SGL::Application.new
25
- sleep 0.01; app.window(100, 100)
26
- sleep 0.01; app.close_window
27
- sleep 0.01; app.window(500, 500)
28
- sleep 0.01; app.close_window
29
- sleep 0.01; app.window(100, 100, :border=>false)
30
- sleep 0.01; app.close_window
31
- sleep 0.01; app.window(100, 100, :shadow=>false, :border=>false)
32
- sleep 0.01; app.close_window
33
- end
34
-
35
- def nutest_color
36
- app = SGL::Application.new
37
- app.window(100, 100)
38
- app.background(100)
39
- bgcolor = app.instance_eval { @bgcolor }
40
- assert_equal([1.0, 1.0, 1.0, 1.0], bgcolor)
41
- app.background(10, 20, 30)
42
- bgcolor = app.instance_eval { @bgcolor }
43
- assert_equal([0.1, 0.2, 0.3, 1.0], bgcolor)
44
- app.color(0)
45
- curcolor = app.instance_eval { @curcolor }
46
- assert_equal([0.0, 0.0, 0.0, 1.0], curcolor)
47
- app.color(10, 20, 30)
48
- curcolor = app.instance_eval { @curcolor }
49
- assert_equal([0.1, 0.2, 0.3, 1.0], curcolor)
50
- app.close_window
51
- end
52
-
53
- def test_setup_and_display
54
- app = SGL::Application.new
55
- app.window(100, 100)
56
-
57
- test_setup_done = false
58
- app.set_setup { test_setup_done = true }
59
- assert_equal(false, test_setup_done)
60
- app.do_setup
61
- assert_equal(true, test_setup_done)
62
-
63
- test_display_done = false
64
- app.set_display { test_display_done = true }
65
- assert_equal(false, test_display_done)
66
- app.do_display
67
- assert_equal(true, test_display_done)
68
- app.close_window
69
- end
70
-
71
- def test_event
72
- app = SGL::Application.new
73
- app.window(100, 100)
74
-
75
- test = {}
76
- app.set_mousedown { test[:mousedown] = true }
77
- assert_equal(nil, test[:mousedown])
78
- app.do_mousedown
79
- assert_equal(true, test[:mousedown])
80
- end
81
- end
82
-
83
- class TestCocoaDraw < Test::Unit::TestCase
84
- def test_commands
85
- app = SGL::Application.new
86
- app.set_setup {
87
- app.window(100, 100)
88
- app.runtime = 0.1
89
- }
90
- app.set_display {
91
- app.line(0, 0, 100, 100)
92
- app.rect(40, 40, 60, 60)
93
- app.circle(20, 20, 10)
94
- }
95
- app.mainloop
96
- end
97
-
98
- def test_for
99
- app = SGL::Application.new
100
- app.set_setup {
101
- app.window(100, 100)
102
- app.runtime = 0.1
103
- }
104
- app.set_display {
105
- for i in 0..20
106
- app.line(0, 0, 100, i*5)
107
- end
108
- }
109
- app.mainloop
110
- end
111
-
112
- def test_iterate
113
- app = SGL::Application.new
114
- app.set_setup {
115
- app.window(100, 100)
116
- app.runtime = 0.2
117
- }
118
- i = 0
119
- app.set_display {
120
- app.line(0, 0, 100, i*5)
121
- i += 1
122
- i = 0 if 20 < i
123
- }
124
- app.mainloop
125
- end
126
-
127
- def test_affine
128
- app = SGL::Application.new
129
- app.set_setup {
130
- app.window(300, 300)
131
- app.runtime = 0.2
132
- }
133
- i = 0
134
- app.set_display {
135
- app.colorHSV 66, 100, 100, 50
136
- app.lineWidth(i/10)
137
- app.line(0, 0, 300, i)
138
- app.translate i, i
139
- app.rotateZ i
140
- app.colorHSV i, 100, 100
141
- app.rect(-10, -10, +10, +10)
142
- i += 20
143
- i = 0 if 300 < i
144
- }
145
- app.mainloop
146
- end
147
- end
1
+ #!/usr/bin/env ruby -w
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+ # License: Ruby License
4
+
5
+ require File.dirname(__FILE__) + '/test_helper.rb'
6
+
7
+ class TestOpenglBasic < Test::Unit::TestCase
8
+ def test_basic
9
+ app = SGL::Application.new
10
+ app.set_setup {
11
+ app.window(100, 100)
12
+ app.runtime = 0.1
13
+ }
14
+ i = 0
15
+ app.set_display {
16
+ app.line(0, 0, 100, i*5)
17
+ i += 2
18
+ i = 0 if 20 < i
19
+ }
20
+ app.mainloop
21
+ end
22
+
23
+ def test_window
24
+ app = SGL::Application.new
25
+ sleep 0.01; app.window(100, 100)
26
+ sleep 0.01; app.close_window
27
+ sleep 0.01; app.window(500, 500)
28
+ sleep 0.01; app.close_window
29
+ sleep 0.01; app.window(100, 100, :border=>false)
30
+ sleep 0.01; app.close_window
31
+ sleep 0.01; app.window(100, 100, :shadow=>false, :border=>false)
32
+ sleep 0.01; app.close_window
33
+ end
34
+
35
+ def nutest_color
36
+ app = SGL::Application.new
37
+ app.window(100, 100)
38
+ app.background(100)
39
+ bgcolor = app.instance_eval { @bgcolor }
40
+ assert_equal([1.0, 1.0, 1.0, 1.0], bgcolor)
41
+ app.background(10, 20, 30)
42
+ bgcolor = app.instance_eval { @bgcolor }
43
+ assert_equal([0.1, 0.2, 0.3, 1.0], bgcolor)
44
+ app.color(0)
45
+ curcolor = app.instance_eval { @curcolor }
46
+ assert_equal([0.0, 0.0, 0.0, 1.0], curcolor)
47
+ app.color(10, 20, 30)
48
+ curcolor = app.instance_eval { @curcolor }
49
+ assert_equal([0.1, 0.2, 0.3, 1.0], curcolor)
50
+ app.close_window
51
+ end
52
+
53
+ def test_setup_and_display
54
+ app = SGL::Application.new
55
+ app.window(100, 100)
56
+
57
+ test_setup_done = false
58
+ app.set_setup { test_setup_done = true }
59
+ assert_equal(false, test_setup_done)
60
+ app.do_setup
61
+ assert_equal(true, test_setup_done)
62
+
63
+ test_display_done = false
64
+ app.set_display { test_display_done = true }
65
+ assert_equal(false, test_display_done)
66
+ app.do_display
67
+ assert_equal(true, test_display_done)
68
+ app.close_window
69
+ end
70
+
71
+ def test_event
72
+ app = SGL::Application.new
73
+ app.window(100, 100)
74
+
75
+ test = {}
76
+ app.set_mousedown { test[:mousedown] = true }
77
+ assert_equal(nil, test[:mousedown])
78
+ app.do_mousedown
79
+ assert_equal(true, test[:mousedown])
80
+ end
81
+ end
82
+
83
+ class TestCocoaDraw < Test::Unit::TestCase
84
+ def test_commands
85
+ app = SGL::Application.new
86
+ app.set_setup {
87
+ app.window(100, 100)
88
+ app.runtime = 0.1
89
+ }
90
+ app.set_display {
91
+ app.line(0, 0, 100, 100)
92
+ app.rect(40, 40, 60, 60)
93
+ app.circle(20, 20, 10)
94
+ }
95
+ app.mainloop
96
+ end
97
+
98
+ def test_for
99
+ app = SGL::Application.new
100
+ app.set_setup {
101
+ app.window(100, 100)
102
+ app.runtime = 0.1
103
+ }
104
+ app.set_display {
105
+ for i in 0..20
106
+ app.line(0, 0, 100, i*5)
107
+ end
108
+ }
109
+ app.mainloop
110
+ end
111
+
112
+ def test_iterate
113
+ app = SGL::Application.new
114
+ app.set_setup {
115
+ app.window(100, 100)
116
+ app.runtime = 0.2
117
+ }
118
+ i = 0
119
+ app.set_display {
120
+ app.line(0, 0, 100, i*5)
121
+ i += 1
122
+ i = 0 if 20 < i
123
+ }
124
+ app.mainloop
125
+ end
126
+
127
+ def test_affine
128
+ app = SGL::Application.new
129
+ app.set_setup {
130
+ app.window(300, 300)
131
+ app.runtime = 0.2
132
+ }
133
+ i = 0
134
+ app.set_display {
135
+ app.colorHSV 66, 100, 100, 50
136
+ app.lineWidth(i/10)
137
+ app.line(0, 0, 300, i)
138
+ app.translate i, i
139
+ app.rotateZ i
140
+ app.colorHSV i, 100, 100
141
+ app.rect(-10, -10, +10, +10)
142
+ i += 20
143
+ i = 0 if 300 < i
144
+ }
145
+ app.mainloop
146
+ end
147
+ end
@@ -1,22 +1,22 @@
1
- #!/usr/bin/env ruby -w
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
- # License: Ruby License
4
-
5
- require File.dirname(__FILE__) + '/test_helper.rb'
6
-
7
- class TestOpenGLBasic < Test::Unit::TestCase
8
- def test_all
9
- app = SGL::Application.new
10
- app.set_setup {
11
- app.window(100, 100)
12
- app.runtime = 0.1
13
- }
14
- @i = 0
15
- app.set_display {
16
- app.line(0, 0, 100, @i*5)
17
- @i += 2
18
- @i = 0 if 20 < @i
19
- }
20
- app.mainloop
21
- end
22
- end
1
+ #!/usr/bin/env ruby -w
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+ # License: Ruby License
4
+
5
+ require File.dirname(__FILE__) + '/test_helper.rb'
6
+
7
+ class TestOpenGLBasic < Test::Unit::TestCase
8
+ def test_all
9
+ app = SGL::Application.new
10
+ app.set_setup {
11
+ app.window(100, 100)
12
+ app.runtime = 0.1
13
+ }
14
+ @i = 0
15
+ app.set_display {
16
+ app.line(0, 0, 100, @i*5)
17
+ @i += 2
18
+ @i = 0 if 20 < @i
19
+ }
20
+ app.mainloop
21
+ end
22
+ end
@@ -1,23 +1,23 @@
1
- #!/usr/bin/env ruby -w
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
- # License: Ruby License
4
-
5
- require File.dirname(__FILE__) + '/test_helper.rb'
6
-
7
- class TestOpenGLFullscreen < Test::Unit::TestCase
8
- def test_all
9
- app = SGL::Application.new
10
- app.set_setup {
11
- app.useFullscreen(1024, 768)
12
- app.window(100, 100)
13
- app.runtime = 0.1
14
- }
15
- @i = 0
16
- app.set_display {
17
- app.line(0, 0, 100, @i*5)
18
- @i += 2
19
- @i = 0 if 20 < @i
20
- }
21
- app.mainloop
22
- end
23
- end
1
+ #!/usr/bin/env ruby -w
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+ # License: Ruby License
4
+
5
+ require File.dirname(__FILE__) + '/test_helper.rb'
6
+
7
+ class TestOpenGLFullscreen < Test::Unit::TestCase
8
+ def test_all
9
+ app = SGL::Application.new
10
+ app.set_setup {
11
+ app.useFullscreen(1024, 768)
12
+ app.window(100, 100)
13
+ app.runtime = 0.1
14
+ }
15
+ @i = 0
16
+ app.set_display {
17
+ app.line(0, 0, 100, @i*5)
18
+ @i += 2
19
+ @i = 0 if 20 < @i
20
+ }
21
+ app.mainloop
22
+ end
23
+ end
@@ -1,35 +1,35 @@
1
- #!/usr/bin/env ruby -w
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
- # License: Ruby License
4
-
5
- require File.dirname(__FILE__) + '/test_helper.rb'
6
-
7
- if $0 == __FILE__
8
- class TestOpenGLNovice < Test::Unit::TestCase
9
- def test_1st
10
- window 100, 100
11
- useRuntime(0.1)
12
- for i in 0..20
13
- line 0, 0, 100, i*2*5
14
- flip
15
- end
16
- wait
17
- end
18
-
19
- def test_2nd
20
- window 400, 400
21
- useRuntime(0.1)
22
- useSmooth
23
- process {
24
- mx = mouseX
25
- my = mouseY
26
- push
27
- translate mx, my
28
- colorHSV(-mx+60, my, 100)
29
- rect 0, 0, 100, 100
30
- pop
31
- flip
32
- }
33
- end
34
- end
35
- end
1
+ #!/usr/bin/env ruby -w
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+ # License: Ruby License
4
+
5
+ require File.dirname(__FILE__) + '/test_helper.rb'
6
+
7
+ if $0 == __FILE__
8
+ class TestOpenGLNovice < Test::Unit::TestCase
9
+ def test_1st
10
+ window 100, 100
11
+ useRuntime(0.1)
12
+ for i in 0..20
13
+ line 0, 0, 100, i*2*5
14
+ flip
15
+ end
16
+ wait
17
+ end
18
+
19
+ def test_2nd
20
+ window 400, 400
21
+ useRuntime(0.1)
22
+ useSmooth
23
+ process {
24
+ mx = mouseX
25
+ my = mouseY
26
+ push
27
+ translate mx, my
28
+ colorHSV(-mx+60, my, 100)
29
+ rect 0, 0, 100, 100
30
+ pop
31
+ flip
32
+ }
33
+ end
34
+ end
35
+ end