ruby-opengl 0.40.1 → 0.50.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 (154) hide show
  1. data/Rakefile +2 -2
  2. data/doc/build_install.txt +48 -28
  3. data/doc/extensions.txt +361 -0
  4. data/doc/history.txt +8 -2
  5. data/doc/requirements_and_design.txt +0 -13
  6. data/doc/roadmap.txt +11 -13
  7. data/doc/supplies/page_template.html +11 -5
  8. data/doc/thanks.txt +2 -4
  9. data/doc/tutorial.txt +1 -4
  10. data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
  11. data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
  12. data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
  13. data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
  14. data/examples/NeHe/nehe_lesson36.rb +303 -0
  15. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  16. data/examples/OrangeBook/brick.frag +36 -0
  17. data/examples/OrangeBook/brick.rb +388 -0
  18. data/examples/OrangeBook/brick.vert +41 -0
  19. data/examples/OrangeBook/particle.frag +17 -0
  20. data/examples/OrangeBook/particle.rb +424 -0
  21. data/examples/OrangeBook/particle.vert +38 -0
  22. data/examples/README +13 -83
  23. data/examples/RedBook/aaindex.rb +97 -0
  24. data/examples/RedBook/aapoly.rb +142 -0
  25. data/examples/RedBook/aargb.rb +119 -0
  26. data/examples/RedBook/accanti.rb +162 -0
  27. data/examples/RedBook/accpersp.rb +215 -0
  28. data/examples/RedBook/alpha.rb +123 -0
  29. data/examples/RedBook/alpha3D.rb +158 -0
  30. data/examples/RedBook/bezcurve.rb +105 -0
  31. data/examples/RedBook/bezmesh.rb +137 -0
  32. data/examples/RedBook/checker.rb +124 -0
  33. data/examples/RedBook/clip.rb +95 -0
  34. data/examples/RedBook/colormat.rb +135 -0
  35. data/examples/RedBook/cube.rb +69 -0
  36. data/examples/RedBook/depthcue.rb +99 -0
  37. data/examples/RedBook/dof.rb +205 -0
  38. data/examples/{legacy → RedBook}/double.rb +59 -58
  39. data/examples/{legacy → RedBook}/drawf.rb +47 -54
  40. data/examples/RedBook/feedback.rb +145 -0
  41. data/examples/RedBook/fog.rb +167 -0
  42. data/examples/RedBook/font.rb +151 -0
  43. data/examples/RedBook/hello.rb +79 -0
  44. data/examples/RedBook/image.rb +137 -0
  45. data/examples/{legacy → RedBook}/jitter.rb +60 -62
  46. data/examples/RedBook/lines.rb +128 -0
  47. data/examples/RedBook/list.rb +111 -0
  48. data/examples/RedBook/material.rb +275 -0
  49. data/examples/RedBook/mipmap.rb +156 -0
  50. data/examples/{legacy → RedBook}/model.rb +66 -72
  51. data/examples/{legacy → RedBook}/movelight.rb +67 -75
  52. data/examples/RedBook/pickdepth.rb +179 -0
  53. data/examples/{legacy → RedBook}/planet.rb +62 -66
  54. data/examples/RedBook/quadric.rb +158 -0
  55. data/examples/RedBook/robot.rb +115 -0
  56. data/examples/RedBook/select.rb +196 -0
  57. data/examples/RedBook/smooth.rb +95 -0
  58. data/examples/RedBook/stencil.rb +163 -0
  59. data/examples/RedBook/stroke.rb +167 -0
  60. data/examples/RedBook/surface.rb +166 -0
  61. data/examples/RedBook/teaambient.rb +132 -0
  62. data/examples/RedBook/teapots.rb +182 -0
  63. data/examples/RedBook/tess.rb +183 -0
  64. data/examples/RedBook/texbind.rb +147 -0
  65. data/examples/RedBook/texgen.rb +169 -0
  66. data/examples/RedBook/texturesurf.rb +128 -0
  67. data/examples/RedBook/varray.rb +159 -0
  68. data/examples/RedBook/wrap.rb +148 -0
  69. data/examples/misc/anisotropic.rb +194 -0
  70. data/examples/misc/font-glut.rb +46 -0
  71. data/examples/{plane.rb → misc/plane.rb} +0 -0
  72. data/examples/misc/readpixel.rb +65 -0
  73. data/examples/{smooth.rb → misc/smooth.rb} +0 -0
  74. data/examples/{test.rb → misc/test.rb} +0 -0
  75. data/ext/common/common.h +252 -70
  76. data/ext/common/gl-enums.h +6102 -7334
  77. data/ext/common/gl-types.h +47 -0
  78. data/ext/common/glu-enums.h +469 -0
  79. data/ext/gl/gl-1.0-1.1.c +842 -2464
  80. data/ext/gl/gl-1.2.c +217 -281
  81. data/ext/gl/gl-1.3.c +113 -133
  82. data/ext/gl/gl-1.4.c +98 -334
  83. data/ext/gl/gl-1.5.c +28 -34
  84. data/ext/gl/gl-2.0.c +26 -235
  85. data/ext/gl/gl-2.1.c +31 -124
  86. data/ext/gl/gl-enums.c +786 -631
  87. data/ext/gl/gl-ext-arb.c +66 -0
  88. data/ext/gl/gl-ext-ext.c +218 -0
  89. data/ext/gl/gl.c +138 -31
  90. data/ext/gl/mkrf_conf.rb +1 -0
  91. data/ext/glu/glu-enums.c +163 -0
  92. data/ext/glu/glu.c +1003 -1205
  93. data/ext/glu/mkrf_conf.rb +1 -0
  94. data/ext/glut/glut.c +1056 -1175
  95. data/lib/opengl.rb +90 -3
  96. data/test/tc_common.rb +26 -13
  97. data/test/tc_ext_arb.rb +73 -0
  98. data/test/tc_ext_ext.rb +74 -0
  99. data/test/tc_func_12.rb +8 -8
  100. data/test/tc_func_13.rb +17 -11
  101. data/test/tc_func_14.rb +8 -8
  102. data/test/tc_func_15.rb +190 -2
  103. data/test/tc_func_20.rb +36 -10
  104. data/test/tc_func_21.rb +445 -2
  105. data/test/tc_glu.rb +305 -0
  106. data/test/tc_misc.rb +1 -0
  107. metadata +84 -68
  108. data/doc/screenshots.txt +0 -23
  109. data/examples/legacy/COPYRIGHT +0 -8
  110. data/examples/legacy/aaindex.rb +0 -98
  111. data/examples/legacy/aapoly.rb +0 -153
  112. data/examples/legacy/aargb.rb +0 -139
  113. data/examples/legacy/accanti.rb +0 -159
  114. data/examples/legacy/accpersp.rb +0 -216
  115. data/examples/legacy/alpha.rb +0 -133
  116. data/examples/legacy/alpha3D.rb +0 -165
  117. data/examples/legacy/bezcurve.rb +0 -107
  118. data/examples/legacy/bezmesh.rb +0 -131
  119. data/examples/legacy/checker.rb +0 -121
  120. data/examples/legacy/clip.rb +0 -104
  121. data/examples/legacy/colormat.rb +0 -145
  122. data/examples/legacy/cube.rb +0 -73
  123. data/examples/legacy/depthcue.rb +0 -101
  124. data/examples/legacy/dof.rb +0 -212
  125. data/examples/legacy/feedback.rb +0 -152
  126. data/examples/legacy/fog.rb +0 -172
  127. data/examples/legacy/font-glut.rb +0 -41
  128. data/examples/legacy/font.rb +0 -158
  129. data/examples/legacy/hello.rb +0 -75
  130. data/examples/legacy/image.rb +0 -145
  131. data/examples/legacy/lines.rb +0 -135
  132. data/examples/legacy/list.rb +0 -120
  133. data/examples/legacy/material.rb +0 -290
  134. data/examples/legacy/mipmap.rb +0 -159
  135. data/examples/legacy/pickdepth.rb +0 -180
  136. data/examples/legacy/quadric.rb +0 -180
  137. data/examples/legacy/readpixel.rb +0 -59
  138. data/examples/legacy/robot.rb +0 -120
  139. data/examples/legacy/select.rb +0 -207
  140. data/examples/legacy/smooth.rb +0 -41
  141. data/examples/legacy/stencil.rb +0 -154
  142. data/examples/legacy/stroke.rb +0 -170
  143. data/examples/legacy/surface.rb +0 -170
  144. data/examples/legacy/teaambient.rb +0 -132
  145. data/examples/legacy/teapots.rb +0 -188
  146. data/examples/legacy/tess.rb +0 -222
  147. data/examples/legacy/texbind.rb +0 -157
  148. data/examples/legacy/texgen.rb +0 -171
  149. data/examples/legacy/texturesurf.rb +0 -128
  150. data/examples/legacy/varray.rb +0 -167
  151. data/examples/legacy/wrap.rb +0 -158
  152. data/lib/gl_prev.rb +0 -46
  153. data/lib/glu_prev.rb +0 -46
  154. data/lib/glut_prev.rb +0 -45
