opengl 0.9.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/.autotest +29 -0
- data/.gemtest +0 -0
- data/.gitignore +6 -0
- data/.travis.yml +19 -0
- data/History.rdoc +77 -0
- data/MIT-LICENSE +18 -0
- data/Manifest.txt +138 -0
- data/README.rdoc +102 -0
- data/Rakefile +60 -0
- data/examples/NeHe/NeHe.png +0 -0
- data/examples/NeHe/crate.png +0 -0
- data/examples/NeHe/glass.png +0 -0
- data/examples/NeHe/nehe_lesson02.rb +117 -0
- data/examples/NeHe/nehe_lesson03.rb +123 -0
- data/examples/NeHe/nehe_lesson04.rb +132 -0
- data/examples/NeHe/nehe_lesson05.rb +182 -0
- data/examples/NeHe/nehe_lesson06.rb +186 -0
- data/examples/NeHe/nehe_lesson07.rb +240 -0
- data/examples/NeHe/nehe_lesson08.rb +255 -0
- data/examples/NeHe/nehe_lesson09.rb +203 -0
- data/examples/NeHe/nehe_lesson11.rb +176 -0
- data/examples/NeHe/nehe_lesson12.rb +203 -0
- data/examples/NeHe/nehe_lesson16.rb +211 -0
- data/examples/NeHe/nehe_lesson19.rb +209 -0
- data/examples/NeHe/nehe_lesson36.rb +308 -0
- data/examples/NeHe/particle.png +0 -0
- data/examples/NeHe/star.png +0 -0
- data/examples/NeHe/tim.png +0 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +378 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +408 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +16 -0
- data/examples/RedBook/aapoly.rb +143 -0
- data/examples/RedBook/aargb.rb +121 -0
- data/examples/RedBook/accanti.rb +164 -0
- data/examples/RedBook/accpersp.rb +217 -0
- data/examples/RedBook/alpha.rb +125 -0
- data/examples/RedBook/alpha3D.rb +160 -0
- data/examples/RedBook/bezcurve.rb +107 -0
- data/examples/RedBook/bezmesh.rb +139 -0
- data/examples/RedBook/checker.rb +126 -0
- data/examples/RedBook/clip.rb +97 -0
- data/examples/RedBook/colormat.rb +137 -0
- data/examples/RedBook/cube.rb +71 -0
- data/examples/RedBook/depthcue.rb +101 -0
- data/examples/RedBook/dof.rb +206 -0
- data/examples/RedBook/double.rb +107 -0
- data/examples/RedBook/drawf.rb +93 -0
- data/examples/RedBook/feedback.rb +147 -0
- data/examples/RedBook/fog.rb +168 -0
- data/examples/RedBook/font.rb +153 -0
- data/examples/RedBook/hello.rb +81 -0
- data/examples/RedBook/image.rb +139 -0
- data/examples/RedBook/jitter.rb +207 -0
- data/examples/RedBook/light.rb +155 -0
- data/examples/RedBook/lines.rb +130 -0
- data/examples/RedBook/list.rb +113 -0
- data/examples/RedBook/material.rb +276 -0
- data/examples/RedBook/mipmap.rb +158 -0
- data/examples/RedBook/model.rb +115 -0
- data/examples/RedBook/movelight.rb +134 -0
- data/examples/RedBook/pickdepth.rb +181 -0
- data/examples/RedBook/planet.rb +110 -0
- data/examples/RedBook/quadric.rb +160 -0
- data/examples/RedBook/robot.rb +117 -0
- data/examples/RedBook/select.rb +198 -0
- data/examples/RedBook/smooth.rb +97 -0
- data/examples/RedBook/stencil.rb +165 -0
- data/examples/RedBook/stroke.rb +169 -0
- data/examples/RedBook/surface.rb +168 -0
- data/examples/RedBook/teaambient.rb +134 -0
- data/examples/RedBook/teapots.rb +184 -0
- data/examples/RedBook/tess.rb +185 -0
- data/examples/RedBook/texbind.rb +149 -0
- data/examples/RedBook/texgen.rb +171 -0
- data/examples/RedBook/texturesurf.rb +130 -0
- data/examples/RedBook/varray.rb +161 -0
- data/examples/RedBook/wrap.rb +150 -0
- data/examples/misc/OGLBench.rb +338 -0
- data/examples/misc/anisotropic.rb +196 -0
- data/examples/misc/fbo_test.rb +357 -0
- data/examples/misc/font-glut.rb +47 -0
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/plane.rb +161 -0
- data/examples/misc/readpixel.rb +66 -0
- data/examples/misc/sdltest.rb +36 -0
- data/examples/misc/trislam.rb +829 -0
- data/ext/opengl/common.h +428 -0
- data/ext/opengl/conv.h +244 -0
- data/ext/opengl/extconf.rb +47 -0
- data/ext/opengl/funcdef.h +313 -0
- data/ext/opengl/gl-1.0-1.1.c +3075 -0
- data/ext/opengl/gl-1.2.c +155 -0
- data/ext/opengl/gl-1.3.c +443 -0
- data/ext/opengl/gl-1.4.c +348 -0
- data/ext/opengl/gl-1.5.c +224 -0
- data/ext/opengl/gl-2.0.c +667 -0
- data/ext/opengl/gl-2.1.c +57 -0
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +4873 -0
- data/ext/opengl/gl-enums.h +14588 -0
- data/ext/opengl/gl-error.c +112 -0
- data/ext/opengl/gl-error.h +28 -0
- data/ext/opengl/gl-ext-3dfx.c +27 -0
- data/ext/opengl/gl-ext-arb.c +875 -0
- data/ext/opengl/gl-ext-ati.c +41 -0
- data/ext/opengl/gl-ext-ext.c +889 -0
- data/ext/opengl/gl-ext-gremedy.c +41 -0
- data/ext/opengl/gl-ext-nv.c +680 -0
- data/ext/opengl/gl-types.h +67 -0
- data/ext/opengl/gl.c +220 -0
- data/ext/opengl/gl_buffer.c +177 -0
- data/ext/opengl/opengl.c +7 -0
- data/lib/gl.rb +1 -0
- data/lib/opengl.rb +53 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +86 -0
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +38 -0
- data/test/test_gl_10_11.rb +1363 -0
- data/test/test_gl_12.rb +71 -0
- data/test/test_gl_13.rb +221 -0
- data/test/test_gl_14.rb +218 -0
- data/test/test_gl_15.rb +258 -0
- data/test/test_gl_20.rb +417 -0
- data/test/test_gl_21.rb +436 -0
- data/test/test_gl_ext_arb.rb +508 -0
- data/test/test_gl_ext_ati.rb +28 -0
- data/test/test_gl_ext_ext.rb +608 -0
- data/test/test_gl_ext_gremedy.rb +29 -0
- data/test/test_gl_ext_nv.rb +349 -0
- data/test/test_opengl_buffer.rb +120 -0
- data/utils/README +6 -0
- data/utils/enumgen.rb +108 -0
- data/utils/extlistgen.rb +90 -0
- metadata +319 -0
- metadata.gz.sig +1 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
3
|
+
# ALL RIGHTS RESERVED
|
4
|
+
# Permission to use, copy, modify, and distribute this software for
|
5
|
+
# any purpose and without fee is hereby granted, provided that the above
|
6
|
+
# copyright notice appear in all copies and that both the copyright notice
|
7
|
+
# and this permission notice appear in supporting documentation, and that
|
8
|
+
# the name of Silicon Graphics, Inc. not be used in advertising
|
9
|
+
# or publicity pertaining to distribution of the software without specific,
|
10
|
+
# written prior permission.
|
11
|
+
#
|
12
|
+
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
13
|
+
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
14
|
+
# INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
16
|
+
# GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
17
|
+
# SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
18
|
+
# KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
19
|
+
# LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
20
|
+
# THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
21
|
+
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
22
|
+
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
23
|
+
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
+
#
|
25
|
+
# US Government Users Restricted Rights
|
26
|
+
# Use, duplication, or disclosure by the Government is subject to
|
27
|
+
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
28
|
+
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
29
|
+
# clause at DFARS 252.227-7013 and/or in similar or successor
|
30
|
+
# clauses in the FAR or the DOD or NASA FAR Supplement.
|
31
|
+
# Unpublished-- rights reserved under the copyright laws of the
|
32
|
+
# United States. Contractor/manufacturer is Silicon Graphics,
|
33
|
+
# Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
34
|
+
#
|
35
|
+
# OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
|
36
|
+
#
|
37
|
+
# double.c
|
38
|
+
# This is a simple double buffered program.
|
39
|
+
# Pressing the left mouse button rotates the rectangle.
|
40
|
+
# Pressing the middle mouse button stops the rotation.
|
41
|
+
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
44
|
+
require 'rational'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
$spin = 0.0
|
48
|
+
|
49
|
+
display = Proc.new do
|
50
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
51
|
+
glPushMatrix()
|
52
|
+
glRotate($spin, 0.0, 0.0, 1.0)
|
53
|
+
glColor(1.0, 1.0, 1.0)
|
54
|
+
glRect(-25.0, -25.0, 25.0, 25.0)
|
55
|
+
glPopMatrix()
|
56
|
+
glutSwapBuffers()
|
57
|
+
end
|
58
|
+
|
59
|
+
$spinDisplay = Proc.new do
|
60
|
+
$spin = $spin + 4.0
|
61
|
+
$spin = $spin - 360.0 if ($spin > 360.0)
|
62
|
+
glutPostRedisplay()
|
63
|
+
end
|
64
|
+
|
65
|
+
def init
|
66
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
67
|
+
glShadeModel(GL_FLAT)
|
68
|
+
end
|
69
|
+
|
70
|
+
reshape = Proc.new do |w, h|
|
71
|
+
glViewport(0, 0, w, h)
|
72
|
+
glMatrixMode(GL_PROJECTION)
|
73
|
+
glLoadIdentity()
|
74
|
+
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0)
|
75
|
+
glMatrixMode(GL_MODELVIEW)
|
76
|
+
glLoadIdentity()
|
77
|
+
end
|
78
|
+
|
79
|
+
mouse = Proc.new do |button, state, x, y|
|
80
|
+
case button
|
81
|
+
when GLUT_LEFT_BUTTON
|
82
|
+
glutIdleFunc($spinDisplay) if (state == GLUT_DOWN)
|
83
|
+
when GLUT_MIDDLE_BUTTON
|
84
|
+
glutIdleFunc(nil) if (state == GLUT_DOWN)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
keyboard = Proc.new do |key, x, y|
|
89
|
+
case (key)
|
90
|
+
when ?\e
|
91
|
+
exit(0)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Request double buffer display mode.
|
96
|
+
# Register mouse input callback functions
|
97
|
+
glutInit
|
98
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
99
|
+
glutInitWindowSize(500, 500)
|
100
|
+
glutInitWindowPosition(100, 100)
|
101
|
+
glutCreateWindow($0)
|
102
|
+
init()
|
103
|
+
glutDisplayFunc(display)
|
104
|
+
glutReshapeFunc(reshape)
|
105
|
+
glutKeyboardFunc(keyboard)
|
106
|
+
glutMouseFunc(mouse)
|
107
|
+
glutMainLoop()
|
@@ -0,0 +1,93 @@
|
|
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
|
+
# drawf.c
|
38
|
+
# Draws the bitmapped letter F on the screen (several times).
|
39
|
+
# This demonstrates use of the glBitmap() call.
|
40
|
+
require 'opengl'
|
41
|
+
require 'glu'
|
42
|
+
require 'glut'
|
43
|
+
include Gl,Glu,Glut
|
44
|
+
|
45
|
+
$rasters = [
|
46
|
+
0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,
|
47
|
+
0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,
|
48
|
+
0xff, 0xc0, 0xff, 0xc0
|
49
|
+
].pack("C*")
|
50
|
+
|
51
|
+
def init
|
52
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
53
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
54
|
+
end
|
55
|
+
|
56
|
+
display = Proc.new do
|
57
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
58
|
+
glColor(1.0, 1.0, 1.0)
|
59
|
+
glRasterPos2i(20, 20)
|
60
|
+
glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, $rasters)
|
61
|
+
glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, $rasters)
|
62
|
+
glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, $rasters)
|
63
|
+
glutSwapBuffers()
|
64
|
+
end
|
65
|
+
|
66
|
+
reshape = Proc.new do |w, h|
|
67
|
+
glViewport(0, 0, w, h)
|
68
|
+
glMatrixMode(GL_PROJECTION)
|
69
|
+
glLoadIdentity()
|
70
|
+
glOrtho(0, w, 0, h, -1.0, 1.0)
|
71
|
+
glMatrixMode(GL_MODELVIEW)
|
72
|
+
end
|
73
|
+
|
74
|
+
keyboard = Proc.new do |key, x, y|
|
75
|
+
case (key)
|
76
|
+
when ?\e
|
77
|
+
exit(0)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Main Loop
|
82
|
+
# Open window with initial window size, title bar,
|
83
|
+
# RGBA display mode, and handle input events.
|
84
|
+
glutInit
|
85
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
86
|
+
glutInitWindowSize(100, 100)
|
87
|
+
glutInitWindowPosition(100, 100)
|
88
|
+
glutCreateWindow($0)
|
89
|
+
init()
|
90
|
+
glutReshapeFunc(reshape)
|
91
|
+
glutKeyboardFunc(keyboard)
|
92
|
+
glutDisplayFunc(display)
|
93
|
+
glutMainLoop()
|
@@ -0,0 +1,147 @@
|
|
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
|
+
# feedback.c
|
38
|
+
# This program demonstrates use of OpenGL feedback. First,
|
39
|
+
# a lighting environment is set up and a few lines are drawn.
|
40
|
+
# Then feedback mode is entered, and the same lines are
|
41
|
+
# drawn. The results in the feedback buffer are printed.
|
42
|
+
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
# Initialize lighting.
|
48
|
+
def init
|
49
|
+
glEnable(GL_LIGHTING)
|
50
|
+
glEnable(GL_LIGHT0)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Draw a few lines and two points, one of which will
|
54
|
+
# be clipped. If in feedback mode, a passthrough token
|
55
|
+
# is issued between the each primitive.
|
56
|
+
def drawGeometry(mode)
|
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()
|
76
|
+
end
|
77
|
+
|
78
|
+
# Write contents of one vertex to stdout.
|
79
|
+
def print3DcolorVertex(size, count, buffer)
|
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
|
87
|
+
end
|
88
|
+
|
89
|
+
# Write contents of entire buffer. (Parse tokens!)
|
90
|
+
def printBuffer(size, buffer)
|
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
|
112
|
+
end
|
113
|
+
|
114
|
+
display = proc do
|
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()
|
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
|
+
glutInit()
|
140
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
141
|
+
glutInitWindowSize(100, 100)
|
142
|
+
glutInitWindowPosition(100, 100)
|
143
|
+
glutCreateWindow()
|
144
|
+
init()
|
145
|
+
glutDisplayFunc(display)
|
146
|
+
glutKeyboardFunc(keyboard)
|
147
|
+
glutMainLoop()
|
@@ -0,0 +1,168 @@
|
|
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 'glu'
|
48
|
+
require 'glut'
|
49
|
+
require 'mathn'
|
50
|
+
include Gl,Glu,Glut
|
51
|
+
|
52
|
+
$fogMode = 0
|
53
|
+
|
54
|
+
selectFog = Proc.new do |mode|
|
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)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Initialize z-buffer, projection matrix, light source,
|
70
|
+
# and lighting model. Do not specify a material property here.
|
71
|
+
def myinit
|
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)
|
95
|
+
end
|
96
|
+
|
97
|
+
def renderRedTeapot(x, y, z)
|
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()
|
117
|
+
end
|
118
|
+
|
119
|
+
# display() draws 5 teapots at different z positions.
|
120
|
+
display = Proc.new do
|
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()
|
128
|
+
end
|
129
|
+
|
130
|
+
myReshape = Proc.new do |w, h|
|
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()
|
141
|
+
end
|
142
|
+
|
143
|
+
keyboard = Proc.new do |key, x, y|
|
144
|
+
case (key)
|
145
|
+
when ?\e
|
146
|
+
exit(0)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Main Loop
|
151
|
+
# Open window with initial window size, title bar,
|
152
|
+
# RGBA display mode, depth buffer, and handle input events.
|
153
|
+
glutInit
|
154
|
+
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
|
155
|
+
glutInitWindowSize(800, 300)
|
156
|
+
glutInitWindowPosition(100, 100)
|
157
|
+
glutCreateWindow($0)
|
158
|
+
myinit()
|
159
|
+
glutReshapeFunc(myReshape)
|
160
|
+
glutDisplayFunc(display)
|
161
|
+
glutKeyboardFunc(keyboard)
|
162
|
+
glutCreateMenu(selectFog)
|
163
|
+
glutAddMenuEntry("Fog EXP", GL_EXP)
|
164
|
+
glutAddMenuEntry("Fog EXP2", GL_EXP2)
|
165
|
+
glutAddMenuEntry("Fog LINEAR", GL_LINEAR)
|
166
|
+
glutAddMenuEntry("Quit", 0)
|
167
|
+
glutAttachMenu(GLUT_RIGHT_BUTTON)
|
168
|
+
glutMainLoop()
|