opengl 0.9.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/.autotest +29 -0
- data/.gemtest +0 -0
- data/.gitignore +6 -0
- data/.travis.yml +19 -0
- data/History.rdoc +77 -0
- data/MIT-LICENSE +18 -0
- data/Manifest.txt +138 -0
- data/README.rdoc +102 -0
- data/Rakefile +60 -0
- data/examples/NeHe/NeHe.png +0 -0
- data/examples/NeHe/crate.png +0 -0
- data/examples/NeHe/glass.png +0 -0
- data/examples/NeHe/nehe_lesson02.rb +117 -0
- data/examples/NeHe/nehe_lesson03.rb +123 -0
- data/examples/NeHe/nehe_lesson04.rb +132 -0
- data/examples/NeHe/nehe_lesson05.rb +182 -0
- data/examples/NeHe/nehe_lesson06.rb +186 -0
- data/examples/NeHe/nehe_lesson07.rb +240 -0
- data/examples/NeHe/nehe_lesson08.rb +255 -0
- data/examples/NeHe/nehe_lesson09.rb +203 -0
- data/examples/NeHe/nehe_lesson11.rb +176 -0
- data/examples/NeHe/nehe_lesson12.rb +203 -0
- data/examples/NeHe/nehe_lesson16.rb +211 -0
- data/examples/NeHe/nehe_lesson19.rb +209 -0
- data/examples/NeHe/nehe_lesson36.rb +308 -0
- data/examples/NeHe/particle.png +0 -0
- data/examples/NeHe/star.png +0 -0
- data/examples/NeHe/tim.png +0 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +378 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +408 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +16 -0
- data/examples/RedBook/aapoly.rb +143 -0
- data/examples/RedBook/aargb.rb +121 -0
- data/examples/RedBook/accanti.rb +164 -0
- data/examples/RedBook/accpersp.rb +217 -0
- data/examples/RedBook/alpha.rb +125 -0
- data/examples/RedBook/alpha3D.rb +160 -0
- data/examples/RedBook/bezcurve.rb +107 -0
- data/examples/RedBook/bezmesh.rb +139 -0
- data/examples/RedBook/checker.rb +126 -0
- data/examples/RedBook/clip.rb +97 -0
- data/examples/RedBook/colormat.rb +137 -0
- data/examples/RedBook/cube.rb +71 -0
- data/examples/RedBook/depthcue.rb +101 -0
- data/examples/RedBook/dof.rb +206 -0
- data/examples/RedBook/double.rb +107 -0
- data/examples/RedBook/drawf.rb +93 -0
- data/examples/RedBook/feedback.rb +147 -0
- data/examples/RedBook/fog.rb +168 -0
- data/examples/RedBook/font.rb +153 -0
- data/examples/RedBook/hello.rb +81 -0
- data/examples/RedBook/image.rb +139 -0
- data/examples/RedBook/jitter.rb +207 -0
- data/examples/RedBook/light.rb +155 -0
- data/examples/RedBook/lines.rb +130 -0
- data/examples/RedBook/list.rb +113 -0
- data/examples/RedBook/material.rb +276 -0
- data/examples/RedBook/mipmap.rb +158 -0
- data/examples/RedBook/model.rb +115 -0
- data/examples/RedBook/movelight.rb +134 -0
- data/examples/RedBook/pickdepth.rb +181 -0
- data/examples/RedBook/planet.rb +110 -0
- data/examples/RedBook/quadric.rb +160 -0
- data/examples/RedBook/robot.rb +117 -0
- data/examples/RedBook/select.rb +198 -0
- data/examples/RedBook/smooth.rb +97 -0
- data/examples/RedBook/stencil.rb +165 -0
- data/examples/RedBook/stroke.rb +169 -0
- data/examples/RedBook/surface.rb +168 -0
- data/examples/RedBook/teaambient.rb +134 -0
- data/examples/RedBook/teapots.rb +184 -0
- data/examples/RedBook/tess.rb +185 -0
- data/examples/RedBook/texbind.rb +149 -0
- data/examples/RedBook/texgen.rb +171 -0
- data/examples/RedBook/texturesurf.rb +130 -0
- data/examples/RedBook/varray.rb +161 -0
- data/examples/RedBook/wrap.rb +150 -0
- data/examples/misc/OGLBench.rb +338 -0
- data/examples/misc/anisotropic.rb +196 -0
- data/examples/misc/fbo_test.rb +357 -0
- data/examples/misc/font-glut.rb +47 -0
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/plane.rb +161 -0
- data/examples/misc/readpixel.rb +66 -0
- data/examples/misc/sdltest.rb +36 -0
- data/examples/misc/trislam.rb +829 -0
- data/ext/opengl/common.h +428 -0
- data/ext/opengl/conv.h +244 -0
- data/ext/opengl/extconf.rb +47 -0
- data/ext/opengl/funcdef.h +313 -0
- data/ext/opengl/gl-1.0-1.1.c +3075 -0
- data/ext/opengl/gl-1.2.c +155 -0
- data/ext/opengl/gl-1.3.c +443 -0
- data/ext/opengl/gl-1.4.c +348 -0
- data/ext/opengl/gl-1.5.c +224 -0
- data/ext/opengl/gl-2.0.c +667 -0
- data/ext/opengl/gl-2.1.c +57 -0
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +4873 -0
- data/ext/opengl/gl-enums.h +14588 -0
- data/ext/opengl/gl-error.c +112 -0
- data/ext/opengl/gl-error.h +28 -0
- data/ext/opengl/gl-ext-3dfx.c +27 -0
- data/ext/opengl/gl-ext-arb.c +875 -0
- data/ext/opengl/gl-ext-ati.c +41 -0
- data/ext/opengl/gl-ext-ext.c +889 -0
- data/ext/opengl/gl-ext-gremedy.c +41 -0
- data/ext/opengl/gl-ext-nv.c +680 -0
- data/ext/opengl/gl-types.h +67 -0
- data/ext/opengl/gl.c +220 -0
- data/ext/opengl/gl_buffer.c +177 -0
- data/ext/opengl/opengl.c +7 -0
- data/lib/gl.rb +1 -0
- data/lib/opengl.rb +53 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +86 -0
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +38 -0
- data/test/test_gl_10_11.rb +1363 -0
- data/test/test_gl_12.rb +71 -0
- data/test/test_gl_13.rb +221 -0
- data/test/test_gl_14.rb +218 -0
- data/test/test_gl_15.rb +258 -0
- data/test/test_gl_20.rb +417 -0
- data/test/test_gl_21.rb +436 -0
- data/test/test_gl_ext_arb.rb +508 -0
- data/test/test_gl_ext_ati.rb +28 -0
- data/test/test_gl_ext_ext.rb +608 -0
- data/test/test_gl_ext_gremedy.rb +29 -0
- data/test/test_gl_ext_nv.rb +349 -0
- data/test/test_opengl_buffer.rb +120 -0
- data/utils/README +6 -0
- data/utils/enumgen.rb +108 -0
- data/utils/extlistgen.rb +90 -0
- metadata +319 -0
- metadata.gz.sig +1 -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()
|