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
@@ -40,6 +40,8 @@
40
40
  # Interaction: pressing the s and e keys (shoulder and elbow)
41
41
  # alters the rotation of the robot arm.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  require 'mathn'
44
46
  include Gl,Glu,Glut
45
47
 
@@ -47,69 +49,69 @@ $shoulder = 0
47
49
  $elbow = 0
48
50
 
49
51
  def init
50
- glClearColor(0.0, 0.0, 0.0, 0.0)
51
- glShadeModel(GL_FLAT)
52
+ glClearColor(0.0, 0.0, 0.0, 0.0)
53
+ glShadeModel(GL_FLAT)
52
54
  end
53
55
 
54
56
  display = Proc.new do
55
- glClear(GL_COLOR_BUFFER_BIT)
56
- glPushMatrix()
57
- glTranslate(-1.0, 0.0, 0.0)
58
- glRotate($shoulder, 0.0, 0.0, 1.0)
59
- glTranslate(1.0, 0.0, 0.0)
60
- glPushMatrix()
61
- glScale(2.0, 0.4, 1.0)
62
- glutWireCube(1.0)
63
- glPopMatrix()
64
-
65
- glTranslate(1.0, 0.0, 0.0)
66
- glRotate($elbow, 0.0, 0.0, 1.0)
67
- glTranslate(1.0, 0.0, 0.0)
68
- glPushMatrix()
69
- glScale(2.0, 0.4, 1.0)
70
- glutWireCube(1.0)
71
- glPopMatrix()
72
-
73
- glPopMatrix()
74
- glutSwapBuffers()
57
+ glClear(GL_COLOR_BUFFER_BIT)
58
+ glPushMatrix()
59
+ glTranslate(-1.0, 0.0, 0.0)
60
+ glRotate($shoulder, 0.0, 0.0, 1.0)
61
+ glTranslate(1.0, 0.0, 0.0)
62
+ glPushMatrix()
63
+ glScale(2.0, 0.4, 1.0)
64
+ glutWireCube(1.0)
65
+ glPopMatrix()
66
+
67
+ glTranslate(1.0, 0.0, 0.0)
68
+ glRotate($elbow, 0.0, 0.0, 1.0)
69
+ glTranslate(1.0, 0.0, 0.0)
70
+ glPushMatrix()
71
+ glScale(2.0, 0.4, 1.0)
72
+ glutWireCube(1.0)
73
+ glPopMatrix()
74
+
75
+ glPopMatrix()
76
+ glutSwapBuffers()
75
77
  end
76
78
 
77
79
  reshape = Proc.new do |w, h|
78
- glViewport(0, 0, w, h)
79
- glMatrixMode(GL_PROJECTION)
80
- glLoadIdentity()
81
- gluPerspective(65.0, w/ h, 1.0, 20.0)
82
- glMatrixMode(GL_MODELVIEW)
83
- glLoadIdentity()
84
- glTranslate(0.0, 0.0, -5.0)
80
+ glViewport(0, 0, w, h)
81
+ glMatrixMode(GL_PROJECTION)
82
+ glLoadIdentity()
83
+ gluPerspective(65.0, w/ h, 1.0, 20.0)
84
+ glMatrixMode(GL_MODELVIEW)
85
+ glLoadIdentity()
86
+ glTranslate(0.0, 0.0, -5.0)
85
87
  end
86
88
 
87
89
  keyboard = Proc.new do|key, x, y|
88
- case (key)
89
- when ?s
90
- $shoulder = ($shoulder + 5) % 360
91
- glutPostRedisplay()
92
- when ?S
93
- $shoulder = ($shoulder - 5) % 360
94
- glutPostRedisplay()
95
- when ?e
96
- $elbow = ($elbow + 5) % 360
97
- glutPostRedisplay()
98
- when ?E
99
- $elbow = ($elbow - 5) % 360
100
- glutPostRedisplay()
101
- when ?\e
102
- exit(0)
103
- end
90
+ case (key)
91
+ when ?s
92
+ $shoulder = ($shoulder + 5) % 360
93
+ glutPostRedisplay()
94
+ when ?S
95
+ $shoulder = ($shoulder - 5) % 360
96
+ glutPostRedisplay()
97
+ when ?e
98
+ $elbow = ($elbow + 5) % 360
99
+ glutPostRedisplay()
100
+ when ?E
101
+ $elbow = ($elbow - 5) % 360
102
+ glutPostRedisplay()
103
+ when ?\e
104
+ exit(0)
105
+ end
104
106
  end
105
107
 
106
108
  glutInit
107
109
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
108
- glutInitWindowSize(500, 500)
110
+ glutInitWindowSize(500, 500)
109
111
  glutInitWindowPosition(100, 100)
