opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +2 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/1.9/opengl.so +0 -0
  103. data/lib/opengl/2.0/opengl.so +0 -0
  104. data/lib/opengl/2.1/opengl.so +0 -0
  105. data/lib/opengl/test_case.rb +1 -2
  106. data/test/dummy.xorg.conf +140 -0
  107. data/test/test_gl.rb +18 -22
  108. data/test/test_gl_10_11.rb +220 -220
  109. data/test/test_gl_12.rb +11 -122
  110. data/test/test_gl_13.rb +202 -210
  111. data/test/test_gl_14.rb +16 -19
  112. data/test/test_gl_15.rb +2 -4
  113. data/test/test_gl_20.rb +45 -58
  114. data/test/test_gl_21.rb +46 -163
  115. data/test/test_gl_ext_arb.rb +54 -72
  116. data/test/test_gl_ext_ati.rb +0 -2
  117. data/test/test_gl_ext_ext.rb +66 -66
  118. data/test/test_gl_ext_gremedy.rb +8 -15
  119. data/test/test_gl_ext_nv.rb +109 -112
  120. data/test/test_opengl_buffer.rb +8 -25
  121. data/utils/README +0 -5
  122. data/utils/enumgen.rb +72 -76
  123. data/utils/extlistgen.rb +55 -55
  124. metadata +90 -67
  125. metadata.gz.sig +0 -0
  126. data/Rakefile.cross +0 -107
  127. data/docs/build_install.txt +0 -119
  128. data/docs/extensions.txt.in +0 -348
  129. data/docs/history.txt +0 -66
  130. data/docs/requirements_and_design.txt +0 -117
  131. data/docs/roadmap.txt +0 -28
  132. data/docs/scientific_use.txt +0 -35
  133. data/docs/supplies/page_template.html +0 -71
  134. data/docs/thanks.txt +0 -29
  135. data/docs/tutorial.txt +0 -469
  136. data/ext/opengl/glu-enums.c +0 -164
  137. data/ext/opengl/glu-enums.h +0 -463
  138. data/ext/opengl/glu.c +0 -1534
  139. data/ext/opengl/glut.c +0 -1145
  140. data/ext/opengl/glut_callbacks.c +0 -845
  141. data/lib/glu.rb +0 -1
  142. data/lib/glut.rb +0 -1
  143. data/lib/opengl/opengl.so +0 -0
  144. data/test/test_glu.rb +0 -309
  145. data/utils/mkdn2html.rb +0 -59
  146. data/utils/post-mkdn2html.rb +0 -91
  147. data/website/images/ogl.jpg +0 -0
  148. data/website/images/tab_bottom.gif +0 -0
  149. data/website/style.css +0 -198
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # (c) Copyright 1993, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
5
  # any purpose and without fee is hereby granted, provided that the above
6
6
  # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
7
+ # and this permission notice appear in supporting documentation, and that
8
8
  # the name of Silicon Graphics, Inc. not be used in advertising
9
9
  # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
10
+ # written prior permission.
11
11
  #
12
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,
@@ -21,8 +21,8 @@
21
21
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
22
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
23
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
24
+ #
25
+ # US Government Users Restricted Rights
26
26
  # Use, duplication, or disclosure by the Government is subject to
27
27
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
28
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -36,10 +36,12 @@
36
36
  #
37
37
  #
38
38
  # surface.c
39
- # This program draws a NURBS surface in the shape of a
39
+ # This program draws a NURBS surface in the shape of a
40
40
  # symmetrical hill.
41
41
  #
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  $ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
@@ -50,104 +52,104 @@ $theNurb = nil
50
52
  # Initializes the control points of the surface to a small hill.
51
53
  # The control points range from -3 to +3 in x, y, and z
52
54
  def init_surface
53
- for u in 0..3
54
- for v in 0..3
55
- $ctlpoints[u][v][0] = 2.0*(u - 1.5)
56
- $ctlpoints[u][v][1] = 2.0*(v - 1.5)
57
-
58
- if ( (u == 1 || u == 2) && (v == 1 || v == 2))
59
- $ctlpoints[u][v][2] = 3
60
- else
61
- $ctlpoints[u][v][2] = -3
62
- end
63
- end
64
- end
65
- end
66
-
55
+ for u in 0..3
56
+ for v in 0..3
57
+ $ctlpoints[u][v][0] = 2.0*(u - 1.5)
58
+ $ctlpoints[u][v][1] = 2.0*(v - 1.5)
59
+
60
+ if ( (u == 1 || u == 2) && (v == 1 || v == 2))
61
+ $ctlpoints[u][v][2] = 3
62
+ else
63
+ $ctlpoints[u][v][2] = -3
64
+ end
65
+ end
66
+ end
67
+ end
68
+
67
69
  # Initialize material property and depth buffer.
