danabr75-opengl 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +29 -0
  3. data/.gemtest +0 -0
  4. data/.gitignore +6 -0
  5. data/.travis.yml +19 -0
  6. data/Gemfile +8 -0
  7. data/History.md +101 -0
  8. data/MIT-LICENSE +18 -0
  9. data/Manifest.txt +142 -0
  10. data/README.rdoc +105 -0
  11. data/Rakefile +170 -0
  12. data/danabr75-opengl.gemspec +32 -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 +157 -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/GL/gl.h +2115 -0
  96. data/ext/opengl/GL/glext.h +11770 -0
  97. data/ext/opengl/common.h +372 -0
  98. data/ext/opengl/conv.h +247 -0
  99. data/ext/opengl/extconf.rb +19 -0
  100. data/ext/opengl/fptr_struct.h +912 -0
  101. data/ext/opengl/funcdef.h +279 -0
  102. data/ext/opengl/gl-1.0-1.1.c +3345 -0
  103. data/ext/opengl/gl-1.2.c +155 -0
  104. data/ext/opengl/gl-1.3.c +447 -0
  105. data/ext/opengl/gl-1.4.c +346 -0
  106. data/ext/opengl/gl-1.5.c +225 -0
  107. data/ext/opengl/gl-2.0.c +665 -0
  108. data/ext/opengl/gl-2.1.c +57 -0
  109. data/ext/opengl/gl-3.0.c +502 -0
  110. data/ext/opengl/gl-enums.c +4853 -0
  111. data/ext/opengl/gl-enums.h +14528 -0
  112. data/ext/opengl/gl-error.c +110 -0
  113. data/ext/opengl/gl-error.h +25 -0
  114. data/ext/opengl/gl-ext-3dfx.c +27 -0
  115. data/ext/opengl/gl-ext-arb.c +880 -0
  116. data/ext/opengl/gl-ext-ati.c +41 -0
  117. data/ext/opengl/gl-ext-ext.c +885 -0
  118. data/ext/opengl/gl-ext-gremedy.c +41 -0
  119. data/ext/opengl/gl-ext-nv.c +679 -0
  120. data/ext/opengl/gl.c +265 -0
  121. data/ext/opengl/gl_buffer.c +202 -0
  122. data/ext/opengl/glimpl.c +187 -0
  123. data/ext/opengl/glimpl.h +47 -0
  124. data/ext/opengl/opengl.c +9 -0
  125. data/lib/gl.rb +1 -0
  126. data/lib/opengl.rb +79 -0
  127. data/lib/opengl/bindings_version.rb +4 -0
  128. data/lib/opengl/implementation.rb +38 -0
  129. data/lib/opengl/test_case.rb +86 -0
  130. data/test/dummy.xorg.conf +140 -0
  131. data/test/test_gl.rb +45 -0
  132. data/test/test_gl_10_11.rb +1363 -0
  133. data/test/test_gl_12.rb +71 -0
  134. data/test/test_gl_13.rb +221 -0
  135. data/test/test_gl_14.rb +218 -0
  136. data/test/test_gl_15.rb +258 -0
  137. data/test/test_gl_20.rb +417 -0
  138. data/test/test_gl_21.rb +436 -0
  139. data/test/test_gl_ext_arb.rb +508 -0
  140. data/test/test_gl_ext_ati.rb +28 -0
  141. data/test/test_gl_ext_ext.rb +608 -0
  142. data/test/test_gl_ext_gremedy.rb +29 -0
  143. data/test/test_gl_ext_nv.rb +349 -0
  144. data/test/test_glimpl.rb +23 -0
  145. data/test/test_opengl_buffer.rb +122 -0
  146. data/utils/README +6 -0
  147. data/utils/enumgen.rb +108 -0
  148. data/utils/extlistgen.rb +90 -0
  149. metadata +326 -0