110
112
  glutCreateWindow($0)
111
113
  init()
112
- glutDisplayFunc(display)
114
+ glutDisplayFunc(display)
113
115
  glutReshapeFunc(reshape)
114
116
  glutKeyboardFunc(keyboard)
115
117
  glutMainLoop()
@@ -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,151 +36,153 @@
36
36
  #
37
37
  #
38
38
  # select.c
39
- # This is an illustration of the selection mode and
40
- # name stack, which detects whether objects which collide
41
- # with a viewing volume. First, four triangles and a
42
- # rectangular box representing a viewing volume are drawn
43
- # (drawScene routine). The green triangle and yellow
44
- # triangles appear to lie within the viewing volume, but
45
- # the red triangle appears to lie outside it. Then the
46
- # selection mode is entered (selectObjects routine).
47
- # Drawing to the screen ceases. To see if any collisions
48
- # occur, the four triangles are called. In this example,
49
- # the green triangle causes one hit with the name 1, and
39
+ # This is an illustration of the selection mode and
40
+ # name stack, which detects whether objects which collide
41
+ # with a viewing volume. First, four triangles and a
42
+ # rectangular box representing a viewing volume are drawn
43
+ # (drawScene routine). The green triangle and yellow
44
+ # triangles appear to lie within the viewing volume, but
45
+ # the red triangle appears to lie outside it. Then the
46
+ # selection mode is entered (selectObjects routine).
47
+ # Drawing to the screen ceases. To see if any collisions
48
+ # occur, the four triangles are called. In this example,
49
+ # the green triangle causes one hit with the name 1, and
50
50
  # the yellow triangles cause one hit with the name 3.
51
51
  require 'opengl'
52
+ require 'glu'
53
+ require 'glut'
52
54
  include Gl,Glu,Glut
53
55
 
54
- # draw a triangle with vertices at (x1, y1), (x2, y2)
56
+ # draw a triangle with vertices at (x1, y1), (x2, y2)
55
57
  # and (x3, y3) at z units away from the origin.
56
58
  def drawTriangle(x1, y1, x2, y2, x3, y3, z)
57
- glBegin(GL_TRIANGLES)
58
- glVertex(x1, y1, z)
59
- glVertex(x2, y2, z)
60
- glVertex(x3, y3, z)
61
- glEnd()
59
+ glBegin(GL_TRIANGLES)
60
+ glVertex(x1, y1, z)
61
+ glVertex(x2, y2, z)
62
+ glVertex(x3, y3, z)
63
+ glEnd()
62
64
  end
63
65
 
64
66
  # draw a rectangular box with these outer x, y, and z values
65
67
  def drawViewVolume(x1, x2, y1, y2, z1, z2)
66
- glColor(1.0, 1.0, 1.0)
67
- glBegin(GL_LINE_LOOP)
68
- glVertex(x1, y1, -z1)
69
- glVertex(x2, y1, -z1)
70
- glVertex(x2, y2, -z1)
71
- glVertex(x1, y2, -z1)
72
- glEnd()
73
-
74
- glBegin(GL_LINE_LOOP)
75
- glVertex(x1, y1, -z2)
76
- glVertex(x2, y1, -z2)
77
- glVertex(x2, y2, -z2)
78
- glVertex(x1, y2, -z2)
79
- glEnd()
80
-
81
- glBegin(GL_LINES)# 4 lines
82
- glVertex(x1, y1, -z1)
83
- glVertex(x1, y1, -z2)
84
- glVertex(x1, y2, -z1)
85
- glVertex(x1, y2, -z2)
86
- glVertex(x2, y1, -z1)
87
- glVertex(x2, y1, -z2)
88
- glVertex(x2, y2, -z1)
89
- glVertex(x2, y2, -z2)
90
- glEnd()
68
+ glColor(1.0, 1.0, 1.0)
69
+ glBegin(GL_LINE_LOOP)
70
+ glVertex(x1, y1, -z1)
71
+ glVertex(x2, y1, -z1)
72
+ glVertex(x2, y2, -z1)
73
+ glVertex(x1, y2, -z1)
74
+ glEnd()
75
+
76
+ glBegin(GL_LINE_LOOP)
77
+ glVertex(x1, y1, -z2)
78
+ glVertex(x2, y1, -z2)
79
+ glVertex(x2, y2, -z2)
80
+ glVertex(x1, y2, -z2)
81
+ glEnd()
82
+
83
+ glBegin(GL_LINES)# 4 lines
84
+ glVertex(x1, y1, -z1)
85
+ glVertex(x1, y1, -z2)
86
+ glVertex(x1, y2, -z1)
87
+ glVertex(x1, y2, -z2)
88
+ glVertex(x2, y1, -z1)
89
+ glVertex(x2, y1, -z2)
90
+ glVertex(x2, y2, -z1)
91
+ glVertex(x2, y2, -z2)
92
+ glEnd()
91
93
  end
