opengl 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +29 -0
  5. data/.gemtest +0 -0
  6. data/.gitignore +6 -0
  7. data/.travis.yml +19 -0
  8. data/History.rdoc +77 -0
  9. data/MIT-LICENSE +18 -0
  10. data/Manifest.txt +138 -0
  11. data/README.rdoc +102 -0
  12. data/Rakefile +60 -0
  13. data/examples/NeHe/NeHe.png +0 -0
  14. data/examples/NeHe/crate.png +0 -0
  15. data/examples/NeHe/glass.png +0 -0
  16. data/examples/NeHe/nehe_lesson02.rb +117 -0
  17. data/examples/NeHe/nehe_lesson03.rb +123 -0
  18. data/examples/NeHe/nehe_lesson04.rb +132 -0
  19. data/examples/NeHe/nehe_lesson05.rb +182 -0
  20. data/examples/NeHe/nehe_lesson06.rb +186 -0
  21. data/examples/NeHe/nehe_lesson07.rb +240 -0
  22. data/examples/NeHe/nehe_lesson08.rb +255 -0
  23. data/examples/NeHe/nehe_lesson09.rb +203 -0
  24. data/examples/NeHe/nehe_lesson11.rb +176 -0
  25. data/examples/NeHe/nehe_lesson12.rb +203 -0
  26. data/examples/NeHe/nehe_lesson16.rb +211 -0
  27. data/examples/NeHe/nehe_lesson19.rb +209 -0
  28. data/examples/NeHe/nehe_lesson36.rb +308 -0
  29. data/examples/NeHe/particle.png +0 -0
  30. data/examples/NeHe/star.png +0 -0
  31. data/examples/NeHe/tim.png +0 -0
  32. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  33. data/examples/OrangeBook/brick.frag +36 -0
  34. data/examples/OrangeBook/brick.rb +378 -0
  35. data/examples/OrangeBook/brick.vert +41 -0
  36. data/examples/OrangeBook/particle.frag +17 -0
  37. data/examples/OrangeBook/particle.rb +408 -0
  38. data/examples/OrangeBook/particle.vert +38 -0
  39. data/examples/README +16 -0
  40. data/examples/RedBook/aapoly.rb +143 -0
  41. data/examples/RedBook/aargb.rb +121 -0
  42. data/examples/RedBook/accanti.rb +164 -0
  43. data/examples/RedBook/accpersp.rb +217 -0
  44. data/examples/RedBook/alpha.rb +125 -0
  45. data/examples/RedBook/alpha3D.rb +160 -0
  46. data/examples/RedBook/bezcurve.rb +107 -0
  47. data/examples/RedBook/bezmesh.rb +139 -0
  48. data/examples/RedBook/checker.rb +126 -0
  49. data/examples/RedBook/clip.rb +97 -0
  50. data/examples/RedBook/colormat.rb +137 -0
  51. data/examples/RedBook/cube.rb +71 -0
  52. data/examples/RedBook/depthcue.rb +101 -0
  53. data/examples/RedBook/dof.rb +206 -0
  54. data/examples/RedBook/double.rb +107 -0
  55. data/examples/RedBook/drawf.rb +93 -0
  56. data/examples/RedBook/feedback.rb +147 -0
  57. data/examples/RedBook/fog.rb +168 -0
  58. data/examples/RedBook/font.rb +153 -0
  59. data/examples/RedBook/hello.rb +81 -0
  60. data/examples/RedBook/image.rb +139 -0
  61. data/examples/RedBook/jitter.rb +207 -0
  62. data/examples/RedBook/light.rb +155 -0
  63. data/examples/RedBook/lines.rb +130 -0
  64. data/examples/RedBook/list.rb +113 -0
  65. data/examples/RedBook/material.rb +276 -0
  66. data/examples/RedBook/mipmap.rb +158 -0
  67. data/examples/RedBook/model.rb +115 -0
  68. data/examples/RedBook/movelight.rb +134 -0
  69. data/examples/RedBook/pickdepth.rb +181 -0
  70. data/examples/RedBook/planet.rb +110 -0
  71. data/examples/RedBook/quadric.rb +160 -0
  72. data/examples/RedBook/robot.rb +117 -0
  73. data/examples/RedBook/select.rb +198 -0
  74. data/examples/RedBook/smooth.rb +97 -0
  75. data/examples/RedBook/stencil.rb +165 -0
  76. data/examples/RedBook/stroke.rb +169 -0
  77. data/examples/RedBook/surface.rb +168 -0
  78. data/examples/RedBook/teaambient.rb +134 -0
  79. data/examples/RedBook/teapots.rb +184 -0
  80. data/examples/RedBook/tess.rb +185 -0
  81. data/examples/RedBook/texbind.rb +149 -0
  82. data/examples/RedBook/texgen.rb +171 -0
  83. data/examples/RedBook/texturesurf.rb +130 -0
  84. data/examples/RedBook/varray.rb +161 -0
  85. data/examples/RedBook/wrap.rb +150 -0
  86. data/examples/misc/OGLBench.rb +338 -0
  87. data/examples/misc/anisotropic.rb +196 -0
  88. data/examples/misc/fbo_test.rb +357 -0
  89. data/examples/misc/font-glut.rb +47 -0
  90. data/examples/misc/glfwtest.rb +30 -0
  91. data/examples/misc/plane.rb +161 -0
  92. data/examples/misc/readpixel.rb +66 -0
  93. data/examples/misc/sdltest.rb +36 -0
  94. data/examples/misc/trislam.rb +829 -0
  95. data/ext/opengl/common.h +428 -0
  96. data/ext/opengl/conv.h +244 -0
  97. data/ext/opengl/extconf.rb +47 -0
  98. data/ext/opengl/funcdef.h +313 -0
  99. data/ext/opengl/gl-1.0-1.1.c +3075 -0
  100. data/ext/opengl/gl-1.2.c +155 -0
  101. data/ext/opengl/gl-1.3.c +443 -0
  102. data/ext/opengl/gl-1.4.c +348 -0
  103. data/ext/opengl/gl-1.5.c +224 -0
  104. data/ext/opengl/gl-2.0.c +667 -0
  105. data/ext/opengl/gl-2.1.c +57 -0
  106. data/ext/opengl/gl-3.0.c +493 -0
  107. data/ext/opengl/gl-enums.c +4873 -0
  108. data/ext/opengl/gl-enums.h +14588 -0
  109. data/ext/opengl/gl-error.c +112 -0
  110. data/ext/opengl/gl-error.h +28 -0
  111. data/ext/opengl/gl-ext-3dfx.c +27 -0
  112. data/ext/opengl/gl-ext-arb.c +875 -0
  113. data/ext/opengl/gl-ext-ati.c +41 -0
  114. data/ext/opengl/gl-ext-ext.c +889 -0
  115. data/ext/opengl/gl-ext-gremedy.c +41 -0
  116. data/ext/opengl/gl-ext-nv.c +680 -0
  117. data/ext/opengl/gl-types.h +67 -0
  118. data/ext/opengl/gl.c +220 -0
  119. data/ext/opengl/gl_buffer.c +177 -0
  120. data/ext/opengl/opengl.c +7 -0
  121. data/lib/gl.rb +1 -0
  122. data/lib/opengl.rb +53 -0
  123. data/lib/opengl/2.0/opengl.so +0 -0
  124. data/lib/opengl/2.1/opengl.so +0 -0
  125. data/lib/opengl/test_case.rb +86 -0
  126. data/test/dummy.xorg.conf +140 -0
  127. data/test/test_gl.rb +38 -0
  128. data/test/test_gl_10_11.rb +1363 -0
  129. data/test/test_gl_12.rb +71 -0
  130. data/test/test_gl_13.rb +221 -0
  131. data/test/test_gl_14.rb +218 -0
  132. data/test/test_gl_15.rb +258 -0
  133. data/test/test_gl_20.rb +417 -0
  134. data/test/test_gl_21.rb +436 -0
  135. data/test/test_gl_ext_arb.rb +508 -0
  136. data/test/test_gl_ext_ati.rb +28 -0
  137. data/test/test_gl_ext_ext.rb +608 -0
  138. data/test/test_gl_ext_gremedy.rb +29 -0
  139. data/test/test_gl_ext_nv.rb +349 -0
  140. data/test/test_opengl_buffer.rb +120 -0
  141. data/utils/README +6 -0
  142. data/utils/enumgen.rb +108 -0
  143. data/utils/extlistgen.rb +90 -0
  144. metadata +319 -0
  145. metadata.gz.sig +1 -0