68
70
  def myinit
69
- mat_diffuse = [ 0.7, 0.7, 0.7, 1.0 ]
70
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
71
- mat_shininess = [ 100.0 ]
72
-
73
- glClearColor(0.0, 0.0, 0.0, 1.0)
74
- glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
75
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
76
- glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
77
-
78
- glEnable(GL_LIGHTING)
79
- glEnable(GL_LIGHT0)
80
- glDepthFunc(GL_LESS)
81
- glEnable(GL_DEPTH_TEST)
82
- glEnable(GL_AUTO_NORMAL)
83
- glEnable(GL_NORMALIZE)
84
-
85
- init_surface()
86
-
87
- $theNurb = gluNewNurbsRenderer()
88
- gluNurbsProperty($theNurb, GLU_SAMPLING_TOLERANCE, 25.0)
89
- gluNurbsProperty($theNurb, GLU_DISPLAY_MODE, GLU_FILL)
71
+ mat_diffuse = [ 0.7, 0.7, 0.7, 1.0 ]
72
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
73
+ mat_shininess = [ 100.0 ]
74
+
75
+ glClearColor(0.0, 0.0, 0.0, 1.0)
76
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
77
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
78
+ glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
79
+
80
+ glEnable(GL_LIGHTING)
81
+ glEnable(GL_LIGHT0)
82
+ glDepthFunc(GL_LESS)
83
+ glEnable(GL_DEPTH_TEST)
84
+ glEnable(GL_AUTO_NORMAL)
85
+ glEnable(GL_NORMALIZE)
86
+
87
+ init_surface()
88
+
89
+ $theNurb = gluNewNurbsRenderer()
90
+ gluNurbsProperty($theNurb, GLU_SAMPLING_TOLERANCE, 25.0)
91
+ gluNurbsProperty($theNurb, GLU_DISPLAY_MODE, GLU_FILL)
90
92
  end
91
93
 
92
94
  display = Proc.new do
93
- knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
94
-
95
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
96
-
97
- glPushMatrix()
98
- glRotate(330.0, 1.0,0.0,0.0)
99
- glScale(0.5, 0.5, 0.5)
100
-
101
- gluBeginSurface($theNurb)
102
- gluNurbsSurface($theNurb,
103
- 8, knots,
104
- 8, knots,
105
- 4 * 3,
106
- 3,
107
- $ctlpoints.flatten,
108
- 4, 4,
109
- GL_MAP2_VERTEX_3)
110
- gluEndSurface($theNurb)
111
-
112
- if($showPoints==1)
113
- glPointSize(5.0)
114
- glDisable(GL_LIGHTING)
115
- glColor(1.0, 1.0, 0.0)
116
- glBegin(GL_POINTS)
117
- for i in 0..3
118
- for j in 0..3
119
- glVertex($ctlpoints[i][j][0], $ctlpoints[i][j][1], $ctlpoints[i][j][2])
120
- end
121
- end
122
- glEnd()
123
- glEnable(GL_LIGHTING)
124
- end
125
-
126
- glPopMatrix()
127
- glutSwapBuffers()
95
+ knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
96
+
97
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
98
+
99
+ glPushMatrix()
100
+ glRotate(330.0, 1.0,0.0,0.0)
101
+ glScale(0.5, 0.5, 0.5)
102
+
103
+ gluBeginSurface($theNurb)
104
+ gluNurbsSurface($theNurb,
105
+ 8, knots,
106
+ 8, knots,
107
+ 4 * 3,
108
+ 3,
109
+ $ctlpoints.flatten,
110
+ 4, 4,
111
+ GL_MAP2_VERTEX_3)
112
+ gluEndSurface($theNurb)
113
+
114
+ if($showPoints==1)
115
+ glPointSize(5.0)
116
+ glDisable(GL_LIGHTING)
117
+ glColor(1.0, 1.0, 0.0)
118
+ glBegin(GL_POINTS)
119
+ for i in 0..3
120
+ for j in 0..3
121
+ glVertex($ctlpoints[i][j][0], $ctlpoints[i][j][1], $ctlpoints[i][j][2])
122
+ end
123
+ end
124
+ glEnd()
125
+ glEnable(GL_LIGHTING)
126
+ end
127
+
128
+ glPopMatrix()
129
+ glutSwapBuffers()
128
130
  end
