ruby-opengl 0.40.1 → 0.50.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 (154) hide show
  1. data/Rakefile +2 -2
  2. data/doc/build_install.txt +48 -28
  3. data/doc/extensions.txt +361 -0
  4. data/doc/history.txt +8 -2
  5. data/doc/requirements_and_design.txt +0 -13
  6. data/doc/roadmap.txt +11 -13
  7. data/doc/supplies/page_template.html +11 -5
  8. data/doc/thanks.txt +2 -4
  9. data/doc/tutorial.txt +1 -4
  10. data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
  11. data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
  12. data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
  13. data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
  14. data/examples/NeHe/nehe_lesson36.rb +303 -0
  15. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  16. data/examples/OrangeBook/brick.frag +36 -0
  17. data/examples/OrangeBook/brick.rb +388 -0
  18. data/examples/OrangeBook/brick.vert +41 -0
  19. data/examples/OrangeBook/particle.frag +17 -0
  20. data/examples/OrangeBook/particle.rb +424 -0
  21. data/examples/OrangeBook/particle.vert +38 -0
  22. data/examples/README +13 -83
  23. data/examples/RedBook/aaindex.rb +97 -0
  24. data/examples/RedBook/aapoly.rb +142 -0
  25. data/examples/RedBook/aargb.rb +119 -0
  26. data/examples/RedBook/accanti.rb +162 -0
  27. data/examples/RedBook/accpersp.rb +215 -0
  28. data/examples/RedBook/alpha.rb +123 -0
  29. data/examples/RedBook/alpha3D.rb +158 -0
  30. data/examples/RedBook/bezcurve.rb +105 -0
  31. data/examples/RedBook/bezmesh.rb +137 -0
  32. data/examples/RedBook/checker.rb +124 -0
  33. data/examples/RedBook/clip.rb +95 -0
  34. data/examples/RedBook/colormat.rb +135 -0
  35. data/examples/RedBook/cube.rb +69 -0
  36. data/examples/RedBook/depthcue.rb +99 -0
  37. data/examples/RedBook/dof.rb +205 -0
  38. data/examples/{legacy → RedBook}/double.rb +59 -58
  39. data/examples/{legacy → RedBook}/drawf.rb +47 -54
  40. data/examples/RedBook/feedback.rb +145 -0
  41. data/examples/RedBook/fog.rb +167 -0
  42. data/examples/RedBook/font.rb +151 -0
  43. data/examples/RedBook/hello.rb +79 -0
  44. data/examples/RedBook/image.rb +137 -0
  45. data/examples/{legacy → RedBook}/jitter.rb +60 -62
  46. data/examples/RedBook/lines.rb +128 -0
  47. data/examples/RedBook/list.rb +111 -0
  48. data/examples/RedBook/material.rb +275 -0
  49. data/examples/RedBook/mipmap.rb +156 -0
  50. data/examples/{legacy → RedBook}/model.rb +66 -72
  51. data/examples/{legacy → RedBook}/movelight.rb +67 -75
  52. data/examples/RedBook/pickdepth.rb +179 -0
  53. data/examples/{legacy → RedBook}/planet.rb +62 -66
  54. data/examples/RedBook/quadric.rb +158 -0
  55. data/examples/RedBook/robot.rb +115 -0
  56. data/examples/RedBook/select.rb +196 -0
  57. data/examples/RedBook/smooth.rb +95 -0
  58. data/examples/RedBook/stencil.rb +163 -0
  59. data/examples/RedBook/stroke.rb +167 -0
  60. data/examples/RedBook/surface.rb +166 -0
  61. data/examples/RedBook/teaambient.rb +132 -0
  62. data/examples/RedBook/teapots.rb +182 -0
  63. data/examples/RedBook/tess.rb +183 -0
  64. data/examples/RedBook/texbind.rb +147 -0
  65. data/examples/RedBook/texgen.rb +169 -0
  66. data/examples/RedBook/texturesurf.rb +128 -0
  67. data/examples/RedBook/varray.rb +159 -0
  68. data/examples/RedBook/wrap.rb +148 -0
  69. data/examples/misc/anisotropic.rb +194 -0
  70. data/examples/misc/font-glut.rb +46 -0
  71. data/examples/{plane.rb → misc/plane.rb} +0 -0
  72. data/examples/misc/readpixel.rb +65 -0
  73. data/examples/{smooth.rb → misc/smooth.rb} +0 -0
  74. data/examples/{test.rb → misc/test.rb} +0 -0
  75. data/ext/common/common.h +252 -70
  76. data/ext/common/gl-enums.h +6102 -7334
  77. data/ext/common/gl-types.h +47 -0
  78. data/ext/common/glu-enums.h +469 -0
  79. data/ext/gl/gl-1.0-1.1.c +842 -2464
  80. data/ext/gl/gl-1.2.c +217 -281
  81. data/ext/gl/gl-1.3.c +113 -133
  82. data/ext/gl/gl-1.4.c +98 -334
  83. data/ext/gl/gl-1.5.c +28 -34
  84. data/ext/gl/gl-2.0.c +26 -235
  85. data/ext/gl/gl-2.1.c +31 -124
  86. data/ext/gl/gl-enums.c +786 -631
  87. data/ext/gl/gl-ext-arb.c +66 -0
  88. data/ext/gl/gl-ext-ext.c +218 -0
  89. data/ext/gl/gl.c +138 -31
  90. data/ext/gl/mkrf_conf.rb +1 -0
  91. data/ext/glu/glu-enums.c +163 -0
  92. data/ext/glu/glu.c +1003 -1205
  93. data/ext/glu/mkrf_conf.rb +1 -0
  94. data/ext/glut/glut.c +1056 -1175
  95. data/lib/opengl.rb +90 -3
  96. data/test/tc_common.rb +26 -13
  97. data/test/tc_ext_arb.rb +73 -0
  98. data/test/tc_ext_ext.rb +74 -0
  99. data/test/tc_func_12.rb +8 -8
  100. data/test/tc_func_13.rb +17 -11
  101. data/test/tc_func_14.rb +8 -8
  102. data/test/tc_func_15.rb +190 -2
  103. data/test/tc_func_20.rb +36 -10
  104. data/test/tc_func_21.rb +445 -2
  105. data/test/tc_glu.rb +305 -0
  106. data/test/tc_misc.rb +1 -0
  107. metadata +84 -68
  108. data/doc/screenshots.txt +0 -23
  109. data/examples/legacy/COPYRIGHT +0 -8
  110. data/examples/legacy/aaindex.rb +0 -98
  111. data/examples/legacy/aapoly.rb +0 -153
  112. data/examples/legacy/aargb.rb +0 -139
  113. data/examples/legacy/accanti.rb +0 -159
  114. data/examples/legacy/accpersp.rb +0 -216
  115. data/examples/legacy/alpha.rb +0 -133
  116. data/examples/legacy/alpha3D.rb +0 -165
  117. data/examples/legacy/bezcurve.rb +0 -107
  118. data/examples/legacy/bezmesh.rb +0 -131
  119. data/examples/legacy/checker.rb +0 -121
  120. data/examples/legacy/clip.rb +0 -104
  121. data/examples/legacy/colormat.rb +0 -145
  122. data/examples/legacy/cube.rb +0 -73
  123. data/examples/legacy/depthcue.rb +0 -101
  124. data/examples/legacy/dof.rb +0 -212
  125. data/examples/legacy/feedback.rb +0 -152
  126. data/examples/legacy/fog.rb +0 -172
  127. data/examples/legacy/font-glut.rb +0 -41
  128. data/examples/legacy/font.rb +0 -158
  129. data/examples/legacy/hello.rb +0 -75
  130. data/examples/legacy/image.rb +0 -145
  131. data/examples/legacy/lines.rb +0 -135
  132. data/examples/legacy/list.rb +0 -120
  133. data/examples/legacy/material.rb +0 -290
  134. data/examples/legacy/mipmap.rb +0 -159
  135. data/examples/legacy/pickdepth.rb +0 -180
  136. data/examples/legacy/quadric.rb +0 -180
  137. data/examples/legacy/readpixel.rb +0 -59
  138. data/examples/legacy/robot.rb +0 -120
  139. data/examples/legacy/select.rb +0 -207
  140. data/examples/legacy/smooth.rb +0 -41
  141. data/examples/legacy/stencil.rb +0 -154
  142. data/examples/legacy/stroke.rb +0 -170
  143. data/examples/legacy/surface.rb +0 -170
  144. data/examples/legacy/teaambient.rb +0 -132
  145. data/examples/legacy/teapots.rb +0 -188
  146. data/examples/legacy/tess.rb +0 -222
  147. data/examples/legacy/texbind.rb +0 -157
  148. data/examples/legacy/texgen.rb +0 -171
  149. data/examples/legacy/texturesurf.rb +0 -128
  150. data/examples/legacy/varray.rb +0 -167
  151. data/examples/legacy/wrap.rb +0 -158
  152. data/lib/gl_prev.rb +0 -46
  153. data/lib/glu_prev.rb +0 -46
  154. data/lib/glut_prev.rb +0 -45