@@ -0,0 +1,151 @@
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
+ # font.c
38
+ #
39
+ # Draws some text in a bitmapped font. Uses glBitmap()
40
+ # and other pixel routines. Also demonstrates use of
41
+ # display lists.
42
+ require 'opengl'
43
+ include Gl,Glu,Glut
44
+
45
+ $space = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
46
+
47
+ $letters = [
48
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18],
49
+ [0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
50
+ [0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
51
+ [0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc],
52
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff],
53
+ [0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff],
54
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
55
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
56
+ [0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e],
57
+ [0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06],
58
+ [0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3],
59
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0],
60
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3],
61
+ [0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3],
62
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e],
63
+ [0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
64
+ [0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c],
65
+ [0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
66
+ [0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e],
67
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff],
68
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
69
+ [0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
70
+ [0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
71
+ [0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
72
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
73
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff]
74
+ ]
75
+
76
+ $fontOffset = 0
77
+
78
+ def makeRasterFont
79
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
80
+
81
+ $fontOffset = glGenLists(128)
82
+ i = 0
83
+ j = ?A
84
+ for i in 0...26
85
+ glNewList($fontOffset + j, GL_COMPILE)
86
+ glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"))
87
+ glEndList()
88
+ j+=1
89
+ end
90
+ glNewList($fontOffset + ' '[0], GL_COMPILE)
91
+ glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"))
92
+ glEndList()
93
+ end
94
+
95
+ def init
96
+ glShadeModel(GL_FLAT)
97
+ makeRasterFont()
98
+ end
99
+
100
+ def printString(s)
101
+ glPushAttrib(GL_LIST_BIT)
102
+ glListBase($fontOffset)
103
+ glCallLists(s)
104
+ glPopAttrib()
105
+ end
106
+
107
+ # Everything above this line could be in a library
108
+ # that defines a font. To make it work, you've got
109
+ # to call makeRasterFont() before you start making
110
+ # calls to printString().
111
+ display = proc do
112
+ white = [ 1.0, 1.0, 1.0 ]
113
+
114
+ glClear(GL_COLOR_BUFFER_BIT)
115
+ glColor(white)
116
+
117
+ glRasterPos(20, 60)
118
+ printString("THE QUICK BROWN FOX JUMPS")
119
+ glRasterPos(20, 40)
120
+ printString("OVER A LAZY DOG")
121
+ glutSwapBuffers()
122
+ end
123
+
124
+ reshape = proc do |w, h|
125
+ glViewport(0, 0, w, h)
126
+ glMatrixMode(GL_PROJECTION)
127
+ glLoadIdentity()
128
+ glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
129
+ glMatrixMode(GL_MODELVIEW)
130
+ end
131
+
132
+ keyboard = proc do |key, x, y|
133
+ case (key)
134
+ when 27
135
+ exit(0)
136
+ end
137
+ end
138
+
139
+ # Main Loop
140
+ # Open window with initial window size, title bar,
141
+ # RGBA display mode, and handle input events.
142
+ glutInit()
143
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
144
+ glutInitWindowSize(400, 100)
145
+ glutInitWindowPosition(100, 100)
146
+ glutCreateWindow()
147
+ init()
148
+ glutReshapeFunc(reshape)
149
+ glutKeyboardFunc(keyboard)
150
+ glutDisplayFunc(display)
151
+ glutMainLoop()
@@ -0,0 +1,79 @@
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
+ # hello.c
38
+ # This is a simple, introductory OpenGL program.
39
+ require 'opengl'
40
+ include Gl,Glu,Glut
41
+
42
+ display = Proc.new do
43
+ glClear(GL_COLOR_BUFFER_BIT)
44
+
45
+ glColor(1.0, 1.0, 1.0)
46
+ glBegin(GL_POLYGON)
47
+ glVertex(0.25, 0.25, 0.0)
48
+ glVertex(0.75, 0.25, 0.0)
49
+ glVertex(0.75, 0.75, 0.0)
50
+ glVertex(0.25, 0.75, 0.0)
51
+ glEnd()
52
+
53
+ glutSwapBuffers()
54
+ end
55
+
56
+ def init
57
+ glClearColor(0.0, 0.0, 0.0, 0.0)
58
+
59
+ glMatrixMode(GL_PROJECTION)
60
+ glLoadIdentity()
61
+ glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0)
62
+ end
63
+
64
+ keyboard = Proc.new do |key, x, y|
65
+ case (key)
66
+ when 27
67
+ exit(0);
68
+ end
69
+ end
70
+
71
+ glutInit
72
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
73
+ glutInitWindowSize(500, 500)
74
+ glutInitWindowPosition(100, 100)
75
+ glutCreateWindow("hello")
76
+ init()
77
+ glutDisplayFunc(display)
78
+ glutKeyboardFunc(keyboard)
79
+ glutMainLoop()
@@ -0,0 +1,137 @@
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
+ # image.c
38
+ # This program demonstrates drawing pixels and shows the effect
39
+ # of glDrawPixels(), glCopyPixels(), and glPixelZoom().
40
+ # Interaction: moving the mouse while pressing the mouse button
41
+ # will copy the image in the lower-left corner of the window
42
+ # to the mouse position, using the current pixel zoom factors.
43
+ # There is no attempt to prevent you from drawing over the original
44
+ # image. If you press the 'r' key, the original image and zoom
45
+ # factors are reset. If you press the 'z' or 'Z' keys, you change
46
+ # the zoom factors.
47
+ require 'opengl'
48
+ require 'mathn'
49
+ include Gl,Glu,Glut
50
+
51
+ # Create checkerboard image
52
+ CheckImageWidth=64
53
+ CheckImageHeight=64
54
+ $checkImage=[]
55
+
56
+ $zoomFactor = 1.0
57
+ $height = 0.0
58
+
59
+ def makeCheckImage
60
+ for i in 0..CheckImageWidth-1
61
+ for j in 0..CheckImageHeight-1
62
+ c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
63
+ $checkImage[(i+CheckImageWidth*j)*3+0] = c
64
+ $checkImage[(i+CheckImageWidth*j)*3+1] = c
65
+ $checkImage[(i+CheckImageWidth*j)*3+2] = c
66
+ end
67
+ end
68
+ end
69
+
70
+ def init
71
+ glClearColor(0.0, 0.0, 0.0, 0.0)
72
+ glShadeModel(GL_FLAT)
73
+ makeCheckImage()
74
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
75
+ end
76
+
77
+ display = Proc.new do
78
+ glClear(GL_COLOR_BUFFER_BIT)
79
+ glRasterPos(0, 0)
80
+ glDrawPixels(CheckImageWidth, CheckImageHeight, GL_RGB, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
81
+ glFlush()
82
+ end
83
+
84
+ reshape = Proc.new do |w, h|
85
+ glViewport(0, 0, w, h)
86
+ $height = h
87
+ glMatrixMode(GL_PROJECTION)
88
+ glLoadIdentity()
89
+ gluOrtho2D(0.0, w, 0.0, h)
90
+ glMatrixMode(GL_MODELVIEW)
91
+ glLoadIdentity()
92
+ end
93
+
94
+ $screeny = 0.0
95
+ motion = Proc.new do |x, y|
96
+ $screeny = $height - y
97
+ glRasterPos(x, $screeny)
98
+ glPixelZoom($zoomFactor, $zoomFactor)
99
+ glCopyPixels(0, 0, CheckImageWidth, CheckImageHeight, GL_COLOR)
100
+ glPixelZoom(1.0, 1.0)
101
+ glFlush()
102
+ end
103
+
104
+ keyboard = Proc.new do |key, x, y|
105
+ case (key)
106
+ when 'r'[0],'R'[0]
107
+ $zoomFactor = 1.0
108
+ glutPostRedisplay()
109
+ printf("zoomFactor reset to 1.0\n")
110
+ when 'z'[0]
111
+ $zoomFactor = $zoomFactor + 0.5
112
+ if ($zoomFactor >= 3.0)
113
+ $zoomFactor = 3.0
114
+ end
115
+ printf("zoomFactor is now %4.1f\n", $zoomFactor)
116
+ when 'Z'[0]
117
+ $zoomFactor = $zoomFactor - 0.5
118
+ if ($zoomFactor <= 0.5)
119
+ $zoomFactor = 0.5
120
+ end
121
+ printf("zoomFactor is now %4.1f\n", $zoomFactor)
122
+ when 27
123
+ exit(0)
124
+ end
125
+ end
126
+
127
+ glutInit
128
+ glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
129
+ glutInitWindowSize(250, 250)
130
+ glutInitWindowPosition(100, 100)
131
+ glutCreateWindow($0)
132
+ init()
133
+ glutDisplayFunc(display)
134
+ glutReshapeFunc(reshape)
135
+ glutKeyboardFunc(keyboard)
136
+ glutMotionFunc(motion)
137
+ glutMainLoop()
@@ -1,83 +1,81 @@
1
- #/*
2
- # * (c) Copyright 1993, 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(TM) is a trademark of Silicon Graphics, Inc.
36
- # */
37
- #/*
38
- #jitter.h
39
1
  #
40
- #This file contains jitter point arrays for 2,3,4,8,15,24 and 66 jitters.
2
+ # (c) Copyright 1993, 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.
41
11
  #
42
- #The arrays are named j2, j3, etc. Each element in the array has the form,
43
- #for example, j8[0].x and j8[0].y
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.
44
34
  #
45
- #Values are floating point in the range -.5 < x < .5, -.5 < y < .5, and
46
- #have a gaussian distribution around the origin.
35
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
36
+ #
37
+ # jitter.h
38
+ #
39
+ # This file contains jitter point arrays for 2,3,4,8,15,24 and 66 jitters.
40
+ #
41
+ # The arrays are named j2, j3, etc. Each element in the array has the form,
42
+ # for example, j8[0].x and j8[0].y
43
+ #
44
+ # Values are floating point in the range -.5 < x < .5, -.5 < y < .5, and
45
+ # have a gaussian distribution around the origin.
46
+ #
47
+ # Use these to do model jittering for scene anti-aliasing and view volume
48
+ # jittering for depth of field effects. Use in conjunction with the
49
+ # accwindow() routine.
47
50
  #
48
- #Use these to do model jittering for scene anti-aliasing and view volume
49
- #jittering for depth of field effects. Use in conjunction with the
50
- #accwindow() routine.
51
- #*/
52
51
 
53
52
  MAX_SAMPLES=66
54
53
 
55
-
56
- #/* 2 jitter points */
54
+ # 2 jitter points
57
55
  $j2 = [
58
56
  [ 0.246490, 0.249999],
59
57
  [-0.246490, -0.249999]
60
- ];
58
+ ]
61
59
 
62
60
 
63
- # /* 3 jitter points */
61
+ # 3 jitter points
64
62
  $j3 = [
65
63
  [-0.373411, -0.250550],
66
64
  [ 0.256263, 0.368119],
67
65
  [ 0.117148, -0.117570]
68
- ];
66
+ ]
69
67
 
