opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -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/1.9/opengl.so +0 -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 +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 +90 -67
- metadata.gz.sig +0 -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/lib/opengl/opengl.so +0 -0
- 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
data/examples/RedBook/tess.rb
CHANGED
@@ -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
|
@@ -43,37 +43,39 @@
|
|
43
43
|
# Note the exterior rectangle is drawn with its vertices
|
44
44
|
# in counter-clockwise order, but its interior clockwise.
|
45
45
|
# Note the combineCallback is needed for the self-intersecting
|
46
|
-
# star. Also note that removing the TessProperty for the
|
46
|
+
# star. Also note that removing the TessProperty for the
|
47
47
|
# star will make the interior unshaded (WINDING_ODD).
|
48
48
|
require 'opengl'
|
49
|
+
require 'glu'
|
50
|
+
require 'glut'
|
49
51
|
include Gl,Glu,Glut
|
50
52
|
|
51
53
|
$startList = nil
|
52
54
|
|
53
55
|
display = proc do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
57
|
+
glColor(1.0, 1.0, 1.0)
|
58
|
+
glCallList($startList)
|
59
|
+
glCallList($startList + 1)
|
60
|
+
glutSwapBuffers()
|
59
61
|
end
|
60
62
|
|
61
63
|
$beginCallback = proc do |which|
|
62
|
-
|
64
|
+
glBegin(which)
|
63
65
|
end
|
64
66
|
|
65
67
|
$errorCallback = proc do |errorCode|
|
66
|
-
|
67
|
-
|
68
|
+
print "Tessellation Error: #{gluErrorString(errorCode)}"
|
69
|
+
exit(0)
|
68
70
|
end
|
69
71
|
|
70
72
|
$endCallback = proc do
|
71
|
-
|
73
|
+
glEnd()
|
72
74
|
end
|
73
75
|
|
74
76
|
$vertexCallback = proc do |vertex|
|
75
|
-
|
76
|
-
|
77
|
+
glColor(vertex[3], vertex[4], vertex[5])
|
78
|
+
glVertex(vertex[0], vertex[1], vertex[2])
|
77
79
|
end
|
78
80
|
|
79
81
|
# combineCallback is used to create a new vertex when edges
|
@@ -81,94 +83,94 @@ end
|
|
81
83
|
# but weight[4] may be used to average color, normal, or texture
|
82
84
|
# coordinate data. In this program, color is weighted.
|
83
85
|
$combineCallback = proc do |coords, vertex_data, weight|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
86
|
+
vertex = []
|
87
|
+
vertex[0] = coords[0]
|
88
|
+
vertex[1] = coords[1]
|
89
|
+
vertex[2] = coords[2]
|
90
|
+
for i in 3...6
|
91
|
+
vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i] + weight[2] * vertex_data[2][i] + weight[3] * vertex_data[3][i]
|
92
|
+
end
|
93
|
+
vertex
|
92
94
|
end
|
93
95
|
|
94
96
|
def init
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
97
|
+
rect = [[50.0, 50.0, 0.0],
|
98
|
+
[200.0, 50.0, 0.0],
|
99
|
+
[200.0, 200.0, 0.0],
|
100
|
+
[50.0, 200.0, 0.0]]
|
101
|
+
tri = [[75.0, 75.0, 0.0],
|
102
|
+
[125.0, 175.0, 0.0],
|
103
|
+
[175.0, 75.0, 0.0]]
|
104
|
+
star= [[250.0, 50.0, 0.0, 1.0, 0.0, 1.0],
|
105
|
+
[325.0, 200.0, 0.0, 1.0, 1.0, 0.0],
|
106
|
+
[400.0, 50.0, 0.0, 0.0, 1.0, 1.0],
|
107
|
+
[250.0, 150.0, 0.0, 1.0, 0.0, 0.0],
|
108
|
+
[400.0, 150.0, 0.0, 0.0, 1.0, 0.0]]
|
109
|
+
|
110
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
111
|
+
|
112
|
+
$startList = glGenLists(2)
|
113
|
+
|
114
|
+
tobj = gluNewTess()
|
115
|
+
gluTessCallback(tobj, GLU_TESS_VERTEX, proc do |v| glVertex(v) end )
|
116
|
+
gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
|
117
|
+
gluTessCallback(tobj, GLU_TESS_END, $endCallback)
|
118
|
+
gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
|
119
|
+
|
120
|
+
# rectangle with triangular hole inside
|
121
|
+
glNewList($startList, GL_COMPILE)
|
122
|
+
glShadeModel(GL_FLAT)
|
123
|
+
gluTessBeginPolygon(tobj, nil)
|
124
|
+
gluTessBeginContour(tobj)
|
125
|
+
gluTessVertex(tobj, rect[0], rect[0])
|
126
|
+
gluTessVertex(tobj, rect[1], rect[1])
|
127
|
+
gluTessVertex(tobj, rect[2], rect[2])
|
128
|
+
gluTessVertex(tobj, rect[3], rect[3])
|
129
|
+
gluTessEndContour(tobj)
|
130
|
+
gluTessBeginContour(tobj)
|
131
|
+
gluTessVertex(tobj, tri[0], tri[0])
|
132
|
+
gluTessVertex(tobj, tri[1], tri[1])
|
133
|
+
gluTessVertex(tobj, tri[2], tri[2])
|
134
|
+
gluTessEndContour(tobj)
|
135
|
+
gluTessEndPolygon(tobj)
|
136
|
+
glEndList()
|
137
|
+
|
138
|
+
gluTessCallback(tobj, GLU_TESS_VERTEX, $vertexCallback)
|
139
|
+
gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
|
140
|
+
gluTessCallback(tobj, GLU_TESS_END, $endCallback)
|
141
|
+
gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
|
142
|
+
gluTessCallback(tobj, GLU_TESS_COMBINE, $combineCallback)
|
141
143
|
|
142
144
|
|
143
145
|
# smooth shaded, self-intersecting star
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
146
|
+
glNewList($startList + 1, GL_COMPILE)
|
147
|
+
glShadeModel(GL_SMOOTH)
|
148
|
+
gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE)
|
149
|
+
gluTessBeginPolygon(tobj, nil)
|
150
|
+
gluTessBeginContour(tobj)
|
151
|
+
gluTessVertex(tobj, star[0], star[0])
|
152
|
+
gluTessVertex(tobj, star[1], star[1])
|
153
|
+
gluTessVertex(tobj, star[2], star[2])
|
154
|
+
gluTessVertex(tobj, star[3], star[3])
|
155
|
+
gluTessVertex(tobj, star[4], star[4])
|
156
|
+
gluTessEndContour(tobj)
|
157
|
+
gluTessEndPolygon(tobj)
|
158
|
+
glEndList()
|
159
|
+
gluDeleteTess(tobj)
|
158
160
|
end
|
159
161
|
|
160
162
|
reshape = proc do |w, h|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
163
|
+
glViewport(0, 0, w, h)
|
164
|
+
glMatrixMode(GL_PROJECTION)
|
165
|
+
glLoadIdentity()
|
166
|
+
gluOrtho2D(0.0, w, 0.0, h)
|
165
167
|
end
|
166
168
|
|
167
169
|
keyboard = proc do |key, x, y|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
170
|
+
case (key)
|
171
|
+
when ?\e
|
172
|
+
exit(0)
|
173
|
+
end
|
172
174
|
end
|
173
175
|
|
174
176
|
glutInit()
|
data/examples/RedBook/texbind.rb
CHANGED
@@ -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
|
@@ -36,9 +36,11 @@
|
|
36
36
|
#
|
37
37
|
|
38
38
|
# texbind.c
|
39
|
-
# This program demonstrates using glBindTexture() by
|
39
|
+
# This program demonstrates using glBindTexture() by
|
40
40
|
# creating and managing two textures.
|
41
41
|
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
42
44
|
require 'mathn'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
@@ -50,88 +52,88 @@ $otherImage = []
|
|
50
52
|
$texName = []
|
51
53
|
|
52
54
|
def makeCheckImages
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
55
|
+
for i in (0..CheckImageHeight-1)
|
56
|
+
for j in (0..CheckImageWidth-1)
|
57
|
+
if ((i&0x8==0)!=(j&0x8==0)) then tmp = 1 else tmp=0 end
|
58
|
+
#c = ((((i&0x8)==0)^((j&0x8))==0))*255
|
59
|
+
c = tmp * 255
|
60
|
+
$checkImage[i*CheckImageWidth*4+j*4+0] = c
|
61
|
+
$checkImage[i*CheckImageWidth*4+j*4+1] = c
|
62
|
+
$checkImage[i*CheckImageWidth*4+j*4+2] = c
|
63
|
+
$checkImage[i*CheckImageWidth*4+j*4+3] = 255
|
64
|
+
#c = ((((i&0x10)==0)^((j&0x10))==0))*255
|
65
|
+
if ((i&0x10==0)!=(j&0x10==0)) then tmp = 1 else tmp=0 end
|
66
|
+
c = tmp * 255
|
67
|
+
$otherImage[i*CheckImageWidth*4+j*4+0] = c
|
68
|
+
$otherImage[i*CheckImageWidth*4+j*4+1] = 0
|
69
|
+
$otherImage[i*CheckImageWidth*4+j*4+2] = 0
|
70
|
+
$otherImage[i*CheckImageWidth*4+j*4+3] = 255
|
71
|
+
end
|
72
|
+
end
|
71
73
|
end
|
72
74
|
|
73
75
|
def init
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
76
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
77
|
+
glShadeModel(GL_FLAT)
|
78
|
+
glEnable(GL_DEPTH_TEST)
|
79
|
+
|
80
|
+
makeCheckImages()
|
81
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
82
|
+
|
83
|
+
$texName = glGenTextures(2)
|
84
|
+
glBindTexture(GL_TEXTURE_2D, $texName[0])
|
85
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
|
86
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
|
87
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST)
|
88
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST)
|
89
|
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
|
90
|
+
CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
|
91
|
+
|
92
|
+
glBindTexture(GL_TEXTURE_2D, $texName[1])
|
93
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
|
94
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
|
95
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
96
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
97
|
+
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
|
98
|
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth, CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
99
|
+
$otherImage.pack("C*"))
|
100
|
+
glEnable(GL_TEXTURE_2D)
|
99
101
|
end
|
100
102
|
|
101
103
|
display = Proc.new do
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
104
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
105
|
+
glBindTexture(GL_TEXTURE_2D, $texName[0])
|
106
|
+
glBegin(GL_QUADS)
|
107
|
+
glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
|
108
|
+
glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
|
109
|
+
glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
|
110
|
+
glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
|
111
|
+
glEnd()
|
112
|
+
glBindTexture(GL_TEXTURE_2D, $texName[1])
|
113
|
+
glBegin(GL_QUADS)
|
114
|
+
glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
|
115
|
+
glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
|
116
|
+
glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
|
117
|
+
glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
|
118
|
+
glEnd()
|
119
|
+
glutSwapBuffers()
|
118
120
|
end
|
119
121
|
|
120
122
|
reshape = Proc.new do |w, h|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
123
|
+
glViewport(0, 0, w, h)
|
124
|
+
glMatrixMode(GL_PROJECTION)
|
125
|
+
glLoadIdentity()
|
126
|
+
gluPerspective(60.0, w/h, 1.0, 30.0)
|
127
|
+
glMatrixMode(GL_MODELVIEW)
|
128
|
+
glLoadIdentity()
|
129
|
+
glTranslate(0.0, 0.0, -3.6)
|
128
130
|
end
|
129
131
|
|
130
132
|
keyboard = Proc.new do |key, x, y|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
133
|
+
case (key)
|
134
|
+
when ?\e
|
135
|
+
exit(0)
|
136
|
+
end
|
135
137
|
end
|
136
138
|
|
137
139
|
# main
|
data/examples/RedBook/texgen.rb
CHANGED
@@ -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
|
@@ -35,7 +35,7 @@
|
|
35
35
|
# OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
|
36
36
|
#
|
37
37
|
# texgen.c
|
38
|
-
# This program draws a texture mapped teapot with
|
38
|
+
# This program draws a texture mapped teapot with
|
39
39
|
# automatically generated texture coordinates. The
|
40
40
|
# texture is rendered as stripes on the teapot.
|
41
41
|
# Initially, the object is drawn with texture coordinates
|
@@ -43,11 +43,13 @@
|
|
43
43
|
# and distance from the plane x = 0. Pressing the 'e'
|
44
44
|
# key changes the coordinate generation to eye coordinates
|
45
45
|
# of the vertex. Pressing the 'o' key switches it back
|
46
|
-
# to the object coordinates. Pressing the 's' key
|
46
|
+
# to the object coordinates. Pressing the 's' key
|
47
47
|
# changes the plane to a slanted one (x + y + z = 0).
|
48
48
|
# Pressing the 'x' key switches it back to x = 0.
|
49
49
|
|
50
50
|
require 'opengl'
|
51
|
+
require 'glu'
|
52
|
+
require 'glut'
|
51
53
|
require 'mathn'
|
52
54
|
include Gl,Glu,Glut
|
53
55
|
|
@@ -57,12 +59,12 @@ $stripeImage = []
|
|
57
59
|
$texName
|
58
60
|
|
59
61
|
def makeStripeImage
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
for j in (0..StripeImageWidth-1)
|
63
|
+
$stripeImage[4*j] = if (j<=4) then 255 else 0 end
|
64
|
+
$stripeImage[4*j+1] = if (j>4) then 255 else 0 end
|
65
|
+
$stripeImage[4*j+2] = 0
|
66
|
+
$stripeImage[4*j+3] = 255
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
68
70
|
# planes for texture coordinate generation
|
@@ -73,87 +75,87 @@ $currentPlane = nil
|
|
73
75
|
$currentGenMode = nil
|
74
76
|
|
75
77
|
def init
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
78
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
79
|
+
glEnable(GL_DEPTH_TEST)
|
80
|
+
glShadeModel(GL_SMOOTH)
|
81
|
+
|
82
|
+
makeStripeImage()
|
83
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
84
|
+
|
85
|
+
$texName = glGenTextures(1)
|
86
|
+
glBindTexture(GL_TEXTURE_2D, $texName[0])
|
87
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
88
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
|
89
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
|
90
|
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, StripeImageWidth, 1, 0,
|
91
|
+
GL_RGBA, GL_UNSIGNED_BYTE, $stripeImage.pack("C*"))
|
92
|
+
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
|
93
|
+
$currentCoeff = $xequalzero
|
94
|
+
$currentGenMode = GL_OBJECT_LINEAR
|
95
|
+
$currentPlane = GL_OBJECT_PLANE
|
96
|
+
glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
|
97
|
+
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
98
|
+
|
99
|
+
glEnable(GL_TEXTURE_GEN_S)
|
100
|
+
glEnable(GL_TEXTURE_2D)
|
101
|
+
glEnable(GL_CULL_FACE)
|
102
|
+
glEnable(GL_LIGHTING)
|
103
|
+
glEnable(GL_LIGHT0)
|
104
|
+
glEnable(GL_AUTO_NORMAL)
|
105
|
+
glEnable(GL_NORMALIZE)
|
106
|
+
glFrontFace(GL_CW)
|
107
|
+
glCullFace(GL_BACK)
|
108
|
+
glMaterial(GL_FRONT, GL_SHININESS, 64.0)
|
107
109
|
end
|
108
110
|
|
109
111
|
display = Proc.new do
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
112
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
113
|
+
glPushMatrix()
|
114
|
+
glRotate(45.0, 0.0, 0.0, 1.0)
|
115
|
+
glBindTexture(GL_TEXTURE_2D, $texName[0])
|
116
|
+
glutSolidTeapot(2.0)
|
117
|
+
glPopMatrix()
|
118
|
+
glutSwapBuffers()
|
117
119
|
end
|
118
120
|
|
119
121
|
reshape = Proc.new do |w, h|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
glViewport(0, 0, w, h)
|
123
|
+
glMatrixMode(GL_PROJECTION)
|
124
|
+
glLoadIdentity()
|
125
|
+
if (w <= h)
|
126
|
+
glOrtho(-3.5, 3.5, -3.5*h/w,3.5*h/w, -3.5, 3.5)
|
127
|
+
else
|
128
|
+
glOrtho(-3.5*w/h, 3.5*w/h, -3.5, 3.5, -3.5, 3.5)
|
129
|
+
end
|
130
|
+
glMatrixMode(GL_MODELVIEW)
|
131
|
+
glLoadIdentity()
|
130
132
|
end
|
131
133
|
|
132
134
|
keyboard = Proc.new do |key, x, y|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
135
|
+
case (key)
|
136
|
+
when ?e,?E
|
137
|
+
$currentGenMode = GL_EYE_LINEAR
|
138
|
+
$currentPlane = GL_EYE_PLANE
|
139
|
+
glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
|
140
|
+
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
141
|
+
glutPostRedisplay()
|
142
|
+
when ?o, ?O
|
143
|
+
$currentGenMode = GL_OBJECT_LINEAR
|
144
|
+
$currentPlane = GL_OBJECT_PLANE
|
145
|
+
glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
|
146
|
+
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
147
|
+
glutPostRedisplay()
|
148
|
+
when ?s,?S
|
149
|
+
$currentCoeff = $slanted
|
150
|
+
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
151
|
+
glutPostRedisplay()
|
152
|
+
when ?x,?X
|
153
|
+
$currentCoeff = $xequalzero
|
154
|
+
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
155
|
+
glutPostRedisplay()
|
156
|
+
when ?\e
|
157
|
+
exit(0)
|
158
|
+
end
|
157
159
|
end
|
158
160
|
|
159
161
|
# main
|