@@ -0,0 +1,156 @@
1
+ #
2
+ # Copyright (c) Mark J. Kilgard, 1994. */
3
+ #
4
+ # (c) Copyright 1993, Silicon Graphics, Inc.
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
+ # any purpose and without fee is hereby granted, provided that the above
8
+ # copyright notice appear in all copies and that both the copyright notice
9
+ # and this permission notice appear in supporting documentation, and that
10
+ # the name of Silicon Graphics, Inc. not be used in advertising
11
+ # or publicity pertaining to distribution of the software without specific,
12
+ # written prior permission.
13
+ #
14
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
16
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
17
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
18
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
19
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
20
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
21
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
22
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
23
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ #
27
+ # US Government Users Restricted Rights
28
+ # Use, duplication, or disclosure by the Government is subject to
29
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
31
+ # clause at DFARS 252.227-7013 and/or in similar or successor
32
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
33
+ # Unpublished-- rights reserved under the copyright laws of the
34
+ # United States. Contractor/manufacturer is Silicon Graphics,
35
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
36
+ #
37
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
38
+ #
39
+ # mipmap.c
40
+ # This program demonstrates using mipmaps for texture maps.
41
+ # To overtly show the effect of mipmaps, each mipmap reduction
42
+ # level has a solidly colored, contrasting texture image.
43
+ # Thus, the quadrilateral which is drawn is drawn with several
44
+ # different colors.
45
+ require 'opengl'
46
+ require 'mathn'
47
+ include Gl,Glu,Glut
48
+
49
+ $mipmapImage32 = []
50
+ $mipmapImage16 = []
51
+ $mipmapImage8 = []
52
+ $mipmapImage4 = []
53
+ $mipmapImage2 = []
54
+ $mipmapImage1 = []
55
+
56
+ def makeImages
57
+ for i in 0..31
58
+ for j in 0..31
59
+ $mipmapImage32[(j*32+i)*3+0] = 255
60
+ $mipmapImage32[(j*32+i)*3+1] = 255
61
+ $mipmapImage32[(j*32+i)*3+2] = 0
62
+ end
63
+ end
64
+ for i in 0..15
65
+ for j in 0..15
66
+ $mipmapImage16[(j*16+i)*3+0] = 255
67
+ $mipmapImage16[(j*16+i)*3+1] = 0
68
+ $mipmapImage16[(j*16+i)*3+2] = 255
69
+ end
70
+ end
71
+ for i in 0..7
72
+ for j in 0..7
73
+ $mipmapImage8[(j*8+i)*3+0] = 255
74
+ $mipmapImage8[(j*8+i)*3+1] = 0
75
+ $mipmapImage8[(j*8+i)*3+2] = 0
76
+ end
77
+ end
78
+ for i in 0..3
79
+ for j in 0..3
80
+ $mipmapImage4[(j*4+i)*3+0] = 0
81
+ $mipmapImage4[(j*4+i)*3+1] = 255
82
+ $mipmapImage4[(j*4+i)*3+2] = 0
83
+ end
84
+ end
85
+ for i in 0..1
86
+ for j in 0..1
87
+ $mipmapImage2[(j*2+i)*3+0] = 0
88
+ $mipmapImage2[(j*2+i)*3+1] = 0
89
+ $mipmapImage2[(j*2+i)*3+2] = 255
90
+ end
91
+ end
92
+ $mipmapImage1[0] = 255
93
+ $mipmapImage1[1] = 255
94
+ $mipmapImage1[2] = 255
95
+ end
96
+
97
+ def myinit
98
+ glEnable(GL_DEPTH_TEST)
99
+ glDepthFunc(GL_LESS)
100
+ glShadeModel(GL_FLAT)
101
+
102
+ glTranslate(0.0, 0.0, -3.6)
103
+ makeImages()
104
+ glPixelStore(GL_UNPACK_ALIGNMENT, 1)
105
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage32.pack("C*"))
106
+ glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage16.pack("C*"))
107
+ glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage8.pack("C*"))
108
+ glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage4.pack("C*"))
109
+ glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage2.pack("C*"))
110
+ glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage1.pack("C*"))
111
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
112
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
113
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
114
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
115
+ GL_NEAREST_MIPMAP_NEAREST)
116
+ glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
117
+ glEnable(GL_TEXTURE_2D)
118
+ end
119
+
120
+ display = Proc.new do
121
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
122
+ glBegin(GL_QUADS)
123
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
124
+ glTexCoord(0.0, 8.0); glVertex(-2.0, 1.0, 0.0)
125
+ glTexCoord(8.0, 8.0); glVertex(2000.0, 1.0, -6000.0)
126
+ glTexCoord(8.0, 0.0); glVertex(2000.0, -1.0, -6000.0)
127
+ glEnd()
128
+ glutSwapBuffers()
129
+ end
130
+
131
+ myReshape = Proc.new do |w, h|
132
+ glViewport(0, 0, w, h)
133
+ glMatrixMode(GL_PROJECTION)
134
+ glLoadIdentity()
135
+ gluPerspective(60.0, 1.0*w/h, 1.0, 30000.0)
136
+ glMatrixMode(GL_MODELVIEW)
137
+ glLoadIdentity()
138
+ end
139
+
140
+ keyboard = Proc.new do |key, x, y|
141
+ case (key)
142
+ when 27
143
+ exit(0);
144
+ end
145
+ end
146
+
147
+ glutInit
148
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
149
+ glutInitWindowSize(500, 500)
150
+ glutInitWindowPosition(100, 100)
151
+ glutCreateWindow($0)
152
+ myinit()
153
+ glutReshapeFunc(myReshape)
154
+ glutDisplayFunc(display)
155
+ glutKeyboardFunc(keyboard)
156
+ glutMainLoop()
@@ -9,7 +9,7 @@
9
9
  # or publicity pertaining to distribution of the software without specific,
