opengl-bindings 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aaf34ba647a0d10f96d95005bb9f7c9c5ce0e298
4
+ data.tar.gz: d705a711712e7ca59de0217300af197bd3803f84
5
+ SHA512:
6
+ metadata.gz: 8573d09a2d0d120fed63d15b33d8557c715f811dc457b86e0ffff1516ad058457ec69681ca8cc43a10474444528ef057c145404acd453a914c3593d103260613
7
+ data.tar.gz: 8ee82b84e8b5dea0cad1e4b8327e41f0fe6dee43100cfaa6feafd318602c3e062a609ff16c2a69f058ed60a87e063453ab18d2938a1b933e26c57b6b0a32193d
data/ChangeLog ADDED
@@ -0,0 +1,41 @@
1
+ 2013-09-15 vaiorabbit <https://twitter.com/vaiorabbit>
2
+
3
+ * opengl-bindings.gemspec: Added to make RubyGems package.
4
+ * Changed directory structure more RubyGems-compliant.
5
+
6
+ 2013-09-14 vaiorabbit <https://twitter.com/vaiorabbit>
7
+
8
+ * generator/aux_generate_typemap.rb: Fixed to handle signed/unsinged correctly.
9
+ * sample/GLExcess: Added.
10
+ * opengl_ext_enum.rb, generator/generate_ext_enum.rb: Now checks if same constant is already defined before cosnt_set.
11
+
12
+ 2013-09-08 vaiorabbit <https://twitter.com/vaiorabbit>
13
+
14
+ * opengl_ext_command.rb, opengl_ext_enum.rb, opengl_ext.rb: Added for OpenGL extension support.
15
+ * sample/report_env.rb: Reports the names of supported extensions.
16
+ * sample/Extension/nvpr_hello_world.rb: Added.
17
+
18
+ 2013-09-07 vaiorabbit <https://twitter.com/vaiorabbit>
19
+
20
+ * opengl_command.rb: Updated using latest gl.xml.
21
+ * opengl_command.rb: Fixed some bugs.
22
+ * opengl_command.rb, glu.rb (load_dll): Updated platform detection.
23
+ * sample/report_env.rb : Added.
24
+ * opengl_common.rb (check_extension): Added.
25
+
26
+ 2013-09-05 vaiorabbit <https://twitter.com/vaiorabbit>
27
+
28
+ * sample/ComputeShader: Added.
29
+
30
+ 2013-09-03 vaiorabbit <https://twitter.com/vaiorabbit>
31
+
32
+ * opengl_platform.rb, opengl_windows.rb: Added.
33
+
34
+ 2013-08-28 vaiorabbit <https://twitter.com/vaiorabbit>
35
+
36
+ * glu.rb: Added.
37
+
38
+ 2013-08-28 vaiorabbit <https://twitter.com/vaiorabbit>
39
+
40
+ * (Announce) First release.
41
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
2
+ Copyright (c) 2013- vaiorabbit <http://twitter.com/vaiorabbit>
3
+
4
+ This software is provided 'as-is', without any express or implied
5
+ warranty. In no event will the authors be held liable for any damages
6
+ arising from the use of this software.
7
+
8
+ Permission is granted to anyone to use this software for any purpose,
9
+ including commercial applications, and to alter it and redistribute it
10
+ freely, subject to the following restrictions:
11
+
12
+ 1. The origin of this software must not be misrepresented; you must not
13
+ claim that you wrote the original software. If you use this software
14
+ in a product, an acknowledgment in the product documentation would be
15
+ appreciated but is not required.
16
+
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+
20
+ 3. This notice may not be removed or altered from any source
21
+ distribution.
data/README.md ADDED
@@ -0,0 +1,299 @@
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 : 2013-09-15
9
+
10
+
11
+ ## Features ##
12
+
13
+ * Uses Fiddle (One of the Ruby standard libraries that wraps libffi)
14
+ * No need to build C extension library
15
+
16
+ * Uses Khronos XML API registry
17
+ * The command/enum wrapper codes are generated via 'gl.xml'
18
+ * Supports OpenGL 1.0 - 4.4, and all OpenGL extensions.
19
+
20
+
21
+ ## How to use ##
22
+
23
+ See sample/simple.rb.
24
+
25
+ To get more samples and generator scripts, please visit:
26
+ https://github.com/vaiorabbit/ruby-opengl
27
+
28
+
29
+ ## Contents ##
30
+
31
+ * 'opengl.rb' includes these scripts:
32
+ * 'opengl_command.rb' : OpenGL command wrapper (glDrawRangeElements, etc.). Generated via generator/generate_command.rb.
33
+ * 'opengl_enum.rb' : OpenGL enum wrapper (GL_TRIANGLE_STRIP, etc.). Generated via generator/generate_enum.rb.
34
+ * 'opengl_common.rb' : Provies utilitiy funcitions.
35
+ * 'opengl_platform.rb' : Provies platform check funcitions (OpneGL.get_platform).
36
+ * 'opengl_windows.rb' : Provies funcitions for Windows platform (wglGetProcAddress).
37
+
38
+ * 'opengl_ext.rb' includes these scripts:
39
+ * 'opengl_ext_command.rb' : OpenGL extension command wrapper. Generated via generator/generate_ext_command.rb.
40
+ * 'opengl_ext_enum.rb' : OpenGL extension enum wrapper Generated via generator/generate_ext_enum.rb.
41
+
42
+ * 'glfw.rb'
43
+ * My handwirtten GLFW wrapper (https://github.com/vaiorabbit/ruby-glfw).
44
+
45
+ * 'glu.rb'
46
+ * My handwirtten GLU wrapper.
47
+
48
+ * 'generator/gl.xml'
49
+ * Khronos' official XML API registry for OpenGL.
50
+
51
+ * 'generator/Rakefile'
52
+ * Type 'rake' to generate wrapper codes / fetch gl.xml.
53
+ * You can get the latest one by 'get_gl_xml.rb'.
54
+
55
+ * 'sample/simple.rb'
56
+ * Simple example.
57
+ * You need to get glfw3.dll (Windows) or libglfw.dylib (Mac OS X). See sample/README.md.
58
+
59
+ * 'sample/data', 'sample/util'
60
+ * Data and utilities for sample programs.
61
+
62
+ ## Prerequisites ##
63
+
64
+ * Fiddle
65
+ * A libffi wrapper
66
+ * Standard library since Ruby 2.0.0
67
+
68
+ ### For sample ###
69
+
70
+ * GLFW
71
+ * http://www.glfw.org/
72
+ * http://www.glfw.org/download.html
73
+
74
+ ### For generator ###
75
+
76
+ * nokogiri XML parser
77
+ * http://nokogiri.org
78
+ * http://nokogiri.org/tutorials/installing_nokogiri.html
79
+
80
+
81
+ ## Tested Environment ##
82
+
83
+ * Ruby
84
+ * ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
85
+ * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
86
+
87
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
88
+ * NVIDIA GeForce GTX 560
89
+ * OpenGL 4.3
90
+
91
+ > ruby report_env.rb
92
+ 4.3.0
93
+
94
+ * Mac OS X 10.8.4, 64-bit
95
+ * NVIDIA GeForce 320M on Mac mini (Mid 2010)
96
+ * OpenGL 2.1
97
+
98
+ $ ruby report_env.rb
99
+ 2.1 NVIDIA-8.12.47 310.40.00.05f01
100
+
101
+ * Though I have not tested on Linux yet, it should work with proper 'OpenGL.load_dll' settings like:
102
+ * OpenGL.load_dll( 'libGL.so', '/usr/lib' )
103
+ * GLFW.load_dll( 'libGLFW.so', '.' )
104
+
105
+
106
+ ## Note ##
107
+
108
+ * No Ruby-Style handy interfaces are available (like one in the ruby-opengl2 (http://ruby-opengl.rubyforge.org/))
109
+ * Example:
110
+ * (Original C API)
111
+
112
+ GLuint tex_names_buf[2];
113
+ glGenTextures( 2, tex_names_buf );
114
+ GLuint tex_name = tex_names_buf[0];
115
+
116
+ * (This library)
117
+
118
+ tex_names_buf = ' ' # String instance that is enough to catch texture names (integer).
119
+ glGenTextures( 2, tex_names_buf )
120
+ tex_name = tex_names_buf.unpack('L2')[0]
121
+
122
+ * (ruby-opengl2)
123
+
124
+ tex_name = glGenTextures( 2 )[0]
125
+
126
+ * Because:
127
+ * I don't want to maintain this feature, which makes difficult to auto-generate.
128
+ * I don't like to modify original OpenGL API.
129
+ * Thanks to Fiddle, all these C-pointer issue can be simply handled with Array#pack and String#unpack.
130
+
131
+ * Reference : Other approaches after ruby-opengl2
132
+ * OpenGL (opengl3) by davll (https://github.com/davll/ruby-opengl)
133
+ * Built on Ruby-FFI, which is useful for JRuby users.
134
+ * opengl-core by nilium (https://github.com/nilium/ruby-opengl)
135
+ * Build on Fiddle.
136
+ * Provides more customize points and handy utilities.
137
+
138
+
139
+ ## License ##
140
+
141
+ The zlib/libpng License (http://opensource.org/licenses/Zlib).
142
+
143
+ Copyright (c) 2013 vaiorabbit@twitter.com
144
+
145
+ This software is provided 'as-is', without any express or implied
146
+ warranty. In no event will the authors be held liable for any damages
147
+ arising from the use of this software.
148
+
149
+ Permission is granted to anyone to use this software for any purpose,
150
+ including commercial applications, and to alter it and redistribute it
151
+ freely, subject to the following restrictions:
152
+
153
+ 1. The origin of this software must not be misrepresented; you must not
154
+ claim that you wrote the original software. If you use this software in a
155
+ product, an acknowledgment in the product documentation would be
156
+ appreciated but is not required.
157
+
158
+ 2. Altered source versions must be plainly marked as such, and must not be
159
+ misrepresented as being the original software.
160
+
161
+ 3. This notice may not be removed or altered from any source distribution.
162
+
163
+ Sample codes/resources under sample/GLExcess are provided under the GNU General
164
+ Public License version 2. See sample/GLExcess/GPL2.txt .
165
+
166
+ -------------------------------------------------------------------------------
167
+
168
+ # 自前 Ruby-OpenGL と自動生成スクリプト #
169
+
170
+ ## 特徴 ##
171
+
172
+ * 標準ライブラリ Fiddle を使っています ⇒ 拡張ライブラリをビルドする必要がありません
173
+ * 関数とenumのラッパーコードは Khronos の XML API registry (gl.xml) から自動生成しています
174
+
175
+
176
+ ## 使い方 ##
177
+
178
+ sample/simple.rb を参照してください。
179
+
180
+ その他のサンプルと自動生成スクリプトはこちらで開発しています:
181
+ https://github.com/vaiorabbit/ruby-opengl
182
+
183
+
184
+ ## 内容 ##
185
+
186
+ * 'opengl.rb' を require することで下記のスクリプトを取り込みます:
187
+ * 'opengl_command.rb' : OpenGL 関数のラッパーコード (glDrawRangeElements, etc.)。 generator/generate_command.rb で自動生成されたものです。
188
+ * 'opengl_enum.rb' : OpenGL enum のラッパーコード (GL_TRIANGLE_STRIP, etc.)。 generator/generate_enum.rb で自動生成されたものです。
189
+ * 'opengl_common.rb' : 共通のユーティリティ関数を提供しています。
190
+ * 'opengl_platform.rb' : 動作プラットフォームの判別機能を提供しています (OpneGL.get_platform)。
191
+ * 'opengl_windows.rb' : Windows用の機能を提供しています (wglGetProcAddress)。
192
+
193
+ * 'opengl_ext.rb' を require することで下記のスクリプトを取り込みます:
194
+ * 'opengl_ext_command.rb' : OpenGL 拡張関数のラッパーコード。 generator/generate_ext_command.rb で自動生成されたものです。
195
+ * 'opengl_ext_enum.rb' : OpenGL 拡張enumのラッパーコード。 generator/generate_ext_enum.rb で自動生成されたものです。
196
+
197
+ * 'glfw.rb'
198
+ * GLFW のラッパーコードです(自動生成ではありません) (https://github.com/vaiorabbit/ruby-glfw)。
199
+
200
+ * 'glu.rb'
201
+ * GLU のラッパーコードです(自動生成ではありません)。
202
+
203
+ * 'generator/gl.xml'
204
+ * Khronos 公式の XML API registry です。
205
+
206
+ * 'generator/Rakefile'
207
+ * 自動生成関連のタスクを自動化するためのものです。'rake' と打てば gl.xml の取得とラッパーコードの生成を実行します。
208
+ * gl.xml の取得だけなど、単体のタスクなら 'get_gl_xml.rb' などの個別Rubyスクリプトでも実行できます。
209
+
210
+ * 'sample/simple.rb'
211
+ * 一番簡単なサンプルです。
212
+ * 同じ場所に glfw3.dll (Windows) もしくは libglfw.dylib (Mac OS X) を置いてください。詳細は sample/README.md に記載されています。
213
+
214
+ * 'sample/data', 'sample/util'
215
+ * サンプルで共有する機能・データの配置場所です。
216
+
217
+
218
+ ## 必要なもの ##
219
+
220
+ * Fiddle
221
+ * libffi のラッパーです
222
+ * Ruby 2.0.0 以降で標準ライブラリになりました
223
+
224
+ ### サンプル用 ###
225
+
226
+ * GLFW
227
+ * http://www.glfw.org/
228
+ * http://www.glfw.org/download.html
229
+
230
+ ### 自動生成スクリプト用 ###
231
+
232
+ * nokogiri XML パーサー
233
+ * http://nokogiri.org
234
+ * http://nokogiri.org/tutorials/installing_nokogiri.html
235
+
236
+ ## テストした環境 ##
237
+
238
+ * Ruby
239
+ * ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
240
+ * ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
241
+
242
+ * Windows 7 Home Premium, 64-bit (Service Pack 1)
243
+ * NVIDIA GeForce GTX 560
244
+ * OpenGL 4.3
245
+
246
+ > ruby report_env.rb
247
+ 4.3.0
248
+
249
+ * Mac OS X 10.8.4, 64-bit
250
+ * NVIDIA GeForce 320M on Mac mini (Mid 2010)
251
+ * OpenGL 2.1
252
+
253
+ $ ruby report_env.rb
254
+ 2.1 NVIDIA-8.12.47 310.40.00.05f01
255
+
256
+ * まだ Linux では動作確認していませんが、'OpenGL.load_dll' などの引数が正しければ動くはず…
257
+ * OpenGL.load_dll( 'libGL.so', '/usr/lib' )
258
+ * GLFW.load_dll( 'libGLFW.so', '.' )
259
+
260
+
261
+ ## メモ ##
262
+
263
+ * Rubyスタイルの便利なインターフェースはサポートしていません (ruby-opengl2 (http://ruby-opengl.rubyforge.org/) にあったような感じのもの)
264
+ * 例:
265
+ * (OpenGLオリジナルの C API)
266
+
267
+ GLuint tex_names_buf[2];
268
+ glGenTextures( 2, tex_names_buf );
269
+ GLuint tex_name = tex_names_buf[0];
270
+
271
+ * (このライブラリの場合)
272
+
273
+ tex_names_buf = ' ' # テクスチャ名(GLuint)を受け取るのに十分なサイズ String インスタンスであればOK
274
+ glGenTextures( 2, tex_names_buf )
275
+ tex_name = tex_names_buf.unpack('L2')[0]
276
+
277
+ * (ruby-opengl2 の場合)
278
+
279
+ tex_name = glGenTextures( 2 )[0] # glGenTextures が配列を返すように修正されています
280
+
281
+ * なぜサポートしないのか:
282
+ * 面倒。自動生成になじまない。
283
+ * OpenGL オリジナルの API を変更するのは個人的に嫌。
284
+ * この手の C ポインタ関連の問題はすべて Array#pack と String#unpack だけで簡単に解決できます (Fiddleのおかげ)。
285
+
286
+ * 参考 : ruby-opengl2 以降に出てきたその他のアプローチ
287
+ * OpenGL (opengl3) by davll (https://github.com/davll/ruby-opengl)
288
+ * Ruby-FFI を利用 ⇒ JRuby でも使えるようです
289
+ * opengl-core by nilium (https://github.com/nilium/ruby-opengl)
290
+ * Fiddle を利用
291
+ * カスタマイズポイント・ユーティリティがこのライブラリよりも揃ってます
292
+
293
+
294
+ ## ライセンス ##
295
+
296
+ * zlib/libpng ライセンスです (http://opensource.org/licenses/Zlib)。
297
+
298
+ * sample/GLExcess 以下にあるものについては GNU General Public License version 2 です。
299
+ sample/GLExcess/GPL2.txt を参照してください。
data/lib/glfw.rb ADDED
@@ -0,0 +1,390 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'fiddle/import'
3
+
4
+ module GLFW
5
+
6
+ extend Fiddle::Importer
7
+
8
+ #
9
+ # Fiddle's default 'extern' stores all methods into local variable '@func_map', that makes difficult to 'include GLFW'.
10
+ # So I override it and replace '@func_map' into 'GLFW_FUNCTIONS_MAP'.
11
+ # Ref.: /lib/ruby/2.0.0/fiddle/import.rb
12
+ #
13
+ GLFW_FUNCTIONS_MAP = {}
14
+ def self.extern(signature, *opts)
15
+ symname, ctype, argtype = parse_signature(signature, @type_alias)
16
+ opt = parse_bind_options(opts)
17
+ f = import_function(symname, ctype, argtype, opt[:call_type])
18
+ name = symname.gsub(/@.+/,'')
19
+ GLFW_FUNCTIONS_MAP[name] = f
20
+ begin
21
+ /^(.+?):(\d+)/ =~ caller.first
22
+ file, line = $1, $2.to_i
23
+ rescue
24
+ file, line = __FILE__, __LINE__+3
25
+ end
26
+ args_str="*args"
27
+ module_eval(<<-EOS, file, line)
28
+ def #{name}(*args, &block)
29
+ GLFW_FUNCTIONS_MAP['#{name}'].call(*args,&block)
30
+ end
31
+ EOS
32
+ module_function(name)
33
+ f
34
+ end
35
+
36
+ # defines
37
+ GLFW_VERSION_MAJOR = 3
38
+ GLFW_VERSION_MINOR = 0
39
+ GLFW_VERSION_REVISION = 1
40
+
41
+ GLFW_RELEASE = 0
42
+ GLFW_PRESS = 1
43
+ GLFW_REPEAT = 2
44
+
45
+ GLFW_KEY_UNKNOWN = -1
46
+
47
+ GLFW_KEY_SPACE = 32
48
+ GLFW_KEY_APOSTROPHE = 39 # '
49
+ GLFW_KEY_COMMA = 44 # ,
50
+ GLFW_KEY_MINUS = 45 # -
51
+ GLFW_KEY_PERIOD = 46 # .
52
+ GLFW_KEY_SLASH = 47 # /
53
+ GLFW_KEY_0 = 48
54
+ GLFW_KEY_1 = 49
55
+ GLFW_KEY_2 = 50
56
+ GLFW_KEY_3 = 51
57
+ GLFW_KEY_4 = 52
58
+ GLFW_KEY_5 = 53
59
+ GLFW_KEY_6 = 54
60
+ GLFW_KEY_7 = 55
61
+ GLFW_KEY_8 = 56
62
+ GLFW_KEY_9 = 57
63
+ GLFW_KEY_SEMICOLON = 59 # ;
64
+ GLFW_KEY_EQUAL = 61 # =
65
+ GLFW_KEY_A = 65
66
+ GLFW_KEY_B = 66
67
+ GLFW_KEY_C = 67
68
+ GLFW_KEY_D = 68
69
+ GLFW_KEY_E = 69
70
+ GLFW_KEY_F = 70
71
+ GLFW_KEY_G = 71
72
+ GLFW_KEY_H = 72
73
+ GLFW_KEY_I = 73
74
+ GLFW_KEY_J = 74
75
+ GLFW_KEY_K = 75
76
+ GLFW_KEY_L = 76
77
+ GLFW_KEY_M = 77
78
+ GLFW_KEY_N = 78
79
+ GLFW_KEY_O = 79
80
+ GLFW_KEY_P = 80
81
+ GLFW_KEY_Q = 81
82
+ GLFW_KEY_R = 82
83
+ GLFW_KEY_S = 83
84
+ GLFW_KEY_T = 84
85
+ GLFW_KEY_U = 85
86
+ GLFW_KEY_V = 86
87
+ GLFW_KEY_W = 87
88
+ GLFW_KEY_X = 88
89
+ GLFW_KEY_Y = 89
90
+ GLFW_KEY_Z = 90
91
+ GLFW_KEY_LEFT_BRACKET = 91 # [
92
+ GLFW_KEY_BACKSLASH = 92 # \
93
+ GLFW_KEY_RIGHT_BRACKET = 93 # ]
94
+ GLFW_KEY_GRAVE_ACCENT = 96 # `
95
+ GLFW_KEY_WORLD_1 = 161 # non-US #1
96
+ GLFW_KEY_WORLD_2 = 162 # non-US #2
97
+
98
+ GLFW_KEY_ESCAPE = 256
99
+ GLFW_KEY_ENTER = 257
100
+ GLFW_KEY_TAB = 258
101
+ GLFW_KEY_BACKSPACE = 259
102
+ GLFW_KEY_INSERT = 260
103
+ GLFW_KEY_DELETE = 261
104
+ GLFW_KEY_RIGHT = 262
105
+ GLFW_KEY_LEFT = 263
106
+ GLFW_KEY_DOWN = 264
107
+ GLFW_KEY_UP = 265
108
+ GLFW_KEY_PAGE_UP = 266
109
+ GLFW_KEY_PAGE_DOWN = 267
110
+ GLFW_KEY_HOME = 268
111
+ GLFW_KEY_END = 269
112
+ GLFW_KEY_CAPS_LOCK = 280
113
+ GLFW_KEY_SCROLL_LOCK = 281
114
+ GLFW_KEY_NUM_LOCK = 282
115
+ GLFW_KEY_PRINT_SCREEN = 283
116
+ GLFW_KEY_PAUSE = 284
117
+ GLFW_KEY_F1 = 290
118
+ GLFW_KEY_F2 = 291
119
+ GLFW_KEY_F3 = 292
120
+ GLFW_KEY_F4 = 293
121
+ GLFW_KEY_F5 = 294
122
+ GLFW_KEY_F6 = 295
123
+ GLFW_KEY_F7 = 296
124
+ GLFW_KEY_F8 = 297
125
+ GLFW_KEY_F9 = 298
126
+ GLFW_KEY_F10 = 299
127
+ GLFW_KEY_F11 = 300
128
+ GLFW_KEY_F12 = 301
129
+ GLFW_KEY_F13 = 302
130
+ GLFW_KEY_F14 = 303
131
+ GLFW_KEY_F15 = 304
132
+ GLFW_KEY_F16 = 305
133
+ GLFW_KEY_F17 = 306
134
+ GLFW_KEY_F18 = 307
135
+ GLFW_KEY_F19 = 308
136
+ GLFW_KEY_F20 = 309
137
+ GLFW_KEY_F21 = 310
138
+ GLFW_KEY_F22 = 311
139
+ GLFW_KEY_F23 = 312
140
+ GLFW_KEY_F24 = 313
141
+ GLFW_KEY_F25 = 314
142
+ GLFW_KEY_KP_0 = 320
143
+ GLFW_KEY_KP_1 = 321
144
+ GLFW_KEY_KP_2 = 322
145
+ GLFW_KEY_KP_3 = 323
146
+ GLFW_KEY_KP_4 = 324
147
+ GLFW_KEY_KP_5 = 325
148
+ GLFW_KEY_KP_6 = 326
149
+ GLFW_KEY_KP_7 = 327
150
+ GLFW_KEY_KP_8 = 328
151
+ GLFW_KEY_KP_9 = 329
152
+ GLFW_KEY_KP_DECIMAL = 330
153
+ GLFW_KEY_KP_DIVIDE = 331
154
+ GLFW_KEY_KP_MULTIPLY = 332
155
+ GLFW_KEY_KP_SUBTRACT = 333
156
+ GLFW_KEY_KP_ADD = 334
157
+ GLFW_KEY_KP_ENTER = 335
158
+ GLFW_KEY_KP_EQUAL = 336
159
+ GLFW_KEY_LEFT_SHIFT = 340
160
+ GLFW_KEY_LEFT_CONTROL = 341
161
+ GLFW_KEY_LEFT_ALT = 342
162
+ GLFW_KEY_LEFT_SUPER = 343
163
+ GLFW_KEY_RIGHT_SHIFT = 344
164
+ GLFW_KEY_RIGHT_CONTROL = 345
165
+ GLFW_KEY_RIGHT_ALT = 346
166
+ GLFW_KEY_RIGHT_SUPER = 347
167
+ GLFW_KEY_MENU = 348
168
+ GLFW_KEY_LAST = GLFW_KEY_MENU
169
+
170
+ GLFW_MOD_SHIFT = 0x0001
171
+ GLFW_MOD_CONTROL = 0x0002
172
+ GLFW_MOD_ALT = 0x0004
173
+ GLFW_MOD_SUPER = 0x0008
174
+
175
+ GLFW_MOUSE_BUTTON_1 = 0
176
+ GLFW_MOUSE_BUTTON_2 = 1
177
+ GLFW_MOUSE_BUTTON_3 = 2
178
+ GLFW_MOUSE_BUTTON_4 = 3
179
+ GLFW_MOUSE_BUTTON_5 = 4
180
+ GLFW_MOUSE_BUTTON_6 = 5
181
+ GLFW_MOUSE_BUTTON_7 = 6
182
+ GLFW_MOUSE_BUTTON_8 = 7
183
+ GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8
184
+ GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1
185
+ GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2
186
+ GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3
187
+
188
+ GLFW_JOYSTICK_1 = 0
189
+ GLFW_JOYSTICK_2 = 1
190
+ GLFW_JOYSTICK_3 = 2
191
+ GLFW_JOYSTICK_4 = 3
192
+ GLFW_JOYSTICK_5 = 4
193
+ GLFW_JOYSTICK_6 = 5
194
+ GLFW_JOYSTICK_7 = 6
195
+ GLFW_JOYSTICK_8 = 7
196
+ GLFW_JOYSTICK_9 = 8
197
+ GLFW_JOYSTICK_10 = 9
198
+ GLFW_JOYSTICK_11 = 10
199
+ GLFW_JOYSTICK_12 = 11
200
+ GLFW_JOYSTICK_13 = 12
201
+ GLFW_JOYSTICK_14 = 13
202
+ GLFW_JOYSTICK_15 = 14
203
+ GLFW_JOYSTICK_16 = 15
204
+ GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16
205
+
206
+ GLFW_NOT_INITIALIZED = 0x00010001
207
+ GLFW_NO_CURRENT_CONTEXT = 0x00010002
208
+ GLFW_INVALID_ENUM = 0x00010003
209
+ GLFW_INVALID_VALUE = 0x00010004
210
+ GLFW_OUT_OF_MEMORY = 0x00010005
211
+ GLFW_API_UNAVAILABLE = 0x00010006
212
+ GLFW_VERSION_UNAVAILABLE = 0x00010007
213
+ GLFW_PLATFORM_ERROR = 0x00010008
214
+ GLFW_FORMAT_UNAVAILABLE = 0x00010009
215
+
216
+ GLFW_FOCUSED = 0x00020001
217
+ GLFW_ICONIFIED = 0x00020002
218
+ GLFW_RESIZABLE = 0x00020003
219
+ GLFW_VISIBLE = 0x00020004
220
+ GLFW_DECORATED = 0x00020005
221
+
222
+ GLFW_RED_BITS = 0x00021001
223
+ GLFW_GREEN_BITS = 0x00021002
224
+ GLFW_BLUE_BITS = 0x00021003
225
+ GLFW_ALPHA_BITS = 0x00021004
226
+ GLFW_DEPTH_BITS = 0x00021005
227
+ GLFW_STENCIL_BITS = 0x00021006
228
+ GLFW_ACCUM_RED_BITS = 0x00021007
229
+ GLFW_ACCUM_GREEN_BITS = 0x00021008
230
+ GLFW_ACCUM_BLUE_BITS = 0x00021009
231
+ GLFW_ACCUM_ALPHA_BITS = 0x0002100A
232
+ GLFW_AUX_BUFFERS = 0x0002100B
233
+ GLFW_STEREO = 0x0002100C
234
+ GLFW_SAMPLES = 0x0002100D
235
+ GLFW_SRGB_CAPABLE = 0x0002100E
236
+ GLFW_REFRESH_RATE = 0x0002100F
237
+
238
+ GLFW_CLIENT_API = 0x00022001
239
+ GLFW_CONTEXT_VERSION_MAJOR = 0x00022002
240
+ GLFW_CONTEXT_VERSION_MINOR = 0x00022003
241
+ GLFW_CONTEXT_REVISION = 0x00022004
242
+ GLFW_CONTEXT_ROBUSTNESS = 0x00022005
243
+ GLFW_OPENGL_FORWARD_COMPAT = 0x00022006
244
+ GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007
245
+ GLFW_OPENGL_PROFILE = 0x00022008
246
+
247
+ GLFW_OPENGL_API = 0x00030001
248
+ GLFW_OPENGL_ES_API = 0x00030002
249
+
250
+ GLFW_NO_ROBUSTNESS = 0
251
+ GLFW_NO_RESET_NOTIFICATION = 0x00031001
252
+ GLFW_LOSE_CONTEXT_ON_RESET = 0x00031002
253
+
254
+ GLFW_OPENGL_ANY_PROFILE = 0
255
+ GLFW_OPENGL_CORE_PROFILE = 0x00032001
256
+ GLFW_OPENGL_COMPAT_PROFILE = 0x00032002
257
+
258
+ GLFW_CURSOR = 0x00033001
259
+ GLFW_STICKY_KEYS = 0x00033002
260
+ GLFW_STICKY_MOUSE_BUTTONS = 0x00033003
261
+
262
+ GLFW_CURSOR_NORMAL = 0x00034001
263
+ GLFW_CURSOR_HIDDEN = 0x00034002
264
+ GLFW_CURSOR_DISABLED = 0x00034003
265
+
266
+ GLFW_CONNECTED = 0x00040001
267
+ GLFW_DISCONNECTED = 0x00040002
268
+
269
+ # typedefs
270
+ @@glfw_cb_signature = {
271
+ :GLFWglproc => "void GLFWglproc()",
272
+ :GLFWerrorfun => "void GLFWerrorfun(int,const char*)",
273
+ :GLFWwindowposfun => "void GLFWwindowposfun(void*,int,int)",
274
+ :GLFWwindowsizefun => "void GLFWwindowsizefun(void*,int,int)",
275
+ :GLFWwindowclosefun => "void GLFWwindowclosefun(void*)",
276
+ :GLFWwindowrefreshfun => "void GLFWwindowrefreshfun(void*)",
277
+ :GLFWwindowfocusfun => "void GLFWwindowfocusfun(void*,int)",
278
+ :GLFWwindowiconifyfun => "void GLFWwindowiconifyfun(void*,int)",
279
+ :GLFWframebuffersizefun => "void GLFWframebuffersizefun(void*,int,int)",
280
+ :GLFWmousebuttonfun => "void GLFWmousebuttonfun(void*,int,int,int)",
281
+ :GLFWcursorposfun => "void GLFWcursorposfun(void*,double,double)",
282
+ :GLFWcursorenterfun => "void GLFWcursorenterfun(void*,int)",
283
+ :GLFWscrollfun => "void GLFWscrollfun(void*,double,double)",
284
+ :GLFWkeyfun => "void GLFWkeyfun(void*,int,int,int,int)",
285
+ :GLFWcharfun => "void GLFWcharfun(void*,unsigned int)",
286
+ :GLFWmonitorfun => "void GLFWmonitorfun(void*,int)",
287
+ }
288
+ def self.create_callback( sym, *opts, &blk )
289
+ return bind( @@glfw_cb_signature[sym], opts, &blk )
290
+ end
291
+
292
+ # struct
293
+ GLFWvidmode = struct(["int width",
294
+ "int height",
295
+ "int redBits",
296
+ "int greenBits",
297
+ "int blueBits",
298
+ "int refreshRate"])
299
+
300
+ GLFWgammaramp = struct(["unsigned short* red",
301
+ "unsigned short* green",
302
+ "unsigned short* blue",
303
+ "unsigned int size"])
304
+
305
+ @@glfw_import_done = false
306
+
307
+ # Load native library.
308
+ def self.load_dll(lib = 'libglfw.dylib', path = '.')
309
+ dlload (path + '/' + lib)
310
+ import_symbols() unless @@glfw_import_done
311
+ end
312
+
313
+ def self.import_symbols
314
+ # function
315
+ extern 'int glfwInit()'
316
+ extern 'void glfwTerminate()'
317
+ extern 'void glfwGetVersion(int*, int*, int*)'
318
+ extern 'const char* glfwGetVersionString()'
319
+ extern 'void* glfwSetErrorCallback(void*)'
320
+ extern 'void** glfwGetMonitors(int*)'
321
+ extern 'void* glfwGetPrimaryMonitor()'
322
+ extern 'void glfwGetMonitorPos(void*, int*, int*)'
323
+ extern 'void glfwGetMonitorPhysicalSize(void*, int*, int*)'
324
+ extern 'const char* glfwGetMonitorName(void*)'
325
+ extern 'void* glfwSetMonitorCallback(void*)'
326
+ extern 'const void* glfwGetVideoModes(void*, int*)'
327
+ extern 'const void* glfwGetVideoMode(void*)'
328
+ extern 'void glfwSetGamma(void*, float)'
329
+ extern 'const void* glfwGetGammaRamp(void*)'
330
+ extern 'void glfwSetGammaRamp(void*, const void*)'
331
+ extern 'void glfwDefaultWindowHints()'
332
+ extern 'void glfwWindowHint(int, int)'
333
+ extern 'void* glfwCreateWindow(int, int, const char*, void*, void*)'
334
+ extern 'void glfwDestroyWindow(void*)'
335
+ extern 'int glfwWindowShouldClose(void*)'
336
+ extern 'void glfwSetWindowShouldClose(void* window, int)'
337
+ extern 'void glfwSetWindowTitle(void*, const char*)'
338
+ extern 'void glfwGetWindowPos(void*, int*, int*)'
339
+ extern 'void glfwSetWindowPos(void*, int, int)'
340
+ extern 'void glfwGetWindowSize(void*, int*, int*)'
341
+ extern 'void glfwSetWindowSize(void*, int, int)'
342
+ extern 'void glfwGetFramebufferSize(void*, int*, int*)'
343
+ extern 'void glfwIconifyWindow(void*)'
344
+ extern 'void glfwRestoreWindow(void*)'
345
+ extern 'void glfwShowWindow(void*)'
346
+ extern 'void glfwHideWindow(void*)'
347
+ extern 'void* glfwGetWindowMonitor(void*)'
348
+ extern 'int glfwGetWindowAttrib(void*, int)'
349
+ extern 'void glfwSetWindowUserPointer(void*, void*)'
350
+ extern 'void* glfwGetWindowUserPointer(void*)'
351
+ extern 'void* glfwSetWindowPosCallback(void*, void*)'
352
+ extern 'void* glfwSetWindowSizeCallback(void*, void*)'
353
+ extern 'void* glfwSetWindowCloseCallback(void*, void*)'
354
+ extern 'void* glfwSetWindowRefreshCallback(void*, void*)'
355
+ extern 'void* glfwSetWindowFocusCallback(void*, void*)'
356
+ extern 'void* glfwSetWindowIconifyCallback(void*, void*)'
357
+ extern 'void* glfwSetFramebufferSizeCallback(void*, void*)'
358
+ extern 'void glfwPollEvents()'
359
+ extern 'void glfwWaitEvents()'
360
+ extern 'int glfwGetInputMode(void*, int)'
361
+ extern 'void glfwSetInputMode(void*, int, int)'
362
+ extern 'int glfwGetKey(void*, int)'
363
+ extern 'int glfwGetMouseButton(void*, int)'
364
+ extern 'void glfwGetCursorPos(void*, void*, void*)'
365
+ extern 'void glfwSetCursorPos(void*, double, double)'
366
+ extern 'void* glfwSetKeyCallback(void*, void*)'
367
+ extern 'void* glfwSetCharCallback(void*, void*)'
368
+ extern 'void* glfwSetMouseButtonCallback(void*, void*)'
369
+ extern 'void* glfwSetCursorPosCallback(void*, void*)'
370
+ extern 'void* glfwSetCursorEnterCallback(void*, void*)'
371
+ extern 'void* glfwSetScrollCallback(void*, void*)'
372
+ extern 'int glfwJoystickPresent(int)'
373
+ extern 'const float* glfwGetJoystickAxes(int, int*)'
374
+ extern 'const unsigned char* glfwGetJoystickButtons(int, int*)'
375
+ extern 'const char* glfwGetJoystickName(int)'
376
+ extern 'void glfwSetClipboardString(void*, const char*)'
377
+ extern 'const char* glfwGetClipboardString(void*)'
378
+ extern 'double glfwGetTime()'
379
+ extern 'void glfwSetTime(double)'
380
+ extern 'void glfwMakeContextCurrent(void*)'
381
+ extern 'void* glfwGetCurrentContext()'
382
+ extern 'void glfwSwapBuffers(void*)'
383
+ extern 'void glfwSwapInterval(int)'
384
+ extern 'int glfwExtensionSupported(const char*)'
385
+ extern 'void* glfwGetProcAddress(const char*)'
386
+
387
+ @@glfw_import_done = true
388
+ end
389
+
390
+ end