129
131
 
130
132
  reshape = Proc.new do |w, h|
131
- glViewport(0, 0, w, h)
132
- glMatrixMode(GL_PROJECTION)
133
- glLoadIdentity()
134
- gluPerspective(45.0, w/h, 3.0, 8.0)
135
-
136
- glMatrixMode(GL_MODELVIEW)
137
- glLoadIdentity()
138
- glTranslate(0.0, 0.0, -5.0)
133
+ glViewport(0, 0, w, h)
134
+ glMatrixMode(GL_PROJECTION)
135
+ glLoadIdentity()
136
+ gluPerspective(45.0, w/h, 3.0, 8.0)
137
+
138
+ glMatrixMode(GL_MODELVIEW)
139
+ glLoadIdentity()
140
+ glTranslate(0.0, 0.0, -5.0)
139
141
  end
140
142
 
141
143
  menu = Proc.new do |value|
142
- $showPoints = value
143
- glutPostRedisplay()
144
+ $showPoints = value
145
+ glutPostRedisplay()
144
146
  end
145
147
 
146
148
  keyboard = Proc.new do |key, x, y|
147
- case (key)
148
- when ?\e
149
- exit(0);
150
- end
149
+ case (key)
150
+ when ?\e
151
+ exit(0);
152
+ end
151
153
  end
152
154
 
153
155
  glutInit
@@ -2,14 +2,14 @@
2
2
  # Copyright (c) Mark J. Kilgard, 1994.
3
3
  #
4
4
  # (c) Copyright 1993, Silicon Graphics, Inc.
5
- # ALL RIGHTS RESERVED
6
- # Permission to use, copy, modify, and distribute this software for
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
7
  # any purpose and without fee is hereby granted, provided that the above
8
8
  # copyright notice appear in all copies and that both the copyright notice
9
- # and this permission notice appear in supporting documentation, and that
9
+ # and this permission notice appear in supporting documentation, and that
10
10
  # the name of Silicon Graphics, Inc. not be used in advertising
11
11
  # or publicity pertaining to distribution of the software without specific,
12
- # written prior permission.
12
+ # written prior permission.
13
13
  #
14
14
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
15
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -23,8 +23,8 @@
23
23
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
24
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
25
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
- #
27
- # US Government Users Restricted Rights
26
+ #
27
+ # US Government Users Restricted Rights
28
28
  # Use, duplication, or disclosure by the Government is subject to
29
29
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
30
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -40,85 +40,87 @@
40
40
  # This program renders three lighted, shaded teapots, with
41
41
  # different ambient values.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  # Initialize light source and lighting model.
46
48
  def myinit