10
10
  # written prior permission.
11
11
  #
12
- #THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
12
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
13
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
14
  # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
15
  # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
@@ -33,87 +33,81 @@
33
33
  # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
34
  #
35
35
  # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
- #/
37
-
38
36
  #
39
37
  # model.c
40
38
  # This program demonstrates modeling transformations
41
- #/
42
- require "gl_prev"
43
- require "glu_prev"
44
- require "glut_prev"
45
- require "mathn"
39
+ require 'opengl'
40
+ require 'mathn'
41
+ include Gl,Glu,Glut
46
42
 
47
43
  def init
48
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
49
- GL.ShadeModel(GL::FLAT);
44
+ glClearColor(0.0, 0.0, 0.0, 0.0)
45
+ glShadeModel(GL_FLAT)
50
46
  end
51
47
 
52
48
  def draw_triangle
53
- GL.Begin (GL::LINE_LOOP);
54
- GL.Vertex(0.0, 25.0);
55
- GL.Vertex(25.0, -25.0);
56
- GL.Vertex(-25.0, -25.0);
57
- GL.End();
49
+ glBegin(GL_LINE_LOOP)
50
+ glVertex(0.0, 25.0)
51
+ glVertex(25.0, -25.0)
52
+ glVertex(-25.0, -25.0)
53
+ glEnd()
58
54
  end
