ruby-opengl 0.50.0 → 0.60.0

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.
Files changed (118) hide show
  1. data/Rakefile +15 -11
  2. data/doc/build_install.txt +10 -6
  3. data/doc/extensions.txt.in +348 -0
  4. data/doc/history.txt +4 -0
  5. data/doc/roadmap.txt +4 -6
  6. data/doc/scientific_use.txt +7 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +5 -0
  9. data/doc/tutorial.txt +431 -121
  10. data/examples/NeHe/nehe_lesson02.rb +1 -1
  11. data/examples/NeHe/nehe_lesson03.rb +1 -1
  12. data/examples/NeHe/nehe_lesson04.rb +1 -1
  13. data/examples/NeHe/nehe_lesson05.rb +1 -1
  14. data/examples/NeHe/nehe_lesson36.rb +1 -1
  15. data/examples/OrangeBook/brick.rb +3 -15
  16. data/examples/OrangeBook/particle.rb +2 -20
  17. data/examples/RedBook/aapoly.rb +1 -1
  18. data/examples/RedBook/aargb.rb +2 -2
  19. data/examples/RedBook/accanti.rb +1 -1
  20. data/examples/RedBook/accpersp.rb +1 -1
  21. data/examples/RedBook/alpha.rb +2 -2
  22. data/examples/RedBook/alpha3D.rb +1 -1
  23. data/examples/RedBook/bezcurve.rb +1 -1
  24. data/examples/RedBook/bezmesh.rb +1 -1
  25. data/examples/RedBook/checker.rb +1 -1
  26. data/examples/RedBook/clip.rb +1 -1
  27. data/examples/RedBook/colormat.rb +1 -1
  28. data/examples/RedBook/cube.rb +1 -1
  29. data/examples/RedBook/depthcue.rb +1 -1
  30. data/examples/RedBook/dof.rb +1 -1
  31. data/examples/RedBook/double.rb +1 -1
  32. data/examples/RedBook/drawf.rb +1 -1
  33. data/examples/RedBook/feedback.rb +1 -1
  34. data/examples/RedBook/fog.rb +1 -1
  35. data/examples/RedBook/font.rb +2 -2
  36. data/examples/RedBook/hello.rb +1 -1
  37. data/examples/RedBook/image.rb +4 -4
  38. data/examples/RedBook/lines.rb +1 -1
  39. data/examples/RedBook/list.rb +1 -1
  40. data/examples/RedBook/material.rb +1 -1
  41. data/examples/RedBook/mipmap.rb +1 -1
  42. data/examples/RedBook/model.rb +1 -1
  43. data/examples/RedBook/movelight.rb +1 -1
  44. data/examples/RedBook/pickdepth.rb +1 -1
  45. data/examples/RedBook/planet.rb +5 -5
  46. data/examples/RedBook/quadric.rb +1 -1
  47. data/examples/RedBook/robot.rb +5 -5
  48. data/examples/RedBook/select.rb +1 -1
  49. data/examples/RedBook/smooth.rb +1 -1
  50. data/examples/RedBook/stencil.rb +1 -1
  51. data/examples/RedBook/stroke.rb +2 -2
  52. data/examples/RedBook/surface.rb +1 -1
  53. data/examples/RedBook/teaambient.rb +1 -1
  54. data/examples/RedBook/teapots.rb +1 -1
  55. data/examples/RedBook/tess.rb +1 -1
  56. data/examples/RedBook/texbind.rb +1 -1
  57. data/examples/RedBook/texgen.rb +5 -5
  58. data/examples/RedBook/texturesurf.rb +1 -1
  59. data/examples/RedBook/varray.rb +1 -1
  60. data/examples/RedBook/wrap.rb +5 -5
  61. data/examples/misc/OGLBench.rb +337 -0
  62. data/examples/misc/anisotropic.rb +1 -1
  63. data/examples/misc/fbo_test.rb +356 -0
  64. data/examples/misc/font-glut.rb +1 -1
  65. data/examples/misc/glfwtest.rb +30 -0
  66. data/examples/misc/md2model.rb +15 -0
  67. data/examples/misc/plane.rb +1 -1
  68. data/examples/misc/readpixel.rb +1 -1
  69. data/examples/misc/sdltest.rb +34 -0
  70. data/examples/misc/trislam.rb +828 -0
  71. data/ext/common/common.h +126 -218
  72. data/ext/common/conv.h +244 -0
  73. data/ext/common/funcdef.h +280 -0
  74. data/ext/common/gl-error.h +23 -0
  75. data/ext/common/gl-types.h +14 -0
  76. data/ext/gl/gl-1.0-1.1.c +497 -1255
  77. data/ext/gl/gl-1.2.c +121 -304
  78. data/ext/gl/gl-1.3.c +78 -339
  79. data/ext/gl/gl-1.4.c +102 -164
  80. data/ext/gl/gl-1.5.c +42 -173
  81. data/ext/gl/gl-2.0.c +273 -1039
  82. data/ext/gl/gl-2.1.c +15 -19
  83. data/ext/gl/gl-enums.c +3 -2
  84. data/ext/gl/gl-error.c +104 -0
  85. data/ext/gl/gl-ext-3dfx.c +27 -0
  86. data/ext/gl/gl-ext-arb.c +812 -12
  87. data/ext/gl/gl-ext-ati.c +41 -0
  88. data/ext/gl/gl-ext-ext.c +791 -119
  89. data/ext/gl/gl-ext-gremedy.c +41 -0
  90. data/ext/gl/gl-ext-nv.c +679 -0
  91. data/ext/gl/gl.c +48 -28
  92. data/ext/gl/mkrf_conf.rb +13 -10
  93. data/ext/glu/glu-enums.c +3 -2
  94. data/ext/glu/glu.c +136 -41
  95. data/ext/glu/mkrf_conf.rb +15 -12
  96. data/ext/glut/glut.c +37 -80
  97. data/ext/glut/mkrf_conf.rb +17 -13
  98. data/lib/opengl.rb +29 -53
  99. data/test/tc_common.rb +9 -3
  100. data/test/tc_ext_arb.rb +397 -3
  101. data/test/tc_ext_ati.rb +33 -0
  102. data/test/tc_ext_ext.rb +479 -2
  103. data/test/tc_ext_gremedy.rb +36 -0
  104. data/test/tc_ext_nv.rb +357 -0
  105. data/test/tc_func_10_11.rb +93 -67
  106. data/test/tc_func_12.rb +11 -11
  107. data/test/tc_func_13.rb +38 -18
  108. data/test/tc_func_14.rb +2 -2
  109. data/test/tc_func_15.rb +10 -10
  110. data/test/tc_func_20.rb +20 -20
  111. data/test/tc_func_21.rb +53 -22
  112. data/test/tc_glu.rb +9 -4
  113. data/test/tc_misc.rb +15 -2
  114. metadata +22 -8
  115. data/doc/extensions.txt +0 -361
  116. data/examples/RedBook/aaindex.rb +0 -97
  117. data/examples/misc/smooth.rb +0 -42
  118. data/examples/misc/test.rb +0 -65
