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
  # 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
@@ -36,96 +36,98 @@
36
36
  #
37
37
  # aapoly.c
38
38
  # This program draws filled polygons with antialiased
39
- # edges. The special GL_SRC_ALPHA_SATURATE blending
39
+ # edges. The special GL_SRC_ALPHA_SATURATE blending
40
40
  # function is used.
41
41
  # Pressing the 't' key turns the antialiasing on and off.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  $polySmooth = true
46
48
 
47
49
  def init
48
- glCullFace(GL_BACK)
49
- glEnable(GL_CULL_FACE)
50
- glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE)
51
- glClearColor(0.0, 0.0, 0.0, 0.0)
50
+ glCullFace(GL_BACK)
51
+ glEnable(GL_CULL_FACE)
52
+ glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE)
53
+ glClearColor(0.0, 0.0, 0.0, 0.0)
52
54
  end
53
55
 
54
56
  NFACE=6
55
57
  NVERT=8
56
58
  $indices = [
57
- [4, 5, 6, 7], [2, 3, 7, 6], [0, 4, 7, 3],
58
- [0, 1, 5, 4], [1, 5, 6, 2], [0, 3, 2, 1]
59
+ [4, 5, 6, 7], [2, 3, 7, 6], [0, 4, 7, 3],
60
+ [0, 1, 5, 4], [1, 5, 6, 2], [0, 3, 2, 1]
59
61
  ]
60
62
 
61
63
  def drawCube(x0, x1, y0, y1, z0, z1)
62
- v = [[],[],[],[],[],[],[],[]]
63
- c = [
64
- [0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0],
65
- [0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 0.0, 1.0],
66
- [0.0, 0.0, 1.0, 1.0], [1.0, 0.0, 1.0, 1.0],
67
- [0.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]
68
- ]
69
-
70
- # indices of front, top, left, bottom, right, back faces
71
-
72
- v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0
73
- v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1
74
- v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0
75
- v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1
76
- v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0
77
- v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1
78
-
79
- glEnableClientState(GL_VERTEX_ARRAY)
80
- glEnableClientState(GL_COLOR_ARRAY)
81
- glVertexPointer(3, GL_FLOAT, 0, v.flatten!.pack("f*"))
82
- glColorPointer(4, GL_FLOAT, 0, c.flatten!.pack("f*"))
83
- glDrawElements(GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, $indices.flatten.pack("C*"))
84
- glDisableClientState(GL_VERTEX_ARRAY)
85
- glDisableClientState(GL_COLOR_ARRAY)
64
+ v = [[],[],[],[],[],[],[],[]]
65
+ c = [
66
+ [0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0],
67
+ [0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 0.0, 1.0],
68
+ [0.0, 0.0, 1.0, 1.0], [1.0, 0.0, 1.0, 1.0],
69
+ [0.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]
70
+ ]
71
+
72
+ # indices of front, top, left, bottom, right, back faces
73
+
74
+ v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0
75
+ v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1
76
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0
77
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1
78
+ v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0
79
+ v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1
80
+
81
+ glEnableClientState(GL_VERTEX_ARRAY)
82
+ glEnableClientState(GL_COLOR_ARRAY)
83
+ glVertexPointer(3, GL_FLOAT, 0, v.flatten!.pack("f*"))
84
+ glColorPointer(4, GL_FLOAT, 0, c.flatten!.pack("f*"))
85
+ glDrawElements(GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, $indices.flatten.pack("C*"))
86
+ glDisableClientState(GL_VERTEX_ARRAY)
87
+ glDisableClientState(GL_COLOR_ARRAY)
86
88
  end
87
89
 
88
90
  # Note: polygons must be drawn from front to back
89
91
  # for proper blending.
90
92
  display = proc do