47
- light_ambient = [0.0, 0.0, 0.0, 1.0]
48
- light_diffuse = [1.0, 1.0, 1.0, 1.0]
49
- light_specular = [1.0, 1.0, 1.0, 1.0]
50
- # light_position is NOT default value
51
- light_position = [1.0, 0.0, 0.0, 0.0]
52
- global_ambient = [0.75, 0.75, 0.75, 1.0]
53
-
54
- glLight(GL_LIGHT0, GL_AMBIENT, light_ambient)
55
- glLight(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
56
- glLight(GL_LIGHT0, GL_SPECULAR, light_specular)
57
- glLight(GL_LIGHT0, GL_POSITION, light_position)
58
-
59
- glLightModel(GL_LIGHT_MODEL_AMBIENT, global_ambient)
60
-
61
- glFrontFace(GL_CW)
62
- glEnable(GL_LIGHTING)
63
- glEnable(GL_LIGHT0)
64
- glEnable(GL_AUTO_NORMAL)
65
- glEnable(GL_NORMALIZE)
66
- glDepthFunc(GL_LESS)
67
- glEnable(GL_DEPTH_TEST)
49
+ light_ambient = [0.0, 0.0, 0.0, 1.0]
50
+ light_diffuse = [1.0, 1.0, 1.0, 1.0]
51
+ light_specular = [1.0, 1.0, 1.0, 1.0]
52
+ # light_position is NOT default value
53
+ light_position = [1.0, 0.0, 0.0, 0.0]
54
+ global_ambient = [0.75, 0.75, 0.75, 1.0]
55
+
56
+ glLight(GL_LIGHT0, GL_AMBIENT, light_ambient)
57
+ glLight(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
58
+ glLight(GL_LIGHT0, GL_SPECULAR, light_specular)
59
+ glLight(GL_LIGHT0, GL_POSITION, light_position)
60
+
61
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, global_ambient)
62
+
63
+ glFrontFace(GL_CW)
64
+ glEnable(GL_LIGHTING)
65
+ glEnable(GL_LIGHT0)
66
+ glEnable(GL_AUTO_NORMAL)
67
+ glEnable(GL_NORMALIZE)
68
+ glDepthFunc(GL_LESS)
69
+ glEnable(GL_DEPTH_TEST)
68
70
  end
69
71
 
70
72
  display = proc do
71
- low_ambient = [0.1, 0.1, 0.1, 1.0]
72
- more_ambient = [0.4, 0.4, 0.4, 1.0]
73
- most_ambient = [1.0, 1.0, 1.0, 1.0]
74
-
75
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
76
-
77
- # material has small ambient reflection
78
- glMaterial(GL_FRONT, GL_AMBIENT, low_ambient)
79
- glMaterial(GL_FRONT, GL_SHININESS, 40.0)
80
- glPushMatrix()
81
- glTranslate(0.0, 2.0, 0.0)
82
- glutSolidTeapot(1.0)
83
- glPopMatrix()
84
-
85
- # material has moderate ambient reflection
86
- glMaterial(GL_FRONT, GL_AMBIENT, more_ambient)
87
- glPushMatrix()
88
- glTranslate(0.0, 0.0, 0.0)
89
- glutSolidTeapot(1.0)
90
- glPopMatrix()
91
-
92
- # material has large ambient reflection
93
- glMaterial(GL_FRONT, GL_AMBIENT, most_ambient)
94
- glPushMatrix()
95
- glTranslate(0.0, -2.0, 0.0)
96
- glutSolidTeapot(1.0)
97
- glPopMatrix()
98
- glFlush()
73
+ low_ambient = [0.1, 0.1, 0.1, 1.0]
74
+ more_ambient = [0.4, 0.4, 0.4, 1.0]
75
+ most_ambient = [1.0, 1.0, 1.0, 1.0]
76
+
77
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
78
+
79
+ # material has small ambient reflection
80
+ glMaterial(GL_FRONT, GL_AMBIENT, low_ambient)
81
+ glMaterial(GL_FRONT, GL_SHININESS, 40.0)
82
+ glPushMatrix()
83
+ glTranslate(0.0, 2.0, 0.0)
84
+ glutSolidTeapot(1.0)
85
+ glPopMatrix()
86
+
87
+ # material has moderate ambient reflection
88
+ glMaterial(GL_FRONT, GL_AMBIENT, more_ambient)
89
+ glPushMatrix()
90
+ glTranslate(0.0, 0.0, 0.0)
91
+ glutSolidTeapot(1.0)
92
+ glPopMatrix()
93
+
94
+ # material has large ambient reflection
95
+ glMaterial(GL_FRONT, GL_AMBIENT, most_ambient)
96
+ glPushMatrix()
97
+ glTranslate(0.0, -2.0, 0.0)
98
+ glutSolidTeapot(1.0)
99
+ glPopMatrix()
100
+ glFlush()
99
101
  end
100
102
 
101
103
  myReshape = proc do |w, h|
102
- glViewport(0, 0, w, h)
103
- glMatrixMode(GL_PROJECTION)
104
- glLoadIdentity()
105
- if (w <= h)
106
- glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -10.0, 10.0)
107
- else
108
- glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -10.0, 10.0)
109
- end
110
- glMatrixMode(GL_MODELVIEW)
104
+ glViewport(0, 0, w, h)
105
+ glMatrixMode(GL_PROJECTION)
106
+ glLoadIdentity()
107
+ if (w <= h)
108
+ glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -10.0, 10.0)
109
+ else
110
+ glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -10.0, 10.0)
111
+ end
112
+ glMatrixMode(GL_MODELVIEW)
111
113
  end
112
114
 
113
115
  keyboard = Proc.new do |key, x, y|
114
- case (key)
115
- when ?\e
116
- exit(0);
117
- end
116
+ case (key)
117
+ when ?\e
118
+ exit(0);
119
+ end
118
120
  end
119
121
 
120
122
  # Main Loop
121
- # Open window with initial window size, title bar,
123
+ # Open window with initial window size, title bar,
122
124
  # RGBA display mode, and handle input events.
123
125
  glutInit()
124
126
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
@@ -40,55 +40,57 @@
40
40
  # This program demonstrates lots of material properties.
