remogatto-ffi-opengl 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,16 @@
1
+ == 0.2.0 / 2009-04-05
2
+
3
+ * Major improvements:
4
+ * Add support for MacOSX
5
+ * Add support for JRuby
6
+
7
+ * Minor improvements:
8
+ * Re-generate wrapper code fixing issues with callbacks
9
+ * Fix return type in functions that return string
10
+ * Add gears example
11
+ * Add a trivial benchmark that compares perfomance against
12
+ ruby-opengl
13
+
1
14
  == 0.1.0 / 2009-03-06
2
15
 
3
16
  * 1 major enhancement
data/README.rdoc CHANGED
@@ -5,16 +5,25 @@ ffi-opengl
5
5
  == DESCRIPTION:
6
6
 
7
7
  ffi-opengl is an autogenerated[1] ruby FFI interface towards OpenGL
8
- libraries (GL, GLU, GLUT).
8
+ libraries (GL, GLU, GLUT). The FFI layer ensures compatibility among
9
+ all Ruby implementation that support it. At the moment, this means
10
+ that you can run the same ffi-opengl script with MRI Ruby and JRuby.
9
11
 
10
- ffi-opengl API aims to be a 1:1 translation of the OpenGL C API: don't
11
- expect idiomatic ruby inside!
12
+ ffi-opengl API aims to be a 1:1 tranposition of the OpenGL C API:
13
+ don't expect idiomatic ruby inside!
12
14
 
13
15
  == FEATURES/PROBLEMS:
14
16
 
15
17
  * Full [auto-generated] wrap of the OpenGL libraries.
16
- * No compilation needed.
17
- * Not yet tested on windows/macosx platforms
18
+
19
+ * JRuby 1.3.0 compatible.
20
+
21
+ * No need of opengl development libraries.
22
+
23
+ * No compilation needed (if you use JRuby or you have ruby-ffi
24
+ installed on your system).
25
+
26
+ * Not yet tested on windows platform.
18
27
 
19
28
  == SYNOPSIS:
20
29
 
@@ -23,19 +32,19 @@ please refer to OpenGL reference pages.
23
32
 
24
33
  == REQUIREMENTS:
25
34
 
26
- * ffi >= 0.3.0 (development version)
35
+ * ffi >= 0.3.0
27
36
  * OpenGL libraries >= 1.2
28
37
 
29
38
  == DOWNLOAD/INSTALL:
30
39
 
31
40
  To download and install the gem from github:
32
41
 
33
- [sudo] gem sources -a http://gems.github.com
42
+ [sudo] gem sources -a http://gems.github.com # needed only the first time
34
43
  [sudo] gem install remogatto-ffi-opengl
35
44
 
36
45
  To download the develpment trunk:
37
46
 
38
- git clone http://github.com/remogatto/ffi-opengl/tree/master
47
+ git clone http://github.com/remogatto/ffi-opengl.git
39
48
 
40
49
  == LINKS:
41
50
 