91
- if ($polySmooth)
92
- glClear(GL_COLOR_BUFFER_BIT)
93
- glEnable(GL_BLEND)
94
- glEnable(GL_POLYGON_SMOOTH)
95
- glDisable(GL_DEPTH_TEST)
96
- else
97
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
98
- glDisable(GL_BLEND)
99
- glDisable(GL_POLYGON_SMOOTH)
100
- glEnable(GL_DEPTH_TEST)
101
- end
102
-
103
- glPushMatrix()
104
- glTranslate(0.0, 0.0, -8.0)
105
- glRotate(30.0, 1.0, 0.0, 0.0)
106
- glRotate(60.0, 0.0, 1.0, 0.0)
107
- drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
108
- glPopMatrix()
109
- glutSwapBuffers()
93
+ if ($polySmooth)
94
+ glClear(GL_COLOR_BUFFER_BIT)
95
+ glEnable(GL_BLEND)
96
+ glEnable(GL_POLYGON_SMOOTH)
97
+ glDisable(GL_DEPTH_TEST)
98
+ else
99
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
100
+ glDisable(GL_BLEND)
101
+ glDisable(GL_POLYGON_SMOOTH)
102
+ glEnable(GL_DEPTH_TEST)
103
+ end
104
+
105
+ glPushMatrix()
106
+ glTranslate(0.0, 0.0, -8.0)
107
+ glRotate(30.0, 1.0, 0.0, 0.0)
108
+ glRotate(60.0, 0.0, 1.0, 0.0)
109
+ drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
110
+ glPopMatrix()
111
+ glutSwapBuffers()
110
112
  end
111
113
 
112
114
  reshape = proc do |w, h|
113
- glViewport(0, 0, w, h)
114
- glMatrixMode(GL_PROJECTION)
115
- glLoadIdentity()
116
- gluPerspective(30.0, w.to_f/ h.to_f, 1.0, 20.0)
117
- glMatrixMode(GL_MODELVIEW)
118
- glLoadIdentity()
115
+ glViewport(0, 0, w, h)
116
+ glMatrixMode(GL_PROJECTION)
117
+ glLoadIdentity()
118
+ gluPerspective(30.0, w.to_f/ h.to_f, 1.0, 20.0)
119
+ glMatrixMode(GL_MODELVIEW)
120
+ glLoadIdentity()
119
121
  end
120
122
 
121
123
  keyboard = proc do |key, x, y|
122
- case (key)
123
- when ?t ,?T
124
- $polySmooth = !$polySmooth
125
- glutPostRedisplay()
126
- when ?\e
127
- exit(0) # Escape key
128
- end
124
+ case (key)
125
+ when ?t ,?T
126
+ $polySmooth = !$polySmooth
127
+ glutPostRedisplay()
128
+ when ?\e
129
+ exit(0) # Escape key
130
+ end
129
131
  end
130
132
 
131
133
  # Main Loop
@@ -139,4 +141,3 @@ glutReshapeFunc(reshape)
139
141
  glutKeyboardFunc(keyboard)
140
142
  glutDisplayFunc(display)
141
143
  glutMainLoop()
142
-
@@ -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
@@ -36,9 +36,11 @@
36
36
  #
37
37
  # aargb.c
38
38
  # This program draws shows how to draw anti-aliased lines. It draws
39
- # two diagonal lines to form an X when 'r' is typed in the window,
39
+ # two diagonal lines to form an X when 'r' is typed in the window,
40
40
  # the lines are rotated in opposite directions.
41
41
  require 'opengl'
42
+ require 'glu'
43
+ require 'glut'
42
44
  require 'mathn'
43
45
  include Gl,Glu,Glut
44
46
 
@@ -48,64 +50,64 @@ $rotAngle = 0.0
48
50
  # blending, hint, and line width. Print out implementation
49
51
  # specific info on line width granularity and width.
50
52
  def init
51
- glEnable(GL_LINE_SMOOTH)
52
- glEnable(GL_BLEND)
53
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
54
- glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE)
55
- glLineWidth(1.5)
56
- glClearColor(0.0, 0.0, 0.0, 0.0)
53
+ glEnable(GL_LINE_SMOOTH)
54
+ glEnable(GL_BLEND)
55
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
56
+ glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE)
57
+ glLineWidth(1.5)
58
+ glClearColor(0.0, 0.0, 0.0, 0.0)
57
59
  end