59
55
 
60
- display = Proc.new {
61
- GL.Clear(GL::COLOR_BUFFER_BIT);
62
- GL.Color(1.0, 1.0, 1.0);
63
-
64
- GL.LoadIdentity();
65
- GL.Color(1.0, 1.0, 1.0);
66
- draw_triangle();
67
-
68
- GL.Enable(GL::LINE_STIPPLE);
69
- GL.LineStipple(1, 0xF0F0);
70
- GL.LoadIdentity();
71
- GL.Translate(-20.0, 0.0, 0.0);
72
- draw_triangle();
73
-
74
- GL.LineStipple(1, 0xF00F);
75
- GL.LoadIdentity();
76
- GL.Scale(1.5, 0.5, 1.0);
77
- draw_triangle();
78
-
79
- GL.LineStipple(1, 0x8888);
80
- GL.LoadIdentity();
81
- GL.Rotate(90.0, 0.0, 0.0, 1.0);
82
- draw_triangle();
83
- GL.Disable(GL::LINE_STIPPLE);
84
-
85
- GL.Flush();
86
- }
56
+ display = Proc.new do
57
+ glClear(GL_COLOR_BUFFER_BIT)
58
+ glColor(1.0, 1.0, 1.0)
59
+
60
+ glLoadIdentity()
61
+ glColor(1.0, 1.0, 1.0)
62
+ draw_triangle()
63
+
64
+ glEnable(GL_LINE_STIPPLE)
65
+ glLineStipple(1, 0xF0F0)
66
+ glLoadIdentity()
67
+ glTranslate(-20.0, 0.0, 0.0)
68
+ draw_triangle()
69
+
70
+ glLineStipple(1, 0xF00F)
71
+ glLoadIdentity()
72
+ glScale(1.5, 0.5, 1.0)
73
+ draw_triangle()
74
+
75
+ glLineStipple(1, 0x8888)
76
+ glLoadIdentity()
77
+ glRotate(90.0, 0.0, 0.0, 1.0)
78
+ draw_triangle()
79
+ glDisable(GL_LINE_STIPPLE)
80
+
81
+ glutSwapBuffers()
82
+ end
87
83
 