@@ -0,0 +1,10 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ffi-opengl]))
2
+
3
+ require 'benchmark'
4
+
5
+ MAX_FRAMES = 30000
6
+
7
+ Benchmark.bm do |x|
8
+ x.report('ffi-opengl') { `ruby bench/ffi-opengl_spinning_cube.rb #{MAX_FRAMES}` }
9
+ x.report('ruby-opengl') { `ruby bench/ruby-opengl_spinning_cube.rb #{MAX_FRAMES}` }
10
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. examples spinning_cube]))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ffi-opengl]))
3
+
4
+ include FFI, GL, GLU, GLUT
5
+ app = SpinningCube.new(ARGV[0].to_i)
6
+ app.light_diffuse = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 0.0, 0.0, 1.0])
7
+ app.light_position = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 1.0, 1.0, 0.0])
8
+ app.start
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'opengl'
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. examples spinning_cube]))
5
+
6
+ class SpinningCube
7
+ def glut_init
8
+ glutInit
9
+ end
10
+ end
11
+
12
+ app = SpinningCube.new(ARGV[0].to_i)
13
+ app.light_diffuse = [1.0, 0.0, 0.0, 1.0]
14
+ app.light_position = [1.0, 1.0, 1.0, 0.0]
15
+ app.start
data/examples/gears.rb ADDED
@@ -0,0 +1,329 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # 3-D gear wheels. This program is in the public domain.
4
+ #
5
+ # Command line options:
6
+ # -info print GL implementation information
7
+ # -exit automatically exit after 30 seconds
8
+ #
9
+ # 2005-05-01 Ruby version by Arto Bendiken based on gears.c rev 1.8.
10
+ # 2005-01-09 Original C version (gears.c) by Brian Paul et al.
11
+ # http://cvs.freedesktop.org/mesa/Mesa/progs/demos/gears.c?rev=1.8
12
+
13
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ffi-opengl]))
14
+
15
+ class Gears
16
+ include FFI, GL, GLU, GLUT
17
+
18
+ POS = MemoryPointer.new(:float, 4).put_array_of_float(0, [5.0, 5.0, 10.0, 0.0])
19
+ RED = MemoryPointer.new(:float, 4).put_array_of_float(0, [0.8, 0.1, 0.0, 1.0])
20
+ GREEN = MemoryPointer.new(:float, 4).put_array_of_float(0, [0.0, 0.8, 0.2, 1.0])
21
+ BLUE = MemoryPointer.new(:float, 4).put_array_of_float(0, [0.2, 0.2, 1.0, 1.0])
22
+
23
+ include Math
24
+
25
+ # Draw a gear wheel. You'll probably want to call this function when
26
+ # building a display list since we do a lot of trig here.
27
+ #
28
+ # Input: inner_radius - radius of hole at center
29
+ # outer_radius - radius at center of teeth
30
+ # width - width of gear
31
+ # teeth - number of teeth
32
+ # tooth_depth - depth of tooth
33
+ def gear(inner_radius, outer_radius, width, teeth, tooth_depth)
34
+ r0 = inner_radius
35
+ r1 = outer_radius - tooth_depth / 2.0
36
+ r2 = outer_radius + tooth_depth / 2.0
37
+
38
+ da = 2.0 * PI / teeth / 4.0
39
+
40
+ glShadeModel(GL_FLAT)
41
+
42
+ glNormal3f(0.0, 0.0, 1.0)
43
+
44
+ # Draw front face
45
+ glBegin(GL_QUAD_STRIP)
46
+ for i in 0..teeth
47
+ angle = i * 2.0 * PI / teeth
48
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5)
49
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5)
50
+ if i < teeth
51
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5)
52
+ glVertex3f(r1 * cos(angle + 3 * da),
53
+ r1 * sin(angle + 3 * da), width * 0.5)
54
+ end
55
+ end
56
+ glEnd()
57
+
58
+ # Draw front sides of teeth
59
+ glBegin(GL_QUADS)
60
+ for i in 0...teeth
61
+ angle = i * 2.0 * PI / teeth
62
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5)
63
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5)
64
+ glVertex3f(r2 * cos(angle + 2 * da),
65
+ r2 * sin(angle + 2 * da), width * 0.5)
66
+ glVertex3f(r1 * cos(angle + 3 * da),
67
+ r1 * sin(angle + 3 * da), width * 0.5)
68
+ end
69
+ glEnd()
70
+
71
+ glNormal3f(0.0, 0.0, -1.0)
72
+
73
+ # Draw back face
74
+ glBegin(GL_QUAD_STRIP)
75
+ for i in 0..teeth
76
+ angle = i * 2.0 * PI / teeth
77
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5)
78
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5)
79
+ if i < teeth
80
+ glVertex3f(r1 * cos(angle + 3 * da),
81
+ r1 * sin(angle + 3 * da), -width * 0.5)
82
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5)
83
+ end
84
+ end
85
+ glEnd()
86
+
87
+ # Draw back sides of teeth
88
+ glBegin(GL_QUADS)
89
+ for i in 0...teeth
90
+ angle = i * 2.0 * PI / teeth
91
+ glVertex3f(r1 * cos(angle + 3 * da),
92
+ r1 * sin(angle + 3 * da), -width * 0.5)
93
+ glVertex3f(r2 * cos(angle + 2 * da),
94
+ r2 * sin(angle + 2 * da), -width * 0.5)
95
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5)
96
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5)
97
+ end
98
+ glEnd()
99
+
100
+ # Draw outward faces of teeth
101
+ glBegin(GL_QUAD_STRIP)
102
+ for i in 0...teeth
103
+ angle = i * 2.0 * PI / teeth
104
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5)
105
+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5)
106
+ u = r2 * cos(angle + da) - r1 * cos(angle)
107
+ v = r2 * sin(angle + da) - r1 * sin(angle)
108
+ len = sqrt(u * u + v * v)
109
+ u /= len
110
+ v /= len
111
+ glNormal3f(v, -u, 0.0)
112
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5)
113
+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5)
114
+ glNormal3f(cos(angle), sin(angle), 0.0)
115
+ glVertex3f(r2 * cos(angle + 2 * da),
116
+ r2 * sin(angle + 2 * da), width * 0.5)
117
+ glVertex3f(r2 * cos(angle + 2 * da),
118
+ r2 * sin(angle + 2 * da), -width * 0.5)
119
+ u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da)
120
+ v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da)
121
+ glNormal3f(v, -u, 0.0)
122
+ glVertex3f(r1 * cos(angle + 3 * da),
123
+ r1 * sin(angle + 3 * da), width * 0.5)
124
+ glVertex3f(r1 * cos(angle + 3 * da),
125
+ r1 * sin(angle + 3 * da), -width * 0.5)
126
+ glNormal3f(cos(angle), sin(angle), 0.0)
127
+ end
128
+ glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5)
129
+ glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5)
130
+ glEnd()
131
+
132
+ glShadeModel(GL_SMOOTH)
133
+
134
+ # Draw inside radius cylinder
135
+ glBegin(GL_QUAD_STRIP)
136
+ for i in 0..teeth
137
+ angle = i * 2.0 * PI / teeth
138
+ glNormal3f(-cos(angle), -sin(angle), 0.0)
139
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5)
140
+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5)
141
+ end
142
+ glEnd()
143
+ end
144
+
145
+ def draw
146
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
147
+
148
+ glPushMatrix()
149
+ glRotatef(@view_rotx, 1.0, 0.0, 0.0)
150
+ glRotatef(@view_roty, 0.0, 1.0, 0.0)
151
+ glRotatef(@view_rotz, 0.0, 0.0, 1.0)
152
+
153
+ glPushMatrix()
154
+ glTranslatef(-3.0, -2.0, 0.0)
155
+ glRotatef(@angle, 0.0, 0.0, 1.0)
156
+ glCallList(@gear1)
157
+ glPopMatrix()
158
+
159
+ glPushMatrix()
160
+ glTranslatef(3.1, -2.0, 0.0)
161
+ glRotatef(-2.0 * @angle - 9.0, 0.0, 0.0, 1.0)
162
+ glCallList(@gear2)
163
+ glPopMatrix()
164
+
165
+ glPushMatrix()
166
+ glTranslatef(-3.1, 4.2, 0.0)
167
+ glRotatef(-2.0 * @angle - 25.0, 0.0, 0.0, 1.0)
168
+ glCallList(@gear3)
169
+ glPopMatrix()
170
+
171
+ glPopMatrix()
172
+
173
+ glutSwapBuffers()
174
+
175
+ @frames = 0 if not defined? @frames
176
+ @t0 = 0 if not defined? @t0
177
+
178
+ @frames += 1
179
+ t = glutGet(GLUT_ELAPSED_TIME)
180
+ if t - @t0 >= 5000
181
+ seconds = (t - @t0) / 1000.0
182
+ fps = @frames / seconds
183
+ printf("%d frames in %6.3f seconds = %6.3f FPS\n",
184
+ @frames, seconds, fps)
185
+ @t0, @frames = t, 0
186
+ exit if defined? @autoexit and t >= 999.0 * @autoexit
187
+ end
188
+ end
189
+
190
+ def idle
191
+ t = glutGet(GLUT_ELAPSED_TIME) / 1000.0
192
+ @t0_idle = t if !defined? @t0_idle
193
+ # 90 degrees per second
194
+ @angle += 70.0 * (t - @t0_idle)
195
+ @t0_idle = t
196
+ glutPostRedisplay()
197
+ end
198
+
199
+ # Change view angle, exit upon ESC
200
+ def key(k, x, y)
201
+ case k
202
+ when ?z
203
+ @view_rotz += 5.0
204
+ when ?Z
205
+ @view_rotz -= 5.0
206
+ when 27 # Escape
207
+ exit
208
+ end
209
+ glutPostRedisplay()
210
+ end
211
+
212
+ # Change view angle
213
+ def special(k, x, y)
214
+ case k
215
+ when GLUT_KEY_UP
216
+ @view_rotx += 5.0
217
+ when GLUT_KEY_DOWN
218
+ @view_rotx -= 5.0
219
+ when GLUT_KEY_LEFT
220
+ @view_roty += 5.0
221
+ when GLUT_KEY_RIGHT
222
+ @view_roty -= 5.0
223
+ end
224
+ glutPostRedisplay()
225
+ end
226
+
227
+ # New window size or exposure
228
+ def reshape(width, height)
229
+ h = height.to_f / width.to_f
230
+ glViewport(0, 0, width, height)
231
+ glMatrixMode(GL_PROJECTION)
232
+ glLoadIdentity()
233
+ glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0)
234
+ glMatrixMode(GL_MODELVIEW)
235
+ glLoadIdentity()
236
+ glTranslatef(0.0, 0.0, -40.0)
237
+ end
238
+
239
+ def init
240
+ @angle = 0.0
241
+ @view_rotx, @view_roty, @view_rotz = 20.0, 30.0, 0.0
242
+
243
+ glLightfv(GL_LIGHT0, GL_POSITION, POS)
244
+ glEnable(GL_CULL_FACE)
245
+ glEnable(GL_LIGHTING)
246
+ glEnable(GL_LIGHT0)
247
+ glEnable(GL_DEPTH_TEST)
248
+
249
+ # Make the gears
250
+ @gear1 = glGenLists(1)
251
+ glNewList(@gear1, GL_COMPILE)
252
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, RED)
253
+ gear(1.0, 4.0, 1.0, 20, 0.7)
254
+ glEndList()
255
+
256
+ @gear2 = glGenLists(1)
257
+ glNewList(@gear2, GL_COMPILE)
258
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, GREEN)
259
+ gear(0.5, 2.0, 2.0, 10, 0.7)
260
+ glEndList()
261
+
262
+ @gear3 = glGenLists(1)
263
+ glNewList(@gear3, GL_COMPILE)
264
+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BLUE)
265
+ gear(1.3, 2.0, 0.5, 10, 0.7)
266
+ glEndList()
267
+
268
+ glEnable(GL_NORMALIZE)
269
+
270
+ ARGV.each do |arg|
271
+ case arg
272
+ when '-info'
273
+ printf("GL_RENDERER = %s\n", glGetString(GL_RENDERER))
274
+ printf("GL_VERSION = %s\n", glGetString(GL_VERSION))
275
+ printf("GL_VENDOR = %s\n", glGetString(GL_VENDOR))
276
+ printf("GL_EXTENSIONS = %s\n", glGetString(GL_EXTENSIONS))
277
+ when '-exit'
278
+ @autoexit = 30
279
+ printf("Auto Exit after %i seconds.\n", @autoexit);
280
+ end
281
+ end
282
+ end
283
+
284
+ def visible(vis)
285
+ glutIdleFunc((vis == GLUT_VISIBLE ? method(:idle).to_proc : nil))
286
+ end
287
+
288
+ def mouse(button, state, x, y)
289
+ @mouse = state
290
+ @x0, @y0 = x, y
291
+ end
292
+
293
+ def motion(x, y)
294
+ if @mouse == GLUT_DOWN then
295
+ @view_roty += @x0 - x
296
+ @view_rotx += @y0 - y
297
+ end
298
+ @x0, @y0 = x, y
299
+ end
300
+
301
+ def initialize
302
+ # argc, argv parameters
303
+ glutInit(MemoryPointer.new(:int, 1).put_int(0, 0),
304
+ MemoryPointer.new(:pointer, 1).put_pointer(0, nil))
305
+ glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE)
306
+
307
+ glutInitWindowPosition(0, 0)
308
+ glutInitWindowSize(300, 300)
309
+ glutCreateWindow('Gears')
310
+ init()
311
+
312
+ glutDisplayFunc(method(:draw).to_proc)
313
+ glutReshapeFunc(method(:reshape).to_proc)
314
+ glutKeyboardFunc(method(:key).to_proc)
315
+ glutSpecialFunc(method(:special).to_proc)
316
+ glutVisibilityFunc(method(:visible).to_proc)
317
+ glutMouseFunc(method(:mouse).to_proc)
318
+ glutMotionFunc(method(:motion).to_proc)
319
+ end
320
+
321
+ def start
322
+ glutMainLoop()
323
+ end
324
+
325
+ end
326
+
327
+ Gears.new.start
328
+
329
+
@@ -3,57 +3,74 @@
3
3
  # http://www.codecolony.de/
