opengl 0.7.0.pre1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +8 -0
  3. data/History.txt +36 -0
  4. data/MIT-LICENSE +18 -0
  5. data/Manifest.txt +140 -0
  6. data/README.rdoc +51 -0
  7. data/Rakefile +129 -0
  8. data/Rakefile.cross +104 -0
  9. data/doc/build_install.txt +119 -0
  10. data/doc/extensions.txt.in +348 -0
  11. data/doc/history.txt +66 -0
  12. data/doc/requirements_and_design.txt +117 -0
  13. data/doc/roadmap.txt +28 -0
  14. data/doc/scientific_use.txt +35 -0
  15. data/doc/supplies/page_template.html +71 -0
  16. data/doc/thanks.txt +29 -0
  17. data/doc/tutorial.txt +469 -0
  18. data/examples/NeHe/nehe_lesson02.rb +117 -0
  19. data/examples/NeHe/nehe_lesson03.rb +122 -0
  20. data/examples/NeHe/nehe_lesson04.rb +133 -0
  21. data/examples/NeHe/nehe_lesson05.rb +186 -0
  22. data/examples/NeHe/nehe_lesson36.rb +303 -0
  23. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  24. data/examples/OrangeBook/brick.frag +36 -0
  25. data/examples/OrangeBook/brick.rb +376 -0
  26. data/examples/OrangeBook/brick.vert +41 -0
  27. data/examples/OrangeBook/particle.frag +17 -0
  28. data/examples/OrangeBook/particle.rb +406 -0
  29. data/examples/OrangeBook/particle.vert +38 -0
  30. data/examples/README +16 -0
  31. data/examples/RedBook/aapoly.rb +142 -0
  32. data/examples/RedBook/aargb.rb +119 -0
  33. data/examples/RedBook/accanti.rb +162 -0
  34. data/examples/RedBook/accpersp.rb +215 -0
  35. data/examples/RedBook/alpha.rb +123 -0
  36. data/examples/RedBook/alpha3D.rb +158 -0
  37. data/examples/RedBook/bezcurve.rb +105 -0
  38. data/examples/RedBook/bezmesh.rb +137 -0
  39. data/examples/RedBook/checker.rb +124 -0
  40. data/examples/RedBook/clip.rb +95 -0
  41. data/examples/RedBook/colormat.rb +135 -0
  42. data/examples/RedBook/cube.rb +69 -0
  43. data/examples/RedBook/depthcue.rb +99 -0
  44. data/examples/RedBook/dof.rb +205 -0
  45. data/examples/RedBook/double.rb +105 -0
  46. data/examples/RedBook/drawf.rb +91 -0
  47. data/examples/RedBook/feedback.rb +145 -0
  48. data/examples/RedBook/fog.rb +167 -0
  49. data/examples/RedBook/font.rb +151 -0
  50. data/examples/RedBook/hello.rb +79 -0
  51. data/examples/RedBook/image.rb +137 -0
  52. data/examples/RedBook/jitter.rb +207 -0
  53. data/examples/RedBook/lines.rb +128 -0
  54. data/examples/RedBook/list.rb +111 -0
  55. data/examples/RedBook/material.rb +275 -0
  56. data/examples/RedBook/mipmap.rb +156 -0
  57. data/examples/RedBook/model.rb +113 -0
  58. data/examples/RedBook/movelight.rb +132 -0
  59. data/examples/RedBook/pickdepth.rb +179 -0
  60. data/examples/RedBook/planet.rb +108 -0
  61. data/examples/RedBook/quadric.rb +158 -0
  62. data/examples/RedBook/robot.rb +115 -0
  63. data/examples/RedBook/select.rb +196 -0
  64. data/examples/RedBook/smooth.rb +95 -0
  65. data/examples/RedBook/stencil.rb +163 -0
  66. data/examples/RedBook/stroke.rb +167 -0
  67. data/examples/RedBook/surface.rb +166 -0
  68. data/examples/RedBook/teaambient.rb +132 -0
  69. data/examples/RedBook/teapots.rb +182 -0
  70. data/examples/RedBook/tess.rb +183 -0
  71. data/examples/RedBook/texbind.rb +147 -0
  72. data/examples/RedBook/texgen.rb +169 -0
  73. data/examples/RedBook/texturesurf.rb +128 -0
  74. data/examples/RedBook/varray.rb +159 -0
  75. data/examples/RedBook/wrap.rb +148 -0
  76. data/examples/misc/OGLBench.rb +337 -0
  77. data/examples/misc/anisotropic.rb +194 -0
  78. data/examples/misc/fbo_test.rb +356 -0
  79. data/examples/misc/font-glut.rb +46 -0
  80. data/examples/misc/glfwtest.rb +30 -0
  81. data/examples/misc/plane.rb +161 -0
  82. data/examples/misc/readpixel.rb +65 -0
  83. data/examples/misc/sdltest.rb +34 -0
  84. data/examples/misc/trislam.rb +828 -0
  85. data/ext/common/common.h +448 -0
  86. data/ext/common/conv.h +234 -0
  87. data/ext/common/funcdef.h +280 -0
  88. data/ext/common/gl-enums.h +10031 -0
  89. data/ext/common/gl-error.h +23 -0
  90. data/ext/common/gl-types.h +67 -0
  91. data/ext/common/glu-enums.h +463 -0
  92. data/ext/gl/extconf.rb +43 -0
  93. data/ext/gl/gl-1.0-1.1.c +2811 -0
  94. data/ext/gl/gl-1.2.c +814 -0
  95. data/ext/gl/gl-1.3.c +443 -0
  96. data/ext/gl/gl-1.4.c +348 -0
  97. data/ext/gl/gl-1.5.c +225 -0
  98. data/ext/gl/gl-2.0.c +657 -0
  99. data/ext/gl/gl-2.1.c +57 -0
  100. data/ext/gl/gl-enums.c +3354 -0
  101. data/ext/gl/gl-error.c +104 -0
  102. data/ext/gl/gl-ext-3dfx.c +27 -0
  103. data/ext/gl/gl-ext-arb.c +866 -0
  104. data/ext/gl/gl-ext-ati.c +41 -0
  105. data/ext/gl/gl-ext-ext.c +889 -0
  106. data/ext/gl/gl-ext-gremedy.c +41 -0
  107. data/ext/gl/gl-ext-nv.c +679 -0
  108. data/ext/gl/gl.c +216 -0
  109. data/ext/glu/extconf.rb +51 -0
  110. data/ext/glu/glu-enums.c +164 -0
  111. data/ext/glu/glu.c +1530 -0
  112. data/ext/glut/extconf.rb +67 -0
  113. data/ext/glut/glut.c +1624 -0
  114. data/lib/opengl.rb +89 -0
  115. data/test/README +10 -0
  116. data/test/tc_common.rb +98 -0
  117. data/test/tc_ext_arb.rb +467 -0
  118. data/test/tc_ext_ati.rb +33 -0
  119. data/test/tc_ext_ext.rb +551 -0
  120. data/test/tc_ext_gremedy.rb +36 -0
  121. data/test/tc_ext_nv.rb +357 -0
  122. data/test/tc_func_10_11.rb +1281 -0
  123. data/test/tc_func_12.rb +186 -0
  124. data/test/tc_func_13.rb +229 -0
  125. data/test/tc_func_14.rb +197 -0
  126. data/test/tc_func_15.rb +270 -0
  127. data/test/tc_func_20.rb +346 -0
  128. data/test/tc_func_21.rb +541 -0
  129. data/test/tc_glu.rb +310 -0
  130. data/test/tc_include_gl.rb +35 -0
  131. data/test/tc_misc.rb +54 -0
  132. data/test/tc_require_gl.rb +34 -0
  133. data/utils/README +11 -0
  134. data/utils/enumgen.rb +112 -0
  135. data/utils/extlistgen.rb +90 -0
  136. data/utils/mkdn2html.rb +59 -0
  137. data/utils/post-mkdn2html.rb +91 -0
  138. data/website/images/ogl.jpg +0 -0
  139. data/website/images/tab_bottom.gif +0 -0
  140. data/website/style.css +198 -0
  141. metadata +274 -0