41
41
  # A single light source illuminates the objects.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  # Initialize depth buffer, projection matrix, light source, and lighting
46
48
  # model. Do not specify a material property here.
47
49
  def myinit
48
- ambient = [0.0, 0.0, 0.0, 1.0]
49
- diffuse = [1.0, 1.0, 1.0, 1.0]
50
- position = [0.0, 3.0, 3.0, 0.0]
51
-
52
- lmodel_ambient = [0.2, 0.2, 0.2, 1.0]
53
- local_view = [0.0]
54
-
55
- glLight(GL_LIGHT0, GL_AMBIENT, ambient)
56
- glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
57
- glLight(GL_LIGHT0, GL_POSITION, position)
58
- glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
59
- glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
60
-
61
- glFrontFace(GL_CW)
62
- glEnable(GL_LIGHTING)
63
- glEnable(GL_LIGHT0)
64
- glEnable(GL_AUTO_NORMAL)
65
- glEnable(GL_NORMALIZE)
66
- glEnable(GL_DEPTH_TEST)
67
- glDepthFunc(GL_LESS)
50
+ ambient = [0.0, 0.0, 0.0, 1.0]
51
+ diffuse = [1.0, 1.0, 1.0, 1.0]
52
+ position = [0.0, 3.0, 3.0, 0.0]
53
+
54
+ lmodel_ambient = [0.2, 0.2, 0.2, 1.0]
55
+ local_view = [0.0]
56
+
57
+ glLight(GL_LIGHT0, GL_AMBIENT, ambient)
58
+ glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
59
+ glLight(GL_LIGHT0, GL_POSITION, position)
60
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
61
+ glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
62
+
63
+ glFrontFace(GL_CW)
64
+ glEnable(GL_LIGHTING)
65
+ glEnable(GL_LIGHT0)
66
+ glEnable(GL_AUTO_NORMAL)
67
+ glEnable(GL_NORMALIZE)
68
+ glEnable(GL_DEPTH_TEST)
69
+ glDepthFunc(GL_LESS)
68
70
  end
69
71
 
70
72
  # Move object into position. Use 3rd through 12th parameters to specify the
71
73
  # material property. Draw a teapot.
72
74
  def renderTeapot(x, y, ambr, ambg, ambb, difr, difg, difb, specr, specg, specb, shine)
73
- mat = []
74
- glPushMatrix()
75
- glTranslate(x, y, 0.0)
76
- mat[0] = ambr
77
- mat[1] = ambg
78
- mat[2] = ambb
79
- mat[3] = 1.0
80
- glMaterial(GL_FRONT, GL_AMBIENT, mat)
81
- mat[0] = difr
82
- mat[1] = difg
83
- mat[2] = difb
84
- glMaterial(GL_FRONT, GL_DIFFUSE, mat)
85
- mat[0] = specr
86
- mat[1] = specg
87
- mat[2] = specb
88
- glMaterial(GL_FRONT, GL_SPECULAR, mat)
89
- glMaterial(GL_FRONT, GL_SHININESS, shine * 128.0)
90
- glutSolidTeapot(1.0)
91
- glPopMatrix()
75
+ mat = []
76
+ glPushMatrix()
77
+ glTranslate(x, y, 0.0)
78
+ mat[0] = ambr
79
+ mat[1] = ambg
80
+ mat[2] = ambb
81
+ mat[3] = 1.0
82
+ glMaterial(GL_FRONT, GL_AMBIENT, mat)
83
+ mat[0] = difr
84
+ mat[1] = difg
85
+ mat[2] = difb
86
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat)
87
+ mat[0] = specr
88
+ mat[1] = specg
89
+ mat[2] = specb
90
+ glMaterial(GL_FRONT, GL_SPECULAR, mat)
91
+ glMaterial(GL_FRONT, GL_SHININESS, shine * 128.0)
92
+ glutSolidTeapot(1.0)
93
+ glPopMatrix()
92
94
  end
93
95
 
94
96
  # First column: emerald, jade, obsidian, pearl, ruby, turquoise
@@ -96,76 +98,76 @@ end
96
98
  # 3rd column: black, cyan, green, red, white, yellow plastic
97
99
  # 4th column: black, cyan, green, red, white, yellow rubber
98
100
  display = proc do
