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,156 +0,0 @@
1
- #
2
- # Copyright (c) Mark J. Kilgard, 1994. */
3
- #
4
- # (c) Copyright 1993, Silicon Graphics, Inc.
5
- # ALL RIGHTS RESERVED
6
- # Permission to use, copy, modify, and distribute this software for
7
- # any purpose and without fee is hereby granted, provided that the above
8
- # copyright notice appear in all copies and that both the copyright notice
9
- # and this permission notice appear in supporting documentation, and that
10
- # the name of Silicon Graphics, Inc. not be used in advertising
11
- # or publicity pertaining to distribution of the software without specific,
12
- # written prior permission.
13
- #
14
- # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
- # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
16
- # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
17
- # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
18
- # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
19
- # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
20
- # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
21
- # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
22
- # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
23
- # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
- # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
- # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
- #
27
- # US Government Users Restricted Rights
28
- # Use, duplication, or disclosure by the Government is subject to
29
- # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
- # (c)(1)(ii) of the Rights in Technical Data and Computer Software
31
- # clause at DFARS 252.227-7013 and/or in similar or successor
32
- # clauses in the FAR or the DOD or NASA FAR Supplement.
33
- # Unpublished-- rights reserved under the copyright laws of the
34
- # United States. Contractor/manufacturer is Silicon Graphics,
35
- # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
36
- #
37
- # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
38
- #
39
- # mipmap.c
40
- # This program demonstrates using mipmaps for texture maps.
41
- # To overtly show the effect of mipmaps, each mipmap reduction
42
- # level has a solidly colored, contrasting texture image.
43
- # Thus, the quadrilateral which is drawn is drawn with several
44
- # different colors.
45
- require 'opengl'
46
- require 'mathn'
47
- include Gl,Glu,Glut
48
-
49
- $mipmapImage32 = []
50
- $mipmapImage16 = []
51
- $mipmapImage8 = []
52
- $mipmapImage4 = []
53
- $mipmapImage2 = []
54
- $mipmapImage1 = []
55
-
56
- def makeImages
57
- for i in 0..31
58
- for j in 0..31
59
- $mipmapImage32[(j*32+i)*3+0] = 255
60
- $mipmapImage32[(j*32+i)*3+1] = 255
61
- $mipmapImage32[(j*32+i)*3+2] = 0
62
- end
63
- end
64
- for i in 0..15
65
- for j in 0..15
66
- $mipmapImage16[(j*16+i)*3+0] = 255
67
- $mipmapImage16[(j*16+i)*3+1] = 0
68
- $mipmapImage16[(j*16+i)*3+2] = 255
69
- end
70
- end
71
- for i in 0..7
72
- for j in 0..7
73
- $mipmapImage8[(j*8+i)*3+0] = 255
74
- $mipmapImage8[(j*8+i)*3+1] = 0
75
- $mipmapImage8[(j*8+i)*3+2] = 0
76
- end
77
- end
78
- for i in 0..3
79
- for j in 0..3
80
- $mipmapImage4[(j*4+i)*3+0] = 0
81
- $mipmapImage4[(j*4+i)*3+1] = 255
82
- $mipmapImage4[(j*4+i)*3+2] = 0
83
- end
84
- end
85
- for i in 0..1
86
- for j in 0..1
87
- $mipmapImage2[(j*2+i)*3+0] = 0
88
- $mipmapImage2[(j*2+i)*3+1] = 0
89
- $mipmapImage2[(j*2+i)*3+2] = 255
90
- end
91
- end
92
- $mipmapImage1[0] = 255
93
- $mipmapImage1[1] = 255
94
- $mipmapImage1[2] = 255
95
- end
96
-
97
- def myinit
98
- glEnable(GL_DEPTH_TEST)
99
- glDepthFunc(GL_LESS)
100
- glShadeModel(GL_FLAT)
101
-
102
- glTranslate(0.0, 0.0, -3.6)
103
- makeImages()
104
- glPixelStore(GL_UNPACK_ALIGNMENT, 1)
105
- glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage32.pack("C*"))
106
- glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage16.pack("C*"))
107
- glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage8.pack("C*"))
108
- glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage4.pack("C*"))
109
- glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage2.pack("C*"))
110
- glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage1.pack("C*"))
111
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
112
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
113
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
114
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
115
- GL_NEAREST_MIPMAP_NEAREST)
116
- glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
117
- glEnable(GL_TEXTURE_2D)
118
- end
119
-
120
- display = Proc.new do
121
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
122
- glBegin(GL_QUADS)
123
- glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
124
- glTexCoord(0.0, 8.0); glVertex(-2.0, 1.0, 0.0)
125
- glTexCoord(8.0, 8.0); glVertex(2000.0, 1.0, -6000.0)
126
- glTexCoord(8.0, 0.0); glVertex(2000.0, -1.0, -6000.0)
127
- glEnd()
128
- glutSwapBuffers()
129
- end
130
-
131
- myReshape = Proc.new do |w, h|
132
- glViewport(0, 0, w, h)
133
- glMatrixMode(GL_PROJECTION)
134
- glLoadIdentity()
135
- gluPerspective(60.0, 1.0*w/h, 1.0, 30000.0)
136
- glMatrixMode(GL_MODELVIEW)
137
- glLoadIdentity()
138
- end
139
-
140
- keyboard = Proc.new do |key, x, y|
141
- case (key)
142
- when ?\e
143
- exit(0);
144
- end
145
- end
146
-
147
- glutInit
148
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
149
- glutInitWindowSize(500, 500)
150
- glutInitWindowPosition(100, 100)
151
- glutCreateWindow($0)
152
- myinit()
153
- glutReshapeFunc(myReshape)
154
- glutDisplayFunc(display)
155
- glutKeyboardFunc(keyboard)
156
- glutMainLoop()
@@ -1,113 +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
- # model.c
38
- # This program demonstrates modeling transformations
39
- require 'opengl'
40
- require 'mathn'
41
- include Gl,Glu,Glut
42
-
43
- def init
44
- glClearColor(0.0, 0.0, 0.0, 0.0)
45
- glShadeModel(GL_FLAT)
46
- end
47
-
48
- def draw_triangle
49
- glBegin(GL_LINE_LOOP)
50
- glVertex(0.0, 25.0)
51
- glVertex(25.0, -25.0)
52
- glVertex(-25.0, -25.0)
53
- glEnd()
54
- end
55
-
56
- display = Proc.new do
57
- glClear(GL_COLOR_BUFFER_BIT)
58
- glColor(1.0, 1.0, 1.0)
59
-
60
- glLoadIdentity()
61
- glColor(1.0, 1.0, 1.0)
62
- draw_triangle()
63
-
64
- glEnable(GL_LINE_STIPPLE)
65
- glLineStipple(1, 0xF0F0)
66
- glLoadIdentity()
67
- glTranslate(-20.0, 0.0, 0.0)
68
- draw_triangle()
69
-
70
- glLineStipple(1, 0xF00F)
71
- glLoadIdentity()
72
- glScale(1.5, 0.5, 1.0)
73
- draw_triangle()
74
-
75
- glLineStipple(1, 0x8888)
76
- glLoadIdentity()
77
- glRotate(90.0, 0.0, 0.0, 1.0)
78
- draw_triangle()
79
- glDisable(GL_LINE_STIPPLE)
80
-
81
- glutSwapBuffers()
82
- end
83
-
84
- reshape = Proc.new do |w, h|
85
- glViewport(0, 0, w, h)
86
- glMatrixMode(GL_PROJECTION)
87
- glLoadIdentity()
88
- if (w <= h)
89
- glOrtho(-50.0, 50.0, -50.0*h/w, 50.0*h/w, -1.0, 1.0)
90
- else
91
- glOrtho(-50.0*w/h,50.0*w/h, -50.0, 50.0, -1.0, 1.0)
92
- end
93
- glMatrixMode(GL_MODELVIEW)
94
- end
95
-
96
- keyboard = Proc.new do |key, x, y|
97
- case key
98
- when ?\e
99
- exit(0)
100
- end
101
- end
102
-
103
- # main
104
- glutInit()
105
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
106
- glutInitWindowSize(500, 500)
107
- glutInitWindowPosition(100, 100)
108
- glutCreateWindow($0)
109
- init()
110
- glutDisplayFunc(display)
111
- glutReshapeFunc(reshape)
112
- glutKeyboardFunc(keyboard)
113
- glutMainLoop()
@@ -1,132 +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
- # movelight.c
38
- # This program demonstrates when to issue lighting and
39
- # transformation commands to render a model with a light
40
- # which is moved by a modeling transformation (rotate or
41
- # translate). The light position is reset after the modeling
42
- # transformation is called. The eye position does not change.
43
- #
44
- # A sphere is drawn using a grey material characteristic.
45
- # A single light source illuminates the object.
46
- #
47
- # Interaction: pressing the left mouse button alters
48
- # the modeling transformation (x rotation) by 30 degrees.
49
- # The scene is then redrawn with the light in a new position.
50
-
51
- require 'opengl'
52
- require 'rational'
53
- require 'mathn'
54
- include Gl,Glu,Glut
55
-
56
- $spin = 0
57
-
58
- # Initialize material property, light source, lighting model,
59
- # and depth buffer.
60
- def init
61
- glClearColor(0.0, 0.0, 0.0, 0.0)
62
- glShadeModel(GL_SMOOTH)
63
- glEnable(GL_LIGHTING)
64
- glEnable(GL_LIGHT0)
65
- glEnable(GL_DEPTH_TEST)
66
- end
67
-
68
- # Here is where the light position is reset after the modeling
69
- # transformation (glRotated) is called. This places the
70
- # light at a new position in world coordinates. The cube
71
- # represents the position of the light.
72
- display = Proc.new do
73
- position = [ 0.0, 0.0, 1.5, 1.0 ]
74
-
75
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
76
- glPushMatrix()
77
- GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
78
-
79
- glPushMatrix()
80
- glRotate($spin, 1.0, 0.0, 0.0)
81
- glLight(GL_LIGHT0, GL_POSITION, position)
82
-
83
- glTranslate(0.0, 0.0, 1.5)
84
- glDisable(GL_LIGHTING)
85
- glColor(0.0, 1.0, 1.0)
86
- glutWireCube(0.1)
87
- glEnable(GL_LIGHTING)
88
- glPopMatrix()
89
-
90
- glutSolidTorus(0.275, 0.85, 8, 15)
91
- glPopMatrix()
92
- glutSwapBuffers()
93
- end
94
-
95
- reshape = Proc.new do |w, h|
96
- glViewport(0, 0, w, h)
97
- glMatrixMode(GL_PROJECTION)
98
- glLoadIdentity()
99
- gluPerspective(40.0, w/h, 1.0, 20.0)
100
- glMatrixMode(GL_MODELVIEW)
101
- glLoadIdentity()
102
- end
103
-
104
- mouse = Proc.new do |button, state, x, y|
105
- case button
106
- when GLUT_LEFT_BUTTON
107
- if (state == GLUT_DOWN)
108
- $spin = ($spin + 30) % 360
109
- glutPostRedisplay()
110
- end
111
- end
112
- end
113
-
114
- keyboard = Proc.new do |key, x, y|
115
- case key
116
- when ?\e
117
- exit(0)
118
- end
119
- end
120
-
121
- # main
122
- glutInit
123
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
124
- glutInitWindowSize(500, 500)
125
- glutInitWindowPosition(100, 100)
126
- glutCreateWindow($0)
127
- init()
128
- glutDisplayFunc(display)
129
- glutReshapeFunc(reshape)
130
- glutMouseFunc(mouse)
131
- glutKeyboardFunc(keyboard)
132
- glutMainLoop()
@@ -1,179 +0,0 @@
1
- #
2
- # Copyright (c) Mark J. Kilgard, 1994. */
3
- #
4
- #
5
- # (c) Copyright 1993, Silicon Graphics, Inc.
6
- # ALL RIGHTS RESERVED
7
- # Permission to use, copy, modify, and distribute this software for
8
- # any purpose and without fee is hereby granted, provided that the above
9
- # copyright notice appear in all copies and that both the copyright notice
10
- # and this permission notice appear in supporting documentation, and that
11
- # the name of Silicon Graphics, Inc. not be used in advertising
12
- # or publicity pertaining to distribution of the software without specific,
13
- # written prior permission.
14
- #
15
- # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16
- # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
17
- # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
18
- # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19
- # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
20
- # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
21
- # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
22
- # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
23
- # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
24
- # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25
- # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26
- # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
27
- #
28
- # US Government Users Restricted Rights
29
- # Use, duplication, or disclosure by the Government is subject to
30
- # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31
- # (c)(1)(ii) of the Rights in Technical Data and Computer Software
32
- # clause at DFARS 252.227-7013 and/or in similar or successor
33
- # clauses in the FAR or the DOD or NASA FAR Supplement.
34
- # Unpublished-- rights reserved under the copyright laws of the
35
- # United States. Contractor/manufacturer is Silicon Graphics,
36
- # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
37
- #
38
- # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
39
- #
40
- # pickdepth.c
41
- # Picking is demonstrated in this program. In
42
- # rendering mode, three overlapping rectangles are
43
- # drawn. When the left mouse button is pressed,
44
- # selection mode is entered with the picking matrix.
45
- # Rectangles which are drawn under the cursor position
46
- # are "picked." Pay special attention to the depth
47
- # value range, which is returned.
48
- require 'opengl'
49
- include Gl,Glu,Glut
50
-
51
- def myinit
52
- glClearColor(0.0, 0.0, 0.0, 0.0)
53
- glDepthFunc(GL_LESS)
54
- glEnable(GL_DEPTH_TEST)
55
- glShadeModel(GL_FLAT)
56
- glDepthRange(0.0, 1.0) #/* The default z mapping */
57
- end
58
-
59
- # The three rectangles are drawn. In selection mode,
60
- # each rectangle is given the same name. Note that
61
- # each rectangle is drawn with a different z value.
62
- def drawRects(mode)
63
- if (mode == GL_SELECT)
64
- glLoadName(1)
65
- end
66
- glBegin(GL_QUADS)
67
- glColor(1.0, 1.0, 0.0)
68
- glVertex(2, 0, 0)
69
- glVertex(2, 6, 0)
70
- glVertex(6, 6, 0)
71
- glVertex(6, 0, 0)
72
- glEnd()
73
- if (mode == GL_SELECT)
74
- glLoadName(2)
75
- end
76
- glBegin(GL_QUADS)
77
- glColor(0.0, 1.0, 1.0)
78
- glVertex(3, 2, -1)
79
- glVertex(3, 8, -1)
80
- glVertex(8, 8, -1)
81
- glVertex(8, 2, -1)
82
- glEnd()
83
- if (mode == GL_SELECT)
84
- glLoadName(3)
85
- end
86
- glBegin(GL_QUADS)
87
- glColor(1.0, 0.0, 1.0)
88
- glVertex(0, 2, -2)
89
- glVertex(0, 7, -2)
90
- glVertex(5, 7, -2)
91
- glVertex(5, 2, -2)
92
- glEnd()
93
- end
94
-
95
- # processHits() prints out the contents of the
96
- # selection array.
97
- def processHits(hits, buffer)
98
- printf("hits = %d\n", hits)
99
- ptr = buffer.unpack("I*")
100
- p = 0
101
- for i in 0...hits # for each hit
102
- names = ptr[p]
103
- printf(" number of names for hit = %d\n", names); p+=1
104
- printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
105
- printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
106
- printf(" the name is ")
107
- for j in 0...names # for each name
108
- printf("%d ", ptr[p]) ; p+=1
109
- end
110
- printf("\n")
111
- end
112
- end
113
-
114
- # pickRects() sets up selection mode, name stack,
115
- # and projection matrix for picking. Then the objects
116
- # are drawn.
117
- BUFSIZE=512
118
-
119
- pickRects = proc do |button, state, x, y|
120
- if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
121
- viewport = glGetDoublev(GL_VIEWPORT)
122
-
123
- selectBuf = glSelectBuffer(BUFSIZE)
124
- glRenderMode(GL_SELECT)
125
-
126
- glInitNames()
127
- glPushName(~0)
128
-
129
- glMatrixMode(GL_PROJECTION)
130
- glPushMatrix()
131
- glLoadIdentity()
132
- # create 5x5 pixel picking region near cursor location
133
- gluPickMatrix( x, viewport[3] - y, 5.0, 5.0, viewport)
134
- glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
135
- drawRects(GL_SELECT)
136
- glPopMatrix()
137
- glFlush()
138
-
139
- hits = glRenderMode(GL_RENDER)
140
- processHits(hits, selectBuf)
141
- end
142
- end
143
-
144
- display = proc do
145
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
146
- drawRects(GL_RENDER)
147
- glutSwapBuffers()
148
- end
149
-
150
- myReshape = proc do |w, h|
151
- glViewport(0, 0, w, h)
152
- glMatrixMode(GL_PROJECTION)
153
- glLoadIdentity()
154
- glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
155
- glMatrixMode(GL_MODELVIEW)
156
- glLoadIdentity()
157
- end
158
-
159
- keyboard = Proc.new do |key, x, y|
160
- case (key)
161
- when ?\e
162
- exit(0)
163
- end
164
- end
165
-
166
- # Main Loop
167
- # Open window with initial window size, title bar,
168
- # RGBA display mode, depth buffer, and handle input events.
169
- glutInitWindowSize(500, 500)
170
- glutInitWindowPosition(100, 100)
171
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
172
- glutInit()
173
- glutCreateWindow()
174
- myinit()
175
- glutMouseFunc(pickRects)
176
- glutReshapeFunc(myReshape)
177
- glutDisplayFunc(display)
178
- glutKeyboardFunc(keyboard)
179
- glutMainLoop()