@@ -0,0 +1,38 @@
1
+ //
2
+ // Vertex shader for rendering a "confetti cannon"
3
+ // via a partcle system
4
+ //
5
+ // Author: Randi Rost
6
+ //
7
+ // Copyright (c) 2003-2004: 3Dlabs, Inc.
8
+ //
9
+ // See 3Dlabs-License.txt for license information
10
+ //
11
+
12
+ uniform float Time; // updated each frame by the application
13
+ uniform vec4 Background; // constant color equal to background
14
+
15
+ attribute vec3 Velocity; // initial velocity
16
+ attribute float StartTime; // time at which particle is activated
17
+
18
+ varying vec4 Color;
19
+
20
+ void main(void)
21
+ {
22
+ vec4 vert;
23
+ float t = Time - StartTime;
24
+
25
+ if (t >= 0.0)
26
+ {
27
+ vert = gl_Vertex + vec4 (Velocity * t, 0.0);
28
+ vert.y -= 4.9 * t * t;
29
+ Color = gl_Color;
30
+ }
31
+ else
32
+ {
33
+ vert = gl_Vertex; // Initial position
34
+ Color = Background; // "pre-birth" color
35
+ }
36
+
37
+ gl_Position = gl_ModelViewProjectionMatrix * vert;
38
+ }
data/examples/README ADDED
@@ -0,0 +1,16 @@
1
+ Examples
2
+ ========
3
+
4
+ This directory contains OpenGL examples converted to ruby from various sources.
5
+ As such, they are distributed under various terms - see each file for licensing info.
6
+
7
+ RedBook/
8
+ Examples from OpenGL Red Book and SGI's example code in general, licensed under
9
+ SGI open-source license.
10
+ OrangeBook/
11
+ Examples from OpenGL Orange Book (GLSL), distributed under BSD license
12
+ NeHe/
13
+ NeHe's opengl tutorials (http://nehe.gamedev.net), licensed under free license.
14
+ Misc/
15
+ Other examples. If license is not given, MIT is assumed.
16
+
@@ -0,0 +1,142 @@
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
+ # aapoly.c
38
+ # This program draws filled polygons with antialiased
39
+ # edges. The special GL_SRC_ALPHA_SATURATE blending
40
+ # function is used.
41
+ # Pressing the 't' key turns the antialiasing on and off.
42
+ require 'opengl'
43
+ include Gl,Glu,Glut
44
+
45
+ $polySmooth = true
46
+
47
+ def init
48
+ glCullFace(GL_BACK)
49
+ glEnable(GL_CULL_FACE)
50
+ glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE)
51
+ glClearColor(0.0, 0.0, 0.0, 0.0)
52
+ end
53
+
54
+ NFACE=6
55
+ NVERT=8
56
+ $indices = [
57
+ [4, 5, 6, 7], [2, 3, 7, 6], [0, 4, 7, 3],
58
+ [0, 1, 5, 4], [1, 5, 6, 2], [0, 3, 2, 1]
59
+ ]
60
+
61
+ def drawCube(x0, x1, y0, y1, z0, z1)
62
+ v = [[],[],[],[],[],[],[],[]]
63
+ c = [
64
+ [0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0],
65
+ [0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 0.0, 1.0],
66
+ [0.0, 0.0, 1.0, 1.0], [1.0, 0.0, 1.0, 1.0],
67
+ [0.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]
68
+ ]
69
+
70
+ # indices of front, top, left, bottom, right, back faces
71
+
72
+ v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0
73
+ v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1
74
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0
75
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1
76
+ v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0
77
+ v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1
78
+
79
+ glEnableClientState(GL_VERTEX_ARRAY)
80
+ glEnableClientState(GL_COLOR_ARRAY)
81
+ glVertexPointer(3, GL_FLOAT, 0, v.flatten!.pack("f*"))
82
+ glColorPointer(4, GL_FLOAT, 0, c.flatten!.pack("f*"))
83
+ glDrawElements(GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, $indices.flatten.pack("C*"))
84
+ glDisableClientState(GL_VERTEX_ARRAY)
85
+ glDisableClientState(GL_COLOR_ARRAY)
86
+ end
87
+
88
+ # Note: polygons must be drawn from front to back
89
+ # for proper blending.
90
+ display = proc do
91
+ if ($polySmooth)
92
+ glClear(GL_COLOR_BUFFER_BIT)
93
+ glEnable(GL_BLEND)
94
+ glEnable(GL_POLYGON_SMOOTH)
95
+ glDisable(GL_DEPTH_TEST)
96
+ else
97
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
98
+ glDisable(GL_BLEND)
99
+ glDisable(GL_POLYGON_SMOOTH)
100
+ glEnable(GL_DEPTH_TEST)
101
+ end
102
+
103
+ glPushMatrix()
104
+ glTranslate(0.0, 0.0, -8.0)
105
+ glRotate(30.0, 1.0, 0.0, 0.0)
106
+ glRotate(60.0, 0.0, 1.0, 0.0)
107
+ drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
108
+ glPopMatrix()
109
+ glutSwapBuffers()
110
+ end
111
+
112
+ reshape = proc do |w, h|
113
+ glViewport(0, 0, w, h)
114
+ glMatrixMode(GL_PROJECTION)
115
+ glLoadIdentity()
116
+ gluPerspective(30.0, w.to_f/ h.to_f, 1.0, 20.0)
117
+ glMatrixMode(GL_MODELVIEW)
118
+ glLoadIdentity()
119
+ end
120
+
121
+ keyboard = proc do |key, x, y|
122
+ case (key)
123
+ when ?t ,?T
124
+ $polySmooth = !$polySmooth
125
+ glutPostRedisplay()
126
+ when ?\e
127
+ exit(0) # Escape key
128
+ end
129
+ end
130
+
131
+ # Main Loop
132
+ glutInit
133
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH)
134
+ glutInitWindowSize(500, 500)
135
+ glutInitWindowPosition(100, 100)
136
+ glutCreateWindow($0)
137
+ init()
138
+ glutReshapeFunc(reshape)
139
+ glutKeyboardFunc(keyboard)
140
+ glutDisplayFunc(display)
141
+ glutMainLoop()
142
+
@@ -0,0 +1,119 @@
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
+ # aargb.c
38
+ # This program draws shows how to draw anti-aliased lines. It draws
39
+ # two diagonal lines to form an X when 'r' is typed in the window,
40
+ # the lines are rotated in opposite directions.
41
+ require 'opengl'
42
+ require 'mathn'
43
+ include Gl,Glu,Glut
44
+
45
+ $rotAngle = 0.0
46
+
47
+ # Initialize antialiasing for RGBA mode, including alpha
48
+ # blending, hint, and line width. Print out implementation
49
+ # specific info on line width granularity and width.
50
+ def init
51
+ glEnable(GL_LINE_SMOOTH)
52
+ glEnable(GL_BLEND)
53
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
54
+ glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE)
55
+ glLineWidth(1.5)
56
+ glClearColor(0.0, 0.0, 0.0, 0.0)
57
+ end
58
+
59
+ # Draw 2 diagonal lines to form an X
60
+ display = Proc.new do
61
+ glClear(GL_COLOR_BUFFER_BIT)
62
+
63
+ glColor(0.0, 1.0, 0.0)
64
+ glPushMatrix()
65
+ glRotate(-$rotAngle, 0.0, 0.0, 0.1)
66
+ glBegin(GL_LINES)
67
+ glVertex(-0.5, 0.5)
68
+ glVertex(0.5, -0.5)
69
+ glEnd()
70
+ glPopMatrix()
71
+
72
+ glColor(0.0, 0.0, 1.0)
73
+ glPushMatrix()
74
+ glRotate($rotAngle, 0.0, 0.0, 0.1)
75
+ glBegin(GL_LINES)
76
+ glVertex(0.5, 0.5)
77
+ glVertex(-0.5, -0.5)
78
+ glEnd()
79
+ glPopMatrix()
80
+ glutSwapBuffers()
81
+ end
82
+
83
+ reshape = Proc.new do |w, h|
84
+ glViewport(0, 0, w, h)
85
+ glMatrixMode(GL_PROJECTION)
86
+ glLoadIdentity()
87
+ if (w <= h)
88
+ gluOrtho2D(-1.0, 1.0, -1.0*h/w, 1.0*h/w)
89
+ else
90
+ gluOrtho2D(-1.0*w/h, 1.0*w/h, -1.0, 1.0)
91
+ end
92
+ glMatrixMode(GL_MODELVIEW)
93
+ glLoadIdentity()
94
+ end
95
+
96
+ keyboard = Proc.new do |key, x, y|
97
+ case (key)
98
+ when ?r,?R
99
+ $rotAngle = $rotAngle + 20.0
100
+ $rotAngle = 0.0 if ($rotAngle >= 360.0)
101
+ glutPostRedisplay()
102
+ when ?\e # Escape Key
103
+ exit(0)
104
+ end
105
+ end
106
+
107
+ # Main Loop
108
+ # Open window with initial window size, title bar,
109
+ # RGBA display mode, and handle input events.
110
+ glutInit
111
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
112
+ glutInitWindowSize(500, 500)
113
+ glutInitWindowPosition(100, 100)
114
+ glutCreateWindow($0)
115
+ init()
116
+ glutReshapeFunc(reshape)
117
+ glutKeyboardFunc(keyboard)
118
+ glutDisplayFunc(display)
119
+ glutMainLoop()
@@ -0,0 +1,162 @@
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
+ # accanti.c
40
+
41
+ require 'opengl'
42
+ require 'jitter'
43
+ include Gl,Glu,Glut
44
+
45
+ # Initialize lighting and other values.
46
+ def myinit
47
+ mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ]
48
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
49
+ light_position = [ 0.0, 0.0, 10.0, 1.0 ]
50
+ lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
51
+
52
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
53
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
54
+ glMaterial(GL_FRONT, GL_SHININESS, 50.0)
55
+ glLight(GL_LIGHT0, GL_POSITION, light_position)
56
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, lm_ambient)
57
+
58
+ glEnable(GL_LIGHTING)
59
+ glEnable(GL_LIGHT0)
60
+ glDepthFunc(GL_LESS)
61
+ glEnable(GL_DEPTH_TEST)
62
+ glShadeModel(GL_FLAT)
63
+
64
+ glClearColor(0.0, 0.0, 0.0, 0.0)
65
+ glClearAccum(0.0, 0.0, 0.0, 0.0)
66
+ end
67
+
68
+ def displayObjects
69
+ torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
70
+ cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ]
71
+ sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ]
72
+ octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ]
73
+
74
+ glPushMatrix()
75
+ glRotate(30.0, 1.0, 0.0, 0.0)
76
+
77
+ glPushMatrix()
78
+ glTranslate(-0.80, 0.35, 0.0)
79
+ glRotate(100.0, 1.0, 0.0, 0.0)
80
+ glMaterial(GL_FRONT, GL_DIFFUSE, torus_diffuse)
81
+ glutSolidTorus(0.275, 0.85, 16, 16)
82
+ glPopMatrix()
83
+
84
+ glPushMatrix()
85
+ glTranslate(-0.75, -0.50, 0.0)
86
+ glRotate(45.0, 0.0, 0.0, 1.0)
87
+ glRotate(45.0, 1.0, 0.0, 0.0)
88
+ glMaterial(GL_FRONT, GL_DIFFUSE, cube_diffuse)
89
+ glutSolidCube(1.5)
90
+ glPopMatrix()
91
+
92
+ glPushMatrix()
93
+ glTranslate(0.75, 0.60, 0.0)
94
+ glRotate(30.0, 1.0, 0.0, 0.0)
95
+ glMaterial(GL_FRONT, GL_DIFFUSE, sphere_diffuse)
96
+ glutSolidSphere(1.0, 16, 16)
97
+ glPopMatrix()
98
+
99
+ glPushMatrix()
100
+ glTranslate(0.70, -0.90, 0.25)
101
+ glMaterial(GL_FRONT, GL_DIFFUSE, octa_diffuse)
102
+ glutSolidOctahedron()
103
+ glPopMatrix()
104
+
105
+ glPopMatrix()
106
+ end
107
+
108
+ ACSIZE=8
109
+
110
+ myDisplay = proc do
111
+ viewport = glGetDoublev(GL_VIEWPORT)
112
+
113
+ glClear(GL_ACCUM_BUFFER_BIT)
114
+ for jitter in 0...ACSIZE
115
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
116
+ glPushMatrix()
117
+ # Note that 4.5 is the distance in world space between
118
+ # left and right and bottom and top.
119
+ # This formula converts fractional pixel movement to
120
+ # world coordinates.
121
+ glTranslate($j8[jitter][0]*4.5/viewport[2], $j8[jitter][1]*4.5/viewport[3], 0.0)
122
+ displayObjects()
123
+ glPopMatrix()
124
+ glAccum(GL_ACCUM, 1.0/ACSIZE)
125
+ end
126
+ glAccum(GL_RETURN, 1.0)
127
+ glutSwapBuffers()
128
+ end
129
+
130
+ myReshape = proc do |w, h|
131
+ glViewport(0, 0, w, h)
132
+ glMatrixMode(GL_PROJECTION)
133
+ glLoadIdentity()
134
+ if (w <= h)
135
+ glOrtho(-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0)
136
+ else
137
+ glOrtho(-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0)
138
+ end
139
+ glMatrixMode(GL_MODELVIEW)
140
+ end
141
+
142
+ keyboard = Proc.new do |key, x, y|
143
+ case (key)
144
+ when ?\e
145
+ exit(0);
146
+ end
147
+ end
148
+
149
+ # Main Loop
150
+ # Open window with initial window size, title bar,
151
+ # RGBA display mode, and handle input events.
152
+ #
153
+ glutInit()
154
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ACCUM | GLUT_DEPTH)
155
+ glutInitWindowSize(500, 500)
156
+ glutInitWindowPosition(100, 100)
157
+ glutCreateWindow($0)
158
+ myinit()
159
+ glutReshapeFunc(myReshape)
160
+ glutDisplayFunc(myDisplay)
161
+ glutKeyboardFunc(keyboard)
162
+ glutMainLoop()