70
68
 
71
- # /* 4 jitter points */
69
+ # 4 jitter points
72
70
  $j4 = [
73
71
  [-0.208147, 0.353730],
74
72
  [ 0.203849, -0.353780],
75
73
  [-0.292626, -0.149945],
76
74
  [ 0.296924, 0.149994]
77
- ];
75
+ ]
78
76
 
79
77
 
80
- # /* 8 jitter points */
78
+ # 8 jitter points
81
79
  $j8 = [
82
80
  [-0.334818, 0.435331],
83
81
  [ 0.286438, -0.393495],
@@ -87,10 +85,10 @@ $j8 = [
87
85
  [-0.079263, -0.317383],
88
86
  [ 0.102254, 0.299133],
89
87
  [ 0.164216, -0.054399]
90
- ];
88
+ ]
91
89
 
92
90
 
93
- # /* 15 jitter points */
91
+ # 15 jitter points
94
92
  $j15 = [
95
93
  [ 0.285561, 0.188437],
96
94
  [ 0.360176, -0.065688],
@@ -107,9 +105,9 @@ $j15 = [
107
105
  [-0.370135, -0.116425],
108
106
  [ 0.451636, -0.300013],
109
107
  [-0.370610, 0.387504]
110
- ];
108
+ ]
111
109
 
112
- # /* 24 jitter points */
110
+ # 24 jitter points
113
111
  $j24 = [
114
112
  [ 0.030245, 0.136384],
115
113
  [ 0.018865, -0.348867],
@@ -135,10 +133,10 @@ $j24 = [
135
133
  [-0.234392, 0.354659],
136
134
  [-0.003102, -0.154402],
137
135
  [ 0.297997, -0.417965]
138
- ];
136
+ ]
139
137
 
140
138
 
141
- # /* 66 jitter points */
139
+ # 66 jitter points
142
140
  $j66 = [
143
141
  [ 0.266377, -0.218171],
144
142
  [-0.170919, -0.429368],
@@ -206,4 +204,4 @@ $j66 = [
206
204
  [ 0.076248, 0.478538],
207
205
  [-0.073036, -0.355064],
208
206
  [ 0.145087, 0.221726]
209
- ];
207
+ ]