@@ -0,0 +1,107 @@
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
+ # bezcurve.c
38
+ # This program uses evaluators to draw a Bezier curve.
39
+
40
+ require "opengl"
41
+ require 'glu'
42
+ require 'glut'
43
+ include Gl,Glu,Glut
44
+
45
+ $ctrlpoints = [
46
+ [-4.0,-4.0, 0.0],
47
+ [-2.0, 4.0, 0.0],
48
+ [ 2.0,-4.0, 0.0],
49
+ [ 4.0, 4.0, 0.0]
50
+ ]
51
+
52
+ def init
53
+ glClearColor(0.0, 0.0, 0.0, 0.0)
54
+ glShadeModel(GL_FLAT)
55
+ glMap1d(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, $ctrlpoints.flatten)
56
+ glEnable(GL_MAP1_VERTEX_3)
57
+ end
58
+
59
+ display = proc do
60
+ glClear(GL_COLOR_BUFFER_BIT)
61
+ glColor(1.0, 1.0, 1.0)
62
+ glBegin(GL_LINE_STRIP)
63
+ for i in 0..30
64
+ glEvalCoord1d(i.to_f/30.0)
65
+ end
66
+ glEnd()
67
+ # The following code displays the control points as dots.
68
+ glPointSize(5.0)
69
+ glColor(1.0, 1.0, 0.0)
70
+ glBegin(GL_POINTS)
71
+ for i in 0...4
72
+ glVertex($ctrlpoints[i])
73
+ end
74
+ glEnd()
75
+ glutSwapBuffers()
76
+ end
77
+
78
+ reshape = proc do |w, h|
79
+ glViewport(0, 0, w, h)
80
+ glMatrixMode(GL_PROJECTION)
81
+ glLoadIdentity()
82
+ if (w <= h)
83
+ glOrtho(-5.0, 5.0, -5.0*h/w, 5.0*h/w, -5.0, 5.0)
84
+ else
85
+ glOrtho(-5.0*w/h, 5.0*w/h, -5.0, 5.0, -5.0, 5.0)
86
+ end
87
+ glMatrixMode(GL_MODELVIEW)
88
+ glLoadIdentity()
89
+ end
90
+
91
+ keyboard = proc do |key, x, y|
92
+ case (key)
93
+ when ?\e
94
+ exit(0)
95
+ end
96
+ end
97
+
98
+ glutInit()
99
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
100
+ glutInitWindowSize(500, 500)
101
+ glutInitWindowPosition(100, 100)
102
+ glutCreateWindow()
103
+ init()
104
+ glutDisplayFunc(display)
105
+ glutReshapeFunc(reshape)
106
+ glutKeyboardFunc(keyboard)
107
+ glutMainLoop()
@@ -0,0 +1,139 @@
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
+ # bezsurf.c
40
+ # This program renders a lighted, filled Bezier surface,
41
+ # using two-dimensional evaluators.
42
+ #
43
+
44
+ require 'opengl'
45
+ require 'glu'
46
+ require 'glut'
47
+ include Gl,Glu,Glut
48
+
49
+ $ctrlpoints = [
50
+ [
51
+ [-1.5, -1.5, 4.0],
52
+ [-0.5, -1.5, 2.0],
53
+ [0.5, -1.5, -1.0],
54
+ [1.5, -1.5, 2.0]],
55
+ [
56
+ [-1.5, -0.5, 1.0],
57
+ [-0.5, -0.5, 3.0],
58
+ [0.5, -0.5, 0.0],
59
+ [1.5, -0.5, -1.0]],
60
+ [
61
+ [-1.5, 0.5, 4.0],
62
+ [-0.5, 0.5, 0.0],
63
+ [0.5, 0.5, 3.0],
64
+ [1.5, 0.5, 4.0]],
65
+ [
66
+ [-1.5, 1.5, -2.0],
67
+ [-0.5, 1.5, -2.0],
68
+ [0.5, 1.5, 0.0],
69
+ [1.5, 1.5, -1.0]]
70
+ ]
71
+
72
+ def initlights
73
+ ambient = [0.2, 0.2, 0.2, 1.0]
74
+ position = [0.0, 0.0, 2.0, 1.0]
75
+ mat_diffuse = [0.6, 0.6, 0.6, 1.0]
76
+ mat_specular = [1.0, 1.0, 1.0, 1.0]
77
+ mat_shininess = [50.0]
78
+
79
+ glEnable(GL_LIGHTING)
80
+ glEnable(GL_LIGHT0)
81
+
82
+ glLight(GL_LIGHT0, GL_AMBIENT, ambient)
83
+ glLight(GL_LIGHT0, GL_POSITION, position)
84
+
85
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
86
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
87
+ glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
88
+ end
89
+
90
+ display = proc do
91
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
92
+ glPushMatrix()
93
+ glRotate(85.0, 1.0, 1.0, 1.0)
94
+ glEvalMesh2(GL_FILL, 0, 20, 0, 20)
95
+ glPopMatrix()
96
+ glutSwapBuffers()
97
+ end
98
+
99
+ def myinit
100
+ glClearColor(0.0, 0.0, 0.0, 1.0)
101
+ glEnable(GL_DEPTH_TEST)
102
+ glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints.flatten)
103
+ glEnable(GL_MAP2_VERTEX_3)
104
+ glEnable(GL_AUTO_NORMAL)
105
+ glEnable(GL_NORMALIZE)
106
+ glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
107
+ initlights() # for lighted version only
108
+ end
109
+
110
+ myReshape = proc do |w, h|
111
+ glViewport(0, 0, w, h)
112
+ glMatrixMode(GL_PROJECTION)
113
+ glLoadIdentity()
114
+ if (w <= h)
115
+ glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -4.0, 4.0)
116
+ else
117
+ glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -4.0, 4.0)
118
+ end
119
+ glMatrixMode(GL_MODELVIEW)
120
+ glLoadIdentity()
121
+ end
122
+
123
+ keyboard = Proc.new do |key, x, y|
124
+ case (key)
125
+ when ?\e
126
+ exit(0);
127
+ end
128
+ end
129
+
130
+ glutInit()
131
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
132
+ glutInitWindowSize(500, 500)
133
+ glutInitWindowPosition(100, 100)
134
+ glutCreateWindow($0)
135
+ myinit()
136
+ glutReshapeFunc(myReshape)
137
+ glutDisplayFunc(display)
138
+ glutKeyboardFunc(keyboard)
139
+ glutMainLoop()
@@ -0,0 +1,126 @@
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
+ # checker.c
40
+ # This program texture maps a checkerboard image onto
41
+ # two rectangles. This program clamps the texture, if
42
+ # the texture coordinates fall outside 0.0 and 1.0.
43
+ require 'opengl'
44
+ require 'glu'
45
+ require 'glut'
46
+ require 'mathn'
47
+ include Gl,Glu,Glut
48
+
49
+ # Create checkerboard texture
50
+ CheckImageWidth=64
51
+ CheckImageHeight=64
52
+ $checkImage = []
53
+
54
+ def makeCheckImage
55
+ for i in 0..CheckImageWidth-1
56
+ for j in 0..CheckImageHeight-1
57
+ c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
58
+ $checkImage[(i+CheckImageWidth*j)*3+0] = c
59
+ $checkImage[(i+CheckImageWidth*j)*3+1] = c
60
+ $checkImage[(i+CheckImageWidth*j)*3+2] = c
61
+ end
62
+ end
63
+ end
64
+
65
+ def myinit
66
+ glClearColor(0.0, 0.0, 0.0, 0.0)
67
+ glEnable(GL_DEPTH_TEST)
68
+ glDepthFunc(GL_LESS)
69
+
70
+ makeCheckImage()
71
+ glPixelStore(GL_UNPACK_ALIGNMENT, 1)
72
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, CheckImageWidth,
73
+ CheckImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
74
+ $checkImage.pack("C*"))
75
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
76
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
77
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
78
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
79
+ glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
80
+ glEnable(GL_TEXTURE_2D)
81
+ glShadeModel(GL_FLAT)
82
+ end
83
+
84
+ display = Proc.new do
85
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
86
+ glBegin(GL_QUADS)
87
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
88
+ glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
89
+ glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
90
+ glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
91
+
92
+ glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
93
+ glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
94
+ glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
95
+ glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
96
+ glEnd()
97
+ glutSwapBuffers()
98
+ end
99
+
100
+ myReshape = Proc.new do |w, h|
101
+ glViewport(0, 0, w, h)
102
+ glMatrixMode(GL_PROJECTION)
103
+ glLoadIdentity()
104
+ gluPerspective(60.0, 1.0*w/h, 1.0, 30.0)
105
+ glMatrixMode(GL_MODELVIEW)
106
+ glLoadIdentity()
107
+ glTranslate(0.0, 0.0, -3.6)
108
+ end
109
+
110
+ keyboard = Proc.new do |key, x, y|
111
+ case (key)
112
+ when ?\e
113
+ exit(0)
114
+ end
115
+ end
116
+
117
+ glutInit
118
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
119
+ glutInitWindowSize(500, 500)
120
+ glutInitWindowPosition(100, 100)
121
+ glutCreateWindow("checker")
122
+ myinit()
123
+ glutReshapeFunc(myReshape)
124
+ glutDisplayFunc(display)
125
+ glutKeyboardFunc(keyboard)
126
+ glutMainLoop()
@@ -0,0 +1,97 @@
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
+ # clip.c
38
+ # This program demonstrates arbitrary clipping planes.
39
+ require 'opengl'
40
+ require 'glu'
41
+ require 'glut'
42
+ require 'mathn'
43
+ include Gl,Glu,Glut
44
+
45
+ def init
46
+ glClearColor(0.0, 0.0, 0.0, 0.0)
47
+ glShadeModel(GL_FLAT)
48
+ end
49
+
50
+ display = Proc.new do
51
+ eqn = [0.0, 1.0, 0.0, 0.0]
52
+ eqn2 = [1.0, 0.0, 0.0, 0.0]
53
+
54
+ glClear(GL_COLOR_BUFFER_BIT)
55
+
56
+ glColor(1.0, 1.0, 1.0)
57
+ glPushMatrix()
58
+ glTranslate(0.0, 0.0, -5.0)
59
+
60
+ # clip lower half -- y < 0
61
+ glClipPlane(GL_CLIP_PLANE0, eqn)
62
+ glEnable(GL_CLIP_PLANE0)
63
+ # clip left half -- x < 0
64
+ glClipPlane(GL_CLIP_PLANE1, eqn2)
65
+ glEnable(GL_CLIP_PLANE1)
66
+
67
+ glRotate(90.0, 1.0, 0.0, 0.0)
68
+ glutWireSphere(1.0, 20, 16)
69
+ glPopMatrix()
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
+ gluPerspective(60.0, w/ h, 1.0, 20.0)
78
+ glMatrixMode(GL_MODELVIEW)
79
+ end
80
+
81
+ keyboard = Proc.new do |key, x, y|
82
+ case (key)
83
+ when ?\e
84
+ exit(0)
85
+ end
86
+ end
87
+
88
+ glutInit
89
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
90
+ glutInitWindowSize(500, 500)
91
+ glutInitWindowPosition(100, 100)
92
+ glutCreateWindow($0)
93
+ init()
94
+ glutDisplayFunc(display)
95
+ glutReshapeFunc(reshape)
96
+ glutKeyboardFunc(keyboard)
97
+ glutMainLoop()