opengl-bindings 1.6.11 → 1.6.13

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,676 @@
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-07-18
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 version 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 version 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.2.0 (2022-12-25 revision a528908271) [arm64-darwin21]
171
+
172
+ * Windows 10 Home, 64-bit (Version 1909, OS Build 18363.778)
173
+ * NVIDIA GeForce RTX 2060 SUPER
174
+ * OpenGL 4.5
175
+
176
+ > ruby report_env.rb
177
+ Version : 4.5.0 NVIDIA 436.30
178
+ Vendor : NVIDIA Corporation
179
+ Renderer : GeForce RTX 2060 SUPER/PCIe/SSE2
180
+ Shader : 4.50 NVIDIA
181
+
182
+ * macOS 12.5.1, 64-bit
183
+ * Mac mini (M1 2020)
184
+ * OpenGL 4.1
185
+
186
+ $ ruby report_env.rb
187
+ Version : 4.1 Metal - 76.3
188
+ Vendor : Apple
189
+ Renderer : Apple M1
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
+ <details>
207
+ <summary>Older versions</summary>
208
+
209
+ * Ruby
210
+ * ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin20]
211
+ * ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]
212
+ * ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
213
+ * ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
214
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
215
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
216
+ * ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
217
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
218
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
219
+ * ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
220
+ * ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
221
+ * ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
222
+ * ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
223
+ * ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
224
+ * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
225
+ * ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
226
+ * ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
227
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
228
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
229
+ * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
230
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
231
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
232
+ * ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
233
+ * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
234
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
235
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mingw32]
236
+ * ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
237
+ * ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
238
+ * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
239
+
240
+ * Windows 10 Home, 64-bit (Version 1511, OS Build 10586.164)
241
+ * NVIDIA GeForce GTX 960
242
+ * OpenGL 4.5
243
+
244
+ > ruby report_env.rb
245
+ Version: 4.5.0 NVIDIA 364.72
246
+
247
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
248
+ * NVIDIA GeForce GTX 560
249
+ * OpenGL 4.3
250
+
251
+ > ruby report_env.rb
252
+ 4.3.0
253
+
254
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
255
+ * NVIDIA GeForce GTX 560
256
+ * OpenGL 4.3
257
+
258
+ > ruby report_env.rb
259
+ 4.3.0
260
+
261
+ * Mac OS X 10.8.4, 64-bit
262
+ * NVIDIA GeForce 320M on Mac mini (Mid 2010)
263
+ * OpenGL 2.1
264
+
265
+ $ ruby report_env.rb
266
+ 2.1 NVIDIA-8.12.47 310.40.00.05f01
267
+
268
+ * Mac OS X 10.10.5, 64-bit
269
+ * Intel Iris on Mac mini (Late 2014)
270
+ * OpenGL 4.1
271
+
272
+ $ ruby report_env.rb
273
+ Version: 4.1 INTEL-10.6.33
274
+
275
+ * Mac OS X 10.15.3, 64-bit
276
+ * Intel Iris on Mac mini (Late 2014)
277
+ * OpenGL 4.1
278
+
279
+ $ ruby report_env.rb
280
+ Version : 4.1 INTEL-14.4.23
281
+ Vendor : Intel Inc.
282
+ Renderer : Intel Iris OpenGL Engine
283
+ Shader : 4.10
284
+
285
+ </details>
286
+
287
+ * You can use any lib/path names by passing as arguments like:
288
+ * OpenGL.load_lib( 'libGL.so', '/usr/lib' )
289
+ * GLFW.load_lib( 'libglfw.so', '/usr/lib' )
290
+ * GLU.load_lib( 'libGLU.so', '/usr/lib' )
291
+ * GLUT.load_lib( 'libglut.so', '/usr/lib' )
292
+
293
+ ## Note ##
294
+
295
+ * No Ruby-Style handy interfaces are available (like one in the ruby-opengl2 ( http://ruby-opengl.rubyforge.org/ ))
296
+ * Example:
297
+ * (Original C API)
298
+
299
+ GLuint tex_names_buf[2];
300
+ glGenTextures( 2, tex_names_buf );
301
+ GLuint tex_name = tex_names_buf[0];
302
+
303
+ * (This library)
304
+
305
+ tex_names_buf = ' ' * 8 # String instance that is enough to catch texture names (integer).
306
+ glGenTextures( 2, tex_names_buf )
307
+ tex_name = tex_names_buf.unpack('L2')[0]
308
+
309
+ * (ruby-opengl2)
310
+
311
+ tex_name = glGenTextures( 2 )[0]
312
+
313
+ * Projects using opengl-bindings
314
+ * ruby-gnome2
315
+ * https://github.com/ruby-gnome2/ruby-gnome2
316
+ * https://github.com/ruby-gnome2/ruby-gnome2/tree/master/gtk3/sample/misc
317
+ * gtkglarea1.rb, gtkglarea2.rb
318
+ * FXRuby - A library for cross-platform graphical user interfaces
319
+ * https://github.com/larskanis/fxruby/blob/1.6/examples/glviewer.rb
320
+ * dxsdl2r
321
+ * https://github.com/mirichi/dxsdl2r
322
+ * mittsu - A direct port of THREE.js from JavaScript/WebGL to Ruby/OpenGL
323
+ * https://rubygems.org/gems/mittsu
324
+ * https://github.com/jellymann/mittsu
325
+ * opencl-bindings - A Ruby binding for OpenCL 1.2
326
+ * https://rubygems.org/gems/opencl-bindings
327
+ * https://github.com/vaiorabbit/ruby-opencl
328
+ * perfume_dance - A BVH motion parser and playback implementation written in Ruby
329
+ * https://github.com/vaiorabbit/perfume_dance
330
+ * open.gl.rb - A port of the https://open.gl/ tutorials to Ruby
331
+ * https://github.com/mechazoidal/opendotgl_rb
332
+
333
+ * Other informative projects
334
+ * argon | neon
335
+ * https://github.com/npomf/argon
336
+ * https://bitbucket.org/npomf/neon/src
337
+ * "vaiorabbit / ruby-opengl - as the basis for the OpenGL, OpenAL, and GLFW FFI libraries."
338
+
339
+ ## License ##
340
+
341
+ The zlib/libpng License ( http://opensource.org/licenses/Zlib ).
342
+
343
+ Copyright (c) 2013-2023 vaiorabbit <http://twitter.com/vaiorabbit>
344
+
345
+ This software is provided 'as-is', without any express or implied
346
+ warranty. In no event will the authors be held liable for any damages
347
+ arising from the use of this software.
348
+
349
+ Permission is granted to anyone to use this software for any purpose,
350
+ including commercial applications, and to alter it and redistribute it
351
+ freely, subject to the following restrictions:
352
+
353
+ 1. The origin of this software must not be misrepresented; you must not
354
+ claim that you wrote the original software. If you use this software in a
355
+ product, an acknowledgment in the product documentation would be
356
+ appreciated but is not required.
357
+
358
+ 2. Altered source versions must be plainly marked as such, and must not be
359
+ misrepresented as being the original software.
360
+
361
+ 3. This notice may not be removed or altered from any source distribution.
362
+
363
+ Sample codes/resources under sample/GLExcess are provided under the GNU General
364
+ Public License version 2. See sample/GLExcess/GPL2.txt .
365
+
366
+ Sample codes under sample/OrangeBook are provided under the BSD 3-Clause License.
367
+ See sample/OrangeBook/3Dlabs-License.txt .
368
+
369
+ -------------------------------------------------------------------------------
370
+
371
+ # Ruby OpenGL ラッパー (とその自動生成スクリプト) #
372
+
373
+ ## Version 2 が利用可能です ##
374
+
375
+ [Version 1.6 系の opengl-bindings](https://rubygems.org/gems/opengl-bindings) も引き続き利用できるようにしますが、[opengl-bindings2](https://rubygems.org/gems/opengl-bindings2) への移行を検討してください。
376
+
377
+ ### API の修正
378
+
379
+ Version 2 では OpenGL API が `module GL` の public メソッドとして定義され、`include OpenGL` を実行する必要がなくなりました。
380
+
381
+ ```ruby
382
+ # opengl-bindings
383
+ require 'opengl'
384
+ include OpenGL
385
+ # ...
386
+ glEnable(GL_DEPTH_TEST)
387
+ ```
388
+
389
+ ```ruby
390
+ # opengl-bindings2
391
+ require 'opengl'
392
+ # ...
393
+ GL.Enable(GL::DEPTH_TEST)
394
+ ```
395
+
396
+ ### 効率の改善
397
+
398
+ API を呼ぶたびに走っていた無駄な `nil` のチェックが Version 2 では削除されています。
399
+
400
+ ```ruby
401
+ # opengl-bindings1
402
+ module OpenGL
403
+ #...
404
+ def self.get_command( sym )
405
+ if GL_FUNCTIONS_MAP[sym] == nil
406
+ bind_command( sym )
407
+ end
408
+ return GL_FUNCTIONS_MAP[sym]
409
+ end
410
+
411
+ #...
412
+
413
+ def glEnable(_cap_)
414
+ f = OpenGL::get_command(:glEnable) # Every API call caused redundant nil check here
415
+ f.call(_cap_)
416
+ end
417
+ ```
418
+
419
+ ```ruby
420
+ # opengl-bindings2
421
+ module GL
422
+ #...
423
+ def self.Enable(_cap_)
424
+ GL_FUNCTIONS_MAP[:glEnable].call(_cap_) # Hashmap is built on initialization so there's no need to do nil check at every API call
425
+ end
426
+ ```
427
+
428
+ ---
429
+
430
+ ## 特徴 ##
431
+
432
+ * 標準ライブラリ Fiddle を使っています ⇒ opengl ( https://rubygems.org/gems/opengl ) のように拡張ライブラリをビルドする必要がありません
433
+ * 関数とenumのラッパーコードは Khronos の XML API registry ( https://github.com/KhronosGroup/OpenGL-Registry ) の gl.xml から自動生成しています
434
+
435
+
436
+ ## インストール ##
437
+
438
+ RubyGems経由で ( https://rubygems.org/gems/opengl-bindings ):
439
+
440
+ $ gem install opengl-bindings
441
+
442
+ もしくは lib 以下の *.rb をコピー → その場所をロードパスに加えて次のように起動:
443
+
444
+ $ ruby -I ./lib your_app.rb
445
+
446
+
447
+ ## 使い方 ##
448
+
449
+ sample/simple.rb または sample/simple_glut.rb を参照してください。
450
+
451
+ その他のサンプルと自動生成スクリプトはこちらで開発しています:
452
+ https://github.com/vaiorabbit/ruby-opengl
453
+
454
+
455
+ ## 内容 ##
456
+
457
+ * 'opengl.rb' を require することで下記のスクリプトを取り込みます:
458
+ * 'opengl_command.rb' : OpenGL 関数のラッパーコード (glDrawRangeElements, etc.)。 generator/generate_command.rb で自動生成されたものです。
459
+ * 'opengl_enum.rb' : OpenGL enum のラッパーコード (GL_TRIANGLE_STRIP, etc.)。 generator/generate_enum.rb で自動生成されたものです。
460
+ * 'opengl_common.rb' : 共通のユーティリティ関数を提供しています。
461
+ * 'opengl_platform.rb' : 動作プラットフォームの判別機能を提供しています (OpneGL.get_platform)。
462
+ * 'opengl_windows.rb' : Windows 用の機能を提供しています (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC).
463
+ * 'opengl_macosx.rb' : Mac OS X 用の機能を提供しています (CGLGetCurrentContext, CGLGetShareGroup).
464
+ * 'opengl_linux.rb' : Linux (X Window) 用の機能を提供しています (glXGetCurrentContext, glXGetCurrentDisplay).
465
+
466
+ * 'opengl_es.rb' 'opengl_es_command.rb' と 'opengl_es_enum.rb' を取り込む以外は 'opengl.rb' と同じです。
467
+
468
+ * 'opengl_ext.rb' を require することで下記のスクリプトを取り込みます:
469
+ * 'opengl_ext_command.rb' : OpenGL 拡張関数のラッパーコード。 generator/generate_ext_command.rb で自動生成されたものです。
470
+ * 'opengl_ext_enum.rb' : OpenGL 拡張enumのラッパーコード。 generator/generate_ext_enum.rb で自動生成されたものです。
471
+
472
+ * 'opengl_es_ext.rb' は 'opengl_es_ext_command.rb' と 'opengl_es_ext_enum.rb' を取り込む以外は 'opengl_ext.rb' と同じです。
473
+
474
+ * 'glfw.rb'
475
+ * GLFW のラッパーコードです(自動生成ではありません)
476
+
477
+ * 'glut.rb'
478
+ * GLUT ラッパー。API Level 4 までサポートしています (GLUT_API_VERSION = 4)。
479
+
480
+
481
+ * 'glu.rb'
482
+ * GLU のラッパーコードです(自動生成ではありません)
483
+
484
+ * 'generator/gl.xml'
485
+ * Khronos 公式の XML API registry です。
486
+
487
+ * 'generator/Rakefile'
488
+ * 自動生成関連のタスクを自動化するためのものです。'rake' と打てば gl.xml の取得とラッパーコードの生成を実行します。
489
+ * gl.xml の取得だけなど、単体のタスクなら 'get_gl_xml.rb' などの個別Rubyスクリプトでも実行できます。
490
+
491
+ * 'sample/simple.rb', 'sample/simple_glut.rb'
492
+ * 一番簡単なサンプルです。
493
+ * simple.rb : 同じ場所に glfw3.dll (Windows) もしくは libglfw.dylib (Mac OS X) を置いてください。詳細は sample/README.md に記載されています。
494
+ * simple_glut.rb : (Windows の場合) freeglut.dll を置いてください。詳細は sample/README.md に記載されています。
495
+
496
+ * 'sample/data', 'sample/util'
497
+ * サンプルで共有する機能・データの配置場所です。
498
+
499
+
500
+ ## 必要なもの ##
501
+
502
+ * Fiddle
503
+ * libffi のラッパーです
504
+ * Ruby 2.0.0 以降で標準ライブラリになりました
505
+ * Fiddle のメモリリーク問題 (https://bugs.ruby-lang.org/issues/9599) が修正された Ruby 2.1.2 以降での利用を推奨します
506
+
507
+ ### サンプル用 ###
508
+
509
+ GLFW GLUT を用意してください。ウィンドウやレンダリングコンテキストの管理に必要です。
510
+
511
+ * GLFW
512
+ * http://www.glfw.org/
513
+ * http://www.glfw.org/download.html
514
+
515
+ * freeglut
516
+ * http://freeglut.sourceforge.net
517
+ * http://freeglut.sourceforge.net/index.php#download
518
+
519
+
520
+ ## テストした環境 ##
521
+
522
+ * Ruby
523
+ * ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
524
+ * ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
525
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
526
+ * ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
527
+ * ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
528
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
529
+ * ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
530
+ * ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
531
+ * ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
532
+ * ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
533
+ * ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
534
+ * ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
535
+ * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
536
+ * ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
537
+ * ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
538
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
539
+ * ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
540
+ * ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
541
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
542
+ * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
543
+ * ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
544
+ * ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
545
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
546
+ * ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mingw32]
547
+ * ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
548
+ * ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
549
+ * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
550
+
551
+ * Windows 10 Home, 64-bit (Version 1909, OS Build 18363.778)
552
+ * NVIDIA GeForce RTX 2060 SUPER
553
+ * OpenGL 4.5
554
+
555
+ > ruby report_env.rb
556
+ Version : 4.5.0 NVIDIA 436.30
557
+ Vendor : NVIDIA Corporation
558
+ Renderer : GeForce RTX 2060 SUPER/PCIe/SSE2
559
+ Shader : 4.50 NVIDIA
560
+
561
+ * Windows 10 Home, 64-bit (Version 1511, OS Build 10586.164)
562
+ * NVIDIA GeForce GTX 960
563
+ * OpenGL 4.5
564
+
565
+ > ruby report_env.rb
566
+ Version: 4.5.0 NVIDIA 364.72
567
+
568
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
569
+ * NVIDIA GeForce GTX 560
570
+ * OpenGL 4.3
571
+
572
+ > ruby report_env.rb
573
+ 4.3.0
574
+
575
+ * Mac OS X 10.8.4, 64-bit
576
+ * NVIDIA GeForce 320M on Mac mini (Mid 2010)
577
+ * OpenGL 2.1
578
+
579
+ $ ruby report_env.rb
580
+ 2.1 NVIDIA-8.12.47 310.40.00.05f01
581
+
582
+ * Mac OS X 10.10.5, 64-bit
583
+ * Intel Iris on Mac mini (Late 2014)
584
+ * OpenGL 4.1
585
+
586
+ $ ruby report_env.rb
587
+ Version: 4.1 INTEL-10.6.33
588
+
589
+ * Mac OS X 10.15.3, 64-bit
590
+ * Intel Iris on Mac mini (Late 2014)
591
+ * OpenGL 4.1
592
+
593
+ $ ruby report_env.rb
594
+ Version : 4.1 INTEL-14.4.23
595
+ Vendor : Intel Inc.
596
+ Renderer : Intel Iris OpenGL Engine
597
+ Shader : 4.10
598
+
599
+ * Arch Linux kernel 4.1.2-2-ARCH, Nvidia Driver, x86_64
600
+ * NVIDIA GeForce GTS 450
601
+ * OpenGL 4.5.0
602
+
603
+ $ ruby report_env.rb
604
+ Version: 4.5.0 NVIDIA 352.21
605
+
606
+ * Arch Linux kernel 4.1.4-1-ARCH, Nouveau Driver, x86_64
607
+ * NVIDIA GeForce GTS 450
608
+ * OpenGL 3.0
609
+
610
+ $ ruby report_env.rb
611
+ Version: 3.0 Mesa 10.6.3
612
+
613
+ * 引数として渡すことで任意のライブラリ名/パス名を利用できます:
614
+ * OpenGL.load_lib( 'libGL.so', '/usr/lib' )
615
+ * GLFW.load_lib( 'libglfw.so', '/usr/lib' )
616
+ * GLU.load_lib( 'libGLU.so', '/usr/lib' )
617
+ * GLUT.load_lib( 'libglut.so', '/usr/lib' )
618
+
619
+
620
+ ## メモ ##
621
+
622
+ * Rubyスタイルの便利なインターフェースはサポートしていません (ruby-opengl2 ( http://ruby-opengl.rubyforge.org/ ) にあったような感じのもの)
623
+ * 例:
624
+ * (OpenGLオリジナルの C API)
625
+
626
+ GLuint tex_names_buf[2];
627
+ glGenTextures( 2, tex_names_buf );
628
+ GLuint tex_name = tex_names_buf[0];
629
+
630
+ * (このライブラリの場合)
631
+
632
+ tex_names_buf = ' ' * 8 # テクスチャ名(GLuint)を受け取るのに十分なサイズ String インスタンスであればOK
633
+ glGenTextures( 2, tex_names_buf )
634
+ tex_name = tex_names_buf.unpack('L2')[0]
635
+
636
+ * (ruby-opengl2 の場合)
637
+
638
+ tex_name = glGenTextures( 2 )[0] # glGenTextures が配列を返すように修正されています
639
+
640
+ * opengl-bindings を使ったプロジェクト
641
+ * ruby-gnome2
642
+ * https://github.com/ruby-gnome2/ruby-gnome2
643
+ * https://github.com/ruby-gnome2/ruby-gnome2/tree/master/gtk3/sample/misc
644
+ * gtkglarea1.rb, gtkglarea2.rb
645
+ * FXRuby - A library for cross-platform graphical user interfaces
646
+ * https://github.com/larskanis/fxruby/blob/1.6/examples/glviewer.rb
647
+ * dxsdl2r
648
+ * https://github.com/mirichi/dxsdl2r
649
+ * mittsu - A direct port of THREE.js from JavaScript/WebGL to Ruby/OpenGL
650
+ * https://rubygems.org/gems/mittsu
651
+ * https://github.com/jellymann/mittsu
652
+ * opencl-bindings - A Ruby binding for OpenCL 1.2
653
+ * https://rubygems.org/gems/opencl-bindings
654
+ * https://github.com/vaiorabbit/ruby-opencl
655
+ * perfume_dance - A BVH motion parser and playback implementation written in Ruby
656
+ * https://github.com/vaiorabbit/perfume_dance
657
+ * open.gl.rb - A port of the https://open.gl/ tutorials to Ruby
658
+ * https://github.com/mechazoidal/opendotgl_rb
659
+
660
+ * 参考になりそうなプロジェクト
661
+ * argon | neon
662
+ * https://github.com/npomf/argon
663
+ * https://bitbucket.org/npomf/neon/src
664
+ * "vaiorabbit / ruby-opengl - as the basis for the OpenGL, OpenAL, and GLFW FFI libraries."
665
+
666
+
667
+ ## ライセンス ##
668
+
669
+ * zlib/libpng ライセンスです ( http://opensource.org/licenses/Zlib )。
670
+
671
+ * sample/GLExcess 以下にあるものについては GNU General Public License version 2 です。
672
+ sample/GLExcess/GPL2.txt を参照してください。
673
+
674
+ * sample/OrangeBook 以下にあるものについては修正BSDライセンスです。
675
+ sample/OrangeBook/3Dlabs-License.txt を参照してください。
676
+