ruby-opengl2 0.60.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +80 -0
- data/examples/NeHe/nehe_lesson02.rb +117 -0
- data/examples/NeHe/nehe_lesson03.rb +122 -0
- data/examples/NeHe/nehe_lesson04.rb +133 -0
- data/examples/NeHe/nehe_lesson05.rb +186 -0
- data/examples/NeHe/nehe_lesson36.rb +303 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +376 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +406 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +16 -0
- data/examples/RedBook/aapoly.rb +142 -0
- data/examples/RedBook/aargb.rb +119 -0
- data/examples/RedBook/accanti.rb +162 -0
- data/examples/RedBook/accpersp.rb +215 -0
- data/examples/RedBook/alpha.rb +123 -0
- data/examples/RedBook/alpha3D.rb +158 -0
- data/examples/RedBook/bezcurve.rb +105 -0
- data/examples/RedBook/bezmesh.rb +137 -0
- data/examples/RedBook/checker.rb +124 -0
- data/examples/RedBook/clip.rb +95 -0
- data/examples/RedBook/colormat.rb +135 -0
- data/examples/RedBook/cube.rb +69 -0
- data/examples/RedBook/depthcue.rb +99 -0
- data/examples/RedBook/dof.rb +205 -0
- data/examples/RedBook/double.rb +105 -0
- data/examples/RedBook/drawf.rb +91 -0
- data/examples/RedBook/feedback.rb +145 -0
- data/examples/RedBook/fog.rb +167 -0
- data/examples/RedBook/font.rb +151 -0
- data/examples/RedBook/hello.rb +79 -0
- data/examples/RedBook/image.rb +137 -0
- data/examples/RedBook/jitter.rb +207 -0
- data/examples/RedBook/lines.rb +128 -0
- data/examples/RedBook/list.rb +111 -0
- data/examples/RedBook/material.rb +275 -0
- data/examples/RedBook/mipmap.rb +156 -0
- data/examples/RedBook/model.rb +113 -0
- data/examples/RedBook/movelight.rb +132 -0
- data/examples/RedBook/pickdepth.rb +179 -0
- data/examples/RedBook/planet.rb +108 -0
- data/examples/RedBook/quadric.rb +158 -0
- data/examples/RedBook/robot.rb +115 -0
- data/examples/RedBook/select.rb +196 -0
- data/examples/RedBook/smooth.rb +95 -0
- data/examples/RedBook/stencil.rb +163 -0
- data/examples/RedBook/stroke.rb +167 -0
- data/examples/RedBook/surface.rb +166 -0
- data/examples/RedBook/teaambient.rb +132 -0
- data/examples/RedBook/teapots.rb +182 -0
- data/examples/RedBook/tess.rb +183 -0
- data/examples/RedBook/texbind.rb +147 -0
- data/examples/RedBook/texgen.rb +169 -0
- data/examples/RedBook/texturesurf.rb +128 -0
- data/examples/RedBook/varray.rb +159 -0
- data/examples/RedBook/wrap.rb +148 -0
- data/examples/misc/OGLBench.rb +337 -0
- data/examples/misc/anisotropic.rb +194 -0
- data/examples/misc/fbo_test.rb +356 -0
- data/examples/misc/font-glut.rb +46 -0
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/plane.rb +161 -0
- data/examples/misc/readpixel.rb +65 -0
- data/examples/misc/sdltest.rb +34 -0
- data/examples/misc/trislam.rb +828 -0
- data/ext/common/common.h +423 -0
- data/ext/common/conv.h +243 -0
- data/ext/common/funcdef.h +280 -0
- data/ext/common/gl-enums.h +10031 -0
- data/ext/common/gl-error.h +23 -0
- data/ext/common/gl-types.h +63 -0
- data/ext/common/glu-enums.h +463 -0
- data/ext/gl/gl-1.0-1.1.c +2811 -0
- data/ext/gl/gl-1.2.c +814 -0
- data/ext/gl/gl-1.3.c +443 -0
- data/ext/gl/gl-1.4.c +348 -0
- data/ext/gl/gl-1.5.c +225 -0
- data/ext/gl/gl-2.0.c +657 -0
- data/ext/gl/gl-2.1.c +57 -0
- data/ext/gl/gl-enums.c +3354 -0
- data/ext/gl/gl-error.c +104 -0
- data/ext/gl/gl-ext-3dfx.c +27 -0
- data/ext/gl/gl-ext-arb.c +866 -0
- data/ext/gl/gl-ext-ati.c +41 -0
- data/ext/gl/gl-ext-ext.c +889 -0
- data/ext/gl/gl-ext-gremedy.c +41 -0
- data/ext/gl/gl-ext-nv.c +679 -0
- data/ext/gl/gl.c +214 -0
- data/ext/gl/mkrf_conf.rb +37 -0
- data/ext/glu/glu-enums.c +164 -0
- data/ext/glu/glu.c +1530 -0
- data/ext/glu/mkrf_conf.rb +39 -0
- data/ext/glut/glut.c +1627 -0
- data/ext/glut/mkrf_conf.rb +37 -0
- data/lib/opengl.rb +84 -0
- data/test/README +10 -0
- data/test/tc_common.rb +98 -0
- data/test/tc_ext_arb.rb +467 -0
- data/test/tc_ext_ati.rb +33 -0
- data/test/tc_ext_ext.rb +551 -0
- data/test/tc_ext_gremedy.rb +36 -0
- data/test/tc_ext_nv.rb +357 -0
- data/test/tc_func_10_11.rb +1281 -0
- data/test/tc_func_12.rb +186 -0
- data/test/tc_func_13.rb +229 -0
- data/test/tc_func_14.rb +197 -0
- data/test/tc_func_15.rb +270 -0
- data/test/tc_func_20.rb +346 -0
- data/test/tc_func_21.rb +541 -0
- data/test/tc_glu.rb +310 -0
- data/test/tc_include_gl.rb +35 -0
- data/test/tc_misc.rb +54 -0
- data/test/tc_require_gl.rb +34 -0
- metadata +164 -0
@@ -0,0 +1,167 @@
|
|
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
|
+
# 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
|
45
|
+
# as fixed start and end values for the linear fog.
|
46
|
+
require 'opengl'
|
47
|
+
require 'mathn'
|
48
|
+
include Gl,Glu,Glut
|
49
|
+
|
50
|
+
$fogMode = 0
|
51
|
+
|
52
|
+
selectFog = Proc.new do |mode|
|
53
|
+
if (mode == GL_LINEAR)
|
54
|
+
glFog(GL_FOG_START, 1.0)
|
55
|
+
glFog(GL_FOG_END, 5.0)
|
56
|
+
# falls through
|
57
|
+
glFog(GL_FOG_MODE, mode)
|
58
|
+
glutPostRedisplay()
|
59
|
+
end
|
60
|
+
if (mode == GL_EXP2 || mode == GL_EXP)
|
61
|
+
glFog(GL_FOG_MODE, mode)
|
62
|
+
glutPostRedisplay()
|
63
|
+
end
|
64
|
+
exit(0) if (mode == 0)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Initialize z-buffer, projection matrix, light source,
|
68
|
+
# and lighting model. Do not specify a material property here.
|
69
|
+
def myinit
|
70
|
+
position = [0.0, 3.0, 3.0, 0.0]
|
71
|
+
local_view = [0.0]
|
72
|
+
|
73
|
+
glEnable(GL_DEPTH_TEST)
|
74
|
+
glDepthFunc(GL_LESS)
|
75
|
+
|
76
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
77
|
+
glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
|
78
|
+
|
79
|
+
glFrontFace(GL_CW)
|
80
|
+
glEnable(GL_LIGHTING)
|
81
|
+
glEnable(GL_LIGHT0)
|
82
|
+
glEnable(GL_AUTO_NORMAL)
|
83
|
+
glEnable(GL_NORMALIZE)
|
84
|
+
glEnable(GL_FOG)
|
85
|
+
fogColor = [0.5, 0.5, 0.5, 1.0]
|
86
|
+
|
87
|
+
fogMode = GL_EXP
|
88
|
+
glFog(GL_FOG_MODE, fogMode)
|
89
|
+
glFog(GL_FOG_COLOR, fogColor)
|
90
|
+
glFog(GL_FOG_DENSITY, 0.35)
|
91
|
+
glHint(GL_FOG_HINT, GL_DONT_CARE)
|
92
|
+
glClearColor(0.5, 0.5, 0.5, 1.0)
|
93
|
+
end
|
94
|
+
|
95
|
+
def renderRedTeapot(x, y, z)
|
96
|
+
mat = []
|
97
|
+
glPushMatrix()
|
98
|
+
glTranslate(x, y, z)
|
99
|
+
mat[0] = 0.1745
|
100
|
+
mat[1] = 0.01175
|
101
|
+
mat[2] = 0.01175
|
102
|
+
mat[3] = 1.0
|
103
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat)
|
104
|
+
mat[0] = 0.61424
|
105
|
+
mat[1] = 0.04136
|
106
|
+
mat[2] = 0.04136
|
107
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat)
|
108
|
+
mat[0] = 0.727811
|
109
|
+
mat[1] = 0.626959
|
110
|
+
mat[2] = 0.626959
|
111
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat)
|
112
|
+
glMaterial(GL_FRONT, GL_SHININESS, 0.6 * 128.0)
|
113
|
+
glutSolidTeapot(1.0)
|
114
|
+
glPopMatrix()
|
115
|
+
end
|
116
|
+
|
117
|
+
# display() draws 5 teapots at different z positions.
|
118
|
+
display = Proc.new do
|
119
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
120
|
+
renderRedTeapot(-4.0, -0.5, -1.0)
|
121
|
+
renderRedTeapot(-2.0, -0.5, -2.0)
|
122
|
+
renderRedTeapot(0.0, -0.5, -3.0)
|
123
|
+
renderRedTeapot(2.0, -0.5, -4.0)
|
124
|
+
renderRedTeapot(4.0, -0.5, -5.0)
|
125
|
+
glFlush()
|
126
|
+
end
|
127
|
+
|
128
|
+
myReshape = Proc.new do |w, h|
|
129
|
+
glViewport(0, 0, w, h)
|
130
|
+
glMatrixMode(GL_PROJECTION)
|
131
|
+
glLoadIdentity()
|
132
|
+
if (w <= (h * 3))
|
133
|
+
glOrtho(-6.0, 6.0, -2.0 * h * 3 / w, 2.0 * h * 3 / w, 0.0, 10.0)
|
134
|
+
elsif
|
135
|
+
glOrtho(-6.0 * w / h * 3, 6.0 * w / h * 3, -2.0, 2.0, 0.0, 10.0)
|
136
|
+
end
|
137
|
+
glMatrixMode(GL_MODELVIEW)
|
138
|
+
glLoadIdentity()
|
139
|
+
end
|
140
|
+
|
141
|
+
keyboard = Proc.new do |key, x, y|
|
142
|
+
case (key)
|
143
|
+
when ?\e
|
144
|
+
exit(0)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Main Loop
|
149
|
+
# Open window with initial window size, title bar,
|
150
|
+
# RGBA display mode, depth buffer, and handle input events.
|
151
|
+
glutInit
|
152
|
+
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
|
153
|
+
glutInitWindowSize(800, 300)
|
154
|
+
glutInitWindowPosition(100, 100)
|
155
|
+
glutCreateWindow($0)
|
156
|
+
myinit()
|
157
|
+
glutReshapeFunc(myReshape)
|
158
|
+
glutDisplayFunc(display)
|
159
|
+
glutKeyboardFunc(keyboard)
|
160
|
+
glutCreateMenu(selectFog)
|
161
|
+
glutAddMenuEntry("Fog EXP", GL_EXP)
|
162
|
+
glutAddMenuEntry("Fog EXP2", GL_EXP2)
|
163
|
+
glutAddMenuEntry("Fog LINEAR", GL_LINEAR)
|
164
|
+
glutAddMenuEntry("Quit", 0)
|
165
|
+
glutAttachMenu(GLUT_RIGHT_BUTTON)
|
166
|
+
glutMainLoop()
|
167
|
+
|
@@ -0,0 +1,151 @@
|
|
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
|
+
# font.c
|
38
|
+
#
|
39
|
+
# Draws some text in a bitmapped font. Uses glBitmap()
|
40
|
+
# and other pixel routines. Also demonstrates use of
|
41
|
+
# display lists.
|
42
|
+
require 'opengl'
|
43
|
+
include Gl,Glu,Glut
|
44
|
+
|
45
|
+
$space = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
46
|
+
|
47
|
+
$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
|
+
[0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e],
|
57
|
+
[0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06],
|
58
|
+
[0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3],
|
59
|
+
[0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0],
|
60
|
+
[0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3],
|
61
|
+
[0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3],
|
62
|
+
[0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e],
|
63
|
+
[0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
|
64
|
+
[0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c],
|
65
|
+
[0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
|
66
|
+
[0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e],
|
67
|
+
[0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff],
|
68
|
+
[0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
69
|
+
[0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
70
|
+
[0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
|
71
|
+
[0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
|
72
|
+
[0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
|
73
|
+
[0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff]
|
74
|
+
]
|
75
|
+
|
76
|
+
$fontOffset = 0
|
77
|
+
|
78
|
+
def makeRasterFont
|
79
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
80
|
+
|
81
|
+
$fontOffset = glGenLists(128)
|
82
|
+
i = 0
|
83
|
+
j = ?A
|
84
|
+
for i in 0...26
|
85
|
+
glNewList($fontOffset + j, GL_COMPILE)
|
86
|
+
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"))
|
87
|
+
glEndList()
|
88
|
+
j+=1
|
89
|
+
end
|
90
|
+
glNewList($fontOffset + ' '[0], GL_COMPILE)
|
91
|
+
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"))
|
92
|
+
glEndList()
|
93
|
+
end
|
94
|
+
|
95
|
+
def init
|
96
|
+
glShadeModel(GL_FLAT)
|
97
|
+
makeRasterFont()
|
98
|
+
end
|
99
|
+
|
100
|
+
def printString(s)
|
101
|
+
glPushAttrib(GL_LIST_BIT)
|
102
|
+
glListBase($fontOffset)
|
103
|
+
glCallLists(GL_BYTE,s)
|
104
|
+
glPopAttrib()
|
105
|
+
end
|
106
|
+
|
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
|
110
|
+
# calls to printString().
|
111
|
+
display = proc do
|
112
|
+
white = [ 1.0, 1.0, 1.0 ]
|
113
|
+
|
114
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
115
|
+
glColor(white)
|
116
|
+
|
117
|
+
glRasterPos(20, 60)
|
118
|
+
printString("THE QUICK BROWN FOX JUMPS")
|
119
|
+
glRasterPos(20, 40)
|
120
|
+
printString("OVER A LAZY DOG")
|
121
|
+
glutSwapBuffers()
|
122
|
+
end
|
123
|
+
|
124
|
+
reshape = proc do |w, h|
|
125
|
+
glViewport(0, 0, w, h)
|
126
|
+
glMatrixMode(GL_PROJECTION)
|
127
|
+
glLoadIdentity()
|
128
|
+
glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
|
129
|
+
glMatrixMode(GL_MODELVIEW)
|
130
|
+
end
|
131
|
+
|
132
|
+
keyboard = proc do |key, x, y|
|
133
|
+
case (key)
|
134
|
+
when ?\e
|
135
|
+
exit(0)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Main Loop
|
140
|
+
# Open window with initial window size, title bar,
|
141
|
+
# RGBA display mode, and handle input events.
|
142
|
+
glutInit()
|
143
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
144
|
+
glutInitWindowSize(400, 100)
|
145
|
+
glutInitWindowPosition(100, 100)
|
146
|
+
glutCreateWindow()
|
147
|
+
init()
|
148
|
+
glutReshapeFunc(reshape)
|
149
|
+
glutKeyboardFunc(keyboard)
|
150
|
+
glutDisplayFunc(display)
|
151
|
+
glutMainLoop()
|
@@ -0,0 +1,79 @@
|
|
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
|
+
# hello.c
|
38
|
+
# This is a simple, introductory OpenGL program.
|
39
|
+
require 'opengl'
|
40
|
+
include Gl,Glu,Glut
|
41
|
+
|
42
|
+
display = Proc.new do
|
43
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
44
|
+
|
45
|
+
glColor(1.0, 1.0, 1.0)
|
46
|
+
glBegin(GL_POLYGON)
|
47
|
+
glVertex(0.25, 0.25, 0.0)
|
48
|
+
glVertex(0.75, 0.25, 0.0)
|
49
|
+
glVertex(0.75, 0.75, 0.0)
|
50
|
+
glVertex(0.25, 0.75, 0.0)
|
51
|
+
glEnd()
|
52
|
+
|
53
|
+
glutSwapBuffers()
|
54
|
+
end
|
55
|
+
|
56
|
+
def init
|
57
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
58
|
+
|
59
|
+
glMatrixMode(GL_PROJECTION)
|
60
|
+
glLoadIdentity()
|
61
|
+
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0)
|
62
|
+
end
|
63
|
+
|
64
|
+
keyboard = Proc.new do |key, x, y|
|
65
|
+
case (key)
|
66
|
+
when ?\e
|
67
|
+
exit(0);
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
glutInit
|
72
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
73
|
+
glutInitWindowSize(500, 500)
|
74
|
+
glutInitWindowPosition(100, 100)
|
75
|
+
glutCreateWindow("hello")
|
76
|
+
init()
|
77
|
+
glutDisplayFunc(display)
|
78
|
+
glutKeyboardFunc(keyboard)
|
79
|
+
glutMainLoop()
|
@@ -0,0 +1,137 @@
|
|
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
|
+
# image.c
|
38
|
+
# This program demonstrates drawing pixels and shows the effect
|
39
|
+
# of glDrawPixels(), glCopyPixels(), and glPixelZoom().
|
40
|
+
# Interaction: moving the mouse while pressing the mouse button
|
41
|
+
# will copy the image in the lower-left corner of the window
|
42
|
+
# to the mouse position, using the current pixel zoom factors.
|
43
|
+
# There is no attempt to prevent you from drawing over the original
|
44
|
+
# image. If you press the 'r' key, the original image and zoom
|
45
|
+
# factors are reset. If you press the 'z' or 'Z' keys, you change
|
46
|
+
# the zoom factors.
|
47
|
+
require 'opengl'
|
48
|
+
require 'mathn'
|
49
|
+
include Gl,Glu,Glut
|
50
|
+
|
51
|
+
# Create checkerboard image
|
52
|
+
CheckImageWidth=64
|
53
|
+
CheckImageHeight=64
|
54
|
+
$checkImage=[]
|
55
|
+
|
56
|
+
$zoomFactor = 1.0
|
57
|
+
$height = 0.0
|
58
|
+
|
59
|
+
def makeCheckImage
|
60
|
+
for i in 0..CheckImageWidth-1
|
61
|
+
for j in 0..CheckImageHeight-1
|
62
|
+
c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
|
63
|
+
$checkImage[(i+CheckImageWidth*j)*3+0] = c
|
64
|
+
$checkImage[(i+CheckImageWidth*j)*3+1] = c
|
65
|
+
$checkImage[(i+CheckImageWidth*j)*3+2] = c
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def init
|
71
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
72
|
+
glShadeModel(GL_FLAT)
|
73
|
+
makeCheckImage()
|
74
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
75
|
+
end
|
76
|
+
|
77
|
+
display = Proc.new do
|
78
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
79
|
+
glRasterPos(0, 0)
|
80
|
+
glDrawPixels(CheckImageWidth, CheckImageHeight, GL_RGB, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
|
81
|
+
glFlush()
|
82
|
+
end
|
83
|
+
|
84
|
+
reshape = Proc.new do |w, h|
|
85
|
+
glViewport(0, 0, w, h)
|
86
|
+
$height = h
|
87
|
+
glMatrixMode(GL_PROJECTION)
|
88
|
+
glLoadIdentity()
|
89
|
+
gluOrtho2D(0.0, w, 0.0, h)
|
90
|
+
glMatrixMode(GL_MODELVIEW)
|
91
|
+
glLoadIdentity()
|
92
|
+
end
|
93
|
+
|
94
|
+
$screeny = 0.0
|
95
|
+
motion = Proc.new do |x, y|
|
96
|
+
$screeny = $height - y
|
97
|
+
glRasterPos(x, $screeny)
|
98
|
+
glPixelZoom($zoomFactor, $zoomFactor)
|
99
|
+
glCopyPixels(0, 0, CheckImageWidth, CheckImageHeight, GL_COLOR)
|
100
|
+
glPixelZoom(1.0, 1.0)
|
101
|
+
glFlush()
|
102
|
+
end
|
103
|
+
|
104
|
+
keyboard = Proc.new do |key, x, y|
|
105
|
+
case (key)
|
106
|
+
when ?r,?R
|
107
|
+
$zoomFactor = 1.0
|
108
|
+
glutPostRedisplay()
|
109
|
+
printf("zoomFactor reset to 1.0\n")
|
110
|
+
when ?z
|
111
|
+
$zoomFactor = $zoomFactor + 0.5
|
112
|
+
if ($zoomFactor >= 3.0)
|
113
|
+
$zoomFactor = 3.0
|
114
|
+
end
|
115
|
+
printf("zoomFactor is now %4.1f\n", $zoomFactor)
|
116
|
+
when ?Z
|
117
|
+
$zoomFactor = $zoomFactor - 0.5
|
118
|
+
if ($zoomFactor <= 0.5)
|
119
|
+
$zoomFactor = 0.5
|
120
|
+
end
|
121
|
+
printf("zoomFactor is now %4.1f\n", $zoomFactor)
|
122
|
+
when ?\e
|
123
|
+
exit(0)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
glutInit
|
128
|
+
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
|
129
|
+
glutInitWindowSize(250, 250)
|
130
|
+
glutInitWindowPosition(100, 100)
|
131
|
+
glutCreateWindow($0)
|
132
|
+
init()
|
133
|
+
glutDisplayFunc(display)
|
134
|
+
glutReshapeFunc(reshape)
|
135
|
+
glutKeyboardFunc(keyboard)
|
136
|
+
glutMotionFunc(motion)
|
137
|
+
glutMainLoop()
|