@@ -172,7 +172,7 @@ class App
172
172
  begin @@anisotropy.rotate! end until @@anisotropy[0]<=max_anisotropy
173
173
  when ?c
174
174
  @@color_tint.rotate!
175
- when 27 # Escape
175
+ when ?\e # Escape
176
176
  exit(0)
177
177
  end
178
178
  glutPostRedisplay()
@@ -0,0 +1,356 @@
1
+ # ogl_bench v1.0 - Copyright 2007 - Graphcomp
2
+ # Bob Free bfree@graphcomp.com
3
+ # http://graphcomp.com/opengl
4
+
5
+ # This program is freely distributable without licensing fees
6
+ # and is provided without guarantee or warrantee expressed or
7
+ # implied. This program is -not- in the public domain.
8
+ #
9
+ # Conversion to ruby by Jan Dvorak <jan.dvorak@kraxnet.cz>
10
+
11
+ # Set up standard libs
12
+ require 'opengl'
13
+ include Gl,Glut
14
+
15
+ # Set up constants
16
+ PROGRAM = "OpenGL Benchmark - Ruby Bindings"
17
+ CYCLES = 1000
18
+
19
+ # Setup OpenGL Extensions
20
+ # (Not needed)
21
+
22
+ # Set up types
23
+ class Bench
24
+ attr_accessor :start,:secs
25
+ def initialize
26
+ @start = 0
27
+ @secs = 0
28
+ end
29
+ end
30
+
31
+ # Set up globals
32
+ $appBench = Bench.new
33
+ $frameBench = Bench.new
34
+ $textureBench = Bench.new
35
+ $teapotBench = Bench.new
36
+ $now = 0
37
+ $frames = 0
38
+
39
+ $idWindow = 0
40
+
41
+ $windowWidth = 512
42
+ $windowHeight = 512
43
+
44
+ $textureWidth = 128
45
+ $textureHeight = 128
46
+
47
+ $rotTeapotX = 0
48
+ $rotTeapotY = 0
49
+
50
+ $idTexture = 0
51
+ $idFrameBuffer = 0
52
+ $idRenderBuffer = 0
53
+ $idVertexProg = 0
54
+ $idFragProg = 0
55
+
56
+ $incY = 0.5
57
+ $rotY = 0.0
58
+
59
+ # Start benchmark
60
+ def startBench(pBench)
61
+ pBench.start = Time.now
62
+ # pBench.secs = 0.0
63
+ end
64
+
65
+ # Accumulate benchmark
66
+ def endBench(pBench)
67
+ $now = Time.now
68
+ pBench.secs += $now - pBench.start
69
+ end
70
+
71
+ # Print benchmark
72
+ def printBench
73
+ if ($frames==0 || $appBench.secs==0 || $frameBench.secs==0 ||
74
+ $textureBench.secs==0 || $teapotBench.secs==0)
75
+ puts "No measurable time has elapsed"
76
+ return
77
+ end
78
+
79
+ puts "FBO Texture Rendering FPS: #{$frames / $textureBench.secs}"
80
+ puts "Teapot Shader FPS: #{$frames / $teapotBench.secs}"
81
+
82
+ overhead = $frameBench.secs - ($textureBench.secs + $teapotBench.secs)
83
+ puts "Frame overhead secs/frame: #{overhead / $frames}"
84
+
85
+ overhead = $appBench.secs - $frameBench.secs
86
+ puts "OS/GLUT overhead secs/frame: #{overhead / $frames}"
87
+
88
+ puts "Overall FPS: #{$frames / $appBench.secs}"
89
+ puts ""
90
+ end
91
+
92
+ # Error handling
93
+ def error(errTitle, errMsg)
94
+ puts "#{errTitle}: #{errMsg}"
95
+ exit(0)
96
+ end
97
+
98
+ # Check OpenGL Version
99
+ def checkVersion
100
+ version = glGetString(GL_VERSION)
101
+ vendor = glGetString(GL_VENDOR)
102
+ renderer = glGetString(GL_RENDERER)
103
+ exts = glGetString(GL_EXTENSIONS)
104
+
105
+ puts PROGRAM
106
+ puts ""
107
+ puts "OpenGL: #{version}"
108
+ puts "Vendor: #{vendor}"
109
+ puts "Renderer: #{renderer}"
110
+ puts ""
111
+
112
+ if Gl.is_available?("GL_EXT_framebuffer_object") == false
113
+ error("Extension not available","EXT_framebuffer_object")
114
+ end
115
+ end
116
+
117
+ # Load Extension Procs
118
+ def initExtensions
119
+ # (Not needed)
120
+ end
121
+
122
+ # Initialize Vertex/Fragment Programs
123
+ def initProgs
124
+ # NOP Vertex shader
125
+ $vertexProg = <<-END_OF_PROGRAM
126
+ !!ARBvp1.0
127
+ TEMP vertexClip;
128
+ DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.position;
129
+ DP4 vertexClip.y, state.matrix.mvp.row[1], vertex.position;
130
+ DP4 vertexClip.z, state.matrix.mvp.row[2], vertex.position;
131
+ DP4 vertexClip.w, state.matrix.mvp.row[3], vertex.position;
132
+ MOV result.position, vertexClip;
133
+ MOV result.color, vertex.color;
134
+ MOV result.texcoord[0], vertex.texcoord;
135
+ MOV result.texcoord[1], vertex.normal;
136
+ END
137
+ END_OF_PROGRAM
138
+
139
+ # Black Light Fragment shader
140
+ $fragProg = <<-END_OF_PROGRAM
141
+ !!ARBfp1.0
142
+ TEMP decal,color;
143
+ TEX decal, fragment.texcoord[0], texture[0], 2D;
144
+ MUL result.color, decal, fragment.texcoord[1];
145
+ END
146
+ END_OF_PROGRAM
147
+
148
+ $idVertexProg,$idFragProg = glGenProgramsARB(2)
149
+
150
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, $idVertexProg)
151
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, $vertexProg)
152
+
153
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, $idFragProg)
154
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, $fragProg)
155
+ end
156
+
157
+ # Terminate Vertex/Fragment Programs
158
+ def termProgs
159
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0)
160
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0)
161
+
162
+ glDeleteProgramsARB([$idVertexProg,$idFragProg])
163
+ end
164
+
165
+ # FBO Status handler
166
+ def statusFBO
167
+ stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
168
+ return if (stat==0 || stat == GL_FRAMEBUFFER_COMPLETE_EXT)
169
+ printf("FBO status: %04X\n", stat)
170
+ exit(0)
171
+ end
172
+
173
+ # Initialize Framebuffers
174
+ def initFBO
175
+ $idTexture = glGenTextures(1)[0]
176
+ $idFrameBuffer = glGenFramebuffersEXT(1)[0]
177
+ $idRenderBuffer = glGenRenderbuffersEXT(1)[0]
178
+
179
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, $idFrameBuffer)
180
+ glBindTexture(GL_TEXTURE_2D, $idTexture)
181
+
182
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, $textureWidth, $textureHeight,
183
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
184
+
185
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
186
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
187
+
188
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
189
+ GL_TEXTURE_2D, $idTexture, 0)
190
+
191
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, $idRenderBuffer)
192
+
193
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
194
+ $textureWidth, $textureHeight)
195
+
196
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
197
+ GL_RENDERBUFFER_EXT, $idRenderBuffer)
198
+
199
+ statusFBO()
200
+ end
201
+
202
+ # FBO texture renderer
203
+ def renderFBO
204
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, $idFrameBuffer)
205
+
206
+ glLoadIdentity()
207
+ glTranslated(-0.75, -0.85, -2.5)
208
+
209
+ glRotated($rotTeapotX, 1.0, 0.0, 0.0)
210
+ $rotTeapotX += 0.5
211
+
212
+ glRotated($rotTeapotY, 0.0, 1.0, 0.0)
213
+ $rotTeapotY += 1.0
214
+
215
+ glClearColor(0, 0, 0, 0)
216
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
217
+ glColor3d(1.0, 1.0, 1.0)
218
+
219
+ glutWireTeapot(0.125)
220
+
221
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
222
+ end
223
+
224
+ # Terminate FBO objects
225
+ def termFBO
226
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0)
227
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
228
+ glBindTexture(GL_TEXTURE_2D, 0)
229
+
230
+ glDeleteRenderbuffersEXT($idRenderBuffer)
231
+ glDeleteFramebuffersEXT($idFrameBuffer)
232
+ glDeleteTextures($idTexture)
233
+ end
234
+
235
+ # Resize Window
236
+ def resizeScene(width,height)
237
+ if (height==0)
238
+ height = 1
239
+ end
240
+
241
+ glViewport(0, 0, width, height)
242
+
243
+ glMatrixMode(GL_PROJECTION)
244
+ glLoadIdentity()
245
+ gluPerspective(45.0,width.to_f/height.to_f,0.1,100.0)
246
+
247
+ glMatrixMode(GL_MODELVIEW)
248
+
249
+ $windowWidth = width
250
+ $windowHeight = height
251
+ end
252
+
253
+ # Initialize OpenGL Environment
254
+ def init
255
+ checkVersion
256
+ initExtensions
257
+
258
+ resizeScene($windowWidth, $windowHeight)
259
+
260
+ initFBO
261
+ initProgs
262
+ end
263
+
264
+ # Terminate OpenGL Environment
265
+ def term
266
+ # Display benchmark
267
+ endBench($appBench)
268
+ printBench()
269
+
270
+ # Disable app
271
+ glutHideWindow()
272
+ glutKeyboardFunc(nil)
273
+ glutSpecialFunc(nil)
274
+ glutIdleFunc(nil)
275
+ glutReshapeFunc(nil)
276
+
277
+ # Release Framebuffers
278
+ termProgs()
279
+ termFBO()
280
+
281
+ # Now we can destroy window
282
+ glutDestroyWindow($idWindow)
283
+ exit(0)
284
+ end
285
+
286
+ # Frame handler
287
+ display = lambda do
288
+ # Run benchmark CYCLES times
289
+ $frames += 1
290
+ term() if ($frames > CYCLES)
291
+ startBench($frameBench)
292
+
293
+ # Render animated texture
294
+ startBench($textureBench)
295
+ renderFBO()
296
+ endBench($textureBench)
297
+
298
+ # Set up ModelView
299
+ glMatrixMode(GL_MODELVIEW)
300
+ glLoadIdentity()
301
+ glTranslatef(0.0,0.0,-5.0)
302
+ glRotated(0.0,1.0,0.0,0.0)
303
+ glRotated($rotY,0.0,1.0,0.0)
304
+ $rotY += $incY
305
+
306
+ # Set attributes
307
+ glEnable(GL_TEXTURE_2D)
308
+ glEnable(GL_DEPTH_TEST)
309
+ glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL)
310
+
311
+ # Clear render buffer and set teapot color
312
+ glClearColor(0.2, 0.2, 0.2, 1.0)
313
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
314
+ glColor3d(0.9, 0.45, 0.0)
315
+
316
+ # Render the teapot using our shader
317
+ startBench($teapotBench)
318
+ glEnable(GL_VERTEX_PROGRAM_ARB)
319
+ glEnable(GL_FRAGMENT_PROGRAM_ARB)
320
+
321
+ glutSolidTeapot(1.0)
322
+
323
+ glDisable(GL_FRAGMENT_PROGRAM_ARB)
324
+ glDisable(GL_VERTEX_PROGRAM_ARB)
325
+ endBench($teapotBench)
326
+
327
+ # Double-buffer and done
328
+ glutSwapBuffers()
329
+ endBench($frameBench)
330
+ end
331
+
332
+ # Keyboard handler
333
+ keyPressed = lambda do |key,x,y|
334
+ term()
335
+ end
336
+
337
+
338
+
339
+ # Main app
340
+
341
+ glutInit()
342
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_ALPHA)
343
+ glutInitWindowSize($windowWidth,$windowHeight)
344
+
345
+ $idWindow = glutCreateWindow(PROGRAM)
346
+
347
+ glutDisplayFunc(display)
348
+ glutIdleFunc(display)
349
+ #glutReshapeFunc(resizeScene)
350
+ glutKeyboardFunc(keyPressed)
351
+
352
+ init()
353
+ startBench($appBench)
354
+ glutMainLoop()
355
+ exit(0)
356
+
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  keyboard = Proc.new do |key, x, y|
27
27
  case (key)