@@ -0,0 +1,153 @@
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
+ require 'glu'
44
+ require 'glut'
45
+ include Gl,Glu,Glut
46
+
47
+ $space = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
48
+
49
+ $letters = [
50
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18],
51
+ [0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
52
+ [0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
53
+ [0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc],
54
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff],
55
+ [0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff],
56
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
57
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
58
+ [0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e],
59
+ [0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06],
60
+ [0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3],
61
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0],
62
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3],
63
+ [0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3],
64
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e],
65
+ [0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
66
+ [0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c],
67
+ [0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
68
+ [0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e],
69
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff],
70
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
71
+ [0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
72
+ [0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
73
+ [0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
74
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
75
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff]
76
+ ]
77
+
78
+ $fontOffset = 0
79
+
80
+ def makeRasterFont
81
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
82
+
83
+ $fontOffset = glGenLists(128)
84
+ i = 0
85
+ j = ?A
86
+ for i in 0...26
87
+ glNewList($fontOffset + j, GL_COMPILE)
88
+ glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"))
89
+ glEndList()
90
+ j+=1
91
+ end
92
+ glNewList($fontOffset + ' '[0], GL_COMPILE)
93
+ glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"))
94
+ glEndList()
95
+ end
96
+
97
+ def init
98
+ glShadeModel(GL_FLAT)
99
+ makeRasterFont()
100
+ end
101
+
102
+ def printString(s)
103
+ glPushAttrib(GL_LIST_BIT)
104
+ glListBase($fontOffset)
105
+ glCallLists(GL_BYTE,s)
106
+ glPopAttrib()
107
+ end
108
+
109
+ # Everything above this line could be in a library
110
+ # that defines a font. To make it work, you've got
111
+ # to call makeRasterFont() before you start making
112
+ # calls to printString().
113
+ display = proc do
114
+ white = [ 1.0, 1.0, 1.0 ]
115
+
116
+ glClear(GL_COLOR_BUFFER_BIT)
117
+ glColor(white)
118
+
119
+ glRasterPos(20, 60)
120
+ printString("THE QUICK BROWN FOX JUMPS")
121
+ glRasterPos(20, 40)
122
+ printString("OVER A LAZY DOG")
123
+ glutSwapBuffers()
124
+ end
125
+
126
+ reshape = proc do |w, h|
127
+ glViewport(0, 0, w, h)
128
+ glMatrixMode(GL_PROJECTION)
129
+ glLoadIdentity()
130
+ glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
131
+ glMatrixMode(GL_MODELVIEW)
132
+ end
133
+
134
+ keyboard = proc do |key, x, y|
135
+ case (key)
136
+ when ?\e
137
+ exit(0)
138
+ end
139
+ end
140
+
141
+ # Main Loop
142
+ # Open window with initial window size, title bar,
143
+ # RGBA display mode, and handle input events.
144
+ glutInit()
145
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
146
+ glutInitWindowSize(400, 100)
147
+ glutInitWindowPosition(100, 100)
148
+ glutCreateWindow()
149
+ init()
150
+ glutReshapeFunc(reshape)
151
+ glutKeyboardFunc(keyboard)
152
+ glutDisplayFunc(display)
153
+ glutMainLoop()
@@ -0,0 +1,81 @@
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
+ require 'glu'
41
+ require 'glut'
42
+ include Gl,Glu,Glut
43
+
44
+ display = Proc.new do
45
+ glClear(GL_COLOR_BUFFER_BIT)
46
+
47
+ glColor(1.0, 1.0, 1.0)
48
+ glBegin(GL_POLYGON)
49
+ glVertex(0.25, 0.25, 0.0)
50
+ glVertex(0.75, 0.25, 0.0)
51
+ glVertex(0.75, 0.75, 0.0)
52
+ glVertex(0.25, 0.75, 0.0)
53
+ glEnd()
54
+
55
+ glutSwapBuffers()
56
+ end
57
+
58
+ def init
59
+ glClearColor(0.0, 0.0, 0.0, 0.0)
60
+
61
+ glMatrixMode(GL_PROJECTION)
62
+ glLoadIdentity()
63
+ glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0)
64
+ end
65
+
66
+ keyboard = Proc.new do |key, x, y|
67
+ case (key)
68
+ when ?\e
69
+ exit(0);
70
+ end
71
+ end
72
+
73
+ glutInit
74
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
75
+ glutInitWindowSize(500, 500)
76
+ glutInitWindowPosition(100, 100)
77
+ glutCreateWindow("hello")
78
+ init()
79
+ glutDisplayFunc(display)
80
+ glutKeyboardFunc(keyboard)
81
+ glutMainLoop()
@@ -0,0 +1,139 @@
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 'glu'
49
+ require 'glut'
50
+ require 'mathn'
51
+ include Gl,Glu,Glut
52
+
53
+ # Create checkerboard image
54
+ CheckImageWidth=64
55
+ CheckImageHeight=64
56
+ $checkImage=[]
57
+
58
+ $zoomFactor = 1.0
59
+ $height = 0.0
60
+
61
+ def makeCheckImage
62
+ for i in 0..CheckImageWidth-1
63
+ for j in 0..CheckImageHeight-1
64
+ c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
65
+ $checkImage[(i+CheckImageWidth*j)*3+0] = c
66
+ $checkImage[(i+CheckImageWidth*j)*3+1] = c
67
+ $checkImage[(i+CheckImageWidth*j)*3+2] = c
68
+ end
69
+ end
70
+ end
71
+
72
+ def init
73
+ glClearColor(0.0, 0.0, 0.0, 0.0)
74
+ glShadeModel(GL_FLAT)
75
+ makeCheckImage()
76
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
77
+ end
78
+
79
+ display = Proc.new do
80
+ glClear(GL_COLOR_BUFFER_BIT)
81
+ glRasterPos(0, 0)
82
+ glDrawPixels(CheckImageWidth, CheckImageHeight, GL_RGB, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
83
+ glFlush()
84
+ end
85
+
86
+ reshape = Proc.new do |w, h|
87
+ glViewport(0, 0, w, h)
88
+ $height = h
89
+ glMatrixMode(GL_PROJECTION)
90
+ glLoadIdentity()
91
+ gluOrtho2D(0.0, w, 0.0, h)
92
+ glMatrixMode(GL_MODELVIEW)
93
+ glLoadIdentity()
94
+ end
95
+
96
+ $screeny = 0.0
97
+ motion = Proc.new do |x, y|
98
+ $screeny = $height - y
99
+ glRasterPos(x, $screeny)
100
+ glPixelZoom($zoomFactor, $zoomFactor)
101
+ glCopyPixels(0, 0, CheckImageWidth, CheckImageHeight, GL_COLOR)
102
+ glPixelZoom(1.0, 1.0)
103
+ glFlush()
104
+ end
105
+
106
+ keyboard = Proc.new do |key, x, y|
107
+ case (key)
108
+ when ?r,?R
109
+ $zoomFactor = 1.0
110
+ glutPostRedisplay()
111
+ printf("zoomFactor reset to 1.0\n")
112
+ when ?z
113
+ $zoomFactor = $zoomFactor + 0.5
114
+ if ($zoomFactor >= 3.0)
115
+ $zoomFactor = 3.0
116
+ end
117
+ printf("zoomFactor is now %4.1f\n", $zoomFactor)
118
+ when ?Z
119
+ $zoomFactor = $zoomFactor - 0.5
120
+ if ($zoomFactor <= 0.5)
121
+ $zoomFactor = 0.5
122
+ end
123
+ printf("zoomFactor is now %4.1f\n", $zoomFactor)
124
+ when ?\e
125
+ exit(0)
126
+ end
127
+ end
128
+
129
+ glutInit
130
+ glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
131
+ glutInitWindowSize(250, 250)
132
+ glutInitWindowPosition(100, 100)
133
+ glutCreateWindow($0)
134
+ init()
135
+ glutDisplayFunc(display)
136
+ glutReshapeFunc(reshape)
137
+ glutKeyboardFunc(keyboard)
138
+ glutMotionFunc(motion)
139
+ glutMainLoop()
@@ -0,0 +1,207 @@
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
+ # 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.
50
+ #
51
+
52
+ MAX_SAMPLES=66
53
+
54
+ # 2 jitter points
55
+ $j2 = [
56
+ [ 0.246490, 0.249999],
57
+ [-0.246490, -0.249999]
58
+ ]
59
+
60
+
61
+ # 3 jitter points
62
+ $j3 = [
63
+ [-0.373411, -0.250550],
64
+ [ 0.256263, 0.368119],
65
+ [ 0.117148, -0.117570]
66
+ ]
67
+
68
+
69
+ # 4 jitter points
70
+ $j4 = [
71
+ [-0.208147, 0.353730],
72
+ [ 0.203849, -0.353780],
73
+ [-0.292626, -0.149945],
74
+ [ 0.296924, 0.149994]
75
+ ]
76
+
77
+
78
+ # 8 jitter points
79
+ $j8 = [
80
+ [-0.334818, 0.435331],
81
+ [ 0.286438, -0.393495],
82
+ [ 0.459462, 0.141540],
83
+ [-0.414498, -0.192829],
84
+ [-0.183790, 0.082102],
85
+ [-0.079263, -0.317383],
86
+ [ 0.102254, 0.299133],
87
+ [ 0.164216, -0.054399]
88
+ ]
89
+
90
+
91
+ # 15 jitter points
92
+ $j15 = [
93
+ [ 0.285561, 0.188437],
94
+ [ 0.360176, -0.065688],
95
+ [-0.111751, 0.275019],
96
+ [-0.055918, -0.215197],
97
+ [-0.080231, -0.470965],
98
+ [ 0.138721, 0.409168],
99
+ [ 0.384120, 0.458500],
100
+ [-0.454968, 0.134088],
101
+ [ 0.179271, -0.331196],
102
+ [-0.307049, -0.364927],
103
+ [ 0.105354, -0.010099],
104
+ [-0.154180, 0.021794],
105
+ [-0.370135, -0.116425],
106
+ [ 0.451636, -0.300013],
107
+ [-0.370610, 0.387504]
108
+ ]
109
+
110
+ # 24 jitter points
111
+ $j24 = [
112
+ [ 0.030245, 0.136384],
113
+ [ 0.018865, -0.348867],
114
+ [-0.350114, -0.472309],
115
+ [ 0.222181, 0.149524],
116
+ [-0.393670, -0.266873],
117
+ [ 0.404568, 0.230436],
118
+ [ 0.098381, 0.465337],
119
+ [ 0.462671, 0.442116],
120
+ [ 0.400373, -0.212720],
121
+ [-0.409988, 0.263345],
122
+ [-0.115878, -0.001981],
123
+ [ 0.348425, -0.009237],
124
+ [-0.464016, 0.066467],
125
+ [-0.138674, -0.468006],
126
+ [ 0.144932, -0.022780],
127
+ [-0.250195, 0.150161],
128
+ [-0.181400, -0.264219],
129
+ [ 0.196097, -0.234139],
130
+ [-0.311082, -0.078815],
131
+ [ 0.268379, 0.366778],
132
+ [-0.040601, 0.327109],
133
+ [-0.234392, 0.354659],
134
+ [-0.003102, -0.154402],
135
+ [ 0.297997, -0.417965]
136
+ ]
137
+
138
+
139
+ # 66 jitter points
140
+ $j66 = [
141
+ [ 0.266377, -0.218171],
142
+ [-0.170919, -0.429368],
143
+ [ 0.047356, -0.387135],
144
+ [-0.430063, 0.363413],
145
+ [-0.221638, -0.313768],
146
+ [ 0.124758, -0.197109],
147
+ [-0.400021, 0.482195],
148
+ [ 0.247882, 0.152010],
149
+ [-0.286709, -0.470214],
150
+ [-0.426790, 0.004977],
151
+ [-0.361249, -0.104549],
152
+ [-0.040643, 0.123453],
153
+ [-0.189296, 0.438963],
154
+ [-0.453521, -0.299889],
155
+ [ 0.408216, -0.457699],
156
+ [ 0.328973, -0.101914],
157
+ [-0.055540, -0.477952],
158
+ [ 0.194421, 0.453510],
159
+ [ 0.404051, 0.224974],
160
+ [ 0.310136, 0.419700],
161
+ [-0.021743, 0.403898],
162
+ [-0.466210, 0.248839],
163
+ [ 0.341369, 0.081490],
164
+ [ 0.124156, -0.016859],
165
+ [-0.461321, -0.176661],
166
+ [ 0.013210, 0.234401],
167
+ [ 0.174258, -0.311854],
168
+ [ 0.294061, 0.263364],
169
+ [-0.114836, 0.328189],
170
+ [ 0.041206, -0.106205],
171
+ [ 0.079227, 0.345021],
172
+ [-0.109319, -0.242380],
173
+ [ 0.425005, -0.332397],
174
+ [ 0.009146, 0.015098],
175
+ [-0.339084, -0.355707],
176
+ [-0.224596, -0.189548],
177
+ [ 0.083475, 0.117028],
178
+ [ 0.295962, -0.334699],
179
+ [ 0.452998, 0.025397],
180
+ [ 0.206511, -0.104668],
181
+ [ 0.447544, -0.096004],
182
+ [-0.108006, -0.002471],
183
+ [-0.380810, 0.130036],
184
+ [-0.242440, 0.186934],
185
+ [-0.200363, 0.070863],
186
+ [-0.344844, -0.230814],
187
+ [ 0.408660, 0.345826],
188
+ [-0.233016, 0.305203],
189
+ [ 0.158475, -0.430762],
190
+ [ 0.486972, 0.139163],
191
+ [-0.301610, 0.009319],
192
+ [ 0.282245, -0.458671],
193
+ [ 0.482046, 0.443890],
194
+ [-0.121527, 0.210223],
195
+ [-0.477606, -0.424878],
196
+ [-0.083941, -0.121440],
197
+ [-0.345773, 0.253779],
198
+ [ 0.234646, 0.034549],
199
+ [ 0.394102, -0.210901],
200
+ [-0.312571, 0.397656],
201
+ [ 0.200906, 0.333293],
202
+ [ 0.018703, -0.261792],
203
+ [-0.209349, -0.065383],
204
+ [ 0.076248, 0.478538],
205
+ [-0.073036, -0.355064],
206
+ [ 0.145087, 0.221726]
207
+ ]