99
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
100
- renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215,
101
- 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6)
102
- renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575,
103
- 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1)
104
- renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625,
105
- 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3)
106
- renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725,
107
- 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088)
108
- renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175,
109
- 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6)
110
- renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745,
111
- 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1)
112
- renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451,
113
- 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843,
114
- 0.21794872)
115
- renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054,
116
- 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2)
117
- renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25,
118
- 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6)
119
- renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225,
120
- 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1)
121
- renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745,
122
- 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4)
123
- renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225,
124
- 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4)
125
- renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01,
126
- 0.50, 0.50, 0.50, 0.25)
127
- renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392,
128
- 0.50196078, 0.50196078, 0.50196078, 0.25)
129
- renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0,
130
- 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, 0.25)
131
- renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
132
- 0.7, 0.6, 0.6, 0.25)
133
- renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55,
134
- 0.70, 0.70, 0.70, 0.25)
135
- renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0,
136
- 0.60, 0.60, 0.50, 0.25)
137
- renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
138
- 0.4, 0.4, 0.4, 0.078125)
139
- renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5,
140
- 0.04, 0.7, 0.7, 0.078125)
141
- renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4,
142
- 0.04, 0.7, 0.04, 0.078125)
143
- renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4,
144
- 0.7, 0.04, 0.04, 0.078125)
145
- renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5,
146
- 0.7, 0.7, 0.7, 0.078125)
147
- renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4,
148
- 0.7, 0.7, 0.04, 0.078125)
149
- glutSwapBuffers()
101
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
102
+ renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215,
103
+ 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6)
104
+ renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575,
105
+ 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1)
106
+ renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625,
107
+ 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3)
108
+ renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725,
109
+ 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088)
110
+ renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175,
111
+ 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6)
112
+ renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745,
113
+ 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1)
114
+ renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451,
115
+ 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843,
116
+ 0.21794872)
117
+ renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054,
118
+ 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2)
119
+ renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25,
120
+ 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6)
121
+ renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225,
122
+ 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1)
123
+ renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745,
124
+ 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4)
125
+ renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225,
126
+ 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4)
127
+ renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01,
128
+ 0.50, 0.50, 0.50, 0.25)
129
+ renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392,
130
+ 0.50196078, 0.50196078, 0.50196078, 0.25)
131
+ renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0,
132
+ 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, 0.25)
133
+ renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
134
+ 0.7, 0.6, 0.6, 0.25)
135
+ renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55,
136
+ 0.70, 0.70, 0.70, 0.25)
137
+ renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0,
138
+ 0.60, 0.60, 0.50, 0.25)
139
+ renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
140
+ 0.4, 0.4, 0.4, 0.078125)
141
+ renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5,
142
+ 0.04, 0.7, 0.7, 0.078125)
143
+ renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4,
144
+ 0.04, 0.7, 0.04, 0.078125)
145
+ renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4,
146
+ 0.7, 0.04, 0.04, 0.078125)
147
+ renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5,
148
+ 0.7, 0.7, 0.7, 0.078125)
149
+ renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4,
150
+ 0.7, 0.7, 0.04, 0.078125)
151
+ glutSwapBuffers()
150
152
  end
151
153
 
152
154
  myReshape = proc do |w, h|
153
- glViewport(0, 0, w, h)
154
- glMatrixMode(GL_PROJECTION)
155
- glLoadIdentity()
156
- if (w <= h)
157
- glOrtho(0.0, 16.0, 0.0, 16.0 * h.to_f / w, -10.0, 10.0)
158
- else
159
- glOrtho(0.0, 16.0 * w.to_f / h, 0.0, 16.0,-10.0, 10.0)
160
- end
161
- glMatrixMode(GL_MODELVIEW)
155
+ glViewport(0, 0, w, h)
156
+ glMatrixMode(GL_PROJECTION)
157
+ glLoadIdentity()
158
+ if (w <= h)
159
+ glOrtho(0.0, 16.0, 0.0, 16.0 * h.to_f / w, -10.0, 10.0)
160
+ else
161
+ glOrtho(0.0, 16.0 * w.to_f / h, 0.0, 16.0,-10.0, 10.0)
162
+ end
163
+ glMatrixMode(GL_MODELVIEW)
162
164
  end
163
165
 
164
166
  keyboard = Proc.new do |key, x, y|
165
- case (key)
166
- when ?\e
167
- exit(0);
168
- end
167
+ case (key)
168
+ when ?\e
169
+ exit(0);
170
+ end
169
171
  end
170
172
 
171
173
  # Main Loop Open window with initial window size, title bar, RGBA display