4
4
  #
5
5
 
6
- require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ffi-opengl]))
6
+ class SpinningCube
7
+ attr_accessor :light_diffuse, :light_position
8
+ attr_reader :max_frames
7
9
 
8
- include GL, GLU, GLUT
10
+ def initialize(max_frames = 0)
11
+ @x_rotated, @y_rotated, @z_rotated = 0.0, 0.0, 0.0
12
+ @frames, @max_frames = 0, max_frames
13
+ glut_init
14
+ end
15
+
16
+ def glut_init
17
+ glutInit(MemoryPointer.new(:int, 1).put_int(0, 0),
18
+ MemoryPointer.new(:pointer, 1).put_pointer(0, nil))
19
+ end
9
20
 
10
- @light_diffuse = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 0.0, 0.0, 1.0])
11
- @light_position = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 1.0, 1.0, 0.0])
12
- @x_rotated, @y_rotated, @z_rotated = 0.0, 0.0, 0.0
21
+ def display
22
+ glClear(GL_COLOR_BUFFER_BIT)
23
+ glLoadIdentity()
24
+ glTranslatef(0.0, 0.0, -5.0)
25
+ glRotatef(@x_rotated, 1.0, 0.0, 0.0)
26
+ glRotatef(@y_rotated, 0.0, 1.0, 0.0)
27
+ glRotatef(@z_rotated, 0.0, 0.0, 1.0)
28
+ glScalef(2.0, 1.0, 1.0)
29
+ glutSolidCube(1.0)
30
+ glFlush
31
+ glutSwapBuffers
32
+ exit if (@max_frames > 0 and (@frames += 1) > @max_frames)
33
+ end
13
34
 
