opengl 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/test_case.rb +1 -2
  103. data/test/dummy.xorg.conf +140 -0
  104. data/test/test_gl.rb +18 -22
  105. data/test/test_gl_10_11.rb +220 -220
  106. data/test/test_gl_12.rb +11 -122
  107. data/test/test_gl_13.rb +202 -210
  108. data/test/test_gl_14.rb +16 -19
  109. data/test/test_gl_15.rb +2 -4
  110. data/test/test_gl_20.rb +45 -58
  111. data/test/test_gl_21.rb +46 -163
  112. data/test/test_gl_ext_arb.rb +54 -72
  113. data/test/test_gl_ext_ati.rb +0 -2
  114. data/test/test_gl_ext_ext.rb +66 -66
  115. data/test/test_gl_ext_gremedy.rb +8 -15
  116. data/test/test_gl_ext_nv.rb +109 -112
  117. data/test/test_opengl_buffer.rb +8 -25
  118. data/utils/README +0 -5
  119. data/utils/enumgen.rb +72 -76
  120. data/utils/extlistgen.rb +55 -55
  121. metadata +87 -66
  122. metadata.gz.sig +2 -0
  123. data/Rakefile.cross +0 -107
  124. data/docs/build_install.txt +0 -119
  125. data/docs/extensions.txt.in +0 -348
  126. data/docs/history.txt +0 -66
  127. data/docs/requirements_and_design.txt +0 -117
  128. data/docs/roadmap.txt +0 -28
  129. data/docs/scientific_use.txt +0 -35
  130. data/docs/supplies/page_template.html +0 -71
  131. data/docs/thanks.txt +0 -29
  132. data/docs/tutorial.txt +0 -469
  133. data/ext/opengl/glu-enums.c +0 -164
  134. data/ext/opengl/glu-enums.h +0 -463
  135. data/ext/opengl/glu.c +0 -1534
  136. data/ext/opengl/glut.c +0 -1145
  137. data/ext/opengl/glut_callbacks.c +0 -845
  138. data/lib/glu.rb +0 -1
  139. data/lib/glut.rb +0 -1
  140. data/test/test_glu.rb +0 -309
  141. data/utils/mkdn2html.rb +0 -59
  142. data/utils/post-mkdn2html.rb +0 -91
  143. data/website/images/ogl.jpg +0 -0
  144. data/website/images/tab_bottom.gif +0 -0
  145. data/website/style.css +0 -198
@@ -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
- include Gl,Glut
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
- attr_accessor :start,:secs
25
- def initialize
26
- @start = 0
27
- @secs = 0
28
- end
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
- pBench.start = Time.now
62
- # pBench.secs = 0.0
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
- $now = Time.now
68
- pBench.secs += $now - pBench.start
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
- puts ""
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
- puts PROGRAM
106
- puts ""
107
- puts "OpenGL: #{version}"
108
- puts "Vendor: #{vendor}"
109
- puts "Renderer: #{renderer}"
110
- puts ""
107
+ puts PROGRAM
108
+ puts ""
109
+ puts "OpenGL: #{version}"
110
+ puts "Vendor: #{vendor}"
111
+ puts "Renderer: #{renderer}"
112
+ puts ""
111
113
 
112
- if Gl.is_available?("GL_EXT_framebuffer_object") == false
114
+ if Gl.is_available?("GL_EXT_framebuffer_object") == false
113
115
  error("Extension not available","EXT_framebuffer_object")
114
- end
116
+ end
115
117
  end
116
118
 
117
119
  # Load Extension Procs
118
120
  def initExtensions
119
- # (Not needed)
121
+ # (Not needed)
120
122
  end
121
123
 
122
124
  # Initialize Vertex/Fragment Programs
123
125
  def initProgs
124
126
  # NOP Vertex shader
125
- $vertexProg = <<-END_OF_PROGRAM
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
- END_OF_PROGRAM
139
+ END_OF_PROGRAM
138
140
 
139
141
  # Black Light Fragment shader