92
94
 
93
95
  # drawScene draws 4 triangles and a wire frame
94
96
  # which represents the viewing volume.
95
97
  def drawScene()
96
- glMatrixMode(GL_PROJECTION)
97
- glLoadIdentity()
98
- gluPerspective(40.0, 4.0/3.0, 1.0, 100.0)
99
-
100
- glMatrixMode(GL_MODELVIEW)
101
- glLoadIdentity()
102
- gluLookAt(7.5, 7.5, 12.5, 2.5, 2.5, -5.0, 0.0, 1.0, 0.0)
103
- glColor(0.0, 1.0, 0.0)# green triangle
104
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0)
105
- glColor(1.0, 0.0, 0.0)# red triangle
106
- drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0)
107
- glColor(1.0, 1.0, 0.0)# yellow triangles
108
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0)
109
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0)
110
- drawViewVolume(0.0, 5.0, 0.0, 5.0, 0.0, 10.0)
98
+ glMatrixMode(GL_PROJECTION)
99
+ glLoadIdentity()
100
+ gluPerspective(40.0, 4.0/3.0, 1.0, 100.0)
101
+
102
+ glMatrixMode(GL_MODELVIEW)
103
+ glLoadIdentity()
104
+ gluLookAt(7.5, 7.5, 12.5, 2.5, 2.5, -5.0, 0.0, 1.0, 0.0)
105
+ glColor(0.0, 1.0, 0.0)# green triangle
106
+ drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0)
107
+ glColor(1.0, 0.0, 0.0)# red triangle
108
+ drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0)
109
+ glColor(1.0, 1.0, 0.0)# yellow triangles
110
+ drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0)
111
+ drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0)
112
+ drawViewVolume(0.0, 5.0, 0.0, 5.0, 0.0, 10.0)
111
113
  end
112
114
 
113
115
  # processHits prints out the contents of the selection array
114
116
  def processHits(hits, buffer)
115
- printf("hits = %d\n", hits)
116
- ptr = buffer.unpack("I*")
117
- p = 0
118
- for i in 0...hits # for each hit
119
- names = ptr[p]
120
- printf(" number of names for hit = %d\n", names); p+=1
121
- printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
122
- printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
123
- printf(" the name is ")
124
- for j in 0...names # for each name
125
- printf("%d ", ptr[p]); p+=1
126
- end
127
- printf("\n")
128
- end
117
+ printf("hits = %d\n", hits)
118
+ ptr = buffer.unpack("I*")
119
+ p = 0
120
+ for i in 0...hits # for each hit
121
+ names = ptr[p]
122
+ printf(" number of names for hit = %d\n", names); p+=1
123
+ printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
124
+ printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
125
+ printf(" the name is ")
126
+ for j in 0...names # for each name
127
+ printf("%d ", ptr[p]); p+=1
128
+ end
129
+ printf("\n")
130
+ end
129
131
  end
130
132
 
131
- # selectObjects "draws" the triangles in selection mode,
133
+ # selectObjects "draws" the triangles in selection mode,
132
134
  # assigning names for the triangles. Note that the third
133
- # and fourth triangles share one name, so that if either
134
- # or both triangles intersects the viewing/clipping volume,
135
+ # and fourth triangles share one name, so that if either
136
+ # or both triangles intersects the viewing/clipping volume,
135
137
  # only one hit will be registered.
136
138
 
137
139
  BUFSIZE=512
138
140
 
139
141
  def selectObjects
140
- selectBuf = glSelectBuffer(BUFSIZE)
141
- glRenderMode(GL_SELECT)
142
-
143
- glInitNames()
144
- glPushName(0)
145
-
146
- glPushMatrix()
147
- glMatrixMode(GL_PROJECTION)
148
- glLoadIdentity()
149
- glOrtho(0.0, 5.0, 0.0, 5.0, 0.0, 10.0)
150
- glMatrixMode(GL_MODELVIEW)
151
- glLoadIdentity()
152
- glLoadName(1)
153
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0)
154
- glLoadName(2)
155
- drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0)
156
- glLoadName(3)
157
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0)
158
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0)
159
- glPopMatrix()
160
- glFlush()
161
-
162
- hits = glRenderMode(GL_RENDER)
163
- processHits(hits, selectBuf)
164
- end
142
+ selectBuf = glSelectBuffer(BUFSIZE)
143
+ glRenderMode(GL_SELECT)
144
+
145
+ glInitNames()
146
+ glPushName(0)
147
+
148
+ glPushMatrix()
149
+ glMatrixMode(GL_PROJECTION)
150
+ glLoadIdentity()
151
+ glOrtho(0.0, 5.0, 0.0, 5.0, 0.0, 10.0)
152
+ glMatrixMode(GL_MODELVIEW)
153
+ glLoadIdentity()
154
+ glLoadName(1)
155
+ drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0)
156
+ glLoadName(2)
157
+ drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0)
158
+ glLoadName(3)
159
+ drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0)
160
+ drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0)
161
+ glPopMatrix()
162
+ glFlush()
163
+
164
+ hits = glRenderMode(GL_RENDER)
165
+ processHits(hits, selectBuf)
166
+ end
165
167
 
