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
@@ -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
|
@@ -37,101 +37,103 @@
|
|
37
37
|
# feedback.c
|
38
38
|
# This program demonstrates use of OpenGL feedback. First,
|
39
39
|
# a lighting environment is set up and a few lines are drawn.
|
40
|
-
# Then feedback mode is entered, and the same lines are
|
40
|
+
# Then feedback mode is entered, and the same lines are
|
41
41
|
# drawn. The results in the feedback buffer are printed.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
# Initialize lighting.
|
46
48
|
def init
|
47
|
-
|
48
|
-
|
49
|
+
glEnable(GL_LIGHTING)
|
50
|
+
glEnable(GL_LIGHT0)
|
49
51
|
end
|
50
52
|
|
51
|
-
# Draw a few lines and two points, one of which will
|
52
|
-
# be clipped. If in feedback mode, a passthrough token
|
53
|
+
# Draw a few lines and two points, one of which will
|
54
|
+
# be clipped. If in feedback mode, a passthrough token
|
53
55
|
# is issued between the each primitive.
|
54
56
|
def drawGeometry(mode)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
57
|
+
glBegin(GL_LINE_STRIP)
|
58
|
+
glNormal(0.0, 0.0, 1.0)
|
59
|
+
glVertex(30.0, 30.0, 0.0)
|
60
|
+
glVertex(50.0, 60.0, 0.0)
|
61
|
+
glVertex(70.0, 40.0, 0.0)
|
62
|
+
glEnd()
|
63
|
+
if (mode == GL_FEEDBACK)
|
64
|
+
glPassThrough(1.0)
|
65
|
+
end
|
66
|
+
glBegin(GL_POINTS)
|
67
|
+
glVertex(-100.0, -100.0, -100.0) # will be clipped
|
68
|
+
glEnd()
|
69
|
+
if (mode == GL_FEEDBACK)
|
70
|
+
glPassThrough(2.0)
|
71
|
+
end
|
72
|
+
glBegin(GL_POINTS)
|
73
|
+
glNormal(0.0, 0.0, 1.0)
|
74
|
+
glVertex(50.0, 50.0, 0.0)
|
75
|
+
glEnd()
|
74
76
|
end
|
75
77
|
|
76
78
|
# Write contents of one vertex to stdout.
|
77
79
|
def print3DcolorVertex(size, count, buffer)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
printf(" ")
|
81
|
+
for i in 0...7
|
82
|
+
printf("%4.2f ", buffer[size-count])
|
83
|
+
count -= 1
|
84
|
+
end
|
85
|
+
printf("\n")
|
86
|
+
return count
|
85
87
|
end
|
86
88
|
|
87
89
|
# Write contents of entire buffer. (Parse tokens!)
|
88
90
|
def printBuffer(size, buffer)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
91
|
+
count = size
|
92
|
+
while (count!=0)
|
93
|
+
token = buffer[size-count]
|
94
|
+
count-=1
|
95
|
+
if (token == GL_PASS_THROUGH_TOKEN)
|
96
|
+
printf("GL_PASS_THROUGH_TOKEN\n")
|
97
|
+
printf(" %4.2f\n", buffer[size-count])
|
98
|
+
count-=1
|
99
|
+
elsif (token == GL_POINT_TOKEN)
|
100
|
+
printf("GL_POINT_TOKEN\n")
|
101
|
+
count = print3DcolorVertex(size, count, buffer)
|
102
|
+
elsif (token == GL_LINE_TOKEN)
|
103
|
+
printf("GL_LINE_TOKEN\n")
|
104
|
+
count = print3DcolorVertex(size, count, buffer)
|
105
|
+
count = print3DcolorVertex(size, count, buffer)
|
106
|
+
elsif (token == GL_LINE_RESET_TOKEN)
|
107
|
+
printf("GL_LINE_RESET_TOKEN\n")
|
108
|
+
count = print3DcolorVertex(size, count, buffer)
|
109
|
+
count = print3DcolorVertex(size, count, buffer)
|
110
|
+
end
|
111
|
+
end
|
110
112
|
end
|
111
113
|
|
112
114
|
display = proc do
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
115
|
+
glMatrixMode(GL_PROJECTION)
|
116
|
+
glLoadIdentity()
|
117
|
+
glOrtho(0.0, 100.0, 0.0, 100.0, 0.0, 1.0)
|
118
|
+
|
119
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
120
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
121
|
+
drawGeometry(GL_RENDER)
|
122
|
+
|
123
|
+
feedBuffer = glFeedbackBuffer(1024, GL_3D_COLOR)
|
124
|
+
glRenderMode(GL_FEEDBACK)
|
125
|
+
drawGeometry(GL_FEEDBACK)
|
126
|
+
|
127
|
+
size = glRenderMode(GL_RENDER)
|
128
|
+
printBuffer(size, feedBuffer.unpack("f#{size}"))
|
129
|
+
glutSwapBuffers()
|
128
130
|
end
|
129
131
|
|
130
132
|
keyboard = proc 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
|
glutInit()
|
data/examples/RedBook/fog.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
|
@@ -37,116 +37,118 @@
|
|
37
37
|
# OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
38
38
|
#
|
39
39
|
# fog.c
|
40
|
-
# This program draws 5 red teapots, each at a different
|
41
|
-
# z distance from the eye, in different types of fog.
|
42
|
-
# Pressing the left mouse button chooses between 3 types of
|
43
|
-
# fog: exponential, exponential squared, and linear.
|
44
|
-
# In this program, there is a fixed density value, as well
|
40
|
+
# This program draws 5 red teapots, each at a different
|
41
|
+
# z distance from the eye, in different types of fog.
|
42
|
+
# Pressing the left mouse button chooses between 3 types of
|
43
|
+
# fog: exponential, exponential squared, and linear.
|
44
|
+
# In this program, there is a fixed density value, as well
|
45
45
|
# as fixed start and end values for the linear fog.
|
46
46
|
require 'opengl'
|
47
|
+
require 'glu'
|
48
|
+
require 'glut'
|
47
49
|
require 'mathn'
|
48
50
|
include Gl,Glu,Glut
|
49
51
|
|
50
52
|
$fogMode = 0
|
51
53
|
|
52
54
|
selectFog = Proc.new do |mode|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
if (mode == GL_LINEAR)
|
56
|
+
glFog(GL_FOG_START, 1.0)
|
57
|
+
glFog(GL_FOG_END, 5.0)
|
58
|
+
# falls through
|
59
|
+
glFog(GL_FOG_MODE, mode)
|
60
|
+
glutPostRedisplay()
|
61
|
+
end
|
62
|
+
if (mode == GL_EXP2 || mode == GL_EXP)
|
63
|
+
glFog(GL_FOG_MODE, mode)
|
64
|
+
glutPostRedisplay()
|
65
|
+
end
|
66
|
+
exit(0) if (mode == 0)
|
65
67
|
end
|
66
68
|
|
67
|
-
# Initialize z-buffer, projection matrix, light source,
|
69
|
+
# Initialize z-buffer, projection matrix, light source,
|
68
70
|
# and lighting model. Do not specify a material property here.
|
69
71
|
def myinit
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
72
|
+
position = [0.0, 3.0, 3.0, 0.0]
|
73
|
+
local_view = [0.0]
|
74
|
+
|
75
|
+
glEnable(GL_DEPTH_TEST)
|
76
|
+
glDepthFunc(GL_LESS)
|
77
|
+
|
78
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
79
|
+
glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
|
80
|
+
|
81
|
+
glFrontFace(GL_CW)
|
82
|
+
glEnable(GL_LIGHTING)
|
83
|
+
glEnable(GL_LIGHT0)
|
84
|
+
glEnable(GL_AUTO_NORMAL)
|
85
|
+
glEnable(GL_NORMALIZE)
|
86
|
+
glEnable(GL_FOG)
|
87
|
+
fogColor = [0.5, 0.5, 0.5, 1.0]
|
88
|
+
|
89
|
+
fogMode = GL_EXP
|
90
|
+
glFog(GL_FOG_MODE, fogMode)
|
91
|
+
glFog(GL_FOG_COLOR, fogColor)
|
92
|
+
glFog(GL_FOG_DENSITY, 0.35)
|
93
|
+
glHint(GL_FOG_HINT, GL_DONT_CARE)
|
94
|
+
glClearColor(0.5, 0.5, 0.5, 1.0)
|
93
95
|
end
|
94
96
|
|
95
97
|
def renderRedTeapot(x, y, z)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
98
|
+
mat = []
|
99
|
+
glPushMatrix()
|
100
|
+
glTranslate(x, y, z)
|
101
|
+
mat[0] = 0.1745
|
102
|
+
mat[1] = 0.01175
|
103
|
+
mat[2] = 0.01175
|
104
|
+
mat[3] = 1.0
|
105
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat)
|
106
|
+
mat[0] = 0.61424
|
107
|
+
mat[1] = 0.04136
|
108
|
+
mat[2] = 0.04136
|
109
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat)
|
110
|
+
mat[0] = 0.727811
|
111
|
+
mat[1] = 0.626959
|
112
|
+
mat[2] = 0.626959
|
113
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat)
|
114
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat)
|
115
|
+
glutSolidTeapot(1.0)
|
116
|
+
glPopMatrix()
|
115
117
|
end
|
116
118
|
|
117
119
|
# display() draws 5 teapots at different z positions.
|
118
120
|
display = Proc.new do
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
122
|
+
renderRedTeapot(-4.0, -0.5, -1.0)
|
123
|
+
renderRedTeapot(-2.0, -0.5, -2.0)
|
124
|
+
renderRedTeapot(0.0, -0.5, -3.0)
|
125
|
+
renderRedTeapot(2.0, -0.5, -4.0)
|
126
|
+
renderRedTeapot(4.0, -0.5, -5.0)
|
127
|
+
glFlush()
|
126
128
|
end
|
127
129
|
|
128
130
|
myReshape = Proc.new do |w, h|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
131
|
+
glViewport(0, 0, w, h)
|
132
|
+
glMatrixMode(GL_PROJECTION)
|
133
|
+
glLoadIdentity()
|
134
|
+
if (w <= (h * 3))
|
135
|
+
glOrtho(-6.0, 6.0, -2.0 * h * 3 / w, 2.0 * h * 3 / w, 0.0, 10.0)
|
136
|
+
elsif
|
137
|
+
glOrtho(-6.0 * w / h * 3, 6.0 * w / h * 3, -2.0, 2.0, 0.0, 10.0)
|
138
|
+
end
|
139
|
+
glMatrixMode(GL_MODELVIEW)
|
140
|
+
glLoadIdentity()
|
139
141
|
end
|
140
142
|
|
141
143
|
keyboard = Proc.new do |key, x, y|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
144
|
+
case (key)
|
145
|
+
when ?\e
|
146
|
+
exit(0)
|
147
|
+
end
|
146
148
|
end
|
147
149
|
|
148
150
|
# Main Loop
|
149
|
-
# Open window with initial window size, title bar,
|
151
|
+
# Open window with initial window size, title bar,
|
150
152
|
# RGBA display mode, depth buffer, and handle input events.
|
151
153
|
glutInit
|
152
154
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
|
@@ -164,4 +166,3 @@ glutAddMenuEntry("Fog LINEAR", GL_LINEAR)
|
|
164
166
|
glutAddMenuEntry("Quit", 0)
|
165
167
|
glutAttachMenu(GLUT_RIGHT_BUTTON)
|
166
168
|
glutMainLoop()
|
167
|
-
|
data/examples/RedBook/font.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,108 +36,110 @@
|
|
36
36
|
#
|
37
37
|
# font.c
|
38
38
|
#
|
39
|
-
# Draws some text in a bitmapped font. Uses glBitmap()
|
40
|
-
# and other pixel routines. Also demonstrates use of
|
39
|
+
# Draws some text in a bitmapped font. Uses glBitmap()
|
40
|
+
# and other pixel routines. Also demonstrates use of
|
41
41
|
# display lists.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
$space = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
46
48
|
|
47
49
|
$letters = [
|
48
|
-
[0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18],
|
49
|
-
[0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
|
50
|
-
[0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
|
51
|
-
[0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc],
|
52
|
-
[0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff],
|
53
|
-
[0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff],
|
54
|
-
[0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
|
55
|
-
[0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
56
|
-
[0x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0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
71
|
+
[0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
72
|
+
[0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
73
|
+
[0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
|
74
|
+
[0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
|
73
75
|
[0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff]
|
74
76
|
]
|
75
77
|
|
76
78
|
$fontOffset = 0
|
77
79
|
|
78
80
|
def makeRasterFont
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
81
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
82
|
+
|
83
|
+
$fontOffset = glGenLists(128)
|
84
|
+
i = 0
|
85
|
+
j = ?A
|
86
|
+
for i in 0...26
|
87
|
+
glNewList($fontOffset + j, GL_COMPILE)
|
88
|
+
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"))
|
89
|
+
glEndList()
|
90
|
+
j+=1
|
91
|
+
end
|
92
|
+
glNewList($fontOffset + ' '[0], GL_COMPILE)
|
93
|
+
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"))
|
94
|
+
glEndList()
|
93
95
|
end
|
94
96
|
|
95
97
|
def init
|
96
|
-
|
97
|
-
|
98
|
+
glShadeModel(GL_FLAT)
|
99
|
+
makeRasterFont()
|
98
100
|
end
|
99
101
|
|
100
102
|
def printString(s)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
glPushAttrib(GL_LIST_BIT)
|
104
|
+
glListBase($fontOffset)
|
105
|
+
glCallLists(GL_BYTE,s)
|
106
|
+
glPopAttrib()
|
105
107
|
end
|
106
108
|
|
107
|
-
# Everything above this line could be in a library
|
108
|
-
# that defines a font. To make it work, you've got
|
109
|
-
# to call makeRasterFont() before you start making
|
109
|
+
# Everything above this line could be in a library
|
110
|
+
# that defines a font. To make it work, you've got
|
111
|
+
# to call makeRasterFont() before you start making
|
110
112
|
# calls to printString().
|
111
113
|
display = proc do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
114
|
+
white = [ 1.0, 1.0, 1.0 ]
|
115
|
+
|
116
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
117
|
+
glColor(white)
|
118
|
+
|
119
|
+
glRasterPos(20, 60)
|
120
|
+
printString("THE QUICK BROWN FOX JUMPS")
|
121
|
+
glRasterPos(20, 40)
|
122
|
+
printString("OVER A LAZY DOG")
|
123
|
+
glutSwapBuffers()
|
122
124
|
end
|
123
125
|
|
124
126
|
reshape = proc do |w, h|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
glViewport(0, 0, w, h)
|
128
|
+
glMatrixMode(GL_PROJECTION)
|
129
|
+
glLoadIdentity()
|
130
|
+
glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
|
131
|
+
glMatrixMode(GL_MODELVIEW)
|
130
132
|
end
|
131
133
|
|
132
134
|
keyboard = proc do |key, x, y|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
case (key)
|
136
|
+
when ?\e
|
137
|
+
exit(0)
|
138
|
+
end
|
137
139
|
end
|
138
140
|
|
139
141
|
# Main Loop
|
140
|
-
# Open window with initial window size, title bar,
|
142
|
+
# Open window with initial window size, title bar,
|
141
143
|
# RGBA display mode, and handle input events.
|
142
144
|
glutInit()
|
143
145
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|