ruby-opengl 0.60.1 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,135 +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
- # colormat.c
38
- # After initialization, the program will be in
39
- # ColorMaterial mode. Interaction: pressing the
40
- # mouse buttons will change the diffuse reflection values.
41
- require 'opengl'
42
- require 'mathn'
43
- include Gl,Glu,Glut
44
-
45
- $diffuseMaterial = [0.5,0.5,0.5,1.0]
46
-
47
- # Initialize material property, light source, lighting model,
48
- # and depth buffer.
49
- def init
50
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
51
- light_position = [ 1.0, 1.0, 1.0, 0.0 ]
52
-
53
- glClearColor(0.0, 0.0, 0.0, 0.0)
54
- glShadeModel(GL_SMOOTH)
55
- glEnable(GL_DEPTH_TEST)
56
- glMaterial(GL_FRONT, GL_DIFFUSE, $diffuseMaterial)
57
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
58
- glMaterial(GL_FRONT, GL_SHININESS, 25.0)
59
- glLight(GL_LIGHT0, GL_POSITION, light_position)
60
- glEnable(GL_LIGHTING)
61
- glEnable(GL_LIGHT0)
62
-
63
- glColorMaterial(GL_FRONT, GL_DIFFUSE)
64
- glEnable(GL_COLOR_MATERIAL)
65
- end
66
-
67
- display = Proc.new do
68
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
69
- glutSolidSphere(1.0, 20, 16)
70
- glutSwapBuffers()
71
- end
72
-
73
- reshape = Proc.new do |w, h|
74
- glViewport(0, 0, w, h)
75
- glMatrixMode(GL_PROJECTION)
76
- glLoadIdentity()
77
- if (w <= h)
78
- glOrtho(-1.5, 1.5, -1.5*h/w, 1.5*h/w, -10.0, 10.0)
79
- else
80
- glOrtho(-1.5*w/h, 1.5*w/h, -1.5, 1.5, -10.0, 10.0)
81
- end
82
- glMatrixMode(GL_MODELVIEW)
83
- glLoadIdentity()
84
- end
85
-
86
- mouse = Proc.new do |button, state, x, y|
87
- case (button)
88
- when GLUT_LEFT_BUTTON
89
- if (state == GLUT_DOWN)
90
- $diffuseMaterial[0] = $diffuseMaterial[0] + 0.1
91
- if ($diffuseMaterial[0] > 1.0)
92
- $diffuseMaterial[0] = 0.0
93
- end
94
- glColor($diffuseMaterial)
95
- glutPostRedisplay()
96
- end
97
- when GLUT_MIDDLE_BUTTON
98
- if (state == GLUT_DOWN)
99
- $diffuseMaterial[1] = $diffuseMaterial[1] + 0.1
100
- if ($diffuseMaterial[1] > 1.0)
101
- $diffuseMaterial[1] = 0.0
102
- end
103
- glColor($diffuseMaterial)
104
- glutPostRedisplay()
105
- end
106
- when GLUT_RIGHT_BUTTON
107
- if (state == GLUT_DOWN)
108
- $diffuseMaterial[2] = $diffuseMaterial[2] + 0.1
109
- if ($diffuseMaterial[2] > 1.0)
110
- $diffuseMaterial[2] = 0.0
111
- end
112
- glColor($diffuseMaterial)
113
- glutPostRedisplay()
114
- end
115
- end
116
- end
117
-
118
- keyboard = Proc.new do |key, x, y|
119
- case (key)
120
- when ?\e
121
- exit(0)
122
- end
123
- end
124
-
125
- glutInit
126
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
127
- glutInitWindowSize(500, 500)
128
- glutInitWindowPosition(100, 100)
129
- glutCreateWindow($0)
130
- init()
131
- glutDisplayFunc(display)
132
- glutReshapeFunc(reshape)
133
- glutMouseFunc(mouse)
134
- glutKeyboardFunc(keyboard)
135
- glutMainLoop()
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env ruby -rubygems
2
- require 'opengl'
3
- include Gl,Glu,Glut
4
-
5
- $light_diffuse = [1.0, 0.0, 0.0, 1.0]
6
- $light_position = [1.0, 1.0, 1.0, 0.0]
7
- $n = [
8
- [-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0],
9
- [0.0, -1.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.0, -1.0] ]
10
- $faces = [
11
- [0, 1, 2, 3], [3, 2, 6, 7], [7, 6, 5, 4],
12
- [4, 5, 1, 0], [5, 6, 2, 1], [7, 4, 0, 3] ]
13
- $v = 0
14
-
15
- def drawBox
16
- for i in (0..5)
17
- glBegin(GL_QUADS)
18
- glNormal(*($n[i]))
19
- glVertex($v[$faces[i][0]])
20
- glVertex($v[$faces[i][1]])
21
- glVertex($v[$faces[i][2]])
22
- glVertex($v[$faces[i][3]])
23
- glEnd()
24
- end
25
- end
26
-
27
- display = Proc.new do
28
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
29
- drawBox
30
- glutSwapBuffers
31
- end
32
-
33
- def myinit
34
- $v = [[-1, -1,1],[-1, -1,-1], [-1,1,-1], [-1,1,1], [1, -1,1],
35
- [1, -1,-1], [1, 1,-1], [1,1,1]]
36
-
37
- glLight(GL_LIGHT0, GL_DIFFUSE, $light_diffuse)
38
- glLight(GL_LIGHT0, GL_POSITION, $light_position)
39
- glEnable(GL_LIGHT0)
40
- glEnable(GL_LIGHTING)
41
-
42
- glEnable(GL_DEPTH_TEST)
43
-
44
- glMatrixMode(GL_PROJECTION)
45
- gluPerspective(40.0, 1.0, 1.0, 10.0)
46
- glMatrixMode(GL_MODELVIEW)
47
- gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
48
-
49
- glTranslate(0.0, 0.0, -1.0)
50
- glRotate(60, 1.0, 0.0, 0.0)
51
- glRotate(-20, 0.0, 0.0, 1.0)
52
- end
53
-
54
- keyboard = Proc.new do |key, x, y|
55
- case (key)
56
- when ?\e
57
- exit(0);
58
- end
59
- end
60
-
61
- glutInit
62
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
63
- glutInitWindowSize(500, 500)
64
- glutInitWindowPosition(100, 100)
65
- glutCreateWindow("red 3D lighted cube")
66
- glutDisplayFunc(display)
67
- glutKeyboardFunc(keyboard)
68
- myinit
69
- glutMainLoop()
@@ -1,99 +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
- # depthcue.c
40
- # This program draws a wireframe model, which uses
41
- # intensity (brightness) to give clues to distance.
42
- # Fog is used to achieve this effect.
43
- require 'opengl'
44
- require 'mathn'
45
- include Gl,Glu,Glut
46
-
47
- # Initialize linear fog for depth cueing.
48
- def myinit
49
- fogColor = [0.0, 0.0, 0.0, 1.0]
50
-
51
- glEnable(GL_FOG)
52
- glFog(GL_FOG_MODE, GL_LINEAR)
53
- glHint(GL_FOG_HINT, GL_NICEST) # per pixel
54
- glFog(GL_FOG_START, 3.0)
55
- glFog(GL_FOG_END, 5.0)
56
- glFog(GL_FOG_COLOR, fogColor)
57
- glClearColor(0.0, 0.0, 0.0, 1.0)
58
-
59
- glDepthFunc(GL_LESS)
60
- glEnable(GL_DEPTH_TEST)
61
- glShadeModel(GL_FLAT)
62
- end
63
-
64
- # display() draws an icosahedron.
65
- display = Proc.new do
66
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
67
- glColor(1.0, 1.0, 1.0)
68
- glutWireIcosahedron()
69
- glFlush()
70
- end
71
-
72
- myReshape = Proc.new do |w, h|
73
- glViewport(0, 0, w, h)
74
- glMatrixMode(GL_PROJECTION)
75
- glLoadIdentity()
76
- gluPerspective(45.0, w/h, 3.0, 5.0)
77
- glMatrixMode(GL_MODELVIEW)
78
- glLoadIdentity()
79
- glTranslate(0.0, 0.0, -4.0) # move object into view
80
- end
81
-
82
- keyboard = Proc.new do |key, x, y|
83
- case (key)
84
- when ?\e
85
- exit(0)
86
- end
87
- end
88
-
89
- # Main Loop
90
- glutInit
91
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
92
- glutInitWindowSize(500, 500)
93
- glutInitWindowPosition(100, 100)
94
- glutCreateWindow($0)
95
- myinit()
96
- glutReshapeFunc(myReshape)
97
- glutDisplayFunc(display)
98
- glutKeyboardFunc(keyboard)
99
- glutMainLoop()
@@ -1,205 +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
- # dof.c
40
- # This program demonstrates use of the accumulation buffer to
41
- # create an out-of-focus depth-of-field effect. The teapots
42
- # are drawn several times into the accumulation buffer. The
43
- # viewing volume is jittered, except at the focal point, where
44
- # the viewing volume is at the same position, each time. In
45
- # this case, the gold teapot remains in focus.
46
- require 'opengl'
47
- require 'jitter'
48
- include Gl,Glu,Glut
49
-
50
- # accFrustum()
51
- # The first 6 arguments are identical to the glFrustum() call.
52
- #
53
- # pixdx and pixdy are anti-alias jitter in pixels.
54
- # Set both equal to 0.0 for no anti-alias jitter.
55
- # eyedx and eyedy are depth-of field jitter in pixels.
56
- # Set both equal to 0.0 for no depth of field effects.
57
- #
58
- # focus is distance from eye to plane in focus.
59
- # focus must be greater than, but not equal to 0.0.
60
- #
61
- # Note that accFrustum() calls glTranslatef(). You will
62
- # probably want to insure that your ModelView matrix has been
63
- # initialized to identity before calling accFrustum().
64
- def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
65
- viewport = glGetDoublev(GL_VIEWPORT)
66
-
67
- xwsize = right - left
68
- ywsize = top - bottom
69
-
70
- dx = -(pixdx*xwsize/viewport[2] + eyedx*nnear/focus)
71
- dy = -(pixdy*ywsize/viewport[3] + eyedy*nnear/focus)
72
-
73
- glMatrixMode(GL_PROJECTION)
74
- glLoadIdentity()
75
- glFrustum(left + dx, right + dx, bottom + dy, top + dy, nnear, ffar)
76
- glMatrixMode(GL_MODELVIEW)
77
- glLoadIdentity()
78
- glTranslate(-eyedx, -eyedy, 0.0)
79
- end
80
-
81
- # accPerspective()
82
- #
83
- # The first 4 arguments are identical to the gluPerspective() call.
84
- # pixdx and pixdy are anti-alias jitter in pixels.
85
- # Set both equal to 0.0 for no anti-alias jitter.
86
- # eyedx and eyedy are depth-of field jitter in pixels.
87
- # Set both equal to 0.0 for no depth of field effects.
88
- #
89
- # focus is distance from eye to plane in focus.
90
- # focus must be greater than, but not equal to 0.0.
91
- #
92
- # Note that accPerspective() calls accFrustum().
93
- def accPerspective(fovy, aspect, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
94
- fov2 = ((fovy*Math::PI) / 180.0) / 2.0
95
-
96
- top = nnear / (Math::cos(fov2) / Math::sin(fov2))
97
- bottom = -top
98
-
99
- right = top * aspect
100
- left = -right
101
-
102
- accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
103
- end
104
-
105
-
106
- def myinit
107
- ambient = [ 0.0, 0.0, 0.0, 1.0 ]
108
- diffuse = [ 1.0, 1.0, 1.0, 1.0 ]
109
- position = [ 0.0, 3.0, 3.0, 0.0 ]
110
-
111
- lmodel_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
112
- local_view = [ 0.0 ]
113
-
114
- glEnable(GL_DEPTH_TEST)
115
- glDepthFunc(GL_LESS)
116
-
117
- glLight(GL_LIGHT0, GL_AMBIENT, ambient)
118
- glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
119
- glLight(GL_LIGHT0, GL_POSITION, position)
120
-
121
- glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
122
- glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
123
-
124
- glFrontFace(GL_CW)
125
- glEnable(GL_LIGHTING)
126
- glEnable(GL_LIGHT0)
127
- glEnable(GL_AUTO_NORMAL)
128
- glEnable(GL_NORMALIZE)
129
-
130
- glMatrixMode(GL_MODELVIEW)
131
- glLoadIdentity()
132
-
133
- glClearColor(0.0, 0.0, 0.0, 0.0)
134
- glClearAccum(0.0, 0.0, 0.0, 0.0)
135
- end
136
-
137
- def renderTeapot (x, y, z, ambr, ambg, ambb, difr, difg, difb, specr, specg, specb, shine)
138
- glPushMatrix()
139
- glTranslate(x, y, z)
140
- mat = []
141
- mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0
142
- glMaterial(GL_FRONT, GL_AMBIENT, mat)
143
- mat[0] = difr; mat[1] = difg; mat[2] = difb
144
- glMaterial(GL_FRONT, GL_DIFFUSE, mat)
145
- mat[0] = specr; mat[1] = specg; mat[2] = specb
146
- glMaterial(GL_FRONT, GL_SPECULAR, mat)
147
- glMaterial(GL_FRONT, GL_SHININESS, shine*128.0)
148
- glutSolidTeapot(0.5)
149
- glPopMatrix()
150
- end
151
-
152
- # display() draws 5 teapots into the accumulation buffer
153
- # several times each time with a jittered perspective.
154
- # The focal point is at z = 5.0, so the gold teapot will
155
- # stay in focus. The amount of jitter is adjusted by the
156
- # magnitude of the accPerspective() jitter in this example, 0.33.
157
- # In this example, the teapots are drawn 8 times. See jitter.rb
158
- display = proc do
159
- viewport = glGetDoublev(GL_VIEWPORT)
160
- glClear(GL_ACCUM_BUFFER_BIT)
161
-
162
- for jitter in 0...8
163
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
164
- accPerspective(45.0,
165
- viewport[2]/ viewport[3],
166
- 1.0, 15.0, 0.0, 0.0,
167
- 0.33*$j8[jitter][0], 0.33*$j8[jitter][1], 5.0)
168
- # ruby, gold, silver, emerald, and cyan teapots
169
- renderTeapot(-1.1, -0.5, -4.5, 0.1745, 0.01175, 0.01175, 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6)
170
- renderTeapot(-0.5, -0.5, -5.0, 0.24725, 0.1995, 0.0745, 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4)
171
- renderTeapot(0.2, -0.5, -5.5, 0.19225, 0.19225, 0.19225, 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4)
172
- renderTeapot(1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215, 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6)
173
- renderTeapot(1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, 0.50196078, 0.50196078, 0.50196078, 0.25)
174
- glAccum(GL_ACCUM, 0.125)
175
- end
176
-
177
- glAccum(GL_RETURN, 1.0)
178
- glutSwapBuffers()
179
- end
180
-
181
- myReshape = proc do |w, h|
182
- glViewport(0, 0, w, h)
183
- end
184
-
185
- keyboard = proc do |key, x, y|
186
- case (key)
187
- when ?\e
188
- exit(0)
189
- end
190
- end
191
-
192
- # Main Loop
193
- # Open window with initial window size, title bar,
194
- # RGBA display mode, depth buffer, and handle input events.
195
- glutInit()
196
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ACCUM | GLUT_DEPTH)
197
- glutInitWindowSize(500, 500)
198
- glutInitWindowPosition(100, 100)
199
- glutCreateWindow()
200
- myinit()
201
- glutReshapeFunc(myReshape)
202
- glutDisplayFunc(display)
203
- glutKeyboardFunc(keyboard)
204
- glutMainLoop()
205
-