58
60
 
59
61
  # Draw 2 diagonal lines to form an X
60
62
  display = Proc.new do
61
- glClear(GL_COLOR_BUFFER_BIT)
62
-
63
- glColor(0.0, 1.0, 0.0)
64
- glPushMatrix()
65
- glRotate(-$rotAngle, 0.0, 0.0, 0.1)
66
- glBegin(GL_LINES)
67
- glVertex(-0.5, 0.5)
68
- glVertex(0.5, -0.5)
69
- glEnd()
70
- glPopMatrix()
71
-
72
- glColor(0.0, 0.0, 1.0)
73
- glPushMatrix()
74
- glRotate($rotAngle, 0.0, 0.0, 0.1)
75
- glBegin(GL_LINES)
76
- glVertex(0.5, 0.5)
77
- glVertex(-0.5, -0.5)
78
- glEnd()
79
- glPopMatrix()
80
- glutSwapBuffers()
63
+ glClear(GL_COLOR_BUFFER_BIT)
64
+
65
+ glColor(0.0, 1.0, 0.0)
66
+ glPushMatrix()
67
+ glRotate(-$rotAngle, 0.0, 0.0, 0.1)
68
+ glBegin(GL_LINES)
69
+ glVertex(-0.5, 0.5)
70
+ glVertex(0.5, -0.5)
71
+ glEnd()
72
+ glPopMatrix()
73
+
74
+ glColor(0.0, 0.0, 1.0)
75
+ glPushMatrix()
76
+ glRotate($rotAngle, 0.0, 0.0, 0.1)
77
+ glBegin(GL_LINES)
78
+ glVertex(0.5, 0.5)
79
+ glVertex(-0.5, -0.5)
80
+ glEnd()
81
+ glPopMatrix()
82
+ glutSwapBuffers()
81
83
  end
82
84
 
83
85
  reshape = Proc.new do |w, h|
84
- glViewport(0, 0, w, h)
85
- glMatrixMode(GL_PROJECTION)
86
- glLoadIdentity()
87
- if (w <= h)
88
- gluOrtho2D(-1.0, 1.0, -1.0*h/w, 1.0*h/w)
89
- else
90
- gluOrtho2D(-1.0*w/h, 1.0*w/h, -1.0, 1.0)
91
- end
92
- glMatrixMode(GL_MODELVIEW)
93
- glLoadIdentity()
86
+ glViewport(0, 0, w, h)
87
+ glMatrixMode(GL_PROJECTION)
88
+ glLoadIdentity()
89
+ if (w <= h)
90
+ gluOrtho2D(-1.0, 1.0, -1.0*h/w, 1.0*h/w)
91
+ else
92
+ gluOrtho2D(-1.0*w/h, 1.0*w/h, -1.0, 1.0)
93
+ end
94
+ glMatrixMode(GL_MODELVIEW)
95
+ glLoadIdentity()
94
96
  end
95
97
 
96
98
  keyboard = Proc.new do |key, x, y|
97
- case (key)
98
- when ?r,?R
99
- $rotAngle = $rotAngle + 20.0
100
- $rotAngle = 0.0 if ($rotAngle >= 360.0)
101
- glutPostRedisplay()
102
- when ?\e # Escape Key
103
- exit(0)
104
- end
99
+ case (key)
100
+ when ?r,?R
101
+ $rotAngle = $rotAngle + 20.0
102
+ $rotAngle = 0.0 if ($rotAngle >= 360.0)
103
+ glutPostRedisplay()
104
+ when ?\e # Escape Key
105
+ exit(0)
106
+ end
105
107
  end
106
108
 
107
109
  # Main Loop
108
- # Open window with initial window size, title bar,
110
+ # Open window with initial window size, title bar,
109
111
  # RGBA display mode, and handle input events.
110
112
  glutInit
111
113
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
@@ -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
@@ -39,115 +39,117 @@
39
39
  # accanti.c
40
40
 
41
41
  require 'opengl'