88
- reshape = Proc.new { |w, h|
89
- GL.Viewport(0, 0, w, h);
90
- GL.MatrixMode(GL::PROJECTION);
91
- GL.LoadIdentity();
92
- if (w <= h)
93
- GL.Ortho(-50.0, 50.0, -50.0*h/w,
94
- 50.0*h/w, -1.0, 1.0);
95
- else
96
- GL.Ortho(-50.0*w/h,
97
- 50.0*w/h, -50.0, 50.0, -1.0, 1.0);
98
- end
99
- GL.MatrixMode(GL::MODELVIEW);
100
- }
84
+ reshape = Proc.new do |w, h|
85
+ glViewport(0, 0, w, h)
86
+ glMatrixMode(GL_PROJECTION)
87
+ glLoadIdentity()
88
+ if (w <= h)
89
+ glOrtho(-50.0, 50.0, -50.0*h/w, 50.0*h/w, -1.0, 1.0)
90
+ else
91
+ glOrtho(-50.0*w/h,50.0*w/h, -50.0, 50.0, -1.0, 1.0)
92
+ end
93
+ glMatrixMode(GL_MODELVIEW)
94
+ end
101
95
 
102
- # ARGSUSED1 */
103
- keyboard = Proc.new {|key, x, y|
104
- case key
105
- when 27
106
- exit(0);
107
- end
108
- }
96
+ keyboard = Proc.new do |key, x, y|
97
+ case key
98
+ when 27
99
+ exit(0)
100
+ end
101
+ end
109
102
 