14
- Display = Proc.new {
15
- glClear(GL_COLOR_BUFFER_BIT)
16
- glLoadIdentity()
17
- glTranslatef(0.0, 0.0, -5.0)
18
- glRotatef(@x_rotated, 1.0, 0.0, 0.0)
19
- glRotatef(@y_rotated, 0.0, 1.0, 0.0)
20
- glRotatef(@z_rotated, 0.0, 0.0, 1.0)
21
- glScalef(2.0, 1.0, 1.0)
22
- glutSolidCube(1.0)
23
- glFlush
24
- glutSwapBuffers
25
- }
35
+ def reshape(x, y)
36
+ exit if (y == 0 || x == 0)
37
+ glMatrixMode(GL_PROJECTION)
38
+ glLoadIdentity
39
+ gluPerspective(30.0, x / y, 0.5, 20.0)
40
+ glMatrixMode(GL_MODELVIEW)
41
+ glViewport(0, 0, x, y)
42
+ end
26
43
 
27
- Reshape = Proc.new { |x, y|
28
- exit if (y == 0 || x == 0)
29
- glMatrixMode(GL_PROJECTION)
30
- glLoadIdentity
31
- gluPerspective(30.0, x / y, 0.5, 20.0)
32
- glMatrixMode(GL_MODELVIEW)
33
- glViewport(0, 0, x, y)
34
- }
44
+ def idle
45
+ @x_rotated += 0.3
46
+ @y_rotated += 0.1
47
+ @z_rotated += -0.4
48
+ display
49
+ end
35
50
 
36
- Idle = Proc.new {
37
- @x_rotated += 0.3
38
- @y_rotated += 0.1
39
- @z_rotated += -0.4
40
- Display.call
41
- }
51
+ def start
52
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
53
+ glutInitWindowSize(300, 300)
54
+ glutCreateWindow("Cube example")
55
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, @light_diffuse)
56
+ glLightfv(GL_LIGHT0, GL_POSITION, @light_position)
57
+ glEnable(GL_LIGHT0)
58
+ glEnable(GL_LIGHTING)
59
+ glEnable(GL_CULL_FACE)
60
+ glShadeModel(GL_SMOOTH)
61
+ glClearColor(0.0, 0.0, 0.0, 0.0)
62
+ glutDisplayFunc(method(:display).to_proc)
63
+ glutIdleFunc(method(:idle).to_proc)
64
+ glutReshapeFunc(method(:reshape).to_proc)
65
+ glutMainLoop
66
+ end
67
+ end
42
68
 
