ruby-opengl 0.60.1 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. metadata +36 -186
  2. data/Rakefile +0 -168
  3. data/doc/build_install.txt +0 -122
  4. data/doc/extensions.txt +0 -556
  5. data/doc/extensions.txt.in +0 -348
  6. data/doc/history.txt +0 -66
  7. data/doc/requirements_and_design.txt +0 -117
  8. data/doc/roadmap.txt +0 -28
  9. data/doc/scientific_use.txt +0 -35
  10. data/doc/supplies/page_template.html +0 -71
  11. data/doc/thanks.txt +0 -29
  12. data/doc/tutorial.txt +0 -469
  13. data/examples/NeHe/nehe_lesson02.rb +0 -117
  14. data/examples/NeHe/nehe_lesson03.rb +0 -122
  15. data/examples/NeHe/nehe_lesson04.rb +0 -133
  16. data/examples/NeHe/nehe_lesson05.rb +0 -186
  17. data/examples/NeHe/nehe_lesson36.rb +0 -303
  18. data/examples/OrangeBook/3Dlabs-License.txt +0 -33
  19. data/examples/OrangeBook/brick.frag +0 -36
  20. data/examples/OrangeBook/brick.rb +0 -376
  21. data/examples/OrangeBook/brick.vert +0 -41
  22. data/examples/OrangeBook/particle.frag +0 -17
  23. data/examples/OrangeBook/particle.rb +0 -406
  24. data/examples/OrangeBook/particle.vert +0 -38
  25. data/examples/README +0 -16
  26. data/examples/RedBook/aapoly.rb +0 -142
  27. data/examples/RedBook/aargb.rb +0 -119
  28. data/examples/RedBook/accanti.rb +0 -162
  29. data/examples/RedBook/accpersp.rb +0 -215
  30. data/examples/RedBook/alpha.rb +0 -123
  31. data/examples/RedBook/alpha3D.rb +0 -158
  32. data/examples/RedBook/bezcurve.rb +0 -105
  33. data/examples/RedBook/bezmesh.rb +0 -137
  34. data/examples/RedBook/checker.rb +0 -124
  35. data/examples/RedBook/clip.rb +0 -95
  36. data/examples/RedBook/colormat.rb +0 -135
  37. data/examples/RedBook/cube.rb +0 -69
  38. data/examples/RedBook/depthcue.rb +0 -99
  39. data/examples/RedBook/dof.rb +0 -205
  40. data/examples/RedBook/double.rb +0 -105
  41. data/examples/RedBook/drawf.rb +0 -91
  42. data/examples/RedBook/feedback.rb +0 -145
  43. data/examples/RedBook/fog.rb +0 -167
  44. data/examples/RedBook/font.rb +0 -151
  45. data/examples/RedBook/hello.rb +0 -79
  46. data/examples/RedBook/image.rb +0 -137
  47. data/examples/RedBook/jitter.rb +0 -207
  48. data/examples/RedBook/lines.rb +0 -128
  49. data/examples/RedBook/list.rb +0 -111
  50. data/examples/RedBook/material.rb +0 -275
  51. data/examples/RedBook/mipmap.rb +0 -156
  52. data/examples/RedBook/model.rb +0 -113
  53. data/examples/RedBook/movelight.rb +0 -132
  54. data/examples/RedBook/pickdepth.rb +0 -179
  55. data/examples/RedBook/planet.rb +0 -108
  56. data/examples/RedBook/quadric.rb +0 -158
  57. data/examples/RedBook/robot.rb +0 -115
  58. data/examples/RedBook/select.rb +0 -196
  59. data/examples/RedBook/smooth.rb +0 -95
  60. data/examples/RedBook/stencil.rb +0 -163
  61. data/examples/RedBook/stroke.rb +0 -167
  62. data/examples/RedBook/surface.rb +0 -166
  63. data/examples/RedBook/teaambient.rb +0 -132
  64. data/examples/RedBook/teapots.rb +0 -182
  65. data/examples/RedBook/tess.rb +0 -183
  66. data/examples/RedBook/texbind.rb +0 -147
  67. data/examples/RedBook/texgen.rb +0 -169
  68. data/examples/RedBook/texturesurf.rb +0 -128
  69. data/examples/RedBook/varray.rb +0 -159
  70. data/examples/RedBook/wrap.rb +0 -148
  71. data/examples/misc/OGLBench.rb +0 -337
  72. data/examples/misc/anisotropic.rb +0 -194
  73. data/examples/misc/fbo_test.rb +0 -356
  74. data/examples/misc/font-glut.rb +0 -46
  75. data/examples/misc/glfwtest.rb +0 -30
  76. data/examples/misc/plane.rb +0 -161
  77. data/examples/misc/readpixel.rb +0 -65
  78. data/examples/misc/sdltest.rb +0 -34
  79. data/examples/misc/trislam.rb +0 -828
  80. data/ext/common/common.h +0 -423
  81. data/ext/common/conv.h +0 -244
  82. data/ext/common/funcdef.h +0 -280
  83. data/ext/common/gl-enums.h +0 -10031
  84. data/ext/common/gl-error.h +0 -23
  85. data/ext/common/gl-types.h +0 -61
  86. data/ext/common/glu-enums.h +0 -463
  87. data/ext/gl/gl-1.0-1.1.c +0 -2817
  88. data/ext/gl/gl-1.2.c +0 -814
  89. data/ext/gl/gl-1.3.c +0 -444
  90. data/ext/gl/gl-1.4.c +0 -349
  91. data/ext/gl/gl-1.5.c +0 -225
  92. data/ext/gl/gl-2.0.c +0 -657
  93. data/ext/gl/gl-2.1.c +0 -57
  94. data/ext/gl/gl-enums.c +0 -3354
  95. data/ext/gl/gl-error.c +0 -104
  96. data/ext/gl/gl-ext-3dfx.c +0 -27
  97. data/ext/gl/gl-ext-arb.c +0 -866
  98. data/ext/gl/gl-ext-ati.c +0 -41
  99. data/ext/gl/gl-ext-ext.c +0 -890
  100. data/ext/gl/gl-ext-gremedy.c +0 -41
  101. data/ext/gl/gl-ext-nv.c +0 -679
  102. data/ext/gl/gl.c +0 -214
  103. data/ext/gl/mkrf_conf.rb +0 -34
  104. data/ext/glu/glu-enums.c +0 -164
  105. data/ext/glu/glu.c +0 -1530
  106. data/ext/glu/mkrf_conf.rb +0 -35
  107. data/ext/glut/glut.c +0 -1623
  108. data/ext/glut/mkrf_conf.rb +0 -37
  109. data/lib/opengl.rb +0 -84
  110. data/test/README +0 -10
  111. data/test/tc_common.rb +0 -98
  112. data/test/tc_ext_arb.rb +0 -467
  113. data/test/tc_ext_ati.rb +0 -33
  114. data/test/tc_ext_ext.rb +0 -551
  115. data/test/tc_ext_gremedy.rb +0 -36
  116. data/test/tc_ext_nv.rb +0 -357
  117. data/test/tc_func_10_11.rb +0 -1281
  118. data/test/tc_func_12.rb +0 -186
  119. data/test/tc_func_13.rb +0 -229
  120. data/test/tc_func_14.rb +0 -197
  121. data/test/tc_func_15.rb +0 -270
  122. data/test/tc_func_20.rb +0 -346
  123. data/test/tc_func_21.rb +0 -541
  124. data/test/tc_glu.rb +0 -310
  125. data/test/tc_include_gl.rb +0 -35
  126. data/test/tc_misc.rb +0 -54
  127. data/test/tc_require_gl.rb +0 -34