110
- GLUT.Init
111
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
112
- GLUT.InitWindowSize(500, 500);
113
- GLUT.InitWindowPosition(100, 100);
114
- GLUT.CreateWindow($0);
115
- init();
116
- GLUT.DisplayFunc(display);
117
- GLUT.ReshapeFunc(reshape);
118
- GLUT.KeyboardFunc(keyboard);
119
- GLUT.MainLoop();
103
+ # main
104
+ glutInit()
105
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
106
+ glutInitWindowSize(500, 500)
107
+ glutInitWindowPosition(100, 100)
108
+ glutCreateWindow($0)
109
+ init()
110
+ glutDisplayFunc(display)
111
+ glutReshapeFunc(reshape)
112
+ glutKeyboardFunc(keyboard)
113
+ glutMainLoop()
@@ -33,8 +33,6 @@
33
33
  # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
34
  #
35
35
  # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
- #/
37
-
38
36
  #
39
37
  # movelight.c
40
38
  # This program demonstrates when to issue lighting and
@@ -49,92 +47,86 @@
49
47
  # Interaction: pressing the left mouse button alters
50
48
  # the modeling transformation (x rotation) by 30 degrees.
51
49
  # The scene is then redrawn with the light in a new position.
52
- #/
53
50
 
54
- require "gl_prev"
55
- require "glu_prev"
56
- require "glut_prev"
57
- require "rational"
58
- require "mathn"
51
+ require 'opengl'
52
+ require 'rational'
53
+ require 'mathn'
54
+ include Gl,Glu,Glut
59
55
 
60
- $spin = 0;
56
+ $spin = 0
61
57
 
62
58
  # Initialize material property, light source, lighting model,
63
59
  # and depth buffer.
64
- #/
65
60
  def init
66
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
67
- GL.ShadeModel(GL::SMOOTH);
68
- GL.Enable(GL::LIGHTING);
69
- GL.Enable(GL::LIGHT0);
70
- GL.Enable(GL::DEPTH_TEST);
61
+ glClearColor(0.0, 0.0, 0.0, 0.0)
62
+ glShadeModel(GL_SMOOTH)
63
+ glEnable(GL_LIGHTING)
64
+ glEnable(GL_LIGHT0)
65
+ glEnable(GL_DEPTH_TEST)
71
66
  end
72
67
 
73
68
  # Here is where the light position is reset after the modeling
74
69
  # transformation (glRotated) is called. This places the
75
70
  # light at a new position in world coordinates. The cube
76
71
  # represents the position of the light.