42
- require 'jitter'
42
+ require 'glu'
43
+ require 'glut'
44
+ require_relative 'jitter'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  # Initialize lighting and other values.
46
48
  def myinit
47
- mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ]
48
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
49
- light_position = [ 0.0, 0.0, 10.0, 1.0 ]
50
- lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
51
-
52
- glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
53
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
54
- glMaterial(GL_FRONT, GL_SHININESS, 50.0)
55
- glLight(GL_LIGHT0, GL_POSITION, light_position)
56
- glLightModel(GL_LIGHT_MODEL_AMBIENT, lm_ambient)
57
-
58
- glEnable(GL_LIGHTING)
59
- glEnable(GL_LIGHT0)
60
- glDepthFunc(GL_LESS)
61
- glEnable(GL_DEPTH_TEST)
62
- glShadeModel(GL_FLAT)
63
-
64
- glClearColor(0.0, 0.0, 0.0, 0.0)
65
- glClearAccum(0.0, 0.0, 0.0, 0.0)
49
+ mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ]
50
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
51
+ light_position = [ 0.0, 0.0, 10.0, 1.0 ]
52
+ lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
53
+
54
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
55
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
56
+ glMaterial(GL_FRONT, GL_SHININESS, 50.0)
57
+ glLight(GL_LIGHT0, GL_POSITION, light_position)
58
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, lm_ambient)
59
+
60
+ glEnable(GL_LIGHTING)
61
+ glEnable(GL_LIGHT0)
62
+ glDepthFunc(GL_LESS)
63
+ glEnable(GL_DEPTH_TEST)
64
+ glShadeModel(GL_FLAT)
65
+
66
+ glClearColor(0.0, 0.0, 0.0, 0.0)
67
+ glClearAccum(0.0, 0.0, 0.0, 0.0)
66
68
  end
67
69
 
68
70
  def displayObjects
69
- torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
70
- cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ]
71
- sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ]
72
- octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ]
73
-
74
- glPushMatrix()
75
- glRotate(30.0, 1.0, 0.0, 0.0)
76
-
77
- glPushMatrix()
78
- glTranslate(-0.80, 0.35, 0.0)
79
- glRotate(100.0, 1.0, 0.0, 0.0)
80
- glMaterial(GL_FRONT, GL_DIFFUSE, torus_diffuse)
81
- glutSolidTorus(0.275, 0.85, 16, 16)
82
- glPopMatrix()
83
-
84
- glPushMatrix()
85
- glTranslate(-0.75, -0.50, 0.0)
86
- glRotate(45.0, 0.0, 0.0, 1.0)
87
- glRotate(45.0, 1.0, 0.0, 0.0)
88
- glMaterial(GL_FRONT, GL_DIFFUSE, cube_diffuse)
89
- glutSolidCube(1.5)
90
- glPopMatrix()
91
-
92
- glPushMatrix()
93
- glTranslate(0.75, 0.60, 0.0)
94
- glRotate(30.0, 1.0, 0.0, 0.0)
95
- glMaterial(GL_FRONT, GL_DIFFUSE, sphere_diffuse)
96
- glutSolidSphere(1.0, 16, 16)
97
- glPopMatrix()
98
-
99
- glPushMatrix()
100
- glTranslate(0.70, -0.90, 0.25)
101
- glMaterial(GL_FRONT, GL_DIFFUSE, octa_diffuse)
102
- glutSolidOctahedron()
103
- glPopMatrix()
104
-
105
- glPopMatrix()
71
+ torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
72
+ cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ]
73
+ sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ]
74
+ octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ]
75
+
76
+ glPushMatrix()
77
+ glRotate(30.0, 1.0, 0.0, 0.0)
78
+
79
+ glPushMatrix()
80
+ glTranslate(-0.80, 0.35, 0.0)
81
+ glRotate(100.0, 1.0, 0.0, 0.0)
82
+ glMaterial(GL_FRONT, GL_DIFFUSE, torus_diffuse)
83
+ glutSolidTorus(0.275, 0.85, 16, 16)
84
+ glPopMatrix()
85
+
86
+ glPushMatrix()
87
+ glTranslate(-0.75, -0.50, 0.0)
88
+ glRotate(45.0, 0.0, 0.0, 1.0)
89
+ glRotate(45.0, 1.0, 0.0, 0.0)
90
+ glMaterial(GL_FRONT, GL_DIFFUSE, cube_diffuse)
91
+ glutSolidCube(1.5)
92
+ glPopMatrix()
93
+
94
+ glPushMatrix()
95
+ glTranslate(0.75, 0.60, 0.0)
96
+ glRotate(30.0, 1.0, 0.0, 0.0)
97
+ glMaterial(GL_FRONT, GL_DIFFUSE, sphere_diffuse)
98
+ glutSolidSphere(1.0, 16, 16)
99
+ glPopMatrix()
100
+
101
+ glPushMatrix()
102
+ glTranslate(0.70, -0.90, 0.25)
103
+ glMaterial(GL_FRONT, GL_DIFFUSE, octa_diffuse)
104
+ glutSolidOctahedron()
105
+ glPopMatrix()
106
+
107
+ glPopMatrix()
106
108
  end
