opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +2 -1
- data/.travis.yml +19 -0
- data/History.rdoc +26 -0
- data/Manifest.txt +3 -23
- data/README.rdoc +43 -37
- data/Rakefile +6 -62
- data/examples/NeHe/nehe_lesson02.rb +3 -2
- data/examples/NeHe/nehe_lesson03.rb +3 -2
- data/examples/NeHe/nehe_lesson04.rb +3 -1
- data/examples/NeHe/nehe_lesson05.rb +4 -1
- data/examples/NeHe/nehe_lesson06.rb +9 -6
- data/examples/NeHe/nehe_lesson07.rb +9 -6
- data/examples/NeHe/nehe_lesson08.rb +9 -6
- data/examples/NeHe/nehe_lesson09.rb +10 -6
- data/examples/NeHe/nehe_lesson11.rb +9 -6
- data/examples/NeHe/nehe_lesson12.rb +9 -6
- data/examples/NeHe/nehe_lesson16.rb +50 -47
- data/examples/NeHe/nehe_lesson19.rb +10 -7
- data/examples/NeHe/nehe_lesson36.rb +234 -229
- data/examples/OrangeBook/brick.rb +227 -225
- data/examples/OrangeBook/particle.rb +233 -231
- data/examples/RedBook/aapoly.rb +71 -70
- data/examples/RedBook/aargb.rb +54 -52
- data/examples/RedBook/accanti.rb +96 -94
- data/examples/RedBook/accpersp.rb +106 -104
- data/examples/RedBook/alpha.rb +54 -52
- data/examples/RedBook/alpha3D.rb +90 -88
- data/examples/RedBook/bezcurve.rb +48 -46
- data/examples/RedBook/bezmesh.rb +71 -69
- data/examples/RedBook/checker.rb +57 -55
- data/examples/RedBook/clip.rb +41 -39
- data/examples/RedBook/colormat.rb +72 -70
- data/examples/RedBook/cube.rb +39 -37
- data/examples/RedBook/depthcue.rb +37 -35
- data/examples/RedBook/dof.rb +110 -109
- data/examples/RedBook/double.rb +40 -38
- data/examples/RedBook/drawf.rb +30 -28
- data/examples/RedBook/feedback.rb +79 -77
- data/examples/RedBook/fog.rb +90 -89
- data/examples/RedBook/font.rb +78 -76
- data/examples/RedBook/hello.rb +29 -27
- data/examples/RedBook/image.rb +57 -55
- data/examples/RedBook/jitter.rb +131 -131
- data/examples/RedBook/light.rb +2 -1
- data/examples/RedBook/lines.rb +70 -68
- data/examples/RedBook/list.rb +48 -46
- data/examples/RedBook/material.rb +200 -199
- data/examples/RedBook/mipmap.rb +84 -82
- data/examples/RedBook/model.rb +55 -53
- data/examples/RedBook/movelight.rb +52 -50
- data/examples/RedBook/pickdepth.rb +103 -101
- data/examples/RedBook/planet.rb +46 -44
- data/examples/RedBook/quadric.rb +97 -95
- data/examples/RedBook/robot.rb +55 -53
- data/examples/RedBook/select.rb +118 -116
- data/examples/RedBook/smooth.rb +35 -33
- data/examples/RedBook/stencil.rb +96 -94
- data/examples/RedBook/stroke.rb +75 -73
- data/examples/RedBook/surface.rb +93 -91
- data/examples/RedBook/teaambient.rb +71 -69
- data/examples/RedBook/teapots.rb +105 -103
- data/examples/RedBook/tess.rb +96 -94
- data/examples/RedBook/texbind.rb +79 -77
- data/examples/RedBook/texgen.rb +88 -86
- data/examples/RedBook/texturesurf.rb +57 -55
- data/examples/RedBook/varray.rb +85 -83
- data/examples/RedBook/wrap.rb +76 -74
- data/examples/misc/OGLBench.rb +114 -113
- data/examples/misc/anisotropic.rb +154 -152
- data/examples/misc/fbo_test.rb +37 -36
- data/examples/misc/font-glut.rb +47 -46
- data/examples/misc/glfwtest.rb +16 -16
- data/examples/misc/plane.rb +13 -13
- data/examples/misc/readpixel.rb +66 -65
- data/examples/misc/sdltest.rb +21 -19
- data/examples/misc/trislam.rb +548 -547
- data/ext/opengl/common.h +16 -38
- data/ext/opengl/conv.h +39 -41
- data/ext/opengl/extconf.rb +4 -31
- data/ext/opengl/funcdef.h +126 -124
- data/ext/opengl/gl-1.0-1.1.c +1917 -1917
- data/ext/opengl/gl-1.2.c +4 -667
- data/ext/opengl/gl-1.3.c +9 -9
- data/ext/opengl/gl-1.4.c +8 -8
- data/ext/opengl/gl-1.5.c +1 -1
- data/ext/opengl/gl-2.0.c +392 -388
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +1523 -5
- data/ext/opengl/gl-enums.h +4679 -122
- data/ext/opengl/gl-error.c +7 -7
- data/ext/opengl/gl-error.h +4 -4
- data/ext/opengl/gl-ext-arb.c +468 -464
- data/ext/opengl/gl-ext-ext.c +18 -18
- data/ext/opengl/gl-ext-nv.c +15 -15
- data/ext/opengl/gl.c +2 -0
- data/ext/opengl/gl_buffer.c +92 -92
- data/ext/opengl/opengl.c +1 -7
- data/lib/opengl.rb +23 -59
- data/lib/opengl/1.9/opengl.so +0 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +1 -2
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +18 -22
- data/test/test_gl_10_11.rb +220 -220
- data/test/test_gl_12.rb +11 -122
- data/test/test_gl_13.rb +202 -210
- data/test/test_gl_14.rb +16 -19
- data/test/test_gl_15.rb +2 -4
- data/test/test_gl_20.rb +45 -58
- data/test/test_gl_21.rb +46 -163
- data/test/test_gl_ext_arb.rb +54 -72
- data/test/test_gl_ext_ati.rb +0 -2
- data/test/test_gl_ext_ext.rb +66 -66
- data/test/test_gl_ext_gremedy.rb +8 -15
- data/test/test_gl_ext_nv.rb +109 -112
- data/test/test_opengl_buffer.rb +8 -25
- data/utils/README +0 -5
- data/utils/enumgen.rb +72 -76
- data/utils/extlistgen.rb +55 -55
- metadata +90 -67
- metadata.gz.sig +0 -0
- data/Rakefile.cross +0 -107
- data/docs/build_install.txt +0 -119
- data/docs/extensions.txt.in +0 -348
- data/docs/history.txt +0 -66
- data/docs/requirements_and_design.txt +0 -117
- data/docs/roadmap.txt +0 -28
- data/docs/scientific_use.txt +0 -35
- data/docs/supplies/page_template.html +0 -71
- data/docs/thanks.txt +0 -29
- data/docs/tutorial.txt +0 -469
- data/ext/opengl/glu-enums.c +0 -164
- data/ext/opengl/glu-enums.h +0 -463
- data/ext/opengl/glu.c +0 -1534
- data/ext/opengl/glut.c +0 -1145
- data/ext/opengl/glut_callbacks.c +0 -845
- data/lib/glu.rb +0 -1
- data/lib/glut.rb +0 -1
- data/lib/opengl/opengl.so +0 -0
- data/test/test_glu.rb +0 -309
- data/utils/mkdn2html.rb +0 -59
- data/utils/post-mkdn2html.rb +0 -91
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +0 -198
data/examples/misc/fbo_test.rb
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
# Bob Free bfree@graphcomp.com
|
3
3
|
# http://graphcomp.com/opengl
|
4
4
|
|
5
|
-
# This program is freely distributable without licensing fees
|
6
|
-
# and is provided without guarantee or warrantee expressed or
|
5
|
+
# This program is freely distributable without licensing fees
|
6
|
+
# and is provided without guarantee or warrantee expressed or
|
7
7
|
# implied. This program is -not- in the public domain.
|
8
8
|
#
|
9
9
|
# Conversion to ruby by Jan Dvorak <jan.dvorak@kraxnet.cz>
|
10
10
|
|
11
11
|
# Set up standard libs
|
12
12
|
require 'opengl'
|
13
|
-
|
13
|
+
require 'glu'
|
14
|
+
require 'glut'
|
15
|
+
include Gl,Glu,Glut
|
14
16
|
|
15
17
|
# Set up constants
|
16
18
|
PROGRAM = "OpenGL Benchmark - Ruby Bindings"
|
@@ -21,11 +23,11 @@ CYCLES = 1000
|
|
21
23
|
|
22
24
|
# Set up types
|
23
25
|
class Bench
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
attr_accessor :start,:secs
|
27
|
+
def initialize
|
28
|
+
@start = 0
|
29
|
+
@secs = 0
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
# Set up globals
|
@@ -58,14 +60,14 @@ $rotY = 0.0
|
|
58
60
|
|
59
61
|
# Start benchmark
|
60
62
|
def startBench(pBench)
|
61
|
-
|
62
|
-
#
|
63
|
+
pBench.start = Time.now
|
64
|
+
# pBench.secs = 0.0
|
63
65
|
end
|
64
66
|
|
65
67
|
# Accumulate benchmark
|
66
68
|
def endBench(pBench)
|
67
|
-
|
68
|
-
|
69
|
+
$now = Time.now
|
70
|
+
pBench.secs += $now - pBench.start
|
69
71
|
end
|
70
72
|
|
71
73
|
# Print benchmark
|
@@ -75,7 +77,7 @@ def printBench
|
|
75
77
|
puts "No measurable time has elapsed"
|
76
78
|
return
|
77
79
|
end
|
78
|
-
|
80
|
+
|
79
81
|
puts "FBO Texture Rendering FPS: #{$frames / $textureBench.secs}"
|
80
82
|
puts "Teapot Shader FPS: #{$frames / $teapotBench.secs}"
|
81
83
|
|
@@ -86,7 +88,7 @@ def printBench
|
|
86
88
|
puts "OS/GLUT overhead secs/frame: #{overhead / $frames}"
|
87
89
|
|
88
90
|
puts "Overall FPS: #{$frames / $appBench.secs}"
|
89
|
-
|
91
|
+
puts ""
|
90
92
|
end
|
91
93
|
|
92
94
|
# Error handling
|
@@ -102,27 +104,27 @@ def checkVersion
|
|
102
104
|
renderer = glGetString(GL_RENDERER)
|
103
105
|
exts = glGetString(GL_EXTENSIONS)
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
puts PROGRAM
|
108
|
+
puts ""
|
109
|
+
puts "OpenGL: #{version}"
|
110
|
+
puts "Vendor: #{vendor}"
|
111
|
+
puts "Renderer: #{renderer}"
|
112
|
+
puts ""
|
111
113
|
|
112
|
-
|
114
|
+
if Gl.is_available?("GL_EXT_framebuffer_object") == false
|
113
115
|
error("Extension not available","EXT_framebuffer_object")
|
114
|
-
|
116
|
+
end
|
115
117
|
end
|
116
118
|
|
117
119
|
# Load Extension Procs
|
118
120
|
def initExtensions
|
119
|
-
|
121
|
+
# (Not needed)
|
120
122
|
end
|
121
123
|
|
122
124
|
# Initialize Vertex/Fragment Programs
|
123
125
|
def initProgs
|
124
126
|
# NOP Vertex shader
|
125
|
-
|
127
|
+
$vertexProg = <<-END_OF_PROGRAM
|
126
128
|
!!ARBvp1.0
|
127
129
|
TEMP vertexClip;
|
128
130
|
DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.position;
|
@@ -134,16 +136,16 @@ MOV result.color, vertex.color;
|
|
134
136
|
MOV result.texcoord[0], vertex.texcoord;
|
135
137
|
MOV result.texcoord[1], vertex.normal;
|
136
138
|
END
|
137
|
-
|
139
|
+
END_OF_PROGRAM
|
138
140
|
|
139
141
|
# Black Light Fragment shader
|
140
|
-
|
142
|
+
$fragProg = <<-END_OF_PROGRAM
|
141
143
|
!!ARBfp1.0
|
142
144
|
TEMP decal,color;
|
143
145
|
TEX decal, fragment.texcoord[0], texture[0], 2D;
|
144
146
|
MUL result.color, decal, fragment.texcoord[1];
|
145
147
|
END
|
146
|
-
|
148
|
+
END_OF_PROGRAM
|
147
149
|
|
148
150
|
$idVertexProg,$idFragProg = glGenProgramsARB(2)
|
149
151
|
|
@@ -180,7 +182,7 @@ def initFBO
|
|
180
182
|
glBindTexture(GL_TEXTURE_2D, $idTexture)
|
181
183
|
|
182
184
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, $textureWidth, $textureHeight,
|
183
|
-
|
185
|
+
0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
|
184
186
|
|
185
187
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
|
186
188
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
|
@@ -191,7 +193,7 @@ def initFBO
|
|
191
193
|
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, $idRenderBuffer)
|
192
194
|
|
193
195
|
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
|
194
|
-
|
196
|
+
$textureWidth, $textureHeight)
|
195
197
|
|
196
198
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
|
197
199
|
GL_RENDERBUFFER_EXT, $idRenderBuffer)
|
@@ -215,7 +217,7 @@ def renderFBO
|
|
215
217
|
glClearColor(0, 0, 0, 0)
|
216
218
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
217
219
|
glColor3d(1.0, 1.0, 1.0)
|
218
|
-
|
220
|
+
|
219
221
|
glutWireTeapot(0.125)
|
220
222
|
|
221
223
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
|
@@ -235,9 +237,9 @@ end
|
|
235
237
|
# Resize Window
|
236
238
|
def resizeScene(width,height)
|
237
239
|
if (height==0)
|
238
|
-
|
240
|
+
height = 1
|
239
241
|
end
|
240
|
-
|
242
|
+
|
241
243
|
glViewport(0, 0, width, height)
|
242
244
|
|
243
245
|
glMatrixMode(GL_PROJECTION)
|
@@ -286,7 +288,7 @@ end
|
|
286
288
|
# Frame handler
|
287
289
|
display = lambda do
|
288
290
|
# Run benchmark CYCLES times
|
289
|
-
|
291
|
+
$frames += 1
|
290
292
|
term() if ($frames > CYCLES)
|
291
293
|
startBench($frameBench)
|
292
294
|
|
@@ -294,7 +296,7 @@ display = lambda do
|
|
294
296
|
startBench($textureBench)
|
295
297
|
renderFBO()
|
296
298
|
endBench($textureBench)
|
297
|
-
|
299
|
+
|
298
300
|
# Set up ModelView
|
299
301
|
glMatrixMode(GL_MODELVIEW)
|
300
302
|
glLoadIdentity()
|
@@ -317,7 +319,7 @@ display = lambda do
|
|
317
319
|
startBench($teapotBench)
|
318
320
|
glEnable(GL_VERTEX_PROGRAM_ARB)
|
319
321
|
glEnable(GL_FRAGMENT_PROGRAM_ARB)
|
320
|
-
|
322
|
+
|
321
323
|
glutSolidTeapot(1.0)
|
322
324
|
|
323
325
|
glDisable(GL_FRAGMENT_PROGRAM_ARB)
|
@@ -353,4 +355,3 @@ init()
|
|
353
355
|
startBench($appBench)
|
354
356
|
glutMainLoop()
|
355
357
|
exit(0)
|
356
|
-
|
data/examples/misc/font-glut.rb
CHANGED
@@ -1,46 +1,47 @@
|
|
1
|
-
require 'opengl'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
1
|
+
require 'opengl'
|
2
|
+
require 'glut'
|
3
|
+
include Gl,Glut
|
4
|
+
|
5
|
+
display = Proc.new do
|
6
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
7
|
+
GL.LoadIdentity
|
8
|
+
|
9
|
+
glRasterPos2d(100,100)
|
10
|
+
"Hello Bitmap".each_byte { |x| glutBitmapCharacter(GLUT_BITMAP_9_BY_15, x) }
|
11
|
+
|
12
|
+
GL.Translate(100, 250, 0)
|
13
|
+
GL.Scale(0.5, 0.5, 1)
|
14
|
+
"Hello Stroke".each_byte { |x| glutStrokeCharacter(GLUT_STROKE_ROMAN, x) }
|
15
|
+
|
16
|
+
glutSwapBuffers()
|
17
|
+
end
|
18
|
+
|
19
|
+
reshape = Proc.new do |w, h|
|
20
|
+
glViewport(0, 0, w, h)
|
21
|
+
glMatrixMode(GL_PROJECTION)
|
22
|
+
glLoadIdentity()
|
23
|
+
glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
|
24
|
+
glMatrixMode(GL_MODELVIEW)
|
25
|
+
end
|
26
|
+
|
27
|
+
keyboard = Proc.new do |key, x, y|
|
28
|
+
case (key)
|
29
|
+
when ?\e
|
30
|
+
exit(0)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Main Loop
|
35
|
+
# Open window with initial window size, title bar,
|
36
|
+
# color index display mode, and handle input events.
|
37
|
+
#
|
38
|
+
glutInit
|
39
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
40
|
+
glutInitWindowSize(500, 500)
|
41
|
+
glutInitWindowPosition(100, 100)
|
42
|
+
glutCreateWindow($0)
|
43
|
+
|
44
|
+
glutReshapeFunc(reshape)
|
45
|
+
glutDisplayFunc(display)
|
46
|
+
glutKeyboardFunc(keyboard)
|
47
|
+
glutMainLoop
|
data/examples/misc/glfwtest.rb
CHANGED
@@ -6,25 +6,25 @@ Glfw.glfwOpenWindow( 500,500, 0,0,0,0, 32,0, Glfw::GLFW_WINDOW )
|
|
6
6
|
|
7
7
|
# main loop
|
8
8
|
while true
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if( Glfw.glfwGetWindowParam( Glfw::GLFW_OPENED ) == false ||
|
10
|
+
Glfw.glfwGetKey(Glfw::GLFW_KEY_ESC) == Glfw::GLFW_PRESS )
|
11
|
+
break
|
12
|
+
end
|
13
13
|
|
14
|
-
|
14
|
+
Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
Gl.glBegin( Gl::GL_POLYGON )
|
17
|
+
Gl.glColor3f( 1.0, 0.0, 0.0 )
|
18
|
+
Gl.glVertex2f( -0.5, -0.5 )
|
19
|
+
Gl.glColor3f( 0.0, 1.0, 0.0 )
|
20
|
+
Gl.glVertex2f( -0.5, 0.5 )
|
21
|
+
Gl.glColor3f( 0.0, 0.0, 1.0 )
|
22
|
+
Gl.glVertex2f( 0.5, 0.5 )
|
23
|
+
Gl.glColor3f( 1.0, 0.0, 1.0 )
|
24
|
+
Gl.glVertex2f( 0.5, -0.5 )
|
25
|
+
Gl.glEnd
|
26
26
|
|
27
27
|
Glfw.glfwSwapBuffers()
|
28
28
|
|
29
|
-
|
29
|
+
sleep 0.01 # to avoid consuming all CPU power
|
30
30
|
end
|
data/examples/misc/plane.rb
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
#
|
4
4
|
#/*
|
5
5
|
# * (c) Copyright 1993, Silicon Graphics, Inc.
|
6
|
-
# * ALL RIGHTS RESERVED
|
7
|
-
# * Permission to use, copy, modify, and distribute this software for
|
6
|
+
# * ALL RIGHTS RESERVED
|
7
|
+
# * Permission to use, copy, modify, and distribute this software for
|
8
8
|
# * any purpose and without fee is hereby granted, provided that the above
|
9
9
|
# * copyright notice appear in all copies and that both the copyright notice
|
10
|
-
# * and this permission notice appear in supporting documentation, and that
|
10
|
+
# * and this permission notice appear in supporting documentation, and that
|
11
11
|
# * the name of Silicon Graphics, Inc. not be used in advertising
|
12
12
|
# * or publicity pertaining to distribution of the software without specific,
|
13
|
-
# * written prior permission.
|
13
|
+
# * written prior permission.
|
14
14
|
# *
|
15
15
|
# * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
16
16
|
# * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -24,8 +24,8 @@
|
|
24
24
|
# * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
25
25
|
# * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
26
26
|
# * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
27
|
-
# *
|
28
|
-
# * US Government Users Restricted Rights
|
27
|
+
# *
|
28
|
+
# * US Government Users Restricted Rights
|
29
29
|
# * Use, duplication, or disclosure by the Government is subject to
|
30
30
|
# * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
31
31
|
# * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -39,7 +39,7 @@
|
|
39
39
|
# */
|
40
40
|
#/*
|
41
41
|
# * plane.c
|
42
|
-
# * This program demonstrates the use of local versus
|
42
|
+
# * This program demonstrates the use of local versus
|
43
43
|
# * infinite lighting on a flat plane.
|
44
44
|
# */
|
45
45
|
|
@@ -51,7 +51,7 @@ require "mathn"
|
|
51
51
|
# */
|
52
52
|
def myinit
|
53
53
|
mat_ambient = [ 0.0, 0.0, 0.0, 1.0 ];
|
54
|
-
#/* mat_specular and mat_shininess are NOT default values
|
54
|
+
#/* mat_specular and mat_shininess are NOT default values */
|
55
55
|
mat_diffuse = [ 0.4, 0.4, 0.4, 1.0 ];
|
56
56
|
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
|
57
57
|
mat_shininess = [ 15.0 ];
|
@@ -128,10 +128,10 @@ myReshape = Proc.new {|w, h|
|
|
128
128
|
Gl.glViewport(0, 0, w, h);
|
129
129
|
Gl.glMatrixMode(Gl::GL_PROJECTION);
|
130
130
|
Gl.glLoadIdentity();
|
131
|
-
if (w <= h)
|
132
|
-
|
133
|
-
else
|
134
|
-
|
131
|
+
if (w <= h)
|
132
|
+
Gl.glOrtho(-1.5, 1.5, -1.5*h/w, 1.5*h/w, -10.0, 10.0);
|
133
|
+
else
|
134
|
+
Gl.glOrtho(-1.5*w/h, 1.5*w/h, -1.5, 1.5, -10.0, 10.0);
|
135
135
|
end
|
136
136
|
Gl.glMatrixMode(Gl::GL_MODELVIEW);
|
137
137
|
}
|
@@ -145,7 +145,7 @@ keyboard = lambda do |key, x, y|
|
|
145
145
|
end
|
146
146
|
|
147
147
|
#/* Main Loop
|
148
|
-
# * Open window with initial window size, title bar,
|
148
|
+
# * Open window with initial window size, title bar,
|
149
149
|
# * RGBA display mode, and handle input events.
|
150
150
|
# */
|
151
151
|
#int main(int argc, char** argv)
|
data/examples/misc/readpixel.rb
CHANGED
@@ -1,65 +1,66 @@
|
|
1
|
-
require 'opengl'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
1
|
+
require 'opengl'
|
2
|
+
require 'glu'
|
3
|
+
require 'glut'
|
4
|
+
include Gl,Glu,Glut
|
5
|
+
|
6
|
+
begin
|
7
|
+
require "RMagick"
|
8
|
+
rescue Exception
|
9
|
+
print "This sample needs RMagick Module.\n"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
WIDTH = 500
|
14
|
+
HEIGHT = 500
|
15
|
+
|
16
|
+
display = Proc.new do
|
17
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
18
|
+
|
19
|
+
glBegin(GL_LINES)
|
20
|
+
glVertex(0.5, 0.5)
|
21
|
+
glVertex(-0.5, -0.5)
|
22
|
+
glEnd
|
23
|
+
|
24
|
+
glFlush()
|
25
|
+
|
26
|
+
pixels = glReadPixels(0, 0, WIDTH, HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT)
|
27
|
+
|
28
|
+
image = Magick::Image.new(WIDTH, HEIGHT)
|
29
|
+
image.import_pixels(0, 0, WIDTH, HEIGHT, "RGBA", pixels,Magick::ShortPixel)
|
30
|
+
image.flip!
|
31
|
+
image.write("opengl_window.gif")
|
32
|
+
end
|
33
|
+
|
34
|
+
reshape = Proc.new do |w, h|
|
35
|
+
glViewport(0, 0, w, h)
|
36
|
+
glMatrixMode(GL_PROJECTION)
|
37
|
+
glLoadIdentity()
|
38
|
+
if (w <= h)
|
39
|
+
gluOrtho2D(-1.0, 1.0, -h.to_f/w.to_f, h.to_f/w.to_f)
|
40
|
+
else
|
41
|
+
gluOrtho2D(w.to_f/h.to_f, w.to_f/h.to_f, -1.0, 1.0)
|
42
|
+
end
|
43
|
+
glMatrixMode(GL_MODELVIEW)
|
44
|
+
glLoadIdentity()
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
keyboard = Proc.new do |key, x, y|
|
49
|
+
case (key)
|
50
|
+
when ?\e
|
51
|
+
exit(0);
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Main Loop
|
56
|
+
# Open window with initial window size, title bar,
|
57
|
+
# color index display mode, and handle input events.
|
58
|
+
glutInit
|
59
|
+
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_ALPHA)
|
60
|
+
glutInitWindowSize(WIDTH, HEIGHT)
|
61
|
+
glutInitWindowPosition(100, 100)
|
62
|
+
glutCreateWindow($0)
|
63
|
+
glutReshapeFunc(reshape)
|
64
|
+
glutDisplayFunc(display)
|
65
|
+
glutKeyboardFunc(keyboard)
|
66
|
+
glutMainLoop
|