140
- $fragProg = <<-END_OF_PROGRAM
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
- END_OF_PROGRAM
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
- 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
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
- $textureWidth, $textureHeight)
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
- height = 1
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
- $frames += 1
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
-
@@ -1,46 +1,47 @@
1
- require 'opengl'
2
- include Gl,Glu,Glut
3
-
4
- display = Proc.new do
5
- glClear(GL_COLOR_BUFFER_BIT)
6
- GL.LoadIdentity
7
-
8
- glRasterPos2d(100,100)
9
- "Hello Bitmap".each_byte { |x| glutBitmapCharacter(GLUT_BITMAP_9_BY_15, x) }
10
-
11
- GL.Translate(100, 250, 0)
12
- GL.Scale(0.5, 0.5, 1)
13
- "Hello Stroke".each_byte { |x| glutStrokeCharacter(GLUT_STROKE_ROMAN, x) }
14
-
15
- glutSwapBuffers()
16
- end
17
-
18
- reshape = Proc.new do |w, h|
19
- glViewport(0, 0, w, h)
20
- glMatrixMode(GL_PROJECTION)
21
- glLoadIdentity()
22
- glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
23
- glMatrixMode(GL_MODELVIEW)
24
- end
25
-
26
- keyboard = Proc.new do |key, x, y|
27
- case (key)
28
- when ?\e
29
- exit(0)
30
- end
31
- end
32
-
33
- # Main Loop
34
- # Open window with initial window size, title bar,
35
- # color index display mode, and handle input events.
36
- #
37
- glutInit
38
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
39
- glutInitWindowSize(500, 500)
40
- glutInitWindowPosition(100, 100)
41
- glutCreateWindow($0)
42
-
43
- glutReshapeFunc(reshape)
44
- glutDisplayFunc(display)
45
- glutKeyboardFunc(keyboard)
46
- glutMainLoop
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
@@ -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
- if( Glfw.glfwGetWindowParam( Glfw::GLFW_OPENED ) == false ||
10
- Glfw.glfwGetKey(Glfw::GLFW_KEY_ESC) == Glfw::GLFW_PRESS )
11
- break
12
- end
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
- Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
14
+ Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
15
15
 
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
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
- sleep 0.01 # to avoid consuming all CPU power
29
+ sleep 0.01 # to avoid consuming all CPU power
30
30
  end
@@ -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
- 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);
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)
@@ -1,65 +1,66 @@
1
- require 'opengl'
2
- include Gl,Glu,Glut
3
-
4
- begin
5
- require "RMagick"
6
- rescue Exception
7
- print "This sample needs RMagick Module.\n"
8
- exit
9
- end
10
-
11
- WIDTH = 500
12
- HEIGHT = 500
13
-
14
- display = Proc.new do
15
- glClear(GL_COLOR_BUFFER_BIT)
16
-
17
- glBegin(GL_LINES)
18
- glVertex(0.5, 0.5)
19
- glVertex(-0.5, -0.5)
20
- glEnd
21
-
22
- glFlush()
23
-
24
- pixels = glReadPixels(0, 0, WIDTH, HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT)
25
-
26
- image = Magick::Image.new(WIDTH, HEIGHT)
27
- image.import_pixels(0, 0, WIDTH, HEIGHT, "RGBA", pixels,Magick::ShortPixel)
28
- image.flip!
29
- image.write("opengl_window.gif")
30
- end
31
-
32
- reshape = Proc.new do |w, h|
33
- glViewport(0, 0, w, h)
34
- glMatrixMode(GL_PROJECTION)
35
- glLoadIdentity()
36
- if (w <= h)
37
- gluOrtho2D(-1.0, 1.0, -h.to_f/w.to_f, h.to_f/w.to_f)
38
- else
39
- gluOrtho2D(w.to_f/h.to_f, w.to_f/h.to_f, -1.0, 1.0)
40
- end
41
- glMatrixMode(GL_MODELVIEW)
42
- glLoadIdentity()
43
- end
44
-
45
-
46
- keyboard = Proc.new do |key, x, y|
47
- case (key)
48
- when ?\e
49
- exit(0);
50
- end
51
- end
52
-
53
- # Main Loop
54
- # Open window with initial window size, title bar,
55
- # color index display mode, and handle input events.
56
- glutInit
57
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_ALPHA)
58
- glutInitWindowSize(WIDTH, HEIGHT)
59
- glutInitWindowPosition(100, 100)
60
- glutCreateWindow($0)
61
- glutReshapeFunc(reshape)
62
- glutDisplayFunc(display)
63
- glutKeyboardFunc(keyboard)
64
- glutMainLoop
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