opengl 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -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/test_case.rb +1 -2
  103. data/test/dummy.xorg.conf +140 -0
  104. data/test/test_gl.rb +18 -22
  105. data/test/test_gl_10_11.rb +220 -220
  106. data/test/test_gl_12.rb +11 -122
  107. data/test/test_gl_13.rb +202 -210
  108. data/test/test_gl_14.rb +16 -19
  109. data/test/test_gl_15.rb +2 -4
  110. data/test/test_gl_20.rb +45 -58
  111. data/test/test_gl_21.rb +46 -163
  112. data/test/test_gl_ext_arb.rb +54 -72
  113. data/test/test_gl_ext_ati.rb +0 -2
  114. data/test/test_gl_ext_ext.rb +66 -66
  115. data/test/test_gl_ext_gremedy.rb +8 -15
  116. data/test/test_gl_ext_nv.rb +109 -112
  117. data/test/test_opengl_buffer.rb +8 -25
  118. data/utils/README +0 -5
  119. data/utils/enumgen.rb +72 -76
  120. data/utils/extlistgen.rb +55 -55
  121. metadata +87 -66
  122. metadata.gz.sig +2 -0
  123. data/Rakefile.cross +0 -107
  124. data/docs/build_install.txt +0 -119
  125. data/docs/extensions.txt.in +0 -348
  126. data/docs/history.txt +0 -66
  127. data/docs/requirements_and_design.txt +0 -117
  128. data/docs/roadmap.txt +0 -28
  129. data/docs/scientific_use.txt +0 -35
  130. data/docs/supplies/page_template.html +0 -71
  131. data/docs/thanks.txt +0 -29
  132. data/docs/tutorial.txt +0 -469
  133. data/ext/opengl/glu-enums.c +0 -164
  134. data/ext/opengl/glu-enums.h +0 -463
  135. data/ext/opengl/glu.c +0 -1534
  136. data/ext/opengl/glut.c +0 -1145
  137. data/ext/opengl/glut_callbacks.c +0 -845
  138. data/lib/glu.rb +0 -1
  139. data/lib/glut.rb +0 -1
  140. data/test/test_glu.rb +0 -309
  141. data/utils/mkdn2html.rb +0 -59
  142. data/utils/post-mkdn2html.rb +0 -91
  143. data/website/images/ogl.jpg +0 -0
  144. data/website/images/tab_bottom.gif +0 -0
  145. data/website/style.css +0 -198
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # Copyright (c) 1993-1997, 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
@@ -34,63 +34,65 @@
34
34
  #
35
35
  # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
36
  #
37
- # bezcurve.c
37
+ # bezcurve.c
38
38
  # This program uses evaluators to draw a Bezier curve.
39
39
 
40
40
  require "opengl"
41
+ require 'glu'
42
+ require 'glut'
41
43
  include Gl,Glu,Glut
42
44
 
43
45
  $ctrlpoints = [
44
- [-4.0,-4.0, 0.0],
45
- [-2.0, 4.0, 0.0],
46
- [ 2.0,-4.0, 0.0],
47
- [ 4.0, 4.0, 0.0]
48
- ]
46
+ [-4.0,-4.0, 0.0],
47
+ [-2.0, 4.0, 0.0],
48
+ [ 2.0,-4.0, 0.0],
49
+ [ 4.0, 4.0, 0.0]
50
+ ]
49
51
 
50
52
  def init
51
- glClearColor(0.0, 0.0, 0.0, 0.0)
52
- glShadeModel(GL_FLAT)
53
- glMap1d(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, $ctrlpoints.flatten)
54
- glEnable(GL_MAP1_VERTEX_3)
53
+ glClearColor(0.0, 0.0, 0.0, 0.0)
54
+ glShadeModel(GL_FLAT)
55
+ glMap1d(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, $ctrlpoints.flatten)
56
+ glEnable(GL_MAP1_VERTEX_3)
55
57
  end
56
58
 
57
59
  display = proc do