28
- when 27
28
+ when ?\e
29
29
  exit(0)
30
30
  end
31
31
  end
@@ -0,0 +1,30 @@
1
+ require 'opengl'
2
+ require 'glfw'
3
+
4
+ #init
5
+ Glfw.glfwOpenWindow( 500,500, 0,0,0,0, 32,0, Glfw::GLFW_WINDOW )
6
+
7
+ # main loop
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
13
+
14
+ Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
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
26
+
27
+ Glfw.glfwSwapBuffers()
28
+
29
+ sleep 0.01 # to avoid consuming all CPU power
30
+ end
@@ -0,0 +1,15 @@
1
+
2
+
3
+ class Md2Model
4
+
5
+ def load(md2file)
6
+ @data = File.open(md2file).read
7
+
8
+ end
9
+
10
+ def verify_header
11
+
12
+
13
+ end
14
+
15
+ end
@@ -139,7 +139,7 @@ myReshape = Proc.new {|w, h|
139
139
  # Keyboard handler to exit when ESC is typed
140
140
  keyboard = lambda do |key, x, y|
141
141
  case(key)
142
- when 27
142
+ when ?\e
143
143
  exit(0)
144
144
  end
145
145
  end
@@ -45,7 +45,7 @@ end
45
45
 
46
46
  keyboard = Proc.new do |key, x, y|
47
47
  case (key)
48
- when 27
48
+ when ?\e
49
49
  exit(0);
50
50
  end
51
51
  end
@@ -0,0 +1,34 @@
1
+ require 'opengl'
2
+ require 'sdl'
3
+
4
+ #init
5
+ SDL.init(SDL::INIT_VIDEO)
6
+ SDL.setGLAttr(SDL::GL_DOUBLEBUFFER,1)
7
+ SDL.setVideoMode(512,512,32,SDL::OPENGL)
8
+
9
+ # main loop
10
+ while true
11
+ while event = SDL::Event2.poll
12
+ case event
13
+ when SDL::Event2::KeyDown, SDL::Event2::Quit
14
+ exit
15
+ end
16
+ end
17
+
18
+ Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
19
+
20
+ Gl.glBegin( Gl::GL_POLYGON )
21
+ Gl.glColor3f( 1.0, 0.0, 0.0 )
22
+ Gl.glVertex2f( -0.5, -0.5 )
23
+ Gl.glColor3f( 0.0, 1.0, 0.0 )
24
+ Gl.glVertex2f( -0.5, 0.5 )
25
+ Gl.glColor3f( 0.0, 0.0, 1.0 )
26
+ Gl.glVertex2f( 0.5, 0.5 )
27
+ Gl.glColor3f( 1.0, 0.0, 1.0 )
28
+ Gl.glVertex2f( 0.5, -0.5 )
29
+ Gl.glEnd
30
+
31
+ SDL.GLSwapBuffers()
32
+
33
+ sleep 0.01 # to avoid consuming all CPU power
34
+ end