opengl-bindings 1.6.11 → 1.6.12

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.
data/README.md CHANGED
@@ -1,536 +1,656 @@
1
- <!-- -*- mode:markdown; coding:utf-8; -*- -->
2
-
3
- # Yet another OpenGL wrapper for Ruby #
4
-
5
- ...and wrapper code generator.
6
-
7
- * Created : 2013-08-28
8
- * Last modified : 2021-04-10
9
-
10
- [![Gem Version](https://badge.fury.io/rb/opengl-bindings.svg)](https://badge.fury.io/rb/opengl-bindings) [![Gem](https://img.shields.io/gem/dt/opengl-bindings.svg)](opengl-bindings)
11
-
12
- <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/simple_rb.jpg" width="200"> <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/nehe_lesson36_rb.jpg" width="200"> <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/brick_rb.jpg" width="200"> <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/glxs_rb.jpg" width="200">
13
-
14
-
15
- ## Features ##
16
-
17
- * Uses Fiddle (One of the Ruby standard libraries that wraps libffi)
18
- * Unlike opengl ( https://rubygems.org/gems/opengl ), you don't need to build C extension library
19
-
20
- * Uses Khronos XML API registry ( https://github.com/KhronosGroup/OpenGL-Registry )
21
- * The command/enum wrapper codes are generated via 'gl.xml'
22
- * Supports OpenGL - 4.6, OpenGL ES - 3.1 and all OpenGL extensions.
23
-
24
-
25
- ## How to install ##
26
-
27
- Via RubyGems ( https://rubygems.org/gems/opengl-bindings ):
28
-
29
- $ gem install opengl-bindings
30
-
31
- Or grab all library codes (`lib/*.rb') and use them by adding as one of the load paths like:
32
-
33
- $ ruby -I ./lib your_app.rb
34
-
35
-
36
- ## How to use ##
37
-
38
- See sample/simple.rb or sample/simple_glut.rb.
39
-
40
- To get more samples and generator scripts, please visit:
41
- https://github.com/vaiorabbit/ruby-opengl
42
-
43
-
44
- ## Contents ##
45
-
46
- * 'opengl.rb' includes these scripts:
47
- * 'opengl_command.rb' : OpenGL command wrapper (glDrawRangeElements, etc.). Generated via generator/generate_command.rb.
48
- * 'opengl_enum.rb' : OpenGL enum wrapper (GL_TRIANGLE_STRIP, etc.). Generated via generator/generate_enum.rb.
49
- * 'opengl_common.rb' : Provides utility functions.
50
- * 'opengl_platform.rb' : Provides platform check functions (OpneGL.get_platform).
51
- * 'opengl_windows.rb' : Provides functions for Windows platform (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC).
52
- * 'opengl_macosx.rb' : Provides functions for Mac OS X platform (CGLGetCurrentContext, CGLGetShareGroup).
53
- * 'opengl_linux.rb' : Provides functions for Linux (X Window) platform (glXGetCurrentContext, glXGetCurrentDisplay).
54
-
55
- * 'opengl_es.rb' is almost the same with 'opengl.rb', except for including 'opengl_es_command.rb' and 'opengl_es_enum.rb'.
56
-
57
- * 'opengl_ext.rb' includes these scripts:
58
- * 'opengl_ext_command.rb' : OpenGL extension command wrapper. Generated via generator/generate_ext_command.rb.
59
- * 'opengl_ext_enum.rb' : OpenGL extension enum wrapper Generated via generator/generate_ext_enum.rb.
60
- * 'opengl_ext_common.rb' : Provides utility functions.
61
-
62
- * 'opengl_es_ext.rb' is almost the same with 'opengl_ext.rb', except for including 'opengl_es_ext_command.rb' and 'opengl_es_ext_enum.rb'.
63
-
64
- * 'glfw.rb'
65
- * My handwritten GLFW wrapper.
66
-
67
- * 'glut.rb'
68
- * GLUT wrapper. Supports API Level 4 (GLUT_API_VERSION = 4).
69
-
70
- * 'glu.rb'
71
- * My handwritten GLU wrapper.
72
-
73
- * 'generator/gl.xml'
74
- * Khronos' official XML API registry for OpenGL.
75
-
76
- * 'generator/Rakefile'
77
- * Type 'rake' to generate wrapper codes / fetch gl.xml.
78
- * You can get the latest one by 'get_gl_xml.rb'.
79
-
80
- * 'sample/simple.rb', 'sample/simple_glut.rb'
81
- * Simple example.
82
- * simple.rb : You need to get glfw3.dll (Windows) or libglfw.dylib (Mac OS X). See sample/README.md.
83
- * simple_glut.rb : (For Windows uses) You need to get freeglut.dll. See sample/README.md.
84
-
85
- * 'sample/data', 'sample/util'
86
- * Data and utilities for sample programs.
87
-
88
- ## Prerequisites ##
89
-
90
- * Fiddle
91
- * A libffi wrapper
92
- * Standard library since Ruby 2.0.0
93
- * I recommend you to use Ruby 2.1.2 and later, which fixed Fiddle's memory leak issue (https://bugs.ruby-lang.org/issues/9599).
94
-
95
- ### For sample ###
96
-
97
- Use GLFW or GLUT for creating windows and OpenGL rendering contexts.
98
-
99
- * GLFW
100
- * http://www.glfw.org/
101
- * http://www.glfw.org/download.html
102
-
103
- * freeglut
104
- * http://freeglut.sourceforge.net
105
- * http://freeglut.sourceforge.net/index.php#download
106
-
107
-
108
- ## Tested Environment ##
109
-
110
- * Ruby
111
- * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
112
- * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
113
- * ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
114
- * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
115
- * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
116
- * ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
117
- * ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
118
- * ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
119
- * ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
120
- * ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
121
- * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
122
- * ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
123
- * ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
124
- * ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
125
- * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
126
- * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
127
- * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
128
- * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
129
- * ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
130
- * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
131
- * ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
132
- * ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mingw32]
133
- * ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
134
- * ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
135
- * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
136
-
137
- * Windows 10 Home, 64-bit (Version 1909, OS Build 18363.778)
138
- * NVIDIA GeForce RTX 2060 SUPER
139
- * OpenGL 4.5
140
-
141
- > ruby report_env.rb
142
- Version : 4.5.0 NVIDIA 436.30
143
- Vendor : NVIDIA Corporation
144
- Renderer : GeForce RTX 2060 SUPER/PCIe/SSE2
145
- Shader : 4.50 NVIDIA
146
-
147
- * Windows 10 Home, 64-bit (Version 1511, OS Build 10586.164)
148
- * NVIDIA GeForce GTX 960
149
- * OpenGL 4.5
150
-
151
- > ruby report_env.rb
152
- Version: 4.5.0 NVIDIA 364.72
153
-
154
- * Windows 7 Home Premium, 64-bit (Service Pack 1)
155
- * NVIDIA GeForce GTX 560
156
- * OpenGL 4.3
157
-
158
- > ruby report_env.rb
159
- 4.3.0
160
-
161
- * Windows 7 Home Premium, 64-bit (Service Pack 1)
162
- * NVIDIA GeForce GTX 560
163
- * OpenGL 4.3
164
-
165
- > ruby report_env.rb
166
- 4.3.0
167
-
168
- * Mac OS X 10.8.4, 64-bit
169
- * NVIDIA GeForce 320M on Mac mini (Mid 2010)
170
- * OpenGL 2.1
171
-
172
- $ ruby report_env.rb
173
- 2.1 NVIDIA-8.12.47 310.40.00.05f01
174
-
175
- * Mac OS X 10.10.5, 64-bit
176
- * Intel Iris on Mac mini (Late 2014)
177
- * OpenGL 4.1
178
-
179
- $ ruby report_env.rb
180
- Version: 4.1 INTEL-10.6.33
181
-
182
- * Mac OS X 10.15.3, 64-bit
183
- * Intel Iris on Mac mini (Late 2014)
184
- * OpenGL 4.1
185
-
186
- $ ruby report_env.rb
187
- Version : 4.1 INTEL-14.4.23
188
- Vendor : Intel Inc.
189
- Renderer : Intel Iris OpenGL Engine
190
- Shader : 4.10
191
-
192
- * Arch Linux kernel 4.1.2-2-ARCH, Nvidia Driver, x86_64
193
- * NVIDIA GeForce GTS 450
194
- * OpenGL 4.5.0
195
-
196
- $ ruby report_env.rb
197
- Version: 4.5.0 NVIDIA 352.21
198
-
199
- * Arch Linux kernel 4.1.4-1-ARCH, Nouveau Driver, x86_64
200
- * NVIDIA GeForce GTS 450
201
- * OpenGL 3.0
202
-
203
- $ ruby report_env.rb
204
- Version: 3.0 Mesa 10.6.3
205
-
206
- * You can use any lib/path names by passing as arguments like:
207
- * OpenGL.load_lib( 'libGL.so', '/usr/lib' )
208
- * GLFW.load_lib( 'libglfw.so', '/usr/lib' )
209
- * GLU.load_lib( 'libGLU.so', '/usr/lib' )
210
- * GLUT.load_lib( 'libglut.so', '/usr/lib' )
211
-
212
- ## Note ##
213
-
214
- * No Ruby-Style handy interfaces are available (like one in the ruby-opengl2 ( http://ruby-opengl.rubyforge.org/ ))
215
- * Example:
216
- * (Original C API)
217
-
218
- GLuint tex_names_buf[2];
219
- glGenTextures( 2, tex_names_buf );
220
- GLuint tex_name = tex_names_buf[0];
221
-
222
- * (This library)
223
-
224
- tex_names_buf = ' ' * 8 # String instance that is enough to catch texture names (integer).
225
- glGenTextures( 2, tex_names_buf )
226
- tex_name = tex_names_buf.unpack('L2')[0]
227
-
228
- * (ruby-opengl2)
229
-
230
- tex_name = glGenTextures( 2 )[0]
231
-
232
- * Projects using opengl-bindings
233
- * ruby-gnome2
234
- * https://github.com/ruby-gnome2/ruby-gnome2
235
- * https://github.com/ruby-gnome2/ruby-gnome2/tree/master/gtk3/sample/misc
236
- * gtkglarea1.rb, gtkglarea2.rb
237
- * FXRuby - A library for cross-platform graphical user interfaces
238
- * https://github.com/larskanis/fxruby/blob/1.6/examples/glviewer.rb
239
- * dxsdl2r
240
- * https://github.com/mirichi/dxsdl2r
241
- * mittsu - A direct port of THREE.js from JavaScript/WebGL to Ruby/OpenGL
242
- * https://rubygems.org/gems/mittsu
243
- * https://github.com/jellymann/mittsu
244
- * opencl-bindings - A Ruby binding for OpenCL 1.2
245
- * https://rubygems.org/gems/opencl-bindings
246
- * https://github.com/vaiorabbit/ruby-opencl
247
- * perfume_dance - A BVH motion parser and playback implementation written in Ruby
248
- * https://github.com/vaiorabbit/perfume_dance
249
- * open.gl.rb - A port of the https://open.gl/ tutorials to Ruby
250
- * https://github.com/mechazoidal/opendotgl_rb
251
-
252
- * Other informative projects
253
- * argon | neon
254
- * https://github.com/npomf/argon
255
- * https://bitbucket.org/npomf/neon/src
256
- * "vaiorabbit / ruby-opengl - as the basis for the OpenGL, OpenAL, and GLFW FFI libraries."
257
-
258
- ## License ##
259
-
260
- The zlib/libpng License ( http://opensource.org/licenses/Zlib ).
261
-
262
- Copyright (c) 2013-2020 vaiorabbit <http://twitter.com/vaiorabbit>
263
-
264
- This software is provided 'as-is', without any express or implied
265
- warranty. In no event will the authors be held liable for any damages
266
- arising from the use of this software.
267
-
268
- Permission is granted to anyone to use this software for any purpose,
269
- including commercial applications, and to alter it and redistribute it
270
- freely, subject to the following restrictions:
271
-
272
- 1. The origin of this software must not be misrepresented; you must not
273
- claim that you wrote the original software. If you use this software in a
274
- product, an acknowledgment in the product documentation would be
275
- appreciated but is not required.
276
-
277
- 2. Altered source versions must be plainly marked as such, and must not be
278
- misrepresented as being the original software.
279
-
280
- 3. This notice may not be removed or altered from any source distribution.
281
-
282
- Sample codes/resources under sample/GLExcess are provided under the GNU General
283
- Public License version 2. See sample/GLExcess/GPL2.txt .
284
-
285
- Sample codes under sample/OrangeBook are provided under the BSD 3-Clause License.
286
- See sample/OrangeBook/3Dlabs-License.txt .
287
-
288
- -------------------------------------------------------------------------------
289
-
290
- # Ruby 用 OpenGL ラッパー (とその自動生成スクリプト) #
291
-
292
- ## 特徴 ##
293
-
294
- * 標準ライブラリ Fiddle を使っています ⇒ opengl ( https://rubygems.org/gems/opengl ) のように拡張ライブラリをビルドする必要がありません
295
- * 関数とenumのラッパーコードは Khronos の XML API registry ( https://github.com/KhronosGroup/OpenGL-Registry ) の gl.xml から自動生成しています
296
-
297
-
298
- ## インストール ##
299
-
300
- RubyGems経由で ( https://rubygems.org/gems/opengl-bindings ):
301
-
302
- $ gem install opengl-bindings
303
-
304
- もしくは lib 以下の *.rb をコピー → その場所をロードパスに加えて次のように起動:
305
-
306
- $ ruby -I ./lib your_app.rb
307
-
308
-
309
- ## 使い方 ##
310
-
311
- sample/simple.rb または sample/simple_glut.rb を参照してください。
312
-
313
- その他のサンプルと自動生成スクリプトはこちらで開発しています:
314
- https://github.com/vaiorabbit/ruby-opengl
315
-
316
-
317
- ## 内容 ##
318
-
319
- * 'opengl.rb' require することで下記のスクリプトを取り込みます:
320
- * 'opengl_command.rb' : OpenGL 関数のラッパーコード (glDrawRangeElements, etc.)。 generator/generate_command.rb で自動生成されたものです。
321
- * 'opengl_enum.rb' : OpenGL enum のラッパーコード (GL_TRIANGLE_STRIP, etc.)。 generator/generate_enum.rb で自動生成されたものです。
322
- * 'opengl_common.rb' : 共通のユーティリティ関数を提供しています。
323
- * 'opengl_platform.rb' : 動作プラットフォームの判別機能を提供しています (OpneGL.get_platform)。
324
- * 'opengl_windows.rb' : Windows 用の機能を提供しています (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC).
325
- * 'opengl_macosx.rb' : Mac OS X 用の機能を提供しています (CGLGetCurrentContext, CGLGetShareGroup).
326
- * 'opengl_linux.rb' : Linux (X Window) 用の機能を提供しています (glXGetCurrentContext, glXGetCurrentDisplay).
327
-
328
- * 'opengl_es.rb' は 'opengl_es_command.rb' と 'opengl_es_enum.rb' を取り込む以外は 'opengl.rb' と同じです。
329
-
330
- * 'opengl_ext.rb' require することで下記のスクリプトを取り込みます:
331
- * 'opengl_ext_command.rb' : OpenGL 拡張関数のラッパーコード。 generator/generate_ext_command.rb で自動生成されたものです。
332
- * 'opengl_ext_enum.rb' : OpenGL 拡張enumのラッパーコード。 generator/generate_ext_enum.rb で自動生成されたものです。
333
-
334
- * 'opengl_es_ext.rb' 'opengl_es_ext_command.rb' 'opengl_es_ext_enum.rb' を取り込む以外は 'opengl_ext.rb' と同じです。
335
-
336
- * 'glfw.rb'
337
- * GLFW のラッパーコードです(自動生成ではありません)。
338
-
339
- * 'glut.rb'
340
- * GLUT ラッパー。API Level 4 までサポートしています (GLUT_API_VERSION = 4)。
341
-
342
-
343
- * 'glu.rb'
344
- * GLU のラッパーコードです(自動生成ではありません)。
345
-
346
- * 'generator/gl.xml'
347
- * Khronos 公式の XML API registry です。
348
-
349
- * 'generator/Rakefile'
350
- * 自動生成関連のタスクを自動化するためのものです。'rake' と打てば gl.xml の取得とラッパーコードの生成を実行します。
351
- * gl.xml の取得だけなど、単体のタスクなら 'get_gl_xml.rb' などの個別Rubyスクリプトでも実行できます。
352
-
353
- * 'sample/simple.rb', 'sample/simple_glut.rb'
354
- * 一番簡単なサンプルです。
355
- * simple.rb : 同じ場所に glfw3.dll (Windows) もしくは libglfw.dylib (Mac OS X) を置いてください。詳細は sample/README.md に記載されています。
356
- * simple_glut.rb : (Windows の場合) freeglut.dll を置いてください。詳細は sample/README.md に記載されています。
357
-
358
- * 'sample/data', 'sample/util'
359
- * サンプルで共有する機能・データの配置場所です。
360
-
361
-
362
- ## 必要なもの ##
363
-
364
- * Fiddle
365
- * libffi のラッパーです
366
- * Ruby 2.0.0 以降で標準ライブラリになりました
367
- * Fiddle のメモリリーク問題 (https://bugs.ruby-lang.org/issues/9599) が修正された Ruby 2.1.2 以降での利用を推奨します
368
-
369
- ### サンプル用 ###
370
-
371
- GLFW か GLUT を用意してください。ウィンドウやレンダリングコンテキストの管理に必要です。
372
-
373
- * GLFW
374
- * http://www.glfw.org/
375
- * http://www.glfw.org/download.html
376
-
377
- * freeglut
378
- * http://freeglut.sourceforge.net
379
- * http://freeglut.sourceforge.net/index.php#download
380
-
381
-
382
- ## テストした環境 ##
383
-
384
- * Ruby
385
- * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
386
- * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
387
- * ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
388
- * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
389
- * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
390
- * ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
391
- * ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
392
- * ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
393
- * ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
394
- * ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
395
- * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
396
- * ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
397
- * ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
398
- * ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
399
- * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
400
- * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
401
- * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
402
- * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
403
- * ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
404
- * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
405
- * ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
406
- * ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mingw32]
407
- * ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
408
- * ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
409
- * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
410
-
411
- * Windows 10 Home, 64-bit (Version 1909, OS Build 18363.778)
412
- * NVIDIA GeForce RTX 2060 SUPER
413
- * OpenGL 4.5
414
-
415
- > ruby report_env.rb
416
- Version : 4.5.0 NVIDIA 436.30
417
- Vendor : NVIDIA Corporation
418
- Renderer : GeForce RTX 2060 SUPER/PCIe/SSE2
419
- Shader : 4.50 NVIDIA
420
-
421
- * Windows 10 Home, 64-bit (Version 1511, OS Build 10586.164)
422
- * NVIDIA GeForce GTX 960
423
- * OpenGL 4.5
424
-
425
- > ruby report_env.rb
426
- Version: 4.5.0 NVIDIA 364.72
427
-
428
- * Windows 7 Home Premium, 64-bit (Service Pack 1)
429
- * NVIDIA GeForce GTX 560
430
- * OpenGL 4.3
431
-
432
- > ruby report_env.rb
433
- 4.3.0
434
-
435
- * Mac OS X 10.8.4, 64-bit
436
- * NVIDIA GeForce 320M on Mac mini (Mid 2010)
437
- * OpenGL 2.1
438
-
439
- $ ruby report_env.rb
440
- 2.1 NVIDIA-8.12.47 310.40.00.05f01
441
-
442
- * Mac OS X 10.10.5, 64-bit
443
- * Intel Iris on Mac mini (Late 2014)
444
- * OpenGL 4.1
445
-
446
- $ ruby report_env.rb
447
- Version: 4.1 INTEL-10.6.33
448
-
449
- * Mac OS X 10.15.3, 64-bit
450
- * Intel Iris on Mac mini (Late 2014)
451
- * OpenGL 4.1
452
-
453
- $ ruby report_env.rb
454
- Version : 4.1 INTEL-14.4.23
455
- Vendor : Intel Inc.
456
- Renderer : Intel Iris OpenGL Engine
457
- Shader : 4.10
458
-
459
- * Arch Linux kernel 4.1.2-2-ARCH, Nvidia Driver, x86_64
460
- * NVIDIA GeForce GTS 450
461
- * OpenGL 4.5.0
462
-
463
- $ ruby report_env.rb
464
- Version: 4.5.0 NVIDIA 352.21
465
-
466
- * Arch Linux kernel 4.1.4-1-ARCH, Nouveau Driver, x86_64
467
- * NVIDIA GeForce GTS 450
468
- * OpenGL 3.0
469
-
470
- $ ruby report_env.rb
471
- Version: 3.0 Mesa 10.6.3
472
-
473
- * 引数として渡すことで任意のライブラリ名/パス名を利用できます:
474
- * OpenGL.load_lib( 'libGL.so', '/usr/lib' )
475
- * GLFW.load_lib( 'libglfw.so', '/usr/lib' )
476
- * GLU.load_lib( 'libGLU.so', '/usr/lib' )
477
- * GLUT.load_lib( 'libglut.so', '/usr/lib' )
478
-
479
-
480
- ## メモ ##
481
-
482
- * Rubyスタイルの便利なインターフェースはサポートしていません (ruby-opengl2 ( http://ruby-opengl.rubyforge.org/ ) にあったような感じのもの)
483
- * 例:
484
- * (OpenGLオリジナルの C API)
485
-
486
- GLuint tex_names_buf[2];
487
- glGenTextures( 2, tex_names_buf );
488
- GLuint tex_name = tex_names_buf[0];
489
-
490
- * (このライブラリの場合)
491
-
492
- tex_names_buf = ' ' * 8 # テクスチャ名(GLuint)を受け取るのに十分なサイズ String インスタンスであればOK
493
- glGenTextures( 2, tex_names_buf )
494
- tex_name = tex_names_buf.unpack('L2')[0]
495
-
496
- * (ruby-opengl2 の場合)
497
-
498
- tex_name = glGenTextures( 2 )[0] # glGenTextures が配列を返すように修正されています
499
-
500
- * opengl-bindings を使ったプロジェクト
501
- * ruby-gnome2
502
- * https://github.com/ruby-gnome2/ruby-gnome2
503
- * https://github.com/ruby-gnome2/ruby-gnome2/tree/master/gtk3/sample/misc
504
- * gtkglarea1.rb, gtkglarea2.rb
505
- * FXRuby - A library for cross-platform graphical user interfaces
506
- * https://github.com/larskanis/fxruby/blob/1.6/examples/glviewer.rb
507
- * dxsdl2r
508
- * https://github.com/mirichi/dxsdl2r
509
- * mittsu - A direct port of THREE.js from JavaScript/WebGL to Ruby/OpenGL
510
- * https://rubygems.org/gems/mittsu
511
- * https://github.com/jellymann/mittsu
512
- * opencl-bindings - A Ruby binding for OpenCL 1.2
513
- * https://rubygems.org/gems/opencl-bindings
514
- * https://github.com/vaiorabbit/ruby-opencl
515
- * perfume_dance - A BVH motion parser and playback implementation written in Ruby
516
- * https://github.com/vaiorabbit/perfume_dance
517
- * open.gl.rb - A port of the https://open.gl/ tutorials to Ruby
518
- * https://github.com/mechazoidal/opendotgl_rb
519
-
520
- * 参考になりそうなプロジェクト
521
- * argon | neon
522
- * https://github.com/npomf/argon
523
- * https://bitbucket.org/npomf/neon/src
524
- * "vaiorabbit / ruby-opengl - as the basis for the OpenGL, OpenAL, and GLFW FFI libraries."
525
-
526
-
527
- ## ライセンス ##
528
-
529
- * zlib/libpng ライセンスです ( http://opensource.org/licenses/Zlib )。
530
-
531
- * sample/GLExcess 以下にあるものについては GNU General Public License version 2 です。
532
- sample/GLExcess/GPL2.txt を参照してください。
533
-
534
- * sample/OrangeBook 以下にあるものについては修正BSDライセンスです。
535
- sample/OrangeBook/3Dlabs-License.txt を参照してください。
536
-
1
+ <!-- -*- mode:markdown; coding:utf-8; -*- -->
2
+
3
+ # Yet another OpenGL wrapper for Ruby #
4
+
5
+ ...and wrapper code generator.
6
+
7
+ * Created : 2013-08-28
8
+ * Last modified : 2022-01-09
9
+
10
+ ---
11
+
12
+ ## Attention : Version 2 is now available ##
13
+
14
+ Though I will continue making this [version 1.6 series of opengl-bindings](https://rubygems.org/gems/opengl-bindings) available, please consider migrating to [opengl-bindings2](https://rubygems.org/gems/opengl-bindings2).
15
+
16
+ ### Redesigned API
17
+
18
+ In verion 2, all OpenGL APIs are defined as public methods under `module GL`, so we don't have to `include OpenGL` and scatter OpenGL APIs under other modules any more:
19
+
20
+ ```ruby
21
+ # opengl-bindings
22
+ require 'opengl'
23
+ include OpenGL
24
+ # ...
25
+ glEnable(GL_DEPTH_TEST)
26
+ ```
27
+
28
+ ```ruby
29
+ # opengl-bindings2
30
+ require 'opengl'
31
+ # ...
32
+ GL.Enable(GL::DEPTH_TEST)
33
+ ```
34
+
35
+ ### Improved efficiency
36
+
37
+ All redundant `nil` checks done on every API calls are removed in verion 2:
38
+
39
+ ```ruby
40
+ # opengl-bindings1
41
+ module OpenGL
42
+ #...
43
+ def self.get_command( sym )
44
+ if GL_FUNCTIONS_MAP[sym] == nil
45
+ bind_command( sym )
46
+ end
47
+ return GL_FUNCTIONS_MAP[sym]
48
+ end
49
+
50
+ #...
51
+
52
+ def glEnable(_cap_)
53
+ f = OpenGL::get_command(:glEnable) # Every API call caused redundant nil check here
54
+ f.call(_cap_)
55
+ end
56
+ ```
57
+
58
+ ```ruby
59
+ # opengl-bindings2
60
+ module GL
61
+ #...
62
+ def self.Enable(_cap_)
63
+ GL_FUNCTIONS_MAP[:glEnable].call(_cap_) # Hashmap is built on initialization so there's no need to do nil check at every API call
64
+ end
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Features ##
70
+
71
+ * Version 1 [![Gem Version](https://badge.fury.io/rb/opengl-bindings.svg)](https://badge.fury.io/rb/opengl-bindings) [![Gem](https://img.shields.io/gem/dt/opengl-bindings.svg)](opengl-bindings)
72
+ * Version 2 [![Gem Version](https://badge.fury.io/rb/opengl-bindings2.svg)](https://badge.fury.io/rb/opengl-bindings2) [![Gem](https://img.shields.io/gem/dt/opengl-bindings2.svg)](opengl-bindings2)
73
+
74
+ <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/simple_rb.jpg" width="200"> <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/nehe_lesson36_rb.jpg" width="200"> <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/brick_rb.jpg" width="200"> <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-opengl/master/doc/glxs_rb.jpg" width="200">
75
+
76
+ * Uses Fiddle (One of the Ruby standard libraries that wraps libffi)
77
+ * Unlike opengl ( https://rubygems.org/gems/opengl ), you don't need to build C extension library
78
+
79
+ * Uses Khronos XML API registry ( https://github.com/KhronosGroup/OpenGL-Registry )
80
+ * The command/enum wrapper codes are generated via 'gl.xml'
81
+ * Supports OpenGL - 4.6, OpenGL ES - 3.1 and all OpenGL extensions.
82
+
83
+
84
+ ## How to install ##
85
+
86
+ Via RubyGems ( https://rubygems.org/gems/opengl-bindings ):
87
+
88
+ $ gem install opengl-bindings
89
+
90
+ Or grab all library codes (`lib/*.rb') and use them by adding as one of the load paths like:
91
+
92
+ $ ruby -I ./lib your_app.rb
93
+
94
+
95
+ ## How to use ##
96
+
97
+ See sample/simple.rb or sample/simple_glut.rb.
98
+
99
+ To get more samples and generator scripts, please visit:
100
+ https://github.com/vaiorabbit/ruby-opengl
101
+
102
+
103
+ ## Contents ##
104
+
105
+ * 'opengl.rb' includes these scripts:
106
+ * 'opengl_command.rb' : OpenGL command wrapper (glDrawRangeElements, etc.). Generated via generator/generate_command.rb.
107
+ * 'opengl_enum.rb' : OpenGL enum wrapper (GL_TRIANGLE_STRIP, etc.). Generated via generator/generate_enum.rb.
108
+ * 'opengl_common.rb' : Provides utility functions.
109
+ * 'opengl_platform.rb' : Provides platform check functions (OpneGL.get_platform).
110
+ * 'opengl_windows.rb' : Provides functions for Windows platform (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC).
111
+ * 'opengl_macosx.rb' : Provides functions for Mac OS X platform (CGLGetCurrentContext, CGLGetShareGroup).
112
+ * 'opengl_linux.rb' : Provides functions for Linux (X Window) platform (glXGetCurrentContext, glXGetCurrentDisplay).
113
+
114
+ * 'opengl_es.rb' is almost the same with 'opengl.rb', except for including 'opengl_es_command.rb' and 'opengl_es_enum.rb'.
115
+
116
+ * 'opengl_ext.rb' includes these scripts:
117
+ * 'opengl_ext_command.rb' : OpenGL extension command wrapper. Generated via generator/generate_ext_command.rb.
118
+ * 'opengl_ext_enum.rb' : OpenGL extension enum wrapper Generated via generator/generate_ext_enum.rb.
119
+ * 'opengl_ext_common.rb' : Provides utility functions.
120
+
121
+ * 'opengl_es_ext.rb' is almost the same with 'opengl_ext.rb', except for including 'opengl_es_ext_command.rb' and 'opengl_es_ext_enum.rb'.
122
+
123
+ * 'glfw.rb'
124
+ * My handwritten GLFW wrapper.
125
+
126
+ * 'glut.rb'
127
+ * GLUT wrapper. Supports API Level 4 (GLUT_API_VERSION = 4).
128
+
129
+ * 'glu.rb'
130
+ * My handwritten GLU wrapper.
131
+
132
+ * 'generator/gl.xml'
133
+ * Khronos' official XML API registry for OpenGL.
134
+
135
+ * 'generator/Rakefile'
136
+ * Type 'rake' to generate wrapper codes / fetch gl.xml.
137
+ * You can get the latest one by 'get_gl_xml.rb'.
138
+
139
+ * 'sample/simple.rb', 'sample/simple_glut.rb'
140
+ * Simple example.
141
+ * simple.rb : You need to get glfw3.dll (Windows) or libglfw.dylib (Mac OS X). See sample/README.md.
142
+ * simple_glut.rb : (For Windows uses) You need to get freeglut.dll. See sample/README.md.
143
+
144
+ * 'sample/data', 'sample/util'
145
+ * Data and utilities for sample programs.
146
+
147
+ ## Prerequisites ##
148
+
149
+ * Fiddle
150
+ * A libffi wrapper
151
+ * Standard library since Ruby 2.0.0
152
+ * I recommend you to use Ruby 2.1.2 and later, which fixed Fiddle's memory leak issue (https://bugs.ruby-lang.org/issues/9599).
153
+
154
+ ### For sample ###
155
+
156
+ Use GLFW or GLUT for creating windows and OpenGL rendering contexts.
157
+
158
+ * GLFW
159
+ * http://www.glfw.org/
160
+ * http://www.glfw.org/download.html
161
+
162
+ * freeglut
163
+ * http://freeglut.sourceforge.net
164
+ * http://freeglut.sourceforge.net/index.php#download
165
+
166
+
167
+ ## Tested Environment ##
168
+
169
+ * Ruby
170
+ * ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
171
+ * ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
172
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
173
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
174
+ * ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
175
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
176
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
177
+ * ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
178
+ * ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
179
+ * ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
180
+ * ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
181
+ * ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
182
+ * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
183
+ * ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
184
+ * ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
185
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
186
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
187
+ * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
188
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
189
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
190
+ * ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
191
+ * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
192
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
193
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mingw32]
194
+ * ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
195
+ * ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
196
+ * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
197
+
198
+ * Windows 10 Home, 64-bit (Version 1909, OS Build 18363.778)
199
+ * NVIDIA GeForce RTX 2060 SUPER
200
+ * OpenGL 4.5
201
+
202
+ > ruby report_env.rb
203
+ Version : 4.5.0 NVIDIA 436.30
204
+ Vendor : NVIDIA Corporation
205
+ Renderer : GeForce RTX 2060 SUPER/PCIe/SSE2
206
+ Shader : 4.50 NVIDIA
207
+
208
+ * Windows 10 Home, 64-bit (Version 1511, OS Build 10586.164)
209
+ * NVIDIA GeForce GTX 960
210
+ * OpenGL 4.5
211
+
212
+ > ruby report_env.rb
213
+ Version: 4.5.0 NVIDIA 364.72
214
+
215
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
216
+ * NVIDIA GeForce GTX 560
217
+ * OpenGL 4.3
218
+
219
+ > ruby report_env.rb
220
+ 4.3.0
221
+
222
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
223
+ * NVIDIA GeForce GTX 560
224
+ * OpenGL 4.3
225
+
226
+ > ruby report_env.rb
227
+ 4.3.0
228
+
229
+ * Mac OS X 10.8.4, 64-bit
230
+ * NVIDIA GeForce 320M on Mac mini (Mid 2010)
231
+ * OpenGL 2.1
232
+
233
+ $ ruby report_env.rb
234
+ 2.1 NVIDIA-8.12.47 310.40.00.05f01
235
+
236
+ * Mac OS X 10.10.5, 64-bit
237
+ * Intel Iris on Mac mini (Late 2014)
238
+ * OpenGL 4.1
239
+
240
+ $ ruby report_env.rb
241
+ Version: 4.1 INTEL-10.6.33
242
+
243
+ * Mac OS X 10.15.3, 64-bit
244
+ * Intel Iris on Mac mini (Late 2014)
245
+ * OpenGL 4.1
246
+
247
+ $ ruby report_env.rb
248
+ Version : 4.1 INTEL-14.4.23
249
+ Vendor : Intel Inc.
250
+ Renderer : Intel Iris OpenGL Engine
251
+ Shader : 4.10
252
+
253
+ * Arch Linux kernel 4.1.2-2-ARCH, Nvidia Driver, x86_64
254
+ * NVIDIA GeForce GTS 450
255
+ * OpenGL 4.5.0
256
+
257
+ $ ruby report_env.rb
258
+ Version: 4.5.0 NVIDIA 352.21
259
+
260
+ * Arch Linux kernel 4.1.4-1-ARCH, Nouveau Driver, x86_64
261
+ * NVIDIA GeForce GTS 450
262
+ * OpenGL 3.0
263
+
264
+ $ ruby report_env.rb
265
+ Version: 3.0 Mesa 10.6.3
266
+
267
+ * You can use any lib/path names by passing as arguments like:
268
+ * OpenGL.load_lib( 'libGL.so', '/usr/lib' )
269
+ * GLFW.load_lib( 'libglfw.so', '/usr/lib' )
270
+ * GLU.load_lib( 'libGLU.so', '/usr/lib' )
271
+ * GLUT.load_lib( 'libglut.so', '/usr/lib' )
272
+
273
+ ## Note ##
274
+
275
+ * No Ruby-Style handy interfaces are available (like one in the ruby-opengl2 ( http://ruby-opengl.rubyforge.org/ ))
276
+ * Example:
277
+ * (Original C API)
278
+
279
+ GLuint tex_names_buf[2];
280
+ glGenTextures( 2, tex_names_buf );
281
+ GLuint tex_name = tex_names_buf[0];
282
+
283
+ * (This library)
284
+
285
+ tex_names_buf = ' ' * 8 # String instance that is enough to catch texture names (integer).
286
+ glGenTextures( 2, tex_names_buf )
287
+ tex_name = tex_names_buf.unpack('L2')[0]
288
+
289
+ * (ruby-opengl2)
290
+
291
+ tex_name = glGenTextures( 2 )[0]
292
+
293
+ * Projects using opengl-bindings
294
+ * ruby-gnome2
295
+ * https://github.com/ruby-gnome2/ruby-gnome2
296
+ * https://github.com/ruby-gnome2/ruby-gnome2/tree/master/gtk3/sample/misc
297
+ * gtkglarea1.rb, gtkglarea2.rb
298
+ * FXRuby - A library for cross-platform graphical user interfaces
299
+ * https://github.com/larskanis/fxruby/blob/1.6/examples/glviewer.rb
300
+ * dxsdl2r
301
+ * https://github.com/mirichi/dxsdl2r
302
+ * mittsu - A direct port of THREE.js from JavaScript/WebGL to Ruby/OpenGL
303
+ * https://rubygems.org/gems/mittsu
304
+ * https://github.com/jellymann/mittsu
305
+ * opencl-bindings - A Ruby binding for OpenCL 1.2
306
+ * https://rubygems.org/gems/opencl-bindings
307
+ * https://github.com/vaiorabbit/ruby-opencl
308
+ * perfume_dance - A BVH motion parser and playback implementation written in Ruby
309
+ * https://github.com/vaiorabbit/perfume_dance
310
+ * open.gl.rb - A port of the https://open.gl/ tutorials to Ruby
311
+ * https://github.com/mechazoidal/opendotgl_rb
312
+
313
+ * Other informative projects
314
+ * argon | neon
315
+ * https://github.com/npomf/argon
316
+ * https://bitbucket.org/npomf/neon/src
317
+ * "vaiorabbit / ruby-opengl - as the basis for the OpenGL, OpenAL, and GLFW FFI libraries."
318
+
319
+ ## License ##
320
+
321
+ The zlib/libpng License ( http://opensource.org/licenses/Zlib ).
322
+
323
+ Copyright (c) 2013-2020 vaiorabbit <http://twitter.com/vaiorabbit>
324
+
325
+ This software is provided 'as-is', without any express or implied
326
+ warranty. In no event will the authors be held liable for any damages
327
+ arising from the use of this software.
328
+
329
+ Permission is granted to anyone to use this software for any purpose,
330
+ including commercial applications, and to alter it and redistribute it
331
+ freely, subject to the following restrictions:
332
+
333
+ 1. The origin of this software must not be misrepresented; you must not
334
+ claim that you wrote the original software. If you use this software in a
335
+ product, an acknowledgment in the product documentation would be
336
+ appreciated but is not required.
337
+
338
+ 2. Altered source versions must be plainly marked as such, and must not be
339
+ misrepresented as being the original software.
340
+
341
+ 3. This notice may not be removed or altered from any source distribution.
342
+
343
+ Sample codes/resources under sample/GLExcess are provided under the GNU General
344
+ Public License version 2. See sample/GLExcess/GPL2.txt .
345
+
346
+ Sample codes under sample/OrangeBook are provided under the BSD 3-Clause License.
347
+ See sample/OrangeBook/3Dlabs-License.txt .
348
+
349
+ -------------------------------------------------------------------------------
350
+
351
+ # Ruby OpenGL ラッパー (とその自動生成スクリプト) #
352
+
353
+ ## Version 2 が利用可能です ##
354
+
355
+ [Version 1.6 系の opengl-bindings](https://rubygems.org/gems/opengl-bindings) も引き続き利用できるようにしますが、[opengl-bindings2](https://rubygems.org/gems/opengl-bindings2) への移行を検討してください。
356
+
357
+ ### API の修正
358
+
359
+ Version 2 では OpenGL API が `module GL` の public メソッドとして定義され、`include OpenGL` を実行する必要がなくなりました。
360
+
361
+ ```ruby
362
+ # opengl-bindings
363
+ require 'opengl'
364
+ include OpenGL
365
+ # ...
366
+ glEnable(GL_DEPTH_TEST)
367
+ ```
368
+
369
+ ```ruby
370
+ # opengl-bindings2
371
+ require 'opengl'
372
+ # ...
373
+ GL.Enable(GL::DEPTH_TEST)
374
+ ```
375
+
376
+ ### 効率の改善
377
+
378
+ API を呼ぶたびに走っていた無駄な `nil` のチェックが Version 2 では削除されています。
379
+
380
+ ```ruby
381
+ # opengl-bindings1
382
+ module OpenGL
383
+ #...
384
+ def self.get_command( sym )
385
+ if GL_FUNCTIONS_MAP[sym] == nil
386
+ bind_command( sym )
387
+ end
388
+ return GL_FUNCTIONS_MAP[sym]
389
+ end
390
+
391
+ #...
392
+
393
+ def glEnable(_cap_)
394
+ f = OpenGL::get_command(:glEnable) # Every API call caused redundant nil check here
395
+ f.call(_cap_)
396
+ end
397
+ ```
398
+
399
+ ```ruby
400
+ # opengl-bindings2
401
+ module GL
402
+ #...
403
+ def self.Enable(_cap_)
404
+ GL_FUNCTIONS_MAP[:glEnable].call(_cap_) # Hashmap is built on initialization so there's no need to do nil check at every API call
405
+ end
406
+ ```
407
+
408
+ ---
409
+
410
+ ## 特徴 ##
411
+
412
+ * 標準ライブラリ Fiddle を使っています opengl ( https://rubygems.org/gems/opengl ) のように拡張ライブラリをビルドする必要がありません
413
+ * 関数とenumのラッパーコードは Khronos の XML API registry ( https://github.com/KhronosGroup/OpenGL-Registry ) の gl.xml から自動生成しています
414
+
415
+
416
+ ## インストール ##
417
+
418
+ RubyGems経由で ( https://rubygems.org/gems/opengl-bindings ):
419
+
420
+ $ gem install opengl-bindings
421
+
422
+ もしくは lib 以下の *.rb をコピー → その場所をロードパスに加えて次のように起動:
423
+
424
+ $ ruby -I ./lib your_app.rb
425
+
426
+
427
+ ## 使い方 ##
428
+
429
+ sample/simple.rb または sample/simple_glut.rb を参照してください。
430
+
431
+ その他のサンプルと自動生成スクリプトはこちらで開発しています:
432
+ https://github.com/vaiorabbit/ruby-opengl
433
+
434
+
435
+ ## 内容 ##
436
+
437
+ * 'opengl.rb' を require することで下記のスクリプトを取り込みます:
438
+ * 'opengl_command.rb' : OpenGL 関数のラッパーコード (glDrawRangeElements, etc.)。 generator/generate_command.rb で自動生成されたものです。
439
+ * 'opengl_enum.rb' : OpenGL enum のラッパーコード (GL_TRIANGLE_STRIP, etc.)。 generator/generate_enum.rb で自動生成されたものです。
440
+ * 'opengl_common.rb' : 共通のユーティリティ関数を提供しています。
441
+ * 'opengl_platform.rb' : 動作プラットフォームの判別機能を提供しています (OpneGL.get_platform)。
442
+ * 'opengl_windows.rb' : Windows 用の機能を提供しています (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC).
443
+ * 'opengl_macosx.rb' : Mac OS X 用の機能を提供しています (CGLGetCurrentContext, CGLGetShareGroup).
444
+ * 'opengl_linux.rb' : Linux (X Window) 用の機能を提供しています (glXGetCurrentContext, glXGetCurrentDisplay).
445
+
446
+ * 'opengl_es.rb' 'opengl_es_command.rb' と 'opengl_es_enum.rb' を取り込む以外は 'opengl.rb' と同じです。
447
+
448
+ * 'opengl_ext.rb' を require することで下記のスクリプトを取り込みます:
449
+ * 'opengl_ext_command.rb' : OpenGL 拡張関数のラッパーコード。 generator/generate_ext_command.rb で自動生成されたものです。
450
+ * 'opengl_ext_enum.rb' : OpenGL 拡張enumのラッパーコード。 generator/generate_ext_enum.rb で自動生成されたものです。
451
+
452
+ * 'opengl_es_ext.rb' は 'opengl_es_ext_command.rb' と 'opengl_es_ext_enum.rb' を取り込む以外は 'opengl_ext.rb' と同じです。
453
+
454
+ * 'glfw.rb'
455
+ * GLFW のラッパーコードです(自動生成ではありません)。
456
+
457
+ * 'glut.rb'
458
+ * GLUT ラッパー。API Level 4 までサポートしています (GLUT_API_VERSION = 4)。
459
+
460
+
461
+ * 'glu.rb'
462
+ * GLU のラッパーコードです(自動生成ではありません)。
463
+
464
+ * 'generator/gl.xml'
465
+ * Khronos 公式の XML API registry です。
466
+
467
+ * 'generator/Rakefile'
468
+ * 自動生成関連のタスクを自動化するためのものです。'rake' と打てば gl.xml の取得とラッパーコードの生成を実行します。
469
+ * gl.xml の取得だけなど、単体のタスクなら 'get_gl_xml.rb' などの個別Rubyスクリプトでも実行できます。
470
+
471
+ * 'sample/simple.rb', 'sample/simple_glut.rb'
472
+ * 一番簡単なサンプルです。
473
+ * simple.rb : 同じ場所に glfw3.dll (Windows) もしくは libglfw.dylib (Mac OS X) を置いてください。詳細は sample/README.md に記載されています。
474
+ * simple_glut.rb : (Windows の場合) freeglut.dll を置いてください。詳細は sample/README.md に記載されています。
475
+
476
+ * 'sample/data', 'sample/util'
477
+ * サンプルで共有する機能・データの配置場所です。
478
+
479
+
480
+ ## 必要なもの ##
481
+
482
+ * Fiddle
483
+ * libffi のラッパーです
484
+ * Ruby 2.0.0 以降で標準ライブラリになりました
485
+ * Fiddle のメモリリーク問題 (https://bugs.ruby-lang.org/issues/9599) が修正された Ruby 2.1.2 以降での利用を推奨します
486
+
487
+ ### サンプル用 ###
488
+
489
+ GLFW か GLUT を用意してください。ウィンドウやレンダリングコンテキストの管理に必要です。
490
+
491
+ * GLFW
492
+ * http://www.glfw.org/
493
+ * http://www.glfw.org/download.html
494
+
495
+ * freeglut
496
+ * http://freeglut.sourceforge.net
497
+ * http://freeglut.sourceforge.net/index.php#download
498
+
499
+
500
+ ## テストした環境 ##
501
+
502
+ * Ruby
503
+ * ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
504
+ * ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
505
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
506
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
507
+ * ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
508
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
509
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
510
+ * ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
511
+ * ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
512
+ * ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
513
+ * ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
514
+ * ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
515
+ * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
516
+ * ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
517
+ * ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
518
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
519
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
520
+ * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
521
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
522
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
523
+ * ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
524
+ * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
525
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
526
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mingw32]
527
+ * ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
528
+ * ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
529
+ * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
530
+
531
+ * Windows 10 Home, 64-bit (Version 1909, OS Build 18363.778)
532
+ * NVIDIA GeForce RTX 2060 SUPER
533
+ * OpenGL 4.5
534
+
535
+ > ruby report_env.rb
536
+ Version : 4.5.0 NVIDIA 436.30
537
+ Vendor : NVIDIA Corporation
538
+ Renderer : GeForce RTX 2060 SUPER/PCIe/SSE2
539
+ Shader : 4.50 NVIDIA
540
+
541
+ * Windows 10 Home, 64-bit (Version 1511, OS Build 10586.164)
542
+ * NVIDIA GeForce GTX 960
543
+ * OpenGL 4.5
544
+
545
+ > ruby report_env.rb
546
+ Version: 4.5.0 NVIDIA 364.72
547
+
548
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
549
+ * NVIDIA GeForce GTX 560
550
+ * OpenGL 4.3
551
+
552
+ > ruby report_env.rb
553
+ 4.3.0
554
+
555
+ * Mac OS X 10.8.4, 64-bit
556
+ * NVIDIA GeForce 320M on Mac mini (Mid 2010)
557
+ * OpenGL 2.1
558
+
559
+ $ ruby report_env.rb
560
+ 2.1 NVIDIA-8.12.47 310.40.00.05f01
561
+
562
+ * Mac OS X 10.10.5, 64-bit
563
+ * Intel Iris on Mac mini (Late 2014)
564
+ * OpenGL 4.1
565
+
566
+ $ ruby report_env.rb
567
+ Version: 4.1 INTEL-10.6.33
568
+
569
+ * Mac OS X 10.15.3, 64-bit
570
+ * Intel Iris on Mac mini (Late 2014)
571
+ * OpenGL 4.1
572
+
573
+ $ ruby report_env.rb
574
+ Version : 4.1 INTEL-14.4.23
575
+ Vendor : Intel Inc.
576
+ Renderer : Intel Iris OpenGL Engine
577
+ Shader : 4.10
578
+
579
+ * Arch Linux kernel 4.1.2-2-ARCH, Nvidia Driver, x86_64
580
+ * NVIDIA GeForce GTS 450
581
+ * OpenGL 4.5.0
582
+
583
+ $ ruby report_env.rb
584
+ Version: 4.5.0 NVIDIA 352.21
585
+
586
+ * Arch Linux kernel 4.1.4-1-ARCH, Nouveau Driver, x86_64
587
+ * NVIDIA GeForce GTS 450
588
+ * OpenGL 3.0
589
+
590
+ $ ruby report_env.rb
591
+ Version: 3.0 Mesa 10.6.3
592
+
593
+ * 引数として渡すことで任意のライブラリ名/パス名を利用できます:
594
+ * OpenGL.load_lib( 'libGL.so', '/usr/lib' )
595
+ * GLFW.load_lib( 'libglfw.so', '/usr/lib' )
596
+ * GLU.load_lib( 'libGLU.so', '/usr/lib' )
597
+ * GLUT.load_lib( 'libglut.so', '/usr/lib' )
598
+
599
+
600
+ ## メモ ##
601
+
602
+ * Rubyスタイルの便利なインターフェースはサポートしていません (ruby-opengl2 ( http://ruby-opengl.rubyforge.org/ ) にあったような感じのもの)
603
+ * 例:
604
+ * (OpenGLオリジナルの C API)
605
+
606
+ GLuint tex_names_buf[2];
607
+ glGenTextures( 2, tex_names_buf );
608
+ GLuint tex_name = tex_names_buf[0];
609
+
610
+ * (このライブラリの場合)
611
+
612
+ tex_names_buf = ' ' * 8 # テクスチャ名(GLuint)を受け取るのに十分なサイズ String インスタンスであればOK
613
+ glGenTextures( 2, tex_names_buf )
614
+ tex_name = tex_names_buf.unpack('L2')[0]
615
+
616
+ * (ruby-opengl2 の場合)
617
+
618
+ tex_name = glGenTextures( 2 )[0] # glGenTextures が配列を返すように修正されています
619
+
620
+ * opengl-bindings を使ったプロジェクト
621
+ * ruby-gnome2
622
+ * https://github.com/ruby-gnome2/ruby-gnome2
623
+ * https://github.com/ruby-gnome2/ruby-gnome2/tree/master/gtk3/sample/misc
624
+ * gtkglarea1.rb, gtkglarea2.rb
625
+ * FXRuby - A library for cross-platform graphical user interfaces
626
+ * https://github.com/larskanis/fxruby/blob/1.6/examples/glviewer.rb
627
+ * dxsdl2r
628
+ * https://github.com/mirichi/dxsdl2r
629
+ * mittsu - A direct port of THREE.js from JavaScript/WebGL to Ruby/OpenGL
630
+ * https://rubygems.org/gems/mittsu
631
+ * https://github.com/jellymann/mittsu
632
+ * opencl-bindings - A Ruby binding for OpenCL 1.2
633
+ * https://rubygems.org/gems/opencl-bindings
634
+ * https://github.com/vaiorabbit/ruby-opencl
635
+ * perfume_dance - A BVH motion parser and playback implementation written in Ruby
636
+ * https://github.com/vaiorabbit/perfume_dance
637
+ * open.gl.rb - A port of the https://open.gl/ tutorials to Ruby
638
+ * https://github.com/mechazoidal/opendotgl_rb
639
+
640
+ * 参考になりそうなプロジェクト
641
+ * argon | neon
642
+ * https://github.com/npomf/argon
643
+ * https://bitbucket.org/npomf/neon/src
644
+ * "vaiorabbit / ruby-opengl - as the basis for the OpenGL, OpenAL, and GLFW FFI libraries."
645
+
646
+
647
+ ## ライセンス ##
648
+
649
+ * zlib/libpng ライセンスです ( http://opensource.org/licenses/Zlib )。
650
+
651
+ * sample/GLExcess 以下にあるものについては GNU General Public License version 2 です。
652
+ sample/GLExcess/GPL2.txt を参照してください。
653
+
654
+ * sample/OrangeBook 以下にあるものについては修正BSDライセンスです。
655
+ sample/OrangeBook/3Dlabs-License.txt を参照してください。
656
+