58
- glClear(GL_COLOR_BUFFER_BIT)
59
- glColor(1.0, 1.0, 1.0)
60
- glBegin(GL_LINE_STRIP)
61
- for i in 0..30
62
- glEvalCoord1d(i.to_f/30.0)
63
- end
64
- glEnd()
65
- # The following code displays the control points as dots.
66
- glPointSize(5.0)
67
- glColor(1.0, 1.0, 0.0)
68
- glBegin(GL_POINTS)
69
- for i in 0...4
70
- glVertex($ctrlpoints[i])
71
- end
72
- glEnd()
73
- glutSwapBuffers()
60
+ glClear(GL_COLOR_BUFFER_BIT)
61
+ glColor(1.0, 1.0, 1.0)
62
+ glBegin(GL_LINE_STRIP)
63
+ for i in 0..30
64
+ glEvalCoord1d(i.to_f/30.0)
65
+ end
66
+ glEnd()
67
+ # The following code displays the control points as dots.
68
+ glPointSize(5.0)
69
+ glColor(1.0, 1.0, 0.0)
70
+ glBegin(GL_POINTS)
71
+ for i in 0...4
72
+ glVertex($ctrlpoints[i])
73
+ end
74
+ glEnd()
75
+ glutSwapBuffers()
74
76
  end
75
77
 
76
78
  reshape = proc do |w, h|
77
- glViewport(0, 0, w, h)
78
- glMatrixMode(GL_PROJECTION)
79
- glLoadIdentity()
80
- if (w <= h)
81
- glOrtho(-5.0, 5.0, -5.0*h/w, 5.0*h/w, -5.0, 5.0)
82
- else
83
- glOrtho(-5.0*w/h, 5.0*w/h, -5.0, 5.0, -5.0, 5.0)
84
- end
85
- glMatrixMode(GL_MODELVIEW)
86
- glLoadIdentity()
79
+ glViewport(0, 0, w, h)
80
+ glMatrixMode(GL_PROJECTION)
81
+ glLoadIdentity()
82
+ if (w <= h)
83
+ glOrtho(-5.0, 5.0, -5.0*h/w, 5.0*h/w, -5.0, 5.0)
84
+ else
85
+ glOrtho(-5.0*w/h, 5.0*w/h, -5.0, 5.0, -5.0, 5.0)
86
+ end
87
+ glMatrixMode(GL_MODELVIEW)
88
+ glLoadIdentity()
87
89
  end
88
90
 
89
91
  keyboard = proc do |key, x, y|
90
- case (key)
91
- when ?\e
92
- exit(0)
93
- end
92
+ case (key)
93
+ when ?\e
94
+ exit(0)
95
+ end
94
96
  end
95
97
 
96
98
  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
@@ -42,87 +42,89 @@
42
42
  #
43
43
 
44
44
  require 'opengl'
45
+ require 'glu'
46
+ require 'glut'
45
47
  include Gl,Glu,Glut
46
48
 
47
49
  $ctrlpoints = [
48
- [
49
- [-1.5, -1.5, 4.0],
50
- [-0.5, -1.5, 2.0],
51
- [0.5, -1.5, -1.0],
52
- [1.5, -1.5, 2.0]],
53
- [
54
- [-1.5, -0.5, 1.0],
55
- [-0.5, -0.5, 3.0],
56
- [0.5, -0.5, 0.0],
57
- [1.5, -0.5, -1.0]],
58
- [
59
- [-1.5, 0.5, 4.0],
60
- [-0.5, 0.5, 0.0],
61
- [0.5, 0.5, 3.0],
62
- [1.5, 0.5, 4.0]],
63
- [
64
- [-1.5, 1.5, -2.0],
65
- [-0.5, 1.5, -2.0],
66
- [0.5, 1.5, 0.0],
67
- [1.5, 1.5, -1.0]]
50
+ [
51
+ [-1.5, -1.5, 4.0],
52
+ [-0.5, -1.5, 2.0],
53
+ [0.5, -1.5, -1.0],
54
+ [1.5, -1.5, 2.0]],
55
+ [
56
+ [-1.5, -0.5, 1.0],
57
+ [-0.5, -0.5, 3.0],
58
+ [0.5, -0.5, 0.0],
59
+ [1.5, -0.5, -1.0]],
60
+ [
61
+ [-1.5, 0.5, 4.0],
62
+ [-0.5, 0.5, 0.0],
63
+ [0.5, 0.5, 3.0],
64
+ [1.5, 0.5, 4.0]],
65
+ [
66
+ [-1.5, 1.5, -2.0],
67
+ [-0.5, 1.5, -2.0],
68
+ [0.5, 1.5, 0.0],
69
+ [1.5, 1.5, -1.0]]
68
70
  ]