107
109
 
108
110
  ACSIZE=8
109
111
 
110
112
  myDisplay = proc do
111
- viewport = glGetDoublev(GL_VIEWPORT)
112
-
113
- glClear(GL_ACCUM_BUFFER_BIT)
114
- for jitter in 0...ACSIZE
115
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
116
- glPushMatrix()
117
- # Note that 4.5 is the distance in world space between
118
- # left and right and bottom and top.
119
- # This formula converts fractional pixel movement to
120
- # world coordinates.
121
- glTranslate($j8[jitter][0]*4.5/viewport[2], $j8[jitter][1]*4.5/viewport[3], 0.0)
122
- displayObjects()
123
- glPopMatrix()
124
- glAccum(GL_ACCUM, 1.0/ACSIZE)
125
- end
126
- glAccum(GL_RETURN, 1.0)
127
- glutSwapBuffers()
113
+ viewport = glGetDoublev(GL_VIEWPORT)
114
+
115
+ glClear(GL_ACCUM_BUFFER_BIT)
116
+ for jitter in 0...ACSIZE
117
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
118
+ glPushMatrix()
119
+ # Note that 4.5 is the distance in world space between
120
+ # left and right and bottom and top.
121
+ # This formula converts fractional pixel movement to
122
+ # world coordinates.
123
+ glTranslate($j8[jitter][0]*4.5/viewport[2], $j8[jitter][1]*4.5/viewport[3], 0.0)
124
+ displayObjects()
125
+ glPopMatrix()
126
+ glAccum(GL_ACCUM, 1.0/ACSIZE)
127
+ end
128
+ glAccum(GL_RETURN, 1.0)
129
+ glutSwapBuffers()
128
130
  end
129
131
 
130
132
  myReshape = proc do |w, h|
131
- glViewport(0, 0, w, h)
132
- glMatrixMode(GL_PROJECTION)
133
- glLoadIdentity()
134
- if (w <= h)
135
- glOrtho(-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0)
136
- else
137
- glOrtho(-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0)
138
- end
139
- glMatrixMode(GL_MODELVIEW)
133
+ glViewport(0, 0, w, h)
134
+ glMatrixMode(GL_PROJECTION)
135
+ glLoadIdentity()
136
+ if (w <= h)
137
+ glOrtho(-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0)
138
+ else
139
+ glOrtho(-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0)
140
+ end
141
+ glMatrixMode(GL_MODELVIEW)
140
142
  end
141
143
 
142
144
  keyboard = Proc.new do |key, x, y|
143
- case (key)
144
- when ?\e
145
- exit(0);
146
- end
145
+ case (key)
146
+ when ?\e
147
+ exit(0);
148
+ end
147
149
  end
148
150
 
149
151
  # Main Loop
150
- # Open window with initial window size, title bar,
152
+ # Open window with initial window size, title bar,
151
153
  # RGBA display mode, and handle input events.
152
154
  #
153
155
  glutInit()