@@ -1,108 +0,0 @@
1
- #
2
- # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
5
- # any purpose and without fee is hereby granted, provided that the above
6
- # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
8
- # the name of Silicon Graphics, Inc. not be used in advertising
9
- # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
11
- #
12
- # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
- # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
- # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
- # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
- # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
- # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
- # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
- # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
- # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
- # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
- # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
- # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
26
- # Use, duplication, or disclosure by the Government is subject to
27
- # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
- # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
- # clause at DFARS 252.227-7013 and/or in similar or successor
30
- # clauses in the FAR or the DOD or NASA FAR Supplement.
31
- # Unpublished-- rights reserved under the copyright laws of the
32
- # United States. Contractor/manufacturer is Silicon Graphics,
33
- # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
- #
35
- # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
- #
37
- # planet.c
38
- # This program shows how to composite modeling transformations
39
- # to draw translated and rotated models.
40
- # Interaction: pressing the d and y keys (day and year)
41
- # alters the rotation of the planet around the sun.
42
- require 'opengl'
43
- require 'rational'
44
- include Gl,Glu,Glut
45
-
46
- STDOUT.sync = TRUE
47
-
48
- $year = 0
49
- $day = 0
50
-
51
- def init
52
- glClearColor(0.0, 0.0, 0.0, 0.0)
53
- glShadeModel(GL_FLAT)
54
- end
55
-
56
- display = Proc.new do
57
- glClear(GL_COLOR_BUFFER_BIT)
58
- glColor(1.0, 1.0, 1.0)
59
-
60
- glPushMatrix()
61
- glutWireSphere(1.0, 20, 16) # draw sun
62
- glRotate($year, 0.0, 1.0, 0.0)
63
- glTranslate(2.0, 0.0, 0.0)
64
- glRotate($day, 0.0, 1.0, 0.0)
65
- glutWireSphere(0.2, 10, 8) # draw smaller planet
66
- glPopMatrix()
67
- glutSwapBuffers()
68
- end
69
-
70
- reshape = Proc.new do |w, h|
71
- glViewport(0, 0, w, h)
72
- glMatrixMode(GL_PROJECTION)
73
- glLoadIdentity()
74
- gluPerspective(60.0, w.to_f/h.to_f, 1.0, 20.0)
75
- glMatrixMode(GL_MODELVIEW)
76
- glLoadIdentity()
77
- gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
78
- end
79
-
80
- keyboard = Proc.new do |key, x, y|
81
- case (key)
82
- when ?d
83
- $day = ($day + 10) % 360
84
- glutPostRedisplay()
85
- when ?D
86
- $day = ($day - 10) % 360
87
- glutPostRedisplay()
88
- when ?y
89
- $year = ($year + 5) % 360
90
- glutPostRedisplay()
91
- when ?Y
92
- $year = ($year - 5) % 360
93
- glutPostRedisplay()
94
- when ?\e
95
- exit(0)
96
- end
97
- end
98
-
99
- glutInit
100
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
101
- glutInitWindowSize(500, 500)
102
- glutInitWindowPosition(100, 100)
103
- glutCreateWindow($0)
104
- init()
105
- glutDisplayFunc(display)
106
- glutReshapeFunc(reshape)
107
- glutKeyboardFunc(keyboard)
108
- glutMainLoop()
@@ -1,158 +0,0 @@
1
- #
2
- # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
5
- # any purpose and without fee is hereby granted, provided that the above
6
- # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
8
- # the name of Silicon Graphics, Inc. not be used in advertising
9
- # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
11
- #
12
- # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
- # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
- # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
- # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
- # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
- # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
- # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
- # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
- # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
- # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
- # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
- # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
26
- # Use, duplication, or disclosure by the Government is subject to
27
- # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
- # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
- # clause at DFARS 252.227-7013 and/or in similar or successor
30
- # clauses in the FAR or the DOD or NASA FAR Supplement.
31
- # Unpublished-- rights reserved under the copyright laws of the
32
- # United States. Contractor/manufacturer is Silicon Graphics,
33
- # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
- #
35
- # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
- #
37
- # quadric.c
38
- # This program demonstrates the use of some of the gluQuadric*
39
- # routines. Quadric objects are created with some quadric
40
- # properties and the callback routine to handle errors.
41
- # Note that the cylinder has no top or bottom and the circle
42
- # has a hole in it.
43
- require 'opengl'
44
- require 'mathn'
45
- include Gl,Glu,Glut
46
-
47
- $startList = nil
48
-
49
- def init
50
- mat_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
51
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
52
- mat_shininess = [ 50.0 ]
53
- light_position = [ 1.0, 1.0, 1.0, 0.0 ]
54
- model_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
55
-
56
- glClearColor(0.0, 0.0, 0.0, 0.0)
57
-
58
- glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
59
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
60
- glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
61
- glLight(GL_LIGHT0, GL_POSITION, light_position)
62
- glLightModel(GL_LIGHT_MODEL_AMBIENT, model_ambient)
63
-
64
- glEnable(GL_LIGHTING)
65
- glEnable(GL_LIGHT0)
66
- glEnable(GL_DEPTH_TEST)
67
-
68
- # Create 4 display lists, each with a different quadric object.
69
- # Different drawing styles and surface normal specifications
70
- # are demonstrated.
71
- $startList = glGenLists(4)
72
- qobj = gluNewQuadric()
73
-
74
- gluQuadricDrawStyle(qobj, GLU_FILL) # smooth shaded
75
- gluQuadricNormals(qobj, GLU_SMOOTH)
76
- glNewList($startList, GL_COMPILE)
77
- gluSphere(qobj, 0.75, 15, 10)
78
- glEndList()
79
-
80
- gluQuadricDrawStyle(qobj, GLU_FILL) # flat shaded
81
- gluQuadricNormals(qobj, GLU_FLAT)
82
- glNewList($startList+1, GL_COMPILE)
83
- gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5)
84
- glEndList()
85
-
86
- gluQuadricDrawStyle(qobj, GLU_LINE) # all polygons wireframe
87
- gluQuadricNormals(qobj, GLU_NONE)
88
- glNewList($startList+2, GL_COMPILE)
89
- gluDisk(qobj, 0.25, 1.0, 20, 4)
90
- glEndList()
91
-
92
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE) # boundary only
93
- gluQuadricNormals(qobj, GLU_NONE)
94
- glNewList($startList+3, GL_COMPILE)
95
- gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0)
96
- glEndList()
97
- end
98
-
99
- display = Proc.new do
100
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
101
- glPushMatrix()
102
-
103
- glEnable(GL_LIGHTING)
104
- glShadeModel(GL_SMOOTH)
105
- glTranslate(-1.0, -1.0, 0.0)
106
- glCallList($startList)
107
-
108
- glShadeModel(GL_FLAT)
109
- glTranslate(0.0, 2.0, 0.0)
110
- glPushMatrix()
111
- glRotate(300.0, 1.0, 0.0, 0.0)
112
- glCallList($startList+1)
113
- glPopMatrix()
114
-
115
- glDisable(GL_LIGHTING)
116
- glColor(0.0, 1.0, 1.0)
117
- glTranslate(2.0, -2.0, 0.0)
118
- glCallList($startList+2)
119
-
120
- glColor(1.0, 1.0, 0.0)
121
- glTranslate(0.0, 2.0, 0.0)
122
- glCallList($startList+3)
123
-
124
- glPopMatrix()
125
- glutSwapBuffers()
126
- end
127
-
128
- reshape = Proc.new do |w, h|
129
- glViewport(0, 0, w, h)
130
- glMatrixMode(GL_PROJECTION)
131
- glLoadIdentity()
132
- if (w <= h)
133
- glOrtho(-2.5, 2.5, -2.5*h/w, 2.5*h/w, -10.0, 10.0)
134
- else
135
- glOrtho(-2.5*w/h, 2.5*w/h, -2.5, 2.5, -10.0, 10.0)
136
- end
137
- glMatrixMode(GL_MODELVIEW)
138
- glLoadIdentity()
139
- end
140
-
141
- keyboard = Proc.new do |key, x, y|
142
- case (key)
143
- when ?\e
144
- exit(0)
145
- end
146
- end
147
-
148
- # main
149
- glutInit
150
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
151
- glutInitWindowSize(500, 500)
152
- glutInitWindowPosition(100, 100)
153
- glutCreateWindow($0)
154
- init()
155
- glutDisplayFunc(display)
156
- glutReshapeFunc(reshape)
157
- glutKeyboardFunc(keyboard)
158
- glutMainLoop()
@@ -1,115 +0,0 @@
1
- #
2
- # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
5
- # any purpose and without fee is hereby granted, provided that the above
6
- # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
8
- # the name of Silicon Graphics, Inc. not be used in advertising
9
- # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
11
- #
12
- # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
- # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
- # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
- # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
- # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
- # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
- # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
- # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
- # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
- # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
- # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
- # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
26
- # Use, duplication, or disclosure by the Government is subject to
27
- # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
- # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
- # clause at DFARS 252.227-7013 and/or in similar or successor
30
- # clauses in the FAR or the DOD or NASA FAR Supplement.
31
- # Unpublished-- rights reserved under the copyright laws of the
32
- # United States. Contractor/manufacturer is Silicon Graphics,
33
- # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
- #
35
- # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
- #
37
- # robot.c
38
- # This program shows how to composite modeling transformations
39
- # to draw translated and rotated hierarchical models.
40
- # Interaction: pressing the s and e keys (shoulder and elbow)
41
- # alters the rotation of the robot arm.
42
- require 'opengl'
43
- require 'mathn'
44
- include Gl,Glu,Glut
45
-
46
- $shoulder = 0
47
- $elbow = 0
48
-
49
- def init
50
- glClearColor(0.0, 0.0, 0.0, 0.0)
51
- glShadeModel(GL_FLAT)
52
- end
53
-
54
- 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()
75
- end
76
-
77
- 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)
85
- end
86
-
87
- 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
104
- end
105
-
106
- glutInit
107
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
108
- glutInitWindowSize(500, 500)
109
- glutInitWindowPosition(100, 100)
110
- glutCreateWindow($0)
111
- init()
112
- glutDisplayFunc(display)
113
- glutReshapeFunc(reshape)
114
- glutKeyboardFunc(keyboard)
115
- glutMainLoop()
@@ -1,196 +0,0 @@
1
- #
2
- # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
5
- # any purpose and without fee is hereby granted, provided that the above
6
- # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
8
- # the name of Silicon Graphics, Inc. not be used in advertising
9
- # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
11
- #
12
- # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
- # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
- # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
- # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
- # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
- # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
- # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
- # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
- # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
- # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
- # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
- # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
26
- # Use, duplication, or disclosure by the Government is subject to
27
- # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
- # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
- # clause at DFARS 252.227-7013 and/or in similar or successor
30
- # clauses in the FAR or the DOD or NASA FAR Supplement.
31
- # Unpublished-- rights reserved under the copyright laws of the
32
- # United States. Contractor/manufacturer is Silicon Graphics,
33
- # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
- #
35
- # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
- #
37
- #
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
50
- # the yellow triangles cause one hit with the name 3.
51
- require 'opengl'
52
- include Gl,Glu,Glut
53
-
54
- # draw a triangle with vertices at (x1, y1), (x2, y2)
55
- # and (x3, y3) at z units away from the origin.
56
- 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()
62
- end
63
-
64
- # draw a rectangular box with these outer x, y, and z values
65
- 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()
91
- end
92
-
93
- # drawScene draws 4 triangles and a wire frame
94
- # which represents the viewing volume.
95
- 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)
111
- end
112
-
113
- # processHits prints out the contents of the selection array
114
- 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
129
- end
130
-
131
- # selectObjects "draws" the triangles in selection mode,
132
- # 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
- # only one hit will be registered.
136
-
137
- BUFSIZE=512
138
-
139
- 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
165
-
166
- def init
167
- glEnable(GL_DEPTH_TEST)
168
- glShadeModel(GL_FLAT)
169
- end
170
-
171
- 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()
177
- end
178
-
179
- keyboard = proc do |key, x, y|
180
- case (key)
181
- when ?\e
182
- exit(0)
183
- end
184
- end
185
-
186
- # Main Loop
187
-
188
- GLUT.Init
189
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
190
- glutInitWindowSize(500, 500)
191
- glutInitWindowPosition(100, 100)
192
- glutCreateWindow $0
193
- init()
194
- glutDisplayFunc(display)
195
- glutKeyboardFunc(keyboard)
196
- glutMainLoop()