43
- # argc, argv parameters
44
- glutInit(MemoryPointer.new(:int, 1).put_int(0, 0),
45
- MemoryPointer.new(:pointer, 1).put_pointer(0, nil))
46
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
47
- glutInitWindowSize(300, 300)
48
- glutCreateWindow("Cube example")
49
- glLightfv(GL_LIGHT0, GL_DIFFUSE, @light_diffuse)
50
- glLightfv(GL_LIGHT0, GL_POSITION, @light_position)
51
- glEnable(GL_LIGHT0)
52
- glEnable(GL_LIGHTING)
53
- glEnable(GL_CULL_FACE)
54
- glShadeModel(GL_SMOOTH)
55
- glClearColor(0.0, 0.0, 0.0, 0.0)
56
- glutDisplayFunc(Display)
57
- glutReshapeFunc(Reshape)
58
- glutIdleFunc(Idle)
59
- glutMainLoop
69
+ if __FILE__ == $0
70
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ffi-opengl]))
71
+ include FFI, GL, GLU, GLUT
72
+ app = SpinningCube.new
73
+ app.light_diffuse = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 0.0, 0.0, 1.0])
74
+ app.light_position = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 1.0, 1.0, 0.0])
75
+ app.start
76
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ffi-opengl}
5
+ s.version = "0.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Andrea Fazzi"]
9
+ s.date = %q{2009-04-05}
10
+ s.description = %q{ffi-opengl is an autogenerated[1] ruby FFI interface towards OpenGL libraries (GL, GLU, GLUT). The FFI layer ensures compatibility among all Ruby implementation that support it. At the moment, this means that you can run the same ffi-opengl script with MRI Ruby and JRuby. ffi-opengl API aims to be a 1:1 tranposition of the OpenGL C API: don't expect idiomatic ruby inside!}
11
+ s.email = %q{andrea.fazzi@alcacoop.it}
12
+ s.extra_rdoc_files = ["History.txt", "README.rdoc"]
13
+ s.files = [".gitignore", "History.txt", "README.rdoc", "Rakefile", "bench/bench_spinning_cube.rb", "bench/ffi-opengl_spinning_cube.rb", "bench/ruby-opengl_spinning_cube.rb", "examples/gears.rb", "examples/spinning_cube.rb", "ffi-opengl.gemspec", "generated/gl_wrap.rb", "generated/gl_wrap.xml", "generated/glu_wrap.rb", "generated/glu_wrap.xml", "generated/glut_wrap.rb", "generated/glut_wrap.xml", "interfaces/freeglut_std.h", "interfaces/gl.h", "interfaces/gl.i", "interfaces/glu.h", "interfaces/glu.i", "interfaces/glut.i", "lib/ffi-opengl.rb", "lib/ffi-opengl/gl.rb", "lib/ffi-opengl/glu.rb", "lib/ffi-opengl/glut.rb", "lib/ffi-opengl/platform.rb", "spec/ffi-opengl_spec.rb", "spec/spec_helper.rb", "tasks/ann.rake", "tasks/bones.rake", "tasks/gem.rake", "tasks/generator.rake", "tasks/git.rake", "tasks/notes.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/spec.rake", "tasks/svn.rake", "tasks/test.rake"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/remogatto/ffi-opengl}
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{ffi-opengl}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{ffi-opengl is an autogenerated[1] ruby FFI interface towards OpenGL libraries (GL, GLU, GLUT)}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<ffi>, [">= 0.3.0"])
28
+ else
29
+ s.add_dependency(%q<ffi>, [">= 0.3.0"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<ffi>, [">= 0.3.0"])
33
+ end
34
+ end
data/interfaces/gl.i CHANGED
@@ -1,10 +1,8 @@
1
1
  %module opengl
2
2
 
3
3
  %{
4
- require 'ffi'
5
4
  module GL
6
5
  extend FFI::Library
7
- ffi_lib 'GL'
8
6
  %}
9
7
 
10
8
  #define GL_MESA_program_debug
data/interfaces/glu.i CHANGED
@@ -1,10 +1,8 @@
1
1
  %module glu
2
2
 
3
3
  %{
4
- require 'ffi'
5
4
  module GLU
6
5
  extend FFI::Library
7
- ffi_lib 'GLU'
8
6
  %}
9
7
 
10
8
  /*
data/interfaces/glut.i CHANGED
@@ -1,10 +1,8 @@
1
1
  %module opengl
2
2
 
3
3
  %{
4
- require 'ffi'
5
4
  module GLUT
6
5
  extend FFI::Library
7
- ffi_lib 'glut'
8
6
  %}
9
7
 
10
8
  /*
data/lib/ffi-opengl.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module FFIOpenGL
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
7
  # :startdoc:
data/lib/ffi-opengl/gl.rb CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  module GL
2
3
  extend FFI::Library
3
4
  GL_VERSION_1_1 = 1
@@ -572,7 +573,7 @@ module GL
572
573
  attach_function :glPopClientAttrib, [ ], :void
573
574
  attach_function :glRenderMode, [ :uint ], :int
574
575
  attach_function :glGetError, [ ], :uint
575
- attach_function :glGetString, [ :uint ], :uchar
576
+ attach_function :glGetString, [ :uint ], :pointer
576
577
  attach_function :glFinish, [ ], :void
577
578
  attach_function :glFlush, [ ], :void
578
579
  attach_function :glHint, [ :uint, :uint ], :void
@@ -1030,8 +1031,8 @@ module GL
1030
1031
  callback(:PFNGLBLENDCOLORPROC, [ :float, :float, :float, :float ], :void)
1031
1032
  callback(:PFNGLBLENDEQUATIONPROC, [ :uint ], :void)
1032
1033
  callback(:PFNGLCOLORTABLEPROC, [ :uint, :uint, :int, :uint, :uint, :pointer ], :void)
1033
- callback(:PFNGLCOLORTABLEPARAMETERFVPROC, [ :uint, :uint, :pointer ], :float)
1034
- callback(:PFNGLCOLORTABLEPARAMETERIVPROC, [ :uint, :uint, :pointer ], :int)
1034
+ callback(:PFNGLCOLORTABLEPARAMETERFVPROC, [ :uint, :uint, :pointer ], :void)
1035
+ callback(:PFNGLCOLORTABLEPARAMETERIVPROC, [ :uint, :uint, :pointer ], :void)
1035
1036
  callback(:PFNGLCOPYCOLORTABLEPROC, [ :uint, :uint, :int, :int, :int ], :void)
1036
1037
  callback(:PFNGLGETCOLORTABLEPROC, [ :uint, :uint, :uint, :pointer ], :void)
1037
1038
  callback(:PFNGLGETCOLORTABLEPARAMETERFVPROC, [ :uint, :uint, :pointer ], :void)
@@ -1041,9 +1042,9 @@ module GL
1041
1042
  callback(:PFNGLCONVOLUTIONFILTER1DPROC, [ :uint, :uint, :int, :uint, :uint, :pointer ], :void)
1042
1043
  callback(:PFNGLCONVOLUTIONFILTER2DPROC, [ :uint, :uint, :int, :int, :uint, :uint, :pointer ], :void)
1043
1044
  callback(:PFNGLCONVOLUTIONPARAMETERFPROC, [ :uint, :uint, :float ], :void)
1044
- callback(:PFNGLCONVOLUTIONPARAMETERFVPROC, [ :uint, :uint, :pointer ], :float)
1045
+ callback(:PFNGLCONVOLUTIONPARAMETERFVPROC, [ :uint, :uint, :pointer ], :void)
1045
1046
  callback(:PFNGLCONVOLUTIONPARAMETERIPROC, [ :uint, :uint, :int ], :void)
1046
- callback(:PFNGLCONVOLUTIONPARAMETERIVPROC, [ :uint, :uint, :pointer ], :int)
1047
+ callback(:PFNGLCONVOLUTIONPARAMETERIVPROC, [ :uint, :uint, :pointer ], :void)
1047
1048
  callback(:PFNGLCOPYCONVOLUTIONFILTER1DPROC, [ :uint, :uint, :int, :int, :int ], :void)
1048
1049
  callback(:PFNGLCOPYCONVOLUTIONFILTER2DPROC, [ :uint, :uint, :int, :int, :int, :int ], :void)
1049
1050
  callback(:PFNGLGETCONVOLUTIONFILTERPROC, [ :uint, :uint, :uint, :pointer ], :void)
@@ -1202,41 +1203,41 @@ module GL
1202
1203
  callback(:PFNGLACTIVETEXTUREPROC, [ :uint ], :void)
1203
1204
  callback(:PFNGLCLIENTACTIVETEXTUREPROC, [ :uint ], :void)
1204
1205
  callback(:PFNGLMULTITEXCOORD1DPROC, [ :uint, :double ], :void)
1205
- callback(:PFNGLMULTITEXCOORD1DVPROC, [ :uint, :pointer ], :double)
1206
+ callback(:PFNGLMULTITEXCOORD1DVPROC, [ :uint, :pointer ], :void)
1206
1207
  callback(:PFNGLMULTITEXCOORD1FPROC, [ :uint, :float ], :void)
1207
- callback(:PFNGLMULTITEXCOORD1FVPROC, [ :uint, :pointer ], :float)
1208
+ callback(:PFNGLMULTITEXCOORD1FVPROC, [ :uint, :pointer ], :void)
1208
1209
  callback(:PFNGLMULTITEXCOORD1IPROC, [ :uint, :int ], :void)
1209
- callback(:PFNGLMULTITEXCOORD1IVPROC, [ :uint, :pointer ], :int)
1210
+ callback(:PFNGLMULTITEXCOORD1IVPROC, [ :uint, :pointer ], :void)
1210
1211
  callback(:PFNGLMULTITEXCOORD1SPROC, [ :uint, :short ], :void)
1211
- callback(:PFNGLMULTITEXCOORD1SVPROC, [ :uint, :pointer ], :short)
1212
+ callback(:PFNGLMULTITEXCOORD1SVPROC, [ :uint, :pointer ], :void)
1212
1213
  callback(:PFNGLMULTITEXCOORD2DPROC, [ :uint, :double, :double ], :void)
1213
- callback(:PFNGLMULTITEXCOORD2DVPROC, [ :uint, :pointer ], :double)
1214
+ callback(:PFNGLMULTITEXCOORD2DVPROC, [ :uint, :pointer ], :void)
1214
1215
  callback(:PFNGLMULTITEXCOORD2FPROC, [ :uint, :float, :float ], :void)
1215
- callback(:PFNGLMULTITEXCOORD2FVPROC, [ :uint, :pointer ], :float)
1216
+ callback(:PFNGLMULTITEXCOORD2FVPROC, [ :uint, :pointer ], :void)
1216
1217
  callback(:PFNGLMULTITEXCOORD2IPROC, [ :uint, :int, :int ], :void)
1217
- callback(:PFNGLMULTITEXCOORD2IVPROC, [ :uint, :pointer ], :int)
1218
+ callback(:PFNGLMULTITEXCOORD2IVPROC, [ :uint, :pointer ], :void)
1218
1219
  callback(:PFNGLMULTITEXCOORD2SPROC, [ :uint, :short, :short ], :void)
1219
- callback(:PFNGLMULTITEXCOORD2SVPROC, [ :uint, :pointer ], :short)
1220
+ callback(:PFNGLMULTITEXCOORD2SVPROC, [ :uint, :pointer ], :void)
1220
1221
  callback(:PFNGLMULTITEXCOORD3DPROC, [ :uint, :double, :double, :double ], :void)
1221
- callback(:PFNGLMULTITEXCOORD3DVPROC, [ :uint, :pointer ], :double)
1222
+ callback(:PFNGLMULTITEXCOORD3DVPROC, [ :uint, :pointer ], :void)
1222
1223
  callback(:PFNGLMULTITEXCOORD3FPROC, [ :uint, :float, :float, :float ], :void)
1223
- callback(:PFNGLMULTITEXCOORD3FVPROC, [ :uint, :pointer ], :float)
1224
+ callback(:PFNGLMULTITEXCOORD3FVPROC, [ :uint, :pointer ], :void)
1224
1225
  callback(:PFNGLMULTITEXCOORD3IPROC, [ :uint, :int, :int, :int ], :void)
1225
- callback(:PFNGLMULTITEXCOORD3IVPROC, [ :uint, :pointer ], :int)
1226
+ callback(:PFNGLMULTITEXCOORD3IVPROC, [ :uint, :pointer ], :void)
1226
1227
  callback(:PFNGLMULTITEXCOORD3SPROC, [ :uint, :short, :short, :short ], :void)
1227
- callback(:PFNGLMULTITEXCOORD3SVPROC, [ :uint, :pointer ], :short)
1228
+ callback(:PFNGLMULTITEXCOORD3SVPROC, [ :uint, :pointer ], :void)
1228
1229
  callback(:PFNGLMULTITEXCOORD4DPROC, [ :uint, :double, :double, :double, :double ], :void)
1229
- callback(:PFNGLMULTITEXCOORD4DVPROC, [ :uint, :pointer ], :double)
1230
+ callback(:PFNGLMULTITEXCOORD4DVPROC, [ :uint, :pointer ], :void)
1230
1231
  callback(:PFNGLMULTITEXCOORD4FPROC, [ :uint, :float, :float, :float, :float ], :void)
1231
- callback(:PFNGLMULTITEXCOORD4FVPROC, [ :uint, :pointer ], :float)
1232
+ callback(:PFNGLMULTITEXCOORD4FVPROC, [ :uint, :pointer ], :void)
1232
1233
  callback(:PFNGLMULTITEXCOORD4IPROC, [ :uint, :int, :int, :int, :int ], :void)
1233
- callback(:PFNGLMULTITEXCOORD4IVPROC, [ :uint, :pointer ], :int)
1234
+ callback(:PFNGLMULTITEXCOORD4IVPROC, [ :uint, :pointer ], :void)
1234
1235
  callback(:PFNGLMULTITEXCOORD4SPROC, [ :uint, :short, :short, :short, :short ], :void)
1235
- callback(:PFNGLMULTITEXCOORD4SVPROC, [ :uint, :pointer ], :short)
1236
- callback(:PFNGLLOADTRANSPOSEMATRIXFPROC, [ :pointer ], :float)
1237
- callback(:PFNGLLOADTRANSPOSEMATRIXDPROC, [ :pointer ], :double)
1238
- callback(:PFNGLMULTTRANSPOSEMATRIXFPROC, [ :pointer ], :float)
1239
- callback(:PFNGLMULTTRANSPOSEMATRIXDPROC, [ :pointer ], :double)
1236
+ callback(:PFNGLMULTITEXCOORD4SVPROC, [ :uint, :pointer ], :void)
1237
+ callback(:PFNGLLOADTRANSPOSEMATRIXFPROC, [ :pointer ], :void)
1238
+ callback(:PFNGLLOADTRANSPOSEMATRIXDPROC, [ :pointer ], :void)
1239
+ callback(:PFNGLMULTTRANSPOSEMATRIXFPROC, [ :pointer ], :void)
1240
+ callback(:PFNGLMULTTRANSPOSEMATRIXDPROC, [ :pointer ], :void)
1240
1241
  callback(:PFNGLSAMPLECOVERAGEPROC, [ :float, :uchar ], :void)
1241
1242
  callback(:PFNGLCOMPRESSEDTEXIMAGE3DPROC, [ :uint, :int, :uint, :int, :int, :int, :int, :int, :pointer ], :void)
1242
1243
  callback(:PFNGLCOMPRESSEDTEXIMAGE2DPROC, [ :uint, :int, :uint, :int, :int, :int, :int, :pointer ], :void)
@@ -1318,37 +1319,37 @@ module GL
1318
1319
  callback(:PFNGLACTIVETEXTUREARBPROC, [ :uint ], :void)
1319
1320
  callback(:PFNGLCLIENTACTIVETEXTUREARBPROC, [ :uint ], :void)
1320
1321
  callback(:PFNGLMULTITEXCOORD1DARBPROC, [ :uint, :double ], :void)
1321
- callback(:PFNGLMULTITEXCOORD1DVARBPROC, [ :uint, :pointer ], :double)
1322
+ callback(:PFNGLMULTITEXCOORD1DVARBPROC, [ :uint, :pointer ], :void)
1322
1323
  callback(:PFNGLMULTITEXCOORD1FARBPROC, [ :uint, :float ], :void)
1323
- callback(:PFNGLMULTITEXCOORD1FVARBPROC, [ :uint, :pointer ], :float)
1324
+ callback(:PFNGLMULTITEXCOORD1FVARBPROC, [ :uint, :pointer ], :void)
1324
1325
  callback(:PFNGLMULTITEXCOORD1IARBPROC, [ :uint, :int ], :void)
1325
- callback(:PFNGLMULTITEXCOORD1IVARBPROC, [ :uint, :pointer ], :int)
1326
+ callback(:PFNGLMULTITEXCOORD1IVARBPROC, [ :uint, :pointer ], :void)
1326
1327
  callback(:PFNGLMULTITEXCOORD1SARBPROC, [ :uint, :short ], :void)
1327
- callback(:PFNGLMULTITEXCOORD1SVARBPROC, [ :uint, :pointer ], :short)
1328
+ callback(:PFNGLMULTITEXCOORD1SVARBPROC, [ :uint, :pointer ], :void)
1328
1329
  callback(:PFNGLMULTITEXCOORD2DARBPROC, [ :uint, :double, :double ], :void)
1329
- callback(:PFNGLMULTITEXCOORD2DVARBPROC, [ :uint, :pointer ], :double)
1330
+ callback(:PFNGLMULTITEXCOORD2DVARBPROC, [ :uint, :pointer ], :void)
1330
1331
  callback(:PFNGLMULTITEXCOORD2FARBPROC, [ :uint, :float, :float ], :void)
1331
- callback(:PFNGLMULTITEXCOORD2FVARBPROC, [ :uint, :pointer ], :float)
1332
+ callback(:PFNGLMULTITEXCOORD2FVARBPROC, [ :uint, :pointer ], :void)
1332
1333
  callback(:PFNGLMULTITEXCOORD2IARBPROC, [ :uint, :int, :int ], :void)
1333
- callback(:PFNGLMULTITEXCOORD2IVARBPROC, [ :uint, :pointer ], :int)
1334
+ callback(:PFNGLMULTITEXCOORD2IVARBPROC, [ :uint, :pointer ], :void)
1334
1335
  callback(:PFNGLMULTITEXCOORD2SARBPROC, [ :uint, :short, :short ], :void)
1335
- callback(:PFNGLMULTITEXCOORD2SVARBPROC, [ :uint, :pointer ], :short)
1336
+ callback(:PFNGLMULTITEXCOORD2SVARBPROC, [ :uint, :pointer ], :void)
1336
1337
  callback(:PFNGLMULTITEXCOORD3DARBPROC, [ :uint, :double, :double, :double ], :void)
1337
- callback(:PFNGLMULTITEXCOORD3DVARBPROC, [ :uint, :pointer ], :double)
1338
+ callback(:PFNGLMULTITEXCOORD3DVARBPROC, [ :uint, :pointer ], :void)
1338
1339
  callback(:PFNGLMULTITEXCOORD3FARBPROC, [ :uint, :float, :float, :float ], :void)
1339
- callback(:PFNGLMULTITEXCOORD3FVARBPROC, [ :uint, :pointer ], :float)
1340
+ callback(:PFNGLMULTITEXCOORD3FVARBPROC, [ :uint, :pointer ], :void)
1340
1341
  callback(:PFNGLMULTITEXCOORD3IARBPROC, [ :uint, :int, :int, :int ], :void)
1341
- callback(:PFNGLMULTITEXCOORD3IVARBPROC, [ :uint, :pointer ], :int)
1342
+ callback(:PFNGLMULTITEXCOORD3IVARBPROC, [ :uint, :pointer ], :void)
1342
1343
  callback(:PFNGLMULTITEXCOORD3SARBPROC, [ :uint, :short, :short, :short ], :void)
1343
- callback(:PFNGLMULTITEXCOORD3SVARBPROC, [ :uint, :pointer ], :short)
1344
+ callback(:PFNGLMULTITEXCOORD3SVARBPROC, [ :uint, :pointer ], :void)
1344
1345
  callback(:PFNGLMULTITEXCOORD4DARBPROC, [ :uint, :double, :double, :double, :double ], :void)
1345
- callback(:PFNGLMULTITEXCOORD4DVARBPROC, [ :uint, :pointer ], :double)
1346
+ callback(:PFNGLMULTITEXCOORD4DVARBPROC, [ :uint, :pointer ], :void)
1346
1347
  callback(:PFNGLMULTITEXCOORD4FARBPROC, [ :uint, :float, :float, :float, :float ], :void)
1347
- callback(:PFNGLMULTITEXCOORD4FVARBPROC, [ :uint, :pointer ], :float)
1348
+ callback(:PFNGLMULTITEXCOORD4FVARBPROC, [ :uint, :pointer ], :void)
1348
1349
  callback(:PFNGLMULTITEXCOORD4IARBPROC, [ :uint, :int, :int, :int, :int ], :void)
1349
- callback(:PFNGLMULTITEXCOORD4IVARBPROC, [ :uint, :pointer ], :int)
1350
+ callback(:PFNGLMULTITEXCOORD4IVARBPROC, [ :uint, :pointer ], :void)
1350
1351
  callback(:PFNGLMULTITEXCOORD4SARBPROC, [ :uint, :short, :short, :short, :short ], :void)
1351
- callback(:PFNGLMULTITEXCOORD4SVARBPROC, [ :uint, :pointer ], :short)
1352
+ callback(:PFNGLMULTITEXCOORD4SVARBPROC, [ :uint, :pointer ], :void)
1352
1353
  GL_MESA_packed_depth_stencil = 1
1353
1354
  GL_DEPTH_STENCIL_MESA = 0x8750
1354
1355
  GL_UNSIGNED_INT_24_8_MESA = 0x8751
@@ -1,3 +1,4 @@
1
+
1
2
  module GLU
2
3
  extend FFI::Library
3
4
  GLU_EXT_object_space_tess = 1
@@ -176,9 +177,9 @@ module GLU
176
177
  attach_function :gluEndPolygon, [ :pointer ], :void
177
178
  attach_function :gluEndSurface, [ :pointer ], :void
178
179
  attach_function :gluEndTrim, [ :pointer ], :void
179
- attach_function :gluErrorString, [ :uint ], :uchar
180
+ attach_function :gluErrorString, [ :uint ], :pointer
180
181
  attach_function :gluGetNurbsProperty, [ :pointer, :uint, :pointer ], :void
181
- attach_function :gluGetString, [ :uint ], :uchar
182
+ attach_function :gluGetString, [ :uint ], :pointer
182
183
  attach_function :gluGetTessProperty, [ :pointer, :uint, :pointer ], :void
183
184
  attach_function :gluLoadSamplingMatrices, [ :pointer, :pointer, :pointer, :pointer ], :void
184
185
  attach_function :gluLookAt, [ :double, :double, :double, :double, :double, :double, :double, :double, :double ], :void
@@ -1,3 +1,4 @@
1
+
1
2
  module GLUT
2
3
  extend FFI::Library
3
4
  FREEGLUT = 1
@@ -244,8 +245,8 @@ module GLUT
244
245
  attach_function :glutBitmapWidth, [ :pointer, :int ], :int
245
246
  attach_function :glutStrokeCharacter, [ :pointer, :int ], :void
246
247
  attach_function :glutStrokeWidth, [ :pointer, :int ], :int
247
- attach_function :glutBitmapLength, [ :pointer, :string ], :int
248
- attach_function :glutStrokeLength, [ :pointer, :string ], :int
248
+ attach_function :glutBitmapLength, [ :pointer, :pointer ], :int
249
+ attach_function :glutStrokeLength, [ :pointer, :pointer ], :int
249
250
  attach_function :glutWireCube, [ :double ], :void
250
251
  attach_function :glutSolidCube, [ :double ], :void
251
252
  attach_function :glutWireSphere, [ :double, :int, :int ], :void
@@ -1,27 +1,28 @@
1
+ require 'rbconfig'
1
2
  module GL
2
3
  extend FFI::Library
3
- case RUBY_PLATFORM
4
+ case Config::CONFIG['target_os']
4
5
  when /linux/
5
- ffi_lib 'GL'
6
+ ffi_lib 'libGL.so.1'
6
7
  when /darwin/
7
8
  ffi_lib '/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib'
8
9
  end
9
10
  end
10
11
  module GLU
11
12
  extend FFI::Library
12
- case RUBY_PLATFORM
13
+ case Config::CONFIG['target_os']
13
14
  when /linux/
14
- ffi_lib 'GLU'
15
+ ffi_lib 'libGLU.so.1'
15
16
  when /darwin/
16
17
  ffi_lib '/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib'
17
18
  end
18
19
  end
19
20
  module GLUT
20
21
  extend FFI::Library
21
- case RUBY_PLATFORM
22
+ case Config::CONFIG['target_os']
22
23
  when /linux/
23
- ffi_lib 'glut'
24
+ ffi_lib 'libglut.so.3'
24
25
  when /darwin/
25
- ffi_lib '/System/Library/Frameworks/GLUT.framework/GLUT.dylib'
26
+ ffi_lib '/System/Library/Frameworks/GLUT.framework/GLUT'
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remogatto-ffi-opengl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Fazzi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-08 00:00:00 -08:00
12
+ date: 2009-04-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,17 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.3.0
24
24
  version:
25
- - !ruby/object:Gem::Dependency
26
- name: bones
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.4.0
34
- version:
35
- description: "ffi-opengl is an autogenerated[1] ruby FFI interface towards OpenGL libraries (GL, GLU, GLUT). ffi-opengl API aims to be a 1:1 translation of the OpenGL C API: don't expect idiomatic ruby inside!"
25
+ description: "ffi-opengl is an autogenerated[1] ruby FFI interface towards OpenGL libraries (GL, GLU, GLUT). The FFI layer ensures compatibility among all Ruby implementation that support it. At the moment, this means that you can run the same ffi-opengl script with MRI Ruby and JRuby. ffi-opengl API aims to be a 1:1 tranposition of the OpenGL C API: don't expect idiomatic ruby inside!"
36
26
  email: andrea.fazzi@alcacoop.it
37
27
  executables: []
38
28
 
@@ -46,7 +36,18 @@ files:
46
36
  - History.txt
47
37
  - README.rdoc
48
38
  - Rakefile
39
+ - bench/bench_spinning_cube.rb
40
+ - bench/ffi-opengl_spinning_cube.rb
41
+ - bench/ruby-opengl_spinning_cube.rb
42
+ - examples/gears.rb
49
43
  - examples/spinning_cube.rb
44
+ - ffi-opengl.gemspec
45
+ - generated/gl_wrap.rb
46
+ - generated/gl_wrap.xml
47
+ - generated/glu_wrap.rb
48
+ - generated/glu_wrap.xml
49
+ - generated/glut_wrap.rb
50
+ - generated/glut_wrap.xml
50
51
  - interfaces/freeglut_std.h
51
52
  - interfaces/gl.h
52
53
  - interfaces/gl.i