77
- #/
78
- display = Proc.new {
79
- position = [ 0.0, 0.0, 1.5, 1.0 ];
80
-
81
- GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
82
- GL.PushMatrix();
83
- GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
84
-
85
- GL.PushMatrix();
86
- GL.Rotate($spin, 1.0, 0.0, 0.0);
87
- GL.Light(GL::LIGHT0, GL::POSITION, position);
88
-
89
- GL.Translate(0.0, 0.0, 1.5);
90
- GL.Disable(GL::LIGHTING);
91
- GL.Color(0.0, 1.0, 1.0);
92
- GLUT.WireCube(0.1);
93
- GL.Enable(GL::LIGHTING);
94
- GL.PopMatrix();
95
-
96
- GLUT.SolidTorus(0.275, 0.85, 8, 15);
97
- GL.PopMatrix();
98
- GL.Flush();
99
- }
72
+ display = Proc.new do
73
+ position = [ 0.0, 0.0, 1.5, 1.0 ]
74
+
75
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
76
+ glPushMatrix()
77
+ GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
78
+
79
+ glPushMatrix()
80
+ glRotate($spin, 1.0, 0.0, 0.0)
81
+ glLight(GL_LIGHT0, GL_POSITION, position)
82
+
83
+ glTranslate(0.0, 0.0, 1.5)
84
+ glDisable(GL_LIGHTING)
85
+ glColor(0.0, 1.0, 1.0)
86
+ glutWireCube(0.1)
87
+ glEnable(GL_LIGHTING)
88
+ glPopMatrix()
89
+
90
+ glutSolidTorus(0.275, 0.85, 8, 15)
91
+ glPopMatrix()
92
+ glutSwapBuffers()
93
+ end
100
94
 
101
- reshape = Proc.new {|w, h|
102
- GL.Viewport(0, 0, w, h);
103
- GL.MatrixMode(GL::PROJECTION);
104
- GL.LoadIdentity();
105
- # GLU.Perspective(40.0, Rational(w,h), 1.0, 20.0);
106
- GLU.Perspective(40.0, w/h, 1.0, 20.0);
107
- GL.MatrixMode(GL::MODELVIEW);
108
- GL.LoadIdentity();
109
- }
95
+ reshape = Proc.new do |w, h|
96
+ glViewport(0, 0, w, h)
97
+ glMatrixMode(GL_PROJECTION)
98
+ glLoadIdentity()
99
+ gluPerspective(40.0, w/h, 1.0, 20.0)
100
+ glMatrixMode(GL_MODELVIEW)
101
+ glLoadIdentity()
102
+ end
110
103
 
111
- # ARGSUSED2 */
112
- mouse = Proc.new {|button, state, x, y|
113
- case button
114
- when GLUT::LEFT_BUTTON
115
- if (state == GLUT::DOWN)
116
- $spin = ($spin + 30) % 360;
117
- GLUT.PostRedisplay();
118
- end
119
- end
120
- }
104
+ mouse = Proc.new do |button, state, x, y|
105
+ case button
106
+ when GLUT_LEFT_BUTTON
107
+ if (state == GLUT_DOWN)
108
+ $spin = ($spin + 30) % 360
109
+ glutPostRedisplay()
110
+ end
111
+ end
112
+ end
121
113
 
122
- # ARGSUSED1 */
123
- keyboard = Proc.new {|key, x, y|
124
- case key
125
- when 27
126
- exit(0);
127
- end
128
- }
114
+ keyboard = Proc.new do |key, x, y|
115
+ case key
116
+ when 27
117
+ exit(0)
118
+ end
119
+ end
129
120
 
130
- GLUT.Init
131
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
132
- GLUT.InitWindowSize(500, 500);
133
- GLUT.InitWindowPosition(100, 100);
134
- GLUT.CreateWindow($0);
135
- init();
136
- GLUT.DisplayFunc(display);
137
- GLUT.ReshapeFunc(reshape);
138
- GLUT.MouseFunc(mouse);
139
- GLUT.KeyboardFunc(keyboard);
140
- GLUT.MainLoop();
121
+ # main
122
+ glutInit
123
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
124
+ glutInitWindowSize(500, 500)
125
+ glutInitWindowPosition(100, 100)
126
+ glutCreateWindow($0)
127
+ init()
128
+ glutDisplayFunc(display)
129
+ glutReshapeFunc(reshape)
130
+ glutMouseFunc(mouse)
131
+ glutKeyboardFunc(keyboard)
132
+ glutMainLoop()