opengl-bindings2 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +686 -0
- data/LICENSE.txt +21 -0
- data/README.md +564 -0
- data/lib/glfw.rb +699 -0
- data/lib/glu.rb +366 -0
- data/lib/glut.rb +575 -0
- data/lib/opengl.rb +36 -0
- data/lib/opengl_command.rb +7356 -0
- data/lib/opengl_common.rb +81 -0
- data/lib/opengl_enum.rb +1818 -0
- data/lib/opengl_es.rb +31 -0
- data/lib/opengl_es_command.rb +2526 -0
- data/lib/opengl_es_enum.rb +1011 -0
- data/lib/opengl_es_ext.rb +28 -0
- data/lib/opengl_es_ext_command.rb +8969 -0
- data/lib/opengl_es_ext_enum.rb +6078 -0
- data/lib/opengl_ext.rb +28 -0
- data/lib/opengl_ext_command.rb +33331 -0
- data/lib/opengl_ext_common.rb +52 -0
- data/lib/opengl_ext_enum.rb +14137 -0
- data/lib/opengl_linux.rb +63 -0
- data/lib/opengl_macosx.rb +68 -0
- data/lib/opengl_platform.rb +43 -0
- data/lib/opengl_windows.rb +71 -0
- data/sample/README.md +55 -0
- data/sample/glfw_get.bat +6 -0
- data/sample/glfw_get.sh +3 -0
- data/sample/report_env.rb +84 -0
- data/sample/simple.rb +57 -0
- metadata +75 -0
data/lib/glut.rb
ADDED
@@ -0,0 +1,575 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# A FreeGLUT wrapper
|
3
|
+
require 'fiddle/import'
|
4
|
+
require_relative 'opengl_platform'
|
5
|
+
|
6
|
+
module GLUT
|
7
|
+
|
8
|
+
extend Fiddle::Importer
|
9
|
+
|
10
|
+
# defines
|
11
|
+
|
12
|
+
GLUT_API_VERSION = 4
|
13
|
+
|
14
|
+
GLUT_KEY_F1 = 0x0001
|
15
|
+
GLUT_KEY_F2 = 0x0002
|
16
|
+
GLUT_KEY_F3 = 0x0003
|
17
|
+
GLUT_KEY_F4 = 0x0004
|
18
|
+
GLUT_KEY_F5 = 0x0005
|
19
|
+
GLUT_KEY_F6 = 0x0006
|
20
|
+
GLUT_KEY_F7 = 0x0007
|
21
|
+
GLUT_KEY_F8 = 0x0008
|
22
|
+
GLUT_KEY_F9 = 0x0009
|
23
|
+
GLUT_KEY_F10 = 0x000A
|
24
|
+
GLUT_KEY_F11 = 0x000B
|
25
|
+
GLUT_KEY_F12 = 0x000C
|
26
|
+
GLUT_KEY_LEFT = 0x0064
|
27
|
+
GLUT_KEY_UP = 0x0065
|
28
|
+
GLUT_KEY_RIGHT = 0x0066
|
29
|
+
GLUT_KEY_DOWN = 0x0067
|
30
|
+
GLUT_KEY_PAGE_UP = 0x0068
|
31
|
+
GLUT_KEY_PAGE_DOWN = 0x0069
|
32
|
+
GLUT_KEY_HOME = 0x006A
|
33
|
+
GLUT_KEY_END = 0x006B
|
34
|
+
GLUT_KEY_INSERT = 0x006C
|
35
|
+
|
36
|
+
GLUT_LEFT_BUTTON = 0x0000
|
37
|
+
GLUT_MIDDLE_BUTTON = 0x0001
|
38
|
+
GLUT_RIGHT_BUTTON = 0x0002
|
39
|
+
GLUT_DOWN = 0x0000
|
40
|
+
GLUT_UP = 0x0001
|
41
|
+
GLUT_LEFT = 0x0000
|
42
|
+
GLUT_ENTERED = 0x0001
|
43
|
+
|
44
|
+
GLUT_RGB = 0x0000
|
45
|
+
GLUT_RGBA = 0x0000
|
46
|
+
GLUT_INDEX = 0x0001
|
47
|
+
GLUT_SINGLE = 0x0000
|
48
|
+
GLUT_DOUBLE = 0x0002
|
49
|
+
GLUT_ACCUM = 0x0004
|
50
|
+
GLUT_ALPHA = 0x0008
|
51
|
+
GLUT_DEPTH = 0x0010
|
52
|
+
GLUT_STENCIL = 0x0020
|
53
|
+
GLUT_MULTISAMPLE = 0x0080
|
54
|
+
GLUT_STEREO = 0x0100
|
55
|
+
GLUT_LUMINANCE = 0x0200
|
56
|
+
|
57
|
+
GLUT_MENU_NOT_IN_USE = 0x0000
|
58
|
+
GLUT_MENU_IN_USE = 0x0001
|
59
|
+
GLUT_NOT_VISIBLE = 0x0000
|
60
|
+
GLUT_VISIBLE = 0x0001
|
61
|
+
GLUT_HIDDEN = 0x0000
|
62
|
+
GLUT_FULLY_RETAINED = 0x0001
|
63
|
+
GLUT_PARTIALLY_RETAINED = 0x0002
|
64
|
+
GLUT_FULLY_COVERED = 0x0003
|
65
|
+
|
66
|
+
GLUT_WINDOW_X = 0x0064
|
67
|
+
GLUT_WINDOW_Y = 0x0065
|
68
|
+
GLUT_WINDOW_WIDTH = 0x0066
|
69
|
+
GLUT_WINDOW_HEIGHT = 0x0067
|
70
|
+
GLUT_WINDOW_BUFFER_SIZE = 0x0068
|
71
|
+
GLUT_WINDOW_STENCIL_SIZE = 0x0069
|
72
|
+
GLUT_WINDOW_DEPTH_SIZE = 0x006A
|
73
|
+
GLUT_WINDOW_RED_SIZE = 0x006B
|
74
|
+
GLUT_WINDOW_GREEN_SIZE = 0x006C
|
75
|
+
GLUT_WINDOW_BLUE_SIZE = 0x006D
|
76
|
+
GLUT_WINDOW_ALPHA_SIZE = 0x006E
|
77
|
+
GLUT_WINDOW_ACCUM_RED_SIZE = 0x006F
|
78
|
+
GLUT_WINDOW_ACCUM_GREEN_SIZE = 0x0070
|
79
|
+
GLUT_WINDOW_ACCUM_BLUE_SIZE = 0x0071
|
80
|
+
GLUT_WINDOW_ACCUM_ALPHA_SIZE = 0x0072
|
81
|
+
GLUT_WINDOW_DOUBLEBUFFER = 0x0073
|
82
|
+
GLUT_WINDOW_RGBA = 0x0074
|
83
|
+
GLUT_WINDOW_PARENT = 0x0075
|
84
|
+
GLUT_WINDOW_NUM_CHILDREN = 0x0076
|
85
|
+
GLUT_WINDOW_COLORMAP_SIZE = 0x0077
|
86
|
+
GLUT_WINDOW_NUM_SAMPLES = 0x0078
|
87
|
+
GLUT_WINDOW_STEREO = 0x0079
|
88
|
+
GLUT_WINDOW_CURSOR = 0x007A
|
89
|
+
|
90
|
+
GLUT_SCREEN_WIDTH = 0x00C8
|
91
|
+
GLUT_SCREEN_HEIGHT = 0x00C9
|
92
|
+
GLUT_SCREEN_WIDTH_MM = 0x00CA
|
93
|
+
GLUT_SCREEN_HEIGHT_MM = 0x00CB
|
94
|
+
GLUT_MENU_NUM_ITEMS = 0x012C
|
95
|
+
GLUT_DISPLAY_MODE_POSSIBLE = 0x0190
|
96
|
+
GLUT_INIT_WINDOW_X = 0x01F4
|
97
|
+
GLUT_INIT_WINDOW_Y = 0x01F5
|
98
|
+
GLUT_INIT_WINDOW_WIDTH = 0x01F6
|
99
|
+
GLUT_INIT_WINDOW_HEIGHT = 0x01F7
|
100
|
+
GLUT_INIT_DISPLAY_MODE = 0x01F8
|
101
|
+
GLUT_ELAPSED_TIME = 0x02BC
|
102
|
+
GLUT_WINDOW_FORMAT_ID = 0x007B
|
103
|
+
GLUT_INIT_STATE = 0x007C
|
104
|
+
|
105
|
+
GLUT_HAS_KEYBOARD = 0x0258
|
106
|
+
GLUT_HAS_MOUSE = 0x0259
|
107
|
+
GLUT_HAS_SPACEBALL = 0x025A
|
108
|
+
GLUT_HAS_DIAL_AND_BUTTON_BOX = 0x025B
|
109
|
+
GLUT_HAS_TABLET = 0x025C
|
110
|
+
GLUT_NUM_MOUSE_BUTTONS = 0x025D
|
111
|
+
GLUT_NUM_SPACEBALL_BUTTONS = 0x025E
|
112
|
+
GLUT_NUM_BUTTON_BOX_BUTTONS = 0x025F
|
113
|
+
GLUT_NUM_DIALS = 0x0260
|
114
|
+
GLUT_NUM_TABLET_BUTTONS = 0x0261
|
115
|
+
GLUT_DEVICE_IGNORE_KEY_REPEAT = 0x0262
|
116
|
+
GLUT_DEVICE_KEY_REPEAT = 0x0263
|
117
|
+
GLUT_HAS_JOYSTICK = 0x0264
|
118
|
+
GLUT_OWNS_JOYSTICK = 0x0265
|
119
|
+
GLUT_JOYSTICK_BUTTONS = 0x0266
|
120
|
+
GLUT_JOYSTICK_AXES = 0x0267
|
121
|
+
GLUT_JOYSTICK_POLL_RATE = 0x0268
|
122
|
+
|
123
|
+
GLUT_OVERLAY_POSSIBLE = 0x0320
|
124
|
+
GLUT_LAYER_IN_USE = 0x0321
|
125
|
+
GLUT_HAS_OVERLAY = 0x0322
|
126
|
+
GLUT_TRANSPARENT_INDEX = 0x0323
|
127
|
+
GLUT_NORMAL_DAMAGED = 0x0324
|
128
|
+
GLUT_OVERLAY_DAMAGED = 0x0325
|
129
|
+
|
130
|
+
GLUT_VIDEO_RESIZE_POSSIBLE = 0x0384
|
131
|
+
GLUT_VIDEO_RESIZE_IN_USE = 0x0385
|
132
|
+
GLUT_VIDEO_RESIZE_X_DELTA = 0x0386
|
133
|
+
GLUT_VIDEO_RESIZE_Y_DELTA = 0x0387
|
134
|
+
GLUT_VIDEO_RESIZE_WIDTH_DELTA = 0x0388
|
135
|
+
GLUT_VIDEO_RESIZE_HEIGHT_DELTA = 0x0389
|
136
|
+
GLUT_VIDEO_RESIZE_X = 0x038A
|
137
|
+
GLUT_VIDEO_RESIZE_Y = 0x038B
|
138
|
+
GLUT_VIDEO_RESIZE_WIDTH = 0x038C
|
139
|
+
GLUT_VIDEO_RESIZE_HEIGHT = 0x038D
|
140
|
+
|
141
|
+
GLUT_NORMAL = 0x0000
|
142
|
+
GLUT_OVERLAY = 0x0001
|
143
|
+
|
144
|
+
GLUT_ACTIVE_SHIFT = 0x0001
|
145
|
+
GLUT_ACTIVE_CTRL = 0x0002
|
146
|
+
GLUT_ACTIVE_ALT = 0x0004
|
147
|
+
|
148
|
+
GLUT_CURSOR_RIGHT_ARROW = 0x0000
|
149
|
+
GLUT_CURSOR_LEFT_ARROW = 0x0001
|
150
|
+
GLUT_CURSOR_INFO = 0x0002
|
151
|
+
GLUT_CURSOR_DESTROY = 0x0003
|
152
|
+
GLUT_CURSOR_HELP = 0x0004
|
153
|
+
GLUT_CURSOR_CYCLE = 0x0005
|
154
|
+
GLUT_CURSOR_SPRAY = 0x0006
|
155
|
+
GLUT_CURSOR_WAIT = 0x0007
|
156
|
+
GLUT_CURSOR_TEXT = 0x0008
|
157
|
+
GLUT_CURSOR_CROSSHAIR = 0x0009
|
158
|
+
GLUT_CURSOR_UP_DOWN = 0x000A
|
159
|
+
GLUT_CURSOR_LEFT_RIGHT = 0x000B
|
160
|
+
GLUT_CURSOR_TOP_SIDE = 0x000C
|
161
|
+
GLUT_CURSOR_BOTTOM_SIDE = 0x000D
|
162
|
+
GLUT_CURSOR_LEFT_SIDE = 0x000E
|
163
|
+
GLUT_CURSOR_RIGHT_SIDE = 0x000F
|
164
|
+
GLUT_CURSOR_TOP_LEFT_CORNER = 0x0010
|
165
|
+
GLUT_CURSOR_TOP_RIGHT_CORNER = 0x0011
|
166
|
+
GLUT_CURSOR_BOTTOM_RIGHT_CORNER = 0x0012
|
167
|
+
GLUT_CURSOR_BOTTOM_LEFT_CORNER = 0x0013
|
168
|
+
GLUT_CURSOR_INHERIT = 0x0064
|
169
|
+
GLUT_CURSOR_NONE = 0x0065
|
170
|
+
GLUT_CURSOR_FULL_CROSSHAIR = 0x0066
|
171
|
+
|
172
|
+
GLUT_RED = 0x0000
|
173
|
+
GLUT_GREEN = 0x0001
|
174
|
+
GLUT_BLUE = 0x0002
|
175
|
+
|
176
|
+
GLUT_KEY_REPEAT_OFF = 0x0000
|
177
|
+
GLUT_KEY_REPEAT_ON = 0x0001
|
178
|
+
GLUT_KEY_REPEAT_DEFAULT = 0x0002
|
179
|
+
|
180
|
+
GLUT_JOYSTICK_BUTTON_A = 0x0001
|
181
|
+
GLUT_JOYSTICK_BUTTON_B = 0x0002
|
182
|
+
GLUT_JOYSTICK_BUTTON_C = 0x0004
|
183
|
+
GLUT_JOYSTICK_BUTTON_D = 0x0008
|
184
|
+
|
185
|
+
GLUT_GAME_MODE_ACTIVE = 0x0000
|
186
|
+
GLUT_GAME_MODE_POSSIBLE = 0x0001
|
187
|
+
GLUT_GAME_MODE_WIDTH = 0x0002
|
188
|
+
GLUT_GAME_MODE_HEIGHT = 0x0003
|
189
|
+
GLUT_GAME_MODE_PIXEL_DEPTH = 0x0004
|
190
|
+
GLUT_GAME_MODE_REFRESH_RATE = 0x0005
|
191
|
+
GLUT_GAME_MODE_DISPLAY_CHANGED = 0x0006
|
192
|
+
|
193
|
+
# typedefs
|
194
|
+
@@glut_cb_function_signature = {
|
195
|
+
:GLUTMenuFunc => "void GLUTMenuFunc(int)",
|
196
|
+
|
197
|
+
:GLUTTimerFunc => "void GLUTTimerFunc(int)",
|
198
|
+
:GLUTIdleFunc => "void GLUTIdleFunc()",
|
199
|
+
|
200
|
+
:GLUTKeyboardFunc => "void GLUTKeyboardFunc(unsigned char, int, int)",
|
201
|
+
:GLUTSpecialFunc => "void GLUTSpecialFunc(int, int, int)",
|
202
|
+
:GLUTReshapeFunc => "void GLUTReshapeFunc(int, int)",
|
203
|
+
:GLUTVisibilityFunc => "void GLUTVisibilityFunc(int)",
|
204
|
+
:GLUTDisplayFunc => "void GLUTDisplayFunc()",
|
205
|
+
:GLUTMouseFunc => "void GLUTMouseFunc(int, int, int, int)",
|
206
|
+
:GLUTMotionFunc => "void GLUTMotionFunc(int, int)",
|
207
|
+
:GLUTPassiveMotionFunc => "void GLUTPassiveMotionFunc(int, int)",
|
208
|
+
:GLUTEntryFunc => "void GLUTEntryFunc(int)",
|
209
|
+
|
210
|
+
:GLUTKeyboardUpFunc => "void GLUTKeyboardUpFunc(unsigned char, int, int)",
|
211
|
+
:GLUTSpecialUpFunc => "void GLUTSpecialUpFunc(int, int, int)",
|
212
|
+
:GLUTJoystickFunc => "void GLUTJoystickFunc(unsigned int, int, int, int)",
|
213
|
+
:GLUTMenuStateFunc => "void GLUTMenuStateFunc(int)",
|
214
|
+
:GLUTMenuStatusFunc => "void GLUTMenuStatusFunc(int, int, int)",
|
215
|
+
:GLUTOverlayDisplayFunc => "void GLUTOverlayDisplayFunc()",
|
216
|
+
:GLUTWindowStatusFunc => "void GLUTWindowStatusFunc(int)",
|
217
|
+
|
218
|
+
:GLUTSpaceballMotionFunc => "void GLUTSpaceballMotionFunc(int, int, int)",
|
219
|
+
:GLUTSpaceballRotateFunc => "void GLUTSpaceballRotateFunc(int, int, int)",
|
220
|
+
:GLUTSpaceballButtonFunc => "void GLUTSpaceballButtonFunc(int, int)",
|
221
|
+
:GLUTButtonBoxFunc => "void GLUTButtonBoxFunc(int, int)",
|
222
|
+
:GLUTDialsFunc => "void GLUTDialsFunc(int, int)",
|
223
|
+
:GLUTTabletMotionFunc => "void GLUTTabletMotionFunc(int, int)",
|
224
|
+
:GLUTTabletButtonFunc => "void GLUTTabletButtonFunc(int, int, int, int)",
|
225
|
+
}
|
226
|
+
|
227
|
+
# Creates a callback as an instance of Fiddle::Function
|
228
|
+
def self.create_callback( sym, proc=nil, &blk )
|
229
|
+
if block_given?
|
230
|
+
return bind( @@glut_cb_function_signature[sym], nil, &blk )
|
231
|
+
else
|
232
|
+
return bind( @@glut_cb_function_signature[sym], nil, &proc )
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
GLUTMenuFunc_cb_args = [Fiddle::TYPE_INT]
|
237
|
+
GLUTMenuFunc_cb_retval = Fiddle::TYPE_VOID
|
238
|
+
GLUTTimerFunc_cb_args = [Fiddle::TYPE_INT]
|
239
|
+
GLUTTimerFunc_cb_retval = Fiddle::TYPE_VOID
|
240
|
+
GLUTIdleFunc_cb_args = []
|
241
|
+
GLUTIdleFunc_cb_retval = Fiddle::TYPE_VOID
|
242
|
+
GLUTKeyboardFunc_cb_args = [-Fiddle::TYPE_CHAR, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
243
|
+
GLUTKeyboardFunc_cb_retval = Fiddle::TYPE_VOID
|
244
|
+
GLUTSpecialFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
245
|
+
GLUTSpecialFunc_cb_retval = Fiddle::TYPE_VOID
|
246
|
+
GLUTReshapeFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
247
|
+
GLUTReshapeFunc_cb_retval = Fiddle::TYPE_VOID
|
248
|
+
GLUTVisibilityFunc_cb_args = [Fiddle::TYPE_INT]
|
249
|
+
GLUTVisibilityFunc_cb_retval = Fiddle::TYPE_VOID
|
250
|
+
GLUTDisplayFunc_cb_args = []
|
251
|
+
GLUTDisplayFunc_cb_retval = Fiddle::TYPE_VOID
|
252
|
+
GLUTMouseFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
253
|
+
GLUTMouseFunc_cb_retval = Fiddle::TYPE_VOID
|
254
|
+
GLUTMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
255
|
+
GLUTMotionFunc_cb_retval = Fiddle::TYPE_VOID
|
256
|
+
GLUTPassiveMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
257
|
+
GLUTPassiveMotionFunc_cb_retval = Fiddle::TYPE_VOID
|
258
|
+
GLUTEntryFunc_cb_args = [Fiddle::TYPE_INT]
|
259
|
+
GLUTEntryFunc_cb_retval = Fiddle::TYPE_VOID
|
260
|
+
GLUTKeyboardUpFunc_cb_args = [-Fiddle::TYPE_CHAR, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
261
|
+
GLUTKeyboardUpFunc_cb_retval = Fiddle::TYPE_VOID
|
262
|
+
GLUTSpecialUpFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
263
|
+
GLUTSpecialUpFunc_cb_retval = Fiddle::TYPE_VOID
|
264
|
+
GLUTJoystickFunc_cb_args = [-Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
265
|
+
GLUTJoystickFunc_cb_retval = Fiddle::TYPE_VOID
|
266
|
+
GLUTMenuStateFunc_cb_args = [Fiddle::TYPE_INT]
|
267
|
+
GLUTMenuStateFunc_cb_retval = Fiddle::TYPE_VOID
|
268
|
+
GLUTMenuStatusFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
269
|
+
GLUTMenuStatusFunc_cb_retval = Fiddle::TYPE_VOID
|
270
|
+
GLUTOverlayDisplayFunc_cb_args = []
|
271
|
+
GLUTOverlayDisplayFunc_cb_retval = Fiddle::TYPE_VOID
|
272
|
+
GLUTWindowStatusFunc_cb_args = [Fiddle::TYPE_INT]
|
273
|
+
GLUTWindowStatusFunc_cb_retval = Fiddle::TYPE_VOID
|
274
|
+
GLUTSpaceballMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
275
|
+
GLUTSpaceballMotionFunc_cb_retval = Fiddle::TYPE_VOID
|
276
|
+
GLUTSpaceballRotateFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
277
|
+
GLUTSpaceballRotateFunc_cb_retval = Fiddle::TYPE_VOID
|
278
|
+
GLUTSpaceballButtonFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
279
|
+
GLUTSpaceballButtonFunc_cb_retval = Fiddle::TYPE_VOID
|
280
|
+
GLUTButtonBoxFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
281
|
+
GLUTButtonBoxFunc_cb_retval = Fiddle::TYPE_VOID
|
282
|
+
GLUTDialsFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
283
|
+
GLUTDialsFunc_cb_retval = Fiddle::TYPE_VOID
|
284
|
+
GLUTTabletMotionFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
285
|
+
GLUTTabletMotionFunc_cb_retval = Fiddle::TYPE_VOID
|
286
|
+
GLUTTabletButtonFunc_cb_args = [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT]
|
287
|
+
GLUTTabletButtonFunc_cb_retval = Fiddle::TYPE_VOID
|
288
|
+
|
289
|
+
@@glut_cb_closure_signature = {
|
290
|
+
:GLUTMenuFunc => [GLUTMenuFunc_cb_retval, GLUTMenuFunc_cb_args],
|
291
|
+
:GLUTTimerFunc => [GLUTTimerFunc_cb_retval, GLUTTimerFunc_cb_args],
|
292
|
+
:GLUTIdleFunc => [GLUTIdleFunc_cb_retval, GLUTIdleFunc_cb_args],
|
293
|
+
:GLUTKeyboardFunc => [GLUTKeyboardFunc_cb_retval, GLUTKeyboardFunc_cb_args],
|
294
|
+
:GLUTSpecialFunc => [GLUTSpecialFunc_cb_retval, GLUTSpecialFunc_cb_args],
|
295
|
+
:GLUTReshapeFunc => [GLUTReshapeFunc_cb_retval, GLUTReshapeFunc_cb_args],
|
296
|
+
:GLUTVisibilityFunc => [GLUTVisibilityFunc_cb_retval, GLUTVisibilityFunc_cb_args],
|
297
|
+
:GLUTDisplayFunc => [GLUTDisplayFunc_cb_retval, GLUTDisplayFunc_cb_args],
|
298
|
+
:GLUTMouseFunc => [GLUTMouseFunc_cb_retval, GLUTMouseFunc_cb_args],
|
299
|
+
:GLUTMotionFunc => [GLUTMotionFunc_cb_retval, GLUTMotionFunc_cb_args],
|
300
|
+
:GLUTPassiveMotionFunc => [GLUTPassiveMotionFunc_cb_retval, GLUTPassiveMotionFunc_cb_args],
|
301
|
+
:GLUTEntryFunc => [GLUTEntryFunc_cb_retval, GLUTEntryFunc_cb_args],
|
302
|
+
:GLUTKeyboardUpFunc => [GLUTKeyboardUpFunc_cb_retval, GLUTKeyboardUpFunc_cb_args],
|
303
|
+
:GLUTSpecialUpFunc => [GLUTSpecialUpFunc_cb_retval, GLUTSpecialUpFunc_cb_args],
|
304
|
+
:GLUTJoystickFunc => [GLUTJoystickFunc_cb_retval, GLUTJoystickFunc_cb_args],
|
305
|
+
:GLUTMenuStateFunc => [GLUTMenuStateFunc_cb_retval, GLUTMenuStateFunc_cb_args],
|
306
|
+
:GLUTMenuStatusFunc => [GLUTMenuStatusFunc_cb_retval, GLUTMenuStatusFunc_cb_args],
|
307
|
+
:GLUTOverlayDisplayFunc => [GLUTOverlayDisplayFunc_cb_retval, GLUTOverlayDisplayFunc_cb_args],
|
308
|
+
:GLUTWindowStatusFunc => [GLUTWindowStatusFunc_cb_retval, GLUTWindowStatusFunc_cb_args],
|
309
|
+
:GLUTSpaceballMotionFunc => [GLUTSpaceballMotionFunc_cb_retval, GLUTSpaceballMotionFunc_cb_args],
|
310
|
+
:GLUTSpaceballRotateFunc => [GLUTSpaceballRotateFunc_cb_retval, GLUTSpaceballRotateFunc_cb_args],
|
311
|
+
:GLUTSpaceballButtonFunc => [GLUTSpaceballButtonFunc_cb_retval, GLUTSpaceballButtonFunc_cb_args],
|
312
|
+
:GLUTButtonBoxFunc => [GLUTButtonBoxFunc_cb_retval, GLUTButtonBoxFunc_cb_args],
|
313
|
+
:GLUTDialsFunc => [GLUTDialsFunc_cb_retval, GLUTDialsFunc_cb_args],
|
314
|
+
:GLUTTabletMotionFunc => [GLUTTabletMotionFunc_cb_retval, GLUTTabletMotionFunc_cb_args],
|
315
|
+
:GLUTTabletButtonFunc => [GLUTTabletButtonFunc_cb_retval, GLUTTabletButtonFunc_cb_args],
|
316
|
+
}
|
317
|
+
|
318
|
+
# Creates a callback as an instance of Fiddle::Closure::BlockCaller
|
319
|
+
def self.create_callback_closure( sym, proc=nil, &blk )
|
320
|
+
cb_retval = @@glut_cb_closure_signature[sym][0]
|
321
|
+
cb_args = @@glut_cb_closure_signature[sym][1]
|
322
|
+
if block_given?
|
323
|
+
return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &blk )
|
324
|
+
else
|
325
|
+
return Fiddle::Closure::BlockCaller.new( cb_retval, cb_args, Fiddle::Function::DEFAULT, &proc )
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
# NOTE : Use 'create_callback_function' for backward compatibility.
|
330
|
+
def self.create_callback( sym, proc=nil, &blk )
|
331
|
+
return self.create_callback_closure( sym, proc, &blk )
|
332
|
+
end
|
333
|
+
|
334
|
+
@@glut_import_done = false
|
335
|
+
|
336
|
+
# Load native library.
|
337
|
+
def self.load_lib(lib_path = nil, output_error = false)
|
338
|
+
if lib_path == nil
|
339
|
+
lib_path = case GL.get_platform
|
340
|
+
when :OPENGL_PLATFORM_WINDOWS
|
341
|
+
Dir.pwd + '/freeglut.dll'
|
342
|
+
when :OPENGL_PLATFORM_MACOSX
|
343
|
+
'/System/Library/Frameworks/GLUT.framework/GLUT'
|
344
|
+
else
|
345
|
+
'libglut.so' # not tested
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
dlload(lib_path)
|
350
|
+
|
351
|
+
import_symbols(output_error) unless @@glut_import_done
|
352
|
+
end
|
353
|
+
|
354
|
+
@@lib_signature = [
|
355
|
+
'void glutInit(int*, char**)',
|
356
|
+
'void glutInitWindowPosition(int, int)',
|
357
|
+
'void glutInitWindowSize(int, int)',
|
358
|
+
'void glutInitDisplayMode(unsigned int)',
|
359
|
+
'void glutInitDisplayString(const char*)',
|
360
|
+
|
361
|
+
'void glutMainLoop()',
|
362
|
+
|
363
|
+
'int glutCreateWindow(const char *)',
|
364
|
+
'int glutCreateSubWindow(int, int, int, int, int)',
|
365
|
+
'void glutDestroyWindow(int)',
|
366
|
+
'void glutSetWindow(int)',
|
367
|
+
'int glutGetWindow()',
|
368
|
+
'void glutSetWindowTitle(const char *)',
|
369
|
+
'void glutSetIconTitle(const char *)',
|
370
|
+
'void glutReshapeWindow(int, int)',
|
371
|
+
'void glutPositionWindow(int, int)',
|
372
|
+
'void glutShowWindow()',
|
373
|
+
'void glutHideWindow()',
|
374
|
+
'void glutIconifyWindow()',
|
375
|
+
'void glutPushWindow()',
|
376
|
+
'void glutPopWindow()',
|
377
|
+
'void glutFullScreen()',
|
378
|
+
|
379
|
+
'void glutPostWindowRedisplay(int)',
|
380
|
+
'void glutPostRedisplay()',
|
381
|
+
'void glutSwapBuffers()',
|
382
|
+
|
383
|
+
'void glutWarpPointer(int, int)',
|
384
|
+
'void glutSetCursor(int)',
|
385
|
+
|
386
|
+
'void glutEstablishOverlay()',
|
387
|
+
'void glutRemoveOverlay()',
|
388
|
+
'void glutUseLayer(unsigned int)',
|
389
|
+
'void glutPostOverlayRedisplay()',
|
390
|
+
'void glutPostWindowOverlayRedisplay(int)',
|
391
|
+
'void glutShowOverlay()',
|
392
|
+
'void glutHideOverlay()',
|
393
|
+
|
394
|
+
'int glutCreateMenu(void *)',
|
395
|
+
'void glutDestroyMenu(int)',
|
396
|
+
'int glutGetMenu()',
|
397
|
+
'void glutSetMenu(int)',
|
398
|
+
'void glutAddMenuEntry(const char *, int)',
|
399
|
+
'void glutAddSubMenu(const char *, int)',
|
400
|
+
'void glutChangeToMenuEntry(int, const char *, int)',
|
401
|
+
'void glutChangeToSubMenu(int, const char *, int)',
|
402
|
+
'void glutRemoveMenuItem(int)',
|
403
|
+
'void glutAttachMenu(int)',
|
404
|
+
'void glutDetachMenu(int)',
|
405
|
+
|
406
|
+
'void glutTimerFunc(unsigned int, void *, int)',
|
407
|
+
'void glutIdleFunc(void *)',
|
408
|
+
|
409
|
+
'void glutKeyboardFunc(void *)',
|
410
|
+
'void glutSpecialFunc(void *)',
|
411
|
+
'void glutReshapeFunc(void *)',
|
412
|
+
'void glutVisibilityFunc(void *)',
|
413
|
+
'void glutDisplayFunc(void *)',
|
414
|
+
'void glutMouseFunc(void *)',
|
415
|
+
'void glutMotionFunc(void *)',
|
416
|
+
'void glutPassiveMotionFunc(void *)',
|
417
|
+
'void glutEntryFunc(void *)',
|
418
|
+
|
419
|
+
'void glutKeyboardUpFunc(void *)',
|
420
|
+
'void glutSpecialUpFunc(void *)',
|
421
|
+
'void glutJoystickFunc(void *, int)',
|
422
|
+
'void glutMenuStateFunc(void *)',
|
423
|
+
'void glutMenuStatusFunc(void *)',
|
424
|
+
'void glutOverlayDisplayFunc(void *)',
|
425
|
+
'void glutWindowStatusFunc(void *)',
|
426
|
+
|
427
|
+
'void glutSpaceballMotionFunc(void *)',
|
428
|
+
'void glutSpaceballRotateFunc(void *)',
|
429
|
+
'void glutSpaceballButtonFunc(void *)',
|
430
|
+
'void glutButtonBoxFunc(void *)',
|
431
|
+
'void glutDialsFunc(void *)',
|
432
|
+
'void glutTabletMotionFunc(void *)',
|
433
|
+
'void glutTabletButtonFunc(void *)',
|
434
|
+
|
435
|
+
'int glutGet(unsigned int)',
|
436
|
+
'int glutDeviceGet(unsigned int)',
|
437
|
+
'int glutGetModifiers()',
|
438
|
+
'int glutLayerGet(unsigned int)',
|
439
|
+
|
440
|
+
'void glutBitmapCharacter(void *, int)',
|
441
|
+
'int glutBitmapWidth(void *, int)',
|
442
|
+
'void glutStrokeCharacter(void *, int)',
|
443
|
+
'int glutStrokeWidth(void *, int)',
|
444
|
+
'int glutBitmapLength(void *, const unsigned char*)',
|
445
|
+
'int glutStrokeLength(void *, const unsigned char*)',
|
446
|
+
|
447
|
+
'void glutWireCube(double)',
|
448
|
+
'void glutSolidCube(double)',
|
449
|
+
'void glutWireSphere(double, int, int)',
|
450
|
+
'void glutSolidSphere(double, int, int)',
|
451
|
+
'void glutWireCone(double, double, int, int)',
|
452
|
+
'void glutSolidCone(double, double, int, int)',
|
453
|
+
|
454
|
+
'void glutWireTorus(double, double, int, int)',
|
455
|
+
'void glutSolidTorus(double, double, int, int)',
|
456
|
+
'void glutWireDodecahedron()',
|
457
|
+
'void glutSolidDodecahedron()',
|
458
|
+
'void glutWireOctahedron()',
|
459
|
+
'void glutSolidOctahedron()',
|
460
|
+
'void glutWireTetrahedron()',
|
461
|
+
'void glutSolidTetrahedron()',
|
462
|
+
'void glutWireIcosahedron()',
|
463
|
+
'void glutSolidIcosahedron()',
|
464
|
+
|
465
|
+
'void glutWireTeapot(double)',
|
466
|
+
'void glutSolidTeapot(double)',
|
467
|
+
|
468
|
+
'void glutGameModeString(const char*)',
|
469
|
+
'int glutEnterGameMode()',
|
470
|
+
'void glutLeaveGameMode()',
|
471
|
+
'int glutGameModeGet(unsigned int)',
|
472
|
+
|
473
|
+
'int glutVideoResizeGet(unsigned int)',
|
474
|
+
'void glutSetupVideoResizing()',
|
475
|
+
'void glutStopVideoResizing()',
|
476
|
+
'void glutVideoResize(int, int, int, int)',
|
477
|
+
'void glutVideoPan(int, int, int, int)',
|
478
|
+
|
479
|
+
'void glutSetColor(int, float, float, float)',
|
480
|
+
'float glutGetColor(int, int)',
|
481
|
+
'void glutCopyColormap(int)',
|
482
|
+
|
483
|
+
'void glutIgnoreKeyRepeat(int)',
|
484
|
+
'void glutSetKeyRepeat(int)',
|
485
|
+
'void glutForceJoystickFunc()',
|
486
|
+
|
487
|
+
'int glutExtensionSupported(const char *)',
|
488
|
+
'void glutReportErrors()',
|
489
|
+
]
|
490
|
+
|
491
|
+
def self.import_symbols(output_error = false)
|
492
|
+
# defines
|
493
|
+
if GL.get_platform == :OPENGL_PLATFORM_WINDOWS
|
494
|
+
const_set('GLUT_STROKE_ROMAN', Fiddle::Pointer.new(0x0000) )
|
495
|
+
const_set('GLUT_STROKE_MONO_ROMAN', Fiddle::Pointer.new(0x0001) )
|
496
|
+
const_set('GLUT_BITMAP_9_BY_15', Fiddle::Pointer.new(0x0002) )
|
497
|
+
const_set('GLUT_BITMAP_8_BY_13', Fiddle::Pointer.new(0x0003) )
|
498
|
+
const_set('GLUT_BITMAP_TIMES_ROMAN_10', Fiddle::Pointer.new(0x0004) )
|
499
|
+
const_set('GLUT_BITMAP_TIMES_ROMAN_24', Fiddle::Pointer.new(0x0005) )
|
500
|
+
const_set('GLUT_BITMAP_HELVETICA_10', Fiddle::Pointer.new(0x0006) )
|
501
|
+
const_set('GLUT_BITMAP_HELVETICA_12', Fiddle::Pointer.new(0x0007) )
|
502
|
+
const_set('GLUT_BITMAP_HELVETICA_18', Fiddle::Pointer.new(0x0008) )
|
503
|
+
else
|
504
|
+
const_set('GLUT_STROKE_ROMAN', import_symbol("glutStrokeRoman") )
|
505
|
+
const_set('GLUT_STROKE_MONO_ROMAN', import_symbol("glutStrokeMonoRoman") )
|
506
|
+
const_set('GLUT_BITMAP_9_BY_15', import_symbol("glutBitmap9By15") )
|
507
|
+
const_set('GLUT_BITMAP_8_BY_13', import_symbol("glutBitmap8By13") )
|
508
|
+
const_set('GLUT_BITMAP_TIMES_ROMAN_10', import_symbol("glutBitmapTimesRoman10") )
|
509
|
+
const_set('GLUT_BITMAP_TIMES_ROMAN_24', import_symbol("glutBitmapTimesRoman24") )
|
510
|
+
const_set('GLUT_BITMAP_HELVETICA_10', import_symbol("glutBitmapHelvetica10") )
|
511
|
+
const_set('GLUT_BITMAP_HELVETICA_12', import_symbol("glutBitmapHelvetica12") )
|
512
|
+
const_set('GLUT_BITMAP_HELVETICA_18', import_symbol("glutBitmapHelvetica18") )
|
513
|
+
end
|
514
|
+
|
515
|
+
# function
|
516
|
+
@@lib_signature.each do |sig|
|
517
|
+
begin
|
518
|
+
extern sig
|
519
|
+
rescue
|
520
|
+
$stderr.puts("[Warning] Failed to import #{sig}.") if output_error
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
# Convert method names (e.g.: GLUT.glutInit -> GLUT.Init)
|
525
|
+
self.singleton_methods(false).each do |method_name|
|
526
|
+
m = singleton_method(method_name)
|
527
|
+
if m.name.to_s.start_with? 'glut'
|
528
|
+
modified_api = m.name.to_s[4..-1] # omit prefix "glut"
|
529
|
+
define_singleton_method(modified_api, m) # define alias
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
# Convert constant names (e.g.: GLUT::GLUT_KEY_F1 -> GLUT::KEY_F1)
|
534
|
+
self.constants.each do |constant|
|
535
|
+
cs = constant.to_s
|
536
|
+
if cs[0..4] == "GLUT_"
|
537
|
+
if cs[5] =~ /\d/
|
538
|
+
# We have to abandon name conversion like 'GL_2D, GL_3D_COLOR, GL_4_BYTES, etc.
|
539
|
+
# Because constants can't start with a digit or underscore.
|
540
|
+
# [Note] This rule has been inherited from Yoshi's very original ruby-opengl (confirmed with opengl-0.32g, 2004-07-17).
|
541
|
+
else
|
542
|
+
# Convert by omitting the 'GLUT_' prefix
|
543
|
+
const_set(cs[5..-1], GLUT.const_get(constant))
|
544
|
+
end
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
@@glut_import_done = true
|
549
|
+
end
|
550
|
+
|
551
|
+
end
|
552
|
+
|
553
|
+
=begin
|
554
|
+
Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
|
555
|
+
Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
|
556
|
+
|
557
|
+
This software is provided 'as-is', without any express or implied
|
558
|
+
warranty. In no event will the authors be held liable for any damages
|
559
|
+
arising from the use of this software.
|
560
|
+
|
561
|
+
Permission is granted to anyone to use this software for any purpose,
|
562
|
+
including commercial applications, and to alter it and redistribute it
|
563
|
+
freely, subject to the following restrictions:
|
564
|
+
|
565
|
+
1. The origin of this software must not be misrepresented; you must not
|
566
|
+
claim that you wrote the original software. If you use this software
|
567
|
+
in a product, an acknowledgment in the product documentation would be
|
568
|
+
appreciated but is not required.
|
569
|
+
|
570
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
571
|
+
misrepresented as being the original software.
|
572
|
+
|
573
|
+
3. This notice may not be removed or altered from any source
|
574
|
+
distribution.
|
575
|
+
=end
|
data/lib/opengl.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'opengl_platform'
|
2
|
+
require_relative 'opengl_common'
|
3
|
+
require_relative 'opengl_enum'
|
4
|
+
require_relative 'opengl_command'
|
5
|
+
case GL.get_platform
|
6
|
+
when :OPENGL_PLATFORM_WINDOWS
|
7
|
+
require_relative 'opengl_windows'
|
8
|
+
when :OPENGL_PLATFORM_MACOSX
|
9
|
+
require_relative 'opengl_macosx'
|
10
|
+
when :OPENGL_PLATFORM_LINUX
|
11
|
+
require_relative 'opengl_linux'
|
12
|
+
end
|
13
|
+
|
14
|
+
=begin
|
15
|
+
Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
|
16
|
+
Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
|
17
|
+
|
18
|
+
This software is provided 'as-is', without any express or implied
|
19
|
+
warranty. In no event will the authors be held liable for any damages
|
20
|
+
arising from the use of this software.
|
21
|
+
|
22
|
+
Permission is granted to anyone to use this software for any purpose,
|
23
|
+
including commercial applications, and to alter it and redistribute it
|
24
|
+
freely, subject to the following restrictions:
|
25
|
+
|
26
|
+
1. The origin of this software must not be misrepresented; you must not
|
27
|
+
claim that you wrote the original software. If you use this software
|
28
|
+
in a product, an acknowledgment in the product documentation would be
|
29
|
+
appreciated but is not required.
|
30
|
+
|
31
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
32
|
+
misrepresented as being the original software.
|
33
|
+
|
34
|
+
3. This notice may not be removed or altered from any source
|
35
|
+
distribution.
|
36
|
+
=end
|