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,38 @@
|
|
1
|
+
//
|
2
|
+
// Vertex shader for rendering a "confetti cannon"
|
3
|
+
// via a partcle system
|
4
|
+
//
|
5
|
+
// Author: Randi Rost
|
6
|
+
//
|
7
|
+
// Copyright (c) 2003-2004: 3Dlabs, Inc.
|
8
|
+
//
|
9
|
+
// See 3Dlabs-License.txt for license information
|
10
|
+
//
|
11
|
+
|
12
|
+
uniform float Time; // updated each frame by the application
|
13
|
+
uniform vec4 Background; // constant color equal to background
|
14
|
+
|
15
|
+
attribute vec3 Velocity; // initial velocity
|
16
|
+
attribute float StartTime; // time at which particle is activated
|
17
|
+
|
18
|
+
varying vec4 Color;
|
19
|
+
|
20
|
+
void main(void)
|
21
|
+
{
|
22
|
+
vec4 vert;
|
23
|
+
float t = Time - StartTime;
|
24
|
+
|
25
|
+
if (t >= 0.0)
|
26
|
+
{
|
27
|
+
vert = gl_Vertex + vec4 (Velocity * t, 0.0);
|
28
|
+
vert.y -= 4.9 * t * t;
|
29
|
+
Color = gl_Color;
|
30
|
+
}
|
31
|
+
else
|
32
|
+
{
|
33
|
+
vert = gl_Vertex; // Initial position
|
34
|
+
Color = Background; // "pre-birth" color
|
35
|
+
}
|
36
|
+
|
37
|
+
gl_Position = gl_ModelViewProjectionMatrix * vert;
|
38
|
+
}
|
data/examples/README
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Examples
|
2
|
+
========
|
3
|
+
|
4
|
+
This directory contains OpenGL examples converted to ruby from various sources.
|
5
|
+
As such, they are distributed under various terms - see each file for licensing info.
|
6
|
+
|
7
|
+
RedBook/
|
8
|
+
Examples from OpenGL Red Book and SGI's example code in general, licensed under
|
9
|
+
SGI open-source license.
|
10
|
+
OrangeBook/
|
11
|
+
Examples from OpenGL Orange Book (GLSL), distributed under BSD license
|
12
|
+
NeHe/
|
13
|
+
NeHe's opengl tutorials (http://nehe.gamedev.net), licensed under free license.
|
14
|
+
Misc/
|
15
|
+
Other examples. If license is not given, MIT is assumed.
|
16
|
+
|
@@ -0,0 +1,143 @@
|
|
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
|
+
# aapoly.c
|
38
|
+
# This program draws filled polygons with antialiased
|
39
|
+
# edges. The special GL_SRC_ALPHA_SATURATE blending
|
40
|
+
# function is used.
|
41
|
+
# Pressing the 't' key turns the antialiasing on and off.
|
42
|
+
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
$polySmooth = true
|
48
|
+
|
49
|
+
def init
|
50
|
+
glCullFace(GL_BACK)
|
51
|
+
glEnable(GL_CULL_FACE)
|
52
|
+
glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE)
|
53
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
54
|
+
end
|
55
|
+
|
56
|
+
NFACE=6
|
57
|
+
NVERT=8
|
58
|
+
$indices = [
|
59
|
+
[4, 5, 6, 7], [2, 3, 7, 6], [0, 4, 7, 3],
|
60
|
+
[0, 1, 5, 4], [1, 5, 6, 2], [0, 3, 2, 1]
|
61
|
+
]
|
62
|
+
|
63
|
+
def drawCube(x0, x1, y0, y1, z0, z1)
|
64
|
+
v = [[],[],[],[],[],[],[],[]]
|
65
|
+
c = [
|
66
|
+
[0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0],
|
67
|
+
[0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 0.0, 1.0],
|
68
|
+
[0.0, 0.0, 1.0, 1.0], [1.0, 0.0, 1.0, 1.0],
|
69
|
+
[0.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]
|
70
|
+
]
|
71
|
+
|
72
|
+
# indices of front, top, left, bottom, right, back faces
|
73
|
+
|
74
|
+
v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0
|
75
|
+
v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1
|
76
|
+
v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0
|
77
|
+
v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1
|
78
|
+
v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0
|
79
|
+
v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1
|
80
|
+
|
81
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
82
|
+
glEnableClientState(GL_COLOR_ARRAY)
|
83
|
+
glVertexPointer(3, GL_FLOAT, 0, v.flatten!.pack("f*"))
|
84
|
+
glColorPointer(4, GL_FLOAT, 0, c.flatten!.pack("f*"))
|
85
|
+
glDrawElements(GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, $indices.flatten.pack("C*"))
|
86
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
87
|
+
glDisableClientState(GL_COLOR_ARRAY)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Note: polygons must be drawn from front to back
|
91
|
+
# for proper blending.
|
92
|
+
display = proc do
|
93
|
+
if ($polySmooth)
|
94
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
95
|
+
glEnable(GL_BLEND)
|
96
|
+
glEnable(GL_POLYGON_SMOOTH)
|
97
|
+
glDisable(GL_DEPTH_TEST)
|
98
|
+
else
|
99
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
100
|
+
glDisable(GL_BLEND)
|
101
|
+
glDisable(GL_POLYGON_SMOOTH)
|
102
|
+
glEnable(GL_DEPTH_TEST)
|
103
|
+
end
|
104
|
+
|
105
|
+
glPushMatrix()
|
106
|
+
glTranslate(0.0, 0.0, -8.0)
|
107
|
+
glRotate(30.0, 1.0, 0.0, 0.0)
|
108
|
+
glRotate(60.0, 0.0, 1.0, 0.0)
|
109
|
+
drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
|
110
|
+
glPopMatrix()
|
111
|
+
glutSwapBuffers()
|
112
|
+
end
|
113
|
+
|
114
|
+
reshape = proc do |w, h|
|
115
|
+
glViewport(0, 0, w, h)
|
116
|
+
glMatrixMode(GL_PROJECTION)
|
117
|
+
glLoadIdentity()
|
118
|
+
gluPerspective(30.0, w.to_f/ h.to_f, 1.0, 20.0)
|
119
|
+
glMatrixMode(GL_MODELVIEW)
|
120
|
+
glLoadIdentity()
|
121
|
+
end
|
122
|
+
|
123
|
+
keyboard = proc do |key, x, y|
|
124
|
+
case (key)
|
125
|
+
when ?t ,?T
|
126
|
+
$polySmooth = !$polySmooth
|
127
|
+
glutPostRedisplay()
|
128
|
+
when ?\e
|
129
|
+
exit(0) # Escape key
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Main Loop
|
134
|
+
glutInit
|
135
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH)
|
136
|
+
glutInitWindowSize(500, 500)
|
137
|
+
glutInitWindowPosition(100, 100)
|
138
|
+
glutCreateWindow($0)
|
139
|
+
init()
|
140
|
+
glutReshapeFunc(reshape)
|
141
|
+
glutKeyboardFunc(keyboard)
|
142
|
+
glutDisplayFunc(display)
|
143
|
+
glutMainLoop()
|
@@ -0,0 +1,121 @@
|
|
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
|
+
# aargb.c
|
38
|
+
# This program draws shows how to draw anti-aliased lines. It draws
|
39
|
+
# two diagonal lines to form an X when 'r' is typed in the window,
|
40
|
+
# the lines are rotated in opposite directions.
|
41
|
+
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
44
|
+
require 'mathn'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
$rotAngle = 0.0
|
48
|
+
|
49
|
+
# Initialize antialiasing for RGBA mode, including alpha
|
50
|
+
# blending, hint, and line width. Print out implementation
|
51
|
+
# specific info on line width granularity and width.
|
52
|
+
def init
|
53
|
+
glEnable(GL_LINE_SMOOTH)
|
54
|
+
glEnable(GL_BLEND)
|
55
|
+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
56
|
+
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE)
|
57
|
+
glLineWidth(1.5)
|
58
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Draw 2 diagonal lines to form an X
|
62
|
+
display = Proc.new do
|
63
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
64
|
+
|
65
|
+
glColor(0.0, 1.0, 0.0)
|
66
|
+
glPushMatrix()
|
67
|
+
glRotate(-$rotAngle, 0.0, 0.0, 0.1)
|
68
|
+
glBegin(GL_LINES)
|
69
|
+
glVertex(-0.5, 0.5)
|
70
|
+
glVertex(0.5, -0.5)
|
71
|
+
glEnd()
|
72
|
+
glPopMatrix()
|
73
|
+
|
74
|
+
glColor(0.0, 0.0, 1.0)
|
75
|
+
glPushMatrix()
|
76
|
+
glRotate($rotAngle, 0.0, 0.0, 0.1)
|
77
|
+
glBegin(GL_LINES)
|
78
|
+
glVertex(0.5, 0.5)
|
79
|
+
glVertex(-0.5, -0.5)
|
80
|
+
glEnd()
|
81
|
+
glPopMatrix()
|
82
|
+
glutSwapBuffers()
|
83
|
+
end
|
84
|
+
|
85
|
+
reshape = Proc.new do |w, h|
|
86
|
+
glViewport(0, 0, w, h)
|
87
|
+
glMatrixMode(GL_PROJECTION)
|
88
|
+
glLoadIdentity()
|
89
|
+
if (w <= h)
|
90
|
+
gluOrtho2D(-1.0, 1.0, -1.0*h/w, 1.0*h/w)
|
91
|
+
else
|
92
|
+
gluOrtho2D(-1.0*w/h, 1.0*w/h, -1.0, 1.0)
|
93
|
+
end
|
94
|
+
glMatrixMode(GL_MODELVIEW)
|
95
|
+
glLoadIdentity()
|
96
|
+
end
|
97
|
+
|
98
|
+
keyboard = Proc.new do |key, x, y|
|
99
|
+
case (key)
|
100
|
+
when ?r,?R
|
101
|
+
$rotAngle = $rotAngle + 20.0
|
102
|
+
$rotAngle = 0.0 if ($rotAngle >= 360.0)
|
103
|
+
glutPostRedisplay()
|
104
|
+
when ?\e # Escape Key
|
105
|
+
exit(0)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Main Loop
|
110
|
+
# Open window with initial window size, title bar,
|
111
|
+
# RGBA display mode, and handle input events.
|
112
|
+
glutInit
|
113
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
114
|
+
glutInitWindowSize(500, 500)
|
115
|
+
glutInitWindowPosition(100, 100)
|
116
|
+
glutCreateWindow($0)
|
117
|
+
init()
|
118
|
+
glutReshapeFunc(reshape)
|
119
|
+
glutKeyboardFunc(keyboard)
|
120
|
+
glutDisplayFunc(display)
|
121
|
+
glutMainLoop()
|
@@ -0,0 +1,164 @@
|
|
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
|
+
# accanti.c
|
40
|
+
|
41
|
+
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
44
|
+
require_relative 'jitter'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
# Initialize lighting and other values.
|
48
|
+
def myinit
|
49
|
+
mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ]
|
50
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
51
|
+
light_position = [ 0.0, 0.0, 10.0, 1.0 ]
|
52
|
+
lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
|
53
|
+
|
54
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
55
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
56
|
+
glMaterial(GL_FRONT, GL_SHININESS, 50.0)
|
57
|
+
glLight(GL_LIGHT0, GL_POSITION, light_position)
|
58
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, lm_ambient)
|
59
|
+
|
60
|
+
glEnable(GL_LIGHTING)
|
61
|
+
glEnable(GL_LIGHT0)
|
62
|
+
glDepthFunc(GL_LESS)
|
63
|
+
glEnable(GL_DEPTH_TEST)
|
64
|
+
glShadeModel(GL_FLAT)
|
65
|
+
|
66
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
67
|
+
glClearAccum(0.0, 0.0, 0.0, 0.0)
|
68
|
+
end
|
69
|
+
|
70
|
+
def displayObjects
|
71
|
+
torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
|
72
|
+
cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ]
|
73
|
+
sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ]
|
74
|
+
octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ]
|
75
|
+
|
76
|
+
glPushMatrix()
|
77
|
+
glRotate(30.0, 1.0, 0.0, 0.0)
|
78
|
+
|
79
|
+
glPushMatrix()
|
80
|
+
glTranslate(-0.80, 0.35, 0.0)
|
81
|
+
glRotate(100.0, 1.0, 0.0, 0.0)
|
82
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, torus_diffuse)
|
83
|
+
glutSolidTorus(0.275, 0.85, 16, 16)
|
84
|
+
glPopMatrix()
|
85
|
+
|
86
|
+
glPushMatrix()
|
87
|
+
glTranslate(-0.75, -0.50, 0.0)
|
88
|
+
glRotate(45.0, 0.0, 0.0, 1.0)
|
89
|
+
glRotate(45.0, 1.0, 0.0, 0.0)
|
90
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, cube_diffuse)
|
91
|
+
glutSolidCube(1.5)
|
92
|
+
glPopMatrix()
|
93
|
+
|
94
|
+
glPushMatrix()
|
95
|
+
glTranslate(0.75, 0.60, 0.0)
|
96
|
+
glRotate(30.0, 1.0, 0.0, 0.0)
|
97
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, sphere_diffuse)
|
98
|
+
glutSolidSphere(1.0, 16, 16)
|
99
|
+
glPopMatrix()
|
100
|
+
|
101
|
+
glPushMatrix()
|
102
|
+
glTranslate(0.70, -0.90, 0.25)
|
103
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, octa_diffuse)
|
104
|
+
glutSolidOctahedron()
|
105
|
+
glPopMatrix()
|
106
|
+
|
107
|
+
glPopMatrix()
|
108
|
+
end
|
109
|
+
|
110
|
+
ACSIZE=8
|
111
|
+
|
112
|
+
myDisplay = proc do
|
113
|
+
viewport = glGetDoublev(GL_VIEWPORT)
|
114
|
+
|
115
|
+
glClear(GL_ACCUM_BUFFER_BIT)
|
116
|
+
for jitter in 0...ACSIZE
|
117
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
118
|
+
glPushMatrix()
|
119
|
+
# Note that 4.5 is the distance in world space between
|
120
|
+
# left and right and bottom and top.
|
121
|
+
# This formula converts fractional pixel movement to
|
122
|
+
# world coordinates.
|
123
|
+
glTranslate($j8[jitter][0]*4.5/viewport[2], $j8[jitter][1]*4.5/viewport[3], 0.0)
|
124
|
+
displayObjects()
|
125
|
+
glPopMatrix()
|
126
|
+
glAccum(GL_ACCUM, 1.0/ACSIZE)
|
127
|
+
end
|
128
|
+
glAccum(GL_RETURN, 1.0)
|
129
|
+
glutSwapBuffers()
|
130
|
+
end
|
131
|
+
|
132
|
+
myReshape = proc do |w, h|
|
133
|
+
glViewport(0, 0, w, h)
|
134
|
+
glMatrixMode(GL_PROJECTION)
|
135
|
+
glLoadIdentity()
|
136
|
+
if (w <= h)
|
137
|
+
glOrtho(-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0)
|
138
|
+
else
|
139
|
+
glOrtho(-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0)
|
140
|
+
end
|
141
|
+
glMatrixMode(GL_MODELVIEW)
|
142
|
+
end
|
143
|
+
|
144
|
+
keyboard = Proc.new do |key, x, y|
|
145
|
+
case (key)
|
146
|
+
when ?\e
|
147
|
+
exit(0);
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Main Loop
|
152
|
+
# Open window with initial window size, title bar,
|
153
|
+
# RGBA display mode, and handle input events.
|
154
|
+
#
|
155
|
+
glutInit()
|
156
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ACCUM | GLUT_DEPTH)
|
157
|
+
glutInitWindowSize(500, 500)
|
158
|
+
glutInitWindowPosition(100, 100)
|
159
|
+
glutCreateWindow($0)
|
160
|
+
myinit()
|
161
|
+
glutReshapeFunc(myReshape)
|
162
|
+
glutDisplayFunc(myDisplay)
|
163
|
+
glutKeyboardFunc(keyboard)
|
164
|
+
glutMainLoop()
|