opengl 0.8.0 → 0.9.0
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 +1 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +2 -1
- data/.travis.yml +19 -0
- data/History.rdoc +26 -0
- data/Manifest.txt +3 -23
- data/README.rdoc +43 -37
- data/Rakefile +6 -62
- data/examples/NeHe/nehe_lesson02.rb +3 -2
- data/examples/NeHe/nehe_lesson03.rb +3 -2
- data/examples/NeHe/nehe_lesson04.rb +3 -1
- data/examples/NeHe/nehe_lesson05.rb +4 -1
- data/examples/NeHe/nehe_lesson06.rb +9 -6
- data/examples/NeHe/nehe_lesson07.rb +9 -6
- data/examples/NeHe/nehe_lesson08.rb +9 -6
- data/examples/NeHe/nehe_lesson09.rb +10 -6
- data/examples/NeHe/nehe_lesson11.rb +9 -6
- data/examples/NeHe/nehe_lesson12.rb +9 -6
- data/examples/NeHe/nehe_lesson16.rb +50 -47
- data/examples/NeHe/nehe_lesson19.rb +10 -7
- data/examples/NeHe/nehe_lesson36.rb +234 -229
- data/examples/OrangeBook/brick.rb +227 -225
- data/examples/OrangeBook/particle.rb +233 -231
- data/examples/RedBook/aapoly.rb +71 -70
- data/examples/RedBook/aargb.rb +54 -52
- data/examples/RedBook/accanti.rb +96 -94
- data/examples/RedBook/accpersp.rb +106 -104
- data/examples/RedBook/alpha.rb +54 -52
- data/examples/RedBook/alpha3D.rb +90 -88
- data/examples/RedBook/bezcurve.rb +48 -46
- data/examples/RedBook/bezmesh.rb +71 -69
- data/examples/RedBook/checker.rb +57 -55
- data/examples/RedBook/clip.rb +41 -39
- data/examples/RedBook/colormat.rb +72 -70
- data/examples/RedBook/cube.rb +39 -37
- data/examples/RedBook/depthcue.rb +37 -35
- data/examples/RedBook/dof.rb +110 -109
- data/examples/RedBook/double.rb +40 -38
- data/examples/RedBook/drawf.rb +30 -28
- data/examples/RedBook/feedback.rb +79 -77
- data/examples/RedBook/fog.rb +90 -89
- data/examples/RedBook/font.rb +78 -76
- data/examples/RedBook/hello.rb +29 -27
- data/examples/RedBook/image.rb +57 -55
- data/examples/RedBook/jitter.rb +131 -131
- data/examples/RedBook/light.rb +2 -1
- data/examples/RedBook/lines.rb +70 -68
- data/examples/RedBook/list.rb +48 -46
- data/examples/RedBook/material.rb +200 -199
- data/examples/RedBook/mipmap.rb +84 -82
- data/examples/RedBook/model.rb +55 -53
- data/examples/RedBook/movelight.rb +52 -50
- data/examples/RedBook/pickdepth.rb +103 -101
- data/examples/RedBook/planet.rb +46 -44
- data/examples/RedBook/quadric.rb +97 -95
- data/examples/RedBook/robot.rb +55 -53
- data/examples/RedBook/select.rb +118 -116
- data/examples/RedBook/smooth.rb +35 -33
- data/examples/RedBook/stencil.rb +96 -94
- data/examples/RedBook/stroke.rb +75 -73
- data/examples/RedBook/surface.rb +93 -91
- data/examples/RedBook/teaambient.rb +71 -69
- data/examples/RedBook/teapots.rb +105 -103
- data/examples/RedBook/tess.rb +96 -94
- data/examples/RedBook/texbind.rb +79 -77
- data/examples/RedBook/texgen.rb +88 -86
- data/examples/RedBook/texturesurf.rb +57 -55
- data/examples/RedBook/varray.rb +85 -83
- data/examples/RedBook/wrap.rb +76 -74
- data/examples/misc/OGLBench.rb +114 -113
- data/examples/misc/anisotropic.rb +154 -152
- data/examples/misc/fbo_test.rb +37 -36
- data/examples/misc/font-glut.rb +47 -46
- data/examples/misc/glfwtest.rb +16 -16
- data/examples/misc/plane.rb +13 -13
- data/examples/misc/readpixel.rb +66 -65
- data/examples/misc/sdltest.rb +21 -19
- data/examples/misc/trislam.rb +548 -547
- data/ext/opengl/common.h +16 -38
- data/ext/opengl/conv.h +39 -41
- data/ext/opengl/extconf.rb +4 -31
- data/ext/opengl/funcdef.h +126 -124
- data/ext/opengl/gl-1.0-1.1.c +1917 -1917
- data/ext/opengl/gl-1.2.c +4 -667
- data/ext/opengl/gl-1.3.c +9 -9
- data/ext/opengl/gl-1.4.c +8 -8
- data/ext/opengl/gl-1.5.c +1 -1
- data/ext/opengl/gl-2.0.c +392 -388
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +1523 -5
- data/ext/opengl/gl-enums.h +4679 -122
- data/ext/opengl/gl-error.c +7 -7
- data/ext/opengl/gl-error.h +4 -4
- data/ext/opengl/gl-ext-arb.c +468 -464
- data/ext/opengl/gl-ext-ext.c +18 -18
- data/ext/opengl/gl-ext-nv.c +15 -15
- data/ext/opengl/gl.c +2 -0
- data/ext/opengl/gl_buffer.c +92 -92
- data/ext/opengl/opengl.c +1 -7
- data/lib/opengl.rb +23 -59
- data/lib/opengl/test_case.rb +1 -2
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +18 -22
- data/test/test_gl_10_11.rb +220 -220
- data/test/test_gl_12.rb +11 -122
- data/test/test_gl_13.rb +202 -210
- data/test/test_gl_14.rb +16 -19
- data/test/test_gl_15.rb +2 -4
- data/test/test_gl_20.rb +45 -58
- data/test/test_gl_21.rb +46 -163
- data/test/test_gl_ext_arb.rb +54 -72
- data/test/test_gl_ext_ati.rb +0 -2
- data/test/test_gl_ext_ext.rb +66 -66
- data/test/test_gl_ext_gremedy.rb +8 -15
- data/test/test_gl_ext_nv.rb +109 -112
- data/test/test_opengl_buffer.rb +8 -25
- data/utils/README +0 -5
- data/utils/enumgen.rb +72 -76
- data/utils/extlistgen.rb +55 -55
- metadata +87 -66
- metadata.gz.sig +2 -0
- data/Rakefile.cross +0 -107
- data/docs/build_install.txt +0 -119
- data/docs/extensions.txt.in +0 -348
- data/docs/history.txt +0 -66
- data/docs/requirements_and_design.txt +0 -117
- data/docs/roadmap.txt +0 -28
- data/docs/scientific_use.txt +0 -35
- data/docs/supplies/page_template.html +0 -71
- data/docs/thanks.txt +0 -29
- data/docs/tutorial.txt +0 -469
- data/ext/opengl/glu-enums.c +0 -164
- data/ext/opengl/glu-enums.h +0 -463
- data/ext/opengl/glu.c +0 -1534
- data/ext/opengl/glut.c +0 -1145
- data/ext/opengl/glut_callbacks.c +0 -845
- data/lib/glu.rb +0 -1
- data/lib/glut.rb +0 -1
- data/test/test_glu.rb +0 -309
- data/utils/mkdn2html.rb +0 -59
- data/utils/post-mkdn2html.rb +0 -91
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +0 -198
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
3
|
-
# ALL RIGHTS RESERVED
|
4
|
-
# Permission to use, copy, modify, and distribute this software for
|
3
|
+
# ALL RIGHTS RESERVED
|
4
|
+
# Permission to use, copy, modify, and distribute this software for
|
5
5
|
# any purpose and without fee is hereby granted, provided that the above
|
6
6
|
# copyright notice appear in all copies and that both the copyright notice
|
7
|
-
# and this permission notice appear in supporting documentation, and that
|
7
|
+
# and this permission notice appear in supporting documentation, and that
|
8
8
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
9
9
|
# or publicity pertaining to distribution of the software without specific,
|
10
|
-
# written prior permission.
|
10
|
+
# written prior permission.
|
11
11
|
#
|
12
12
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
13
13
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -21,8 +21,8 @@
|
|
21
21
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
22
22
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
23
23
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
#
|
25
|
-
# US Government Users Restricted Rights
|
24
|
+
#
|
25
|
+
# US Government Users Restricted Rights
|
26
26
|
# Use, duplication, or disclosure by the Government is subject to
|
27
27
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
28
28
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -34,63 +34,65 @@
|
|
34
34
|
#
|
35
35
|
# OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
|
36
36
|
#
|
37
|
-
# bezcurve.c
|
37
|
+
# bezcurve.c
|
38
38
|
# This program uses evaluators to draw a Bezier curve.
|
39
39
|
|
40
40
|
require "opengl"
|
41
|
+
require 'glu'
|
42
|
+
require 'glut'
|
41
43
|
include Gl,Glu,Glut
|
42
44
|
|
43
45
|
$ctrlpoints = [
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
+
]
|
49
51
|
|
50
52
|
def init
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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)
|
55
57
|
end
|
56
58
|
|
57
59
|
display = proc do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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()
|
74
76
|
end
|
75
77
|
|
76
78
|
reshape = proc do |w, h|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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()
|
87
89
|
end
|
88
90
|
|
89
91
|
keyboard = proc do |key, x, y|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
case (key)
|
93
|
+
when ?\e
|
94
|
+
exit(0)
|
95
|
+
end
|
94
96
|
end
|
95
97
|
|
96
98
|
glutInit()
|
data/examples/RedBook/bezmesh.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
# Copyright (c) Mark J. Kilgard, 1994.
|
3
3
|
#
|
4
4
|
# (c) Copyright 1993, Silicon Graphics, Inc.
|
5
|
-
# ALL RIGHTS RESERVED
|
6
|
-
# Permission to use, copy, modify, and distribute this software for
|
5
|
+
# ALL RIGHTS RESERVED
|
6
|
+
# Permission to use, copy, modify, and distribute this software for
|
7
7
|
# any purpose and without fee is hereby granted, provided that the above
|
8
8
|
# copyright notice appear in all copies and that both the copyright notice
|
9
|
-
# and this permission notice appear in supporting documentation, and that
|
9
|
+
# and this permission notice appear in supporting documentation, and that
|
10
10
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
11
11
|
# or publicity pertaining to distribution of the software without specific,
|
12
|
-
# written prior permission.
|
12
|
+
# written prior permission.
|
13
13
|
#
|
14
14
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
15
15
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -23,8 +23,8 @@
|
|
23
23
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
24
24
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
25
25
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
26
|
-
#
|
27
|
-
# US Government Users Restricted Rights
|
26
|
+
#
|
27
|
+
# US Government Users Restricted Rights
|
28
28
|
# Use, duplication, or disclosure by the Government is subject to
|
29
29
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
30
30
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -42,87 +42,89 @@
|
|
42
42
|
#
|
43
43
|
|
44
44
|
require 'opengl'
|
45
|
+
require 'glu'
|
46
|
+
require 'glut'
|
45
47
|
include Gl,Glu,Glut
|
46
48
|
|
47
49
|
$ctrlpoints = [
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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]]
|
68
70
|
]
|
69
71
|
|
70
72
|
def initlights
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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)
|
86
88
|
end
|
87
89
|
|
88
90
|
display = proc do
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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()
|
95
97
|
end
|
96
98
|
|
97
99
|
def myinit
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
106
108
|
end
|
107
109
|
|
108
110
|
myReshape = proc do |w, h|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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()
|
119
121
|
end
|
120
122
|
|
121
123
|
keyboard = Proc.new do |key, x, y|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
case (key)
|
125
|
+
when ?\e
|
126
|
+
exit(0);
|
127
|
+
end
|
126
128
|
end
|
127
129
|
|
128
130
|
glutInit()
|
data/examples/RedBook/checker.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
# Copyright (c) Mark J. Kilgard, 1994.
|
3
3
|
#
|
4
4
|
# (c) Copyright 1993, Silicon Graphics, Inc.
|
5
|
-
# ALL RIGHTS RESERVED
|
6
|
-
# Permission to use, copy, modify, and distribute this software for
|
5
|
+
# ALL RIGHTS RESERVED
|
6
|
+
# Permission to use, copy, modify, and distribute this software for
|
7
7
|
# any purpose and without fee is hereby granted, provided that the above
|
8
8
|
# copyright notice appear in all copies and that both the copyright notice
|
9
|
-
# and this permission notice appear in supporting documentation, and that
|
9
|
+
# and this permission notice appear in supporting documentation, and that
|
10
10
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
11
11
|
# or publicity pertaining to distribution of the software without specific,
|
12
|
-
# written prior permission.
|
12
|
+
# written prior permission.
|
13
13
|
#
|
14
14
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
15
15
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -23,8 +23,8 @@
|
|
23
23
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
24
24
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
25
25
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
26
|
-
#
|
27
|
-
# US Government Users Restricted Rights
|
26
|
+
#
|
27
|
+
# US Government Users Restricted Rights
|
28
28
|
# Use, duplication, or disclosure by the Government is subject to
|
29
29
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
30
30
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -41,75 +41,77 @@
|
|
41
41
|
# two rectangles. This program clamps the texture, if
|
42
42
|
# the texture coordinates fall outside 0.0 and 1.0.
|
43
43
|
require 'opengl'
|
44
|
+
require 'glu'
|
45
|
+
require 'glut'
|
44
46
|
require 'mathn'
|
45
47
|
include Gl,Glu,Glut
|
46
48
|
|
47
|
-
#
|
49
|
+
# Create checkerboard texture
|
48
50
|
CheckImageWidth=64
|
49
51
|
CheckImageHeight=64
|
50
52
|
$checkImage = []
|
51
53
|
|
52
54
|
def makeCheckImage
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
61
63
|
end
|
62
64
|
|
63
65
|
def myinit
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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)
|
80
82
|
end
|
81
83
|
|
82
84
|
display = Proc.new do
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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()
|
96
98
|
end
|
97
99
|
|
98
100
|
myReshape = Proc.new do |w, h|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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)
|
106
108
|
end
|
107
109
|
|
108
110
|
keyboard = Proc.new do |key, x, y|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
case (key)
|
112
|
+
when ?\e
|
113
|
+
exit(0)
|
114
|
+
end
|
113
115
|
end
|
114
116
|
|
115
117
|
glutInit
|