166
168
  def init
167
- glEnable(GL_DEPTH_TEST)
168
- glShadeModel(GL_FLAT)
169
+ glEnable(GL_DEPTH_TEST)
170
+ glShadeModel(GL_FLAT)
169
171
  end
170
172
 
171
173
  display = proc do
172
- glClearColor(0.0, 0.0, 0.0, 0.0)
173
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
174
- drawScene()
175
- selectObjects()
176
- glFlush()
174
+ glClearColor(0.0, 0.0, 0.0, 0.0)
175
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
176
+ drawScene()
177
+ selectObjects()
178
+ glFlush()
177
179
  end
178
180
 
179
181
  keyboard = proc do |key, x, y|
180
- case (key)
181
- when ?\e
182
- exit(0)
183
- end
182
+ case (key)
183
+ when ?\e
184
+ exit(0)
185
+ end
184
186
  end
185
187
 
186
188
  # Main Loop
@@ -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
@@ -39,48 +39,50 @@
39
39
  # A smooth shaded polygon is drawn in a 2-D projection.
40
40
 
41
41
  require 'opengl'
42
+ require 'glu'
43
+ require 'glut'
42
44
  include Gl,Glu,Glut
43
45
 
44
46
  def init
45
- glClearColor(0,0,0,0)
46
- glShadeModel(GL_SMOOTH)
47
+ glClearColor(0,0,0,0)
48
+ glShadeModel(GL_SMOOTH)
47
49
  end
48
50
 
49
51
  def triangle
50
- glBegin(GL_TRIANGLES)
51
- glColor3f(1.0, 0.0, 0.0)
52
- glVertex2f(5, 5)
53
- glColor3f(0.0, 1.0, 0.0)
54
- glVertex2f(25, 5)
55
- glColor3f(0.0, 0.0, 1.0)
56
- glVertex2f(5, 25)
57
- glEnd()
52
+ glBegin(GL_TRIANGLES)
53
+ glColor3f(1.0, 0.0, 0.0)
54
+ glVertex2f(5, 5)
55
+ glColor3f(0.0, 1.0, 0.0)
56
+ glVertex2f(25, 5)
57
+ glColor3f(0.0, 0.0, 1.0)
58
+ glVertex2f(5, 25)
59
+ glEnd()
58
60
  end
59
61
 
60
62
 
61
- display = Proc.new do
62
- glClear(GL_COLOR_BUFFER_BIT)
63
- triangle
64
- glutSwapBuffers()
63
+ display = Proc.new do
64
+ glClear(GL_COLOR_BUFFER_BIT)
65
+ triangle
66
+ glutSwapBuffers()
65
67
  end
66
68
 
67
69
  reshape = Proc.new do |w, h|
68
- glViewport(0, 0, w, h)
69
- glMatrixMode(GL_PROJECTION)
70
- glLoadIdentity
71
- if w<=h
72
- gluOrtho2D(0,30,0, 30 * h/w)
73
- else
74
- gluOrtho2D(0,30 * w/h, 0,30)
75
- end
76
- glMatrixMode(GL_MODELVIEW)
70
+ glViewport(0, 0, w, h)
71
+ glMatrixMode(GL_PROJECTION)
72
+ glLoadIdentity
73
+ if w<=h
74
+ gluOrtho2D(0,30,0, 30 * h/w)
75
+ else
76
+ gluOrtho2D(0,30 * w/h, 0,30)
77
+ end
78
+ glMatrixMode(GL_MODELVIEW)
77
79
  end
78
80
 
79
81
  keyboard = lambda do |key, x, y|
80
- case(key)
81
- when ?\e
82
- exit(0)
83
- end
82
+ case(key)
83
+ when ?\e
84
+ exit(0)
85
+ end
84
86
  end
85
87
 
86
88
  glutInit()