69
71
 
70
72
  def initlights
71
- ambient = [0.2, 0.2, 0.2, 1.0]
72
- position = [0.0, 0.0, 2.0, 1.0]
73
- mat_diffuse = [0.6, 0.6, 0.6, 1.0]
74
- mat_specular = [1.0, 1.0, 1.0, 1.0]
75
- mat_shininess = [50.0]
76
-
77
- glEnable(GL_LIGHTING)
78
- glEnable(GL_LIGHT0)
79
-
80
- glLight(GL_LIGHT0, GL_AMBIENT, ambient)
81
- glLight(GL_LIGHT0, GL_POSITION, position)
82
-
83
- glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
84
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
85
- glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
73
+ ambient = [0.2, 0.2, 0.2, 1.0]
74
+ position = [0.0, 0.0, 2.0, 1.0]
75
+ mat_diffuse = [0.6, 0.6, 0.6, 1.0]
76
+ mat_specular = [1.0, 1.0, 1.0, 1.0]
77
+ mat_shininess = [50.0]
78
+
79
+ glEnable(GL_LIGHTING)
80
+ glEnable(GL_LIGHT0)
81
+
82
+ glLight(GL_LIGHT0, GL_AMBIENT, ambient)
83
+ glLight(GL_LIGHT0, GL_POSITION, position)
84
+
85
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
86
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
87
+ glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
86
88
  end
87
89
 
88
90
  display = proc do
89
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
90
- glPushMatrix()
91
- glRotate(85.0, 1.0, 1.0, 1.0)
92
- glEvalMesh2(GL_FILL, 0, 20, 0, 20)
93
- glPopMatrix()
94
- glutSwapBuffers()
91
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
92
+ glPushMatrix()
93
+ glRotate(85.0, 1.0, 1.0, 1.0)
94
+ glEvalMesh2(GL_FILL, 0, 20, 0, 20)
95
+ glPopMatrix()
96
+ glutSwapBuffers()
95
97
  end
96
98
 
97
99
  def myinit
98
- glClearColor(0.0, 0.0, 0.0, 1.0)
99
- glEnable(GL_DEPTH_TEST)
100
- glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints.flatten)
101
- glEnable(GL_MAP2_VERTEX_3)
102
- glEnable(GL_AUTO_NORMAL)
103
- glEnable(GL_NORMALIZE)
104
- glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
105
- initlights() # for lighted version only
100
+ glClearColor(0.0, 0.0, 0.0, 1.0)
101
+ glEnable(GL_DEPTH_TEST)
102
+ glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints.flatten)
103
+ glEnable(GL_MAP2_VERTEX_3)
104
+ glEnable(GL_AUTO_NORMAL)
105
+ glEnable(GL_NORMALIZE)
106
+ glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
107
+ initlights() # for lighted version only
106
108
  end
107
109
 
108
110
  myReshape = proc do |w, h|
109
- glViewport(0, 0, w, h)
110
- glMatrixMode(GL_PROJECTION)
111
- glLoadIdentity()
112
- if (w <= h)
113
- glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -4.0, 4.0)
114
- else
115
- glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -4.0, 4.0)
116
- end
117
- glMatrixMode(GL_MODELVIEW)
118
- glLoadIdentity()
111
+ glViewport(0, 0, w, h)
112
+ glMatrixMode(GL_PROJECTION)
113
+ glLoadIdentity()
114
+ if (w <= h)
115
+ glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -4.0, 4.0)
116
+ else
117
+ glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -4.0, 4.0)
118
+ end
119
+ glMatrixMode(GL_MODELVIEW)
120
+ glLoadIdentity()
119
121
  end
120
122
 
121
123
  keyboard = Proc.new do |key, x, y|
122
- case (key)
123
- when ?\e
124
- exit(0);
125
- end
124
+ case (key)
125
+ when ?\e
126
+ exit(0);
127
+ end
126
128
  end
127
129
 
128
130
  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
@@ -41,75 +41,77 @@
41
41
  # two rectangles. This program clamps the texture, if
42
42
  # the texture coordinates fall outside 0.0 and 1.0.
43
43
  require 'opengl'
44
+ require 'glu'
45
+ require 'glut'
44
46
  require 'mathn'
45
47
  include Gl,Glu,Glut
46
48
 
47
- # Create checkerboard texture
49
+ # Create checkerboard texture
48
50
  CheckImageWidth=64
49
51
  CheckImageHeight=64
50
52
  $checkImage = []
51
53
 
52
54
  def makeCheckImage
53
- for i in 0..CheckImageWidth-1
54
- for j in 0..CheckImageHeight-1
55
- c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
56
- $checkImage[(i+CheckImageWidth*j)*3+0] = c
57
- $checkImage[(i+CheckImageWidth*j)*3+1] = c
58
- $checkImage[(i+CheckImageWidth*j)*3+2] = c
59
- end
60
- end
55
+ for i in 0..CheckImageWidth-1
56
+ for j in 0..CheckImageHeight-1
57
+ c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
58
+ $checkImage[(i+CheckImageWidth*j)*3+0] = c
59
+ $checkImage[(i+CheckImageWidth*j)*3+1] = c
60
+ $checkImage[(i+CheckImageWidth*j)*3+2] = c
61
+ end
62
+ end
61
63
  end
62
64
 
63
65
  def myinit
64
- glClearColor(0.0, 0.0, 0.0, 0.0)
65
- glEnable(GL_DEPTH_TEST)
66
- glDepthFunc(GL_LESS)
67
-
68
- makeCheckImage()
69
- glPixelStore(GL_UNPACK_ALIGNMENT, 1)
70
- glTexImage2D(GL_TEXTURE_2D, 0, 3, CheckImageWidth,
71
- CheckImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
72
- $checkImage.pack("C*"))
73
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
74
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
75
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
76
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
77
- glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
78
- glEnable(GL_TEXTURE_2D)
79
- glShadeModel(GL_FLAT)
66
+ glClearColor(0.0, 0.0, 0.0, 0.0)
67
+ glEnable(GL_DEPTH_TEST)
68
+ glDepthFunc(GL_LESS)
69
+
70
+ makeCheckImage()
71
+ glPixelStore(GL_UNPACK_ALIGNMENT, 1)
72
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, CheckImageWidth,
73
+ CheckImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
74
+ $checkImage.pack("C*"))
75
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
76
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
77
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
78
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
79
+ glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
80
+ glEnable(GL_TEXTURE_2D)
81
+ glShadeModel(GL_FLAT)
80
82
  end
81
83
 
82
84
  display = Proc.new do
83
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
84
- glBegin(GL_QUADS)
85
- glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
86
- glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
87
- glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
88
- glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
89
-
90
- glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
91
- glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
92
- glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
93
- glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
94
- glEnd()
95
- glutSwapBuffers()
85
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
86
+ glBegin(GL_QUADS)
87
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
88
+ glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
89
+ glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
90
+ glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
91
+
92
+ glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
93
+ glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
94
+ glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
95
+ glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
96
+ glEnd()
97
+ glutSwapBuffers()
96
98
  end
97
99
 
98
100
  myReshape = Proc.new do |w, h|
99
- glViewport(0, 0, w, h)
100
- glMatrixMode(GL_PROJECTION)
101
- glLoadIdentity()
102
- gluPerspective(60.0, 1.0*w/h, 1.0, 30.0)
103
- glMatrixMode(GL_MODELVIEW)
104
- glLoadIdentity()
105
- glTranslate(0.0, 0.0, -3.6)
101
+ glViewport(0, 0, w, h)
102
+ glMatrixMode(GL_PROJECTION)
103
+ glLoadIdentity()
104
+ gluPerspective(60.0, 1.0*w/h, 1.0, 30.0)
105
+ glMatrixMode(GL_MODELVIEW)
106
+ glLoadIdentity()
107
+ glTranslate(0.0, 0.0, -3.6)
106
108
  end
107
109
 
108
110
  keyboard = Proc.new do |key, x, y|
109
- case (key)
110
- when ?\e
111
- exit(0)
112
- end
111
+ case (key)
112
+ when ?\e
113
+ exit(0)
114
+ end
113
115
  end
114
116
 
115
117
  glutInit