ruby-sdl-ffi 0.1

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.
@@ -0,0 +1,57 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ module SDL
32
+
33
+ MUTEX_TIMEDOUT = 1
34
+
35
+ sdl_func :CreateMutex, [ ], :pointer
36
+ sdl_func :mutexP, [ :pointer ], :int
37
+ sdl_func :mutexV, [ :pointer ], :int
38
+ sdl_func :DestroyMutex, [ :pointer ], :void
39
+
40
+ sdl_func :CreateSemaphore, [ :uint32 ], :pointer
41
+ sdl_func :DestroySemaphore, [ :pointer ], :void
42
+
43
+ sdl_func :SemWait, [ :pointer ], :int
44
+ sdl_func :SemTryWait, [ :pointer ], :int
45
+ sdl_func :SemWaitTimeout, [ :pointer, :uint32 ], :int
46
+ sdl_func :SemPost, [ :pointer ], :int
47
+ sdl_func :SemValue, [ :pointer ], :uint32
48
+
49
+ sdl_func :CreateCond, [ ], :pointer
50
+ sdl_func :DestroyCond, [ :pointer ], :void
51
+ sdl_func :CondSignal, [ :pointer ], :int
52
+ sdl_func :CondBroadcast, [ :pointer ], :int
53
+ sdl_func :CondWait, [ :pointer, :pointer ], :int
54
+
55
+ sdl_func :CondWaitTimeout, [ :pointer, :pointer, :uint32 ], :int
56
+
57
+ end
@@ -0,0 +1,137 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ module SDL
32
+
33
+ class RWopsHiddenStdio < NiceFFI::Struct
34
+ layout( :autoclose, :int,
35
+ :fp, :pointer )
36
+ end
37
+
38
+
39
+ class RWopsHiddenMem < NiceFFI::Struct
40
+ layout( :base, :pointer,
41
+ :here, :pointer,
42
+ :stop, :pointer )
43
+ end
44
+
45
+
46
+ class RWopsHiddenUnknown < NiceFFI::Struct
47
+ layout( :data1, :pointer )
48
+ end
49
+
50
+
51
+ class RWopsHidden < FFI::Union
52
+ layout( :stdio, SDL::RWopsHiddenStdio,
53
+ :mem, SDL::RWopsHiddenMem,
54
+ :unknown, SDL::RWopsHiddenUnknown )
55
+ end
56
+
57
+
58
+ SDL::callback(:rwops_seek_cb, [:pointer, :int, :int], :int)
59
+ SDL::callback(:rwops_read_cb, [:pointer, :pointer, :int, :int], :int)
60
+ SDL::callback(:rwops_write_cb,[:pointer, :pointer, :int, :int], :int)
61
+ SDL::callback(:rwops_close_cb,[:pointer], :int)
62
+
63
+ class RWops < NiceFFI::Struct
64
+ layout( :seek, :rwops_seek_cb,
65
+ :read, :rwops_read_cb,
66
+ :write, :rwops_write_cb,
67
+ :close, :rwops_close_cb,
68
+ :type, :uint32,
69
+ :hidden, SDL::RWopsHidden )
70
+
71
+ hidden( :hidden )
72
+
73
+ def seek=(cb)
74
+ @seek = cb
75
+ self[:seek] = @seek
76
+ end
77
+
78
+ def seek
79
+ @seek
80
+ end
81
+
82
+ def read=(cb)
83
+ @read = cb
84
+ self[:read] = @read
85
+ end
86
+
87
+ def read
88
+ @read
89
+ end
90
+
91
+ def write=(cb)
92
+ @write = cb
93
+ self[:write] = @write
94
+ end
95
+
96
+ def write
97
+ @write
98
+ end
99
+
100
+ def close=(cb)
101
+ @close = cb
102
+ self[:close] = @close
103
+ end
104
+
105
+ def close
106
+ @close
107
+ end
108
+
109
+ end
110
+
111
+
112
+ sdl_func :RWFromFile, [ :string, :string ], :pointer
113
+ sdl_func :RWFromFP, [ :pointer, :int ], :pointer
114
+ sdl_func :RWFromMem, [ :pointer, :int ], :pointer
115
+ sdl_func :RWFromConstMem, [ :pointer, :int ], :pointer
116
+
117
+ sdl_func :AllocRW, [ ], :pointer
118
+ sdl_func :FreeRW, [ :pointer ], :void
119
+
120
+ RW_SEEK_SET = 0
121
+ RW_SEEK_CUR = 1
122
+ RW_SEEK_END = 2
123
+
124
+ sdl_func :ReadLE16, [ :pointer ], :uint16
125
+ sdl_func :ReadBE16, [ :pointer ], :uint16
126
+ sdl_func :ReadLE32, [ :pointer ], :uint32
127
+ sdl_func :ReadBE32, [ :pointer ], :uint32
128
+ sdl_func :ReadLE64, [ :pointer ], :uint64
129
+ sdl_func :ReadBE64, [ :pointer ], :uint64
130
+ sdl_func :WriteLE16, [ :pointer, :uint16 ], :int
131
+ sdl_func :WriteBE16, [ :pointer, :uint16 ], :int
132
+ sdl_func :WriteLE32, [ :pointer, :uint32 ], :int
133
+ sdl_func :WriteBE32, [ :pointer, :uint32 ], :int
134
+ sdl_func :WriteLE64, [ :pointer, :uint64 ], :int
135
+ sdl_func :WriteBE64, [ :pointer, :uint64 ], :int
136
+
137
+ end
@@ -0,0 +1,47 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ module SDL
32
+
33
+ TIMESLICE = 10
34
+ TIMER_RESOLUTION = 10
35
+
36
+ sdl_func :GetTicks, [ ], :uint32
37
+ sdl_func :Delay, [ :uint32 ], :void
38
+
39
+ callback(:timer_cb, [ :uint32 ], :uint32)
40
+ sdl_func :SetTimer, [ :uint32, :timer_cb ], :int
41
+
42
+ callback(:newtimer_cb, [ :uint32, :pointer ], :uint32)
43
+ sdl_func :AddTimer, [:uint32, :newtimer_cb, :pointer], :pointer
44
+
45
+ sdl_func :RemoveTimer, [ :pointer ], SDL::BOOL
46
+
47
+ end
@@ -0,0 +1,447 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ module SDL
32
+
33
+ ALPHA_OPAQUE = 255
34
+ ALPHA_TRANSPARENT = 0
35
+
36
+ class Rect < NiceFFI::Struct
37
+ layout( :x, :int16,
38
+ :y, :int16,
39
+ :w, :uint16,
40
+ :h, :uint16 )
41
+ end
42
+
43
+ class Color < NiceFFI::Struct
44
+ layout( :r, :uint8,
45
+ :g, :uint8,
46
+ :b, :uint8,
47
+ :unused, :uint8 )
48
+
49
+ hidden( :unused )
50
+
51
+ end
52
+
53
+ class Palette < NiceFFI::Struct
54
+ layout( :ncolors, :int,
55
+ :colors, :pointer )
56
+ end
57
+
58
+ class PixelFormat < NiceFFI::Struct
59
+ layout( :palette, Palette.typed_pointer,
60
+ :BitsPerPixel, :uint8,
61
+ :BytesPerPixel, :uint8,
62
+ :Rloss, :uint8,
63
+ :Gloss, :uint8,
64
+ :Bloss, :uint8,
65
+ :Aloss, :uint8,
66
+ :Rshift, :uint8,
67
+ :Gshift, :uint8,
68
+ :Bshift, :uint8,
69
+ :Ashift, :uint8,
70
+ :Rmask, :uint32,
71
+ :Gmask, :uint32,
72
+ :Bmask, :uint32,
73
+ :Amask, :uint32,
74
+ :colorkey, :uint32,
75
+ :alpha, :uint8 )
76
+ end
77
+
78
+ class Surface < NiceFFI::Struct
79
+ layout( :flags, :uint32,
80
+ :format, PixelFormat.typed_pointer,
81
+ :w, :int,
82
+ :h, :int,
83
+ :pitch, :uint16,
84
+ :pixels, :pointer,
85
+ :offset, :int,
86
+ :hwdata, :pointer,
87
+ :clip_rect, SDL::Rect,
88
+ :unused1, :uint32,
89
+ :locked, :uint32,
90
+ :map, :pointer,
91
+ :format_version, :uint,
92
+ :refcount, :int )
93
+
94
+ read_only( :flags, :format, :w, :h,
95
+ :pitch, :clip_rect, :refcount )
96
+
97
+ hidden( :offset, :hwdata, :unused1,
98
+ :locked, :map, :format_version )
99
+
100
+ def self.release( pointer )
101
+ SDL.FreeSurface( pointer )
102
+ end
103
+ end
104
+
105
+
106
+ SWSURFACE = 0x00000000
107
+ HWSURFACE = 0x00000001
108
+ ASYNCBLIT = 0x00000004
109
+ ANYFORMAT = 0x10000000
110
+ HWPALETTE = 0x20000000
111
+ DOUBLEBUF = 0x40000000
112
+ FULLSCREEN = 0x80000000
113
+ OPENGL = 0x00000002
114
+ OPENGLBLIT = 0x0000000A
115
+ RESIZABLE = 0x00000010
116
+ NOFRAME = 0x00000020
117
+ HWACCEL = 0x00000100
118
+ SRCCOLORKEY = 0x00001000
119
+ RLEACCELOK = 0x00002000
120
+ RLEACCEL = 0x00004000
121
+ SRCALPHA = 0x00010000
122
+ PREALLOC = 0x01000000
123
+
124
+ callback(:blit_cb, [ :pointer, :pointer, :pointer, :pointer ], :int)
125
+
126
+
127
+ class VideoInfo < NiceFFI::Struct
128
+ layout( :flags, :uint32,
129
+
130
+ ## flags contains:
131
+ # :hw_available, :uint32, #bitfield: 1
132
+ # :wm_available, :uint32, #bitfield: 1
133
+ # :UnusedBits1, :uint32, #bitfield: 6
134
+ # :UnusedBits2, :uint32, #bitfield: 1
135
+ # :blit_hw, :uint32, #bitfield: 1
136
+ # :blit_hw_CC, :uint32, #bitfield: 1
137
+ # :blit_hw_A, :uint32, #bitfield: 1
138
+ # :blit_sw, :uint32, #bitfield: 1
139
+ # :blit_sw_CC, :uint32, #bitfield: 1
140
+ # :blit_sw_A, :uint32, #bitfield: 1
141
+ # :blit_fill, :uint32, #bitfield: 1
142
+ # :UnusedBits3, :uint32, #bitfield: 16
143
+
144
+ :video_mem, :uint32,
145
+ :vfmt, PixelFormat.typed_pointer,
146
+ :current_w, :int,
147
+ :current_h, :int )
148
+
149
+ hidden( :flags )
150
+
151
+ def hw_available
152
+ self[:flags][1]
153
+ end
154
+
155
+ def wm_available
156
+ self[:flags][2]
157
+ end
158
+
159
+ def blit_hw
160
+ self[:flags][9]
161
+ end
162
+
163
+ def blit_hw_CC
164
+ self[:flags][10]
165
+ end
166
+
167
+ def blit_hw_A
168
+ self[:flags][11]
169
+ end
170
+
171
+ def blit_sw
172
+ self[:flags][12]
173
+ end
174
+
175
+ def blit_sw_CC
176
+ self[:flags][13]
177
+ end
178
+
179
+ def blit_sw_A
180
+ self[:flags][14]
181
+ end
182
+
183
+ def blit_fill
184
+ self[:flags][15]
185
+ end
186
+ end
187
+
188
+
189
+ YV12_OVERLAY = 0x32315659
190
+ IYUV_OVERLAY = 0x56555949
191
+ YUY2_OVERLAY = 0x32595559
192
+ UYVY_OVERLAY = 0x59565955
193
+ YVYU_OVERLAY = 0x55595659
194
+
195
+ class Overlay < NiceFFI::Struct
196
+ layout( :format, :uint32,
197
+ :w, :int,
198
+ :h, :int,
199
+ :planes, :int,
200
+ :pitches, :pointer,
201
+ :pixels, :pointer,
202
+ :hwfuncs, :pointer,
203
+ :hwdata, :pointer,
204
+ :hw_overlay, :uint32,
205
+ :UnusedBits, :uint32 )
206
+
207
+ read_only( :format, :w, :h, :planes,
208
+ :pitches, :hw_overlay )
209
+
210
+ hidden( :hwfuncs, :hwdata, :UnusedBits )
211
+
212
+ def self.release( pointer )
213
+ SDL.FreeYUVOverlay( pointer )
214
+ end
215
+ end
216
+
217
+
218
+ GL_RED_SIZE = 0
219
+ GL_GREEN_SIZE = 1
220
+ GL_BLUE_SIZE = 2
221
+ GL_ALPHA_SIZE = 3
222
+ GL_BUFFER_SIZE = 4
223
+ GL_DOUBLEBUFFER = 5
224
+ GL_DEPTH_SIZE = 6
225
+ GL_STENCIL_SIZE = 7
226
+ GL_ACCUM_RED_SIZE = 8
227
+ GL_ACCUM_GREEN_SIZE = 9
228
+ GL_ACCUM_BLUE_SIZE = 10
229
+ GL_ACCUM_ALPHA_SIZE = 11
230
+ GL_STEREO = 12
231
+ GL_MULTISAMPLEBUFFERS = 13
232
+ GL_MULTISAMPLESAMPLES = 14
233
+ GL_ACCELERATED_VISUAL = 15
234
+ GL_SWAP_CONTROL = 16
235
+
236
+ LOGPAL = 0x01
237
+ PHYSPAL = 0x02
238
+
239
+
240
+ sdl_func :VideoInit, [ :string, :uint32 ], :int
241
+ sdl_func :VideoQuit, [ ], :void
242
+
243
+ sdl_func :VideoDriverName, [ :string, :int ], :string
244
+
245
+ sdl_func :GetVideoSurface, [],
246
+ SDL::Surface.typed_pointer( :autorelease => false )
247
+
248
+ sdl_func :GetVideoInfo, [ ], SDL::VideoInfo.typed_pointer
249
+
250
+ sdl_func :VideoModeOK, [ :int, :int, :int, :uint32 ], :int
251
+
252
+ ## Don't know how to implement this one. :-\
253
+ # sdl_func :ListModes, [ :pointer, :uint32 ], :pointer
254
+
255
+ sdl_func :SetVideoMode, [ :int, :int, :int, :uint32 ],
256
+ SDL::Surface.typed_pointer( :autorelease => false )
257
+
258
+
259
+
260
+ func :__UpdateRects, "SDL_UpdateRects", [ :pointer, :int, :pointer ], :void
261
+
262
+ def self.UpdateRects( surf, rects )
263
+ rects_mp = FFI::Buffer.new( Rect, rects.length )
264
+
265
+ rects.each_with_index do |rect, i|
266
+ rects_mp[i].put_bytes( 0, rect.to_bytes )
267
+ end
268
+
269
+ __UpdateRects( surf, rects.length, rects_mp )
270
+ end
271
+
272
+
273
+ sdl_func :UpdateRect, [ :pointer, :int32, :int32, :uint32, :uint32 ], :void
274
+ sdl_func :Flip, [ :pointer ], :int
275
+
276
+
277
+
278
+ sdl_func :SetGamma, [ :float, :float, :float ], :int
279
+ sdl_func :SetGammaRamp, [ :pointer, :pointer, :pointer ], :int
280
+
281
+
282
+ func :__SDL_GetGammaRamp, "SDL_GetGammaRamp",
283
+ [ :pointer, :pointer, :pointer ], :int
284
+
285
+ def self.GetGammaRamp()
286
+ rtable = FFI::Buffer.new( :uint16, 256 )
287
+ gtable = FFI::Buffer.new( :uint16, 256 )
288
+ btable = FFI::Buffer.new( :uint16, 256 )
289
+
290
+ n = __SDL_GetGammaRamp( rtable, gtable, btable )
291
+
292
+ if( n == -1 )
293
+ return nil
294
+ else
295
+ return [ rtable.get_array_of_uint16(0, 256),
296
+ gtable.get_array_of_uint16(0, 256),
297
+ btable.get_array_of_uint16(0, 256) ]
298
+ end
299
+ end
300
+
301
+
302
+ sdl_func :SetColors, [ :pointer, :pointer, :int, :int ], :int
303
+ sdl_func :SetPalette, [ :pointer, :int, :pointer, :int, :int ], :int
304
+ sdl_func :MapRGB, [ :pointer, :uint8, :uint8, :uint8 ], :uint32
305
+ sdl_func :MapRGBA, [ :pointer, :uint8, :uint8, :uint8, :uint8 ], :uint32
306
+
307
+
308
+ func :__SDL_GetRGB, "SDL_GetRGB",
309
+ [ :uint32, :pointer, :pointer, :pointer, :pointer ], :void
310
+
311
+ def self.GetRGB( uint32, format )
312
+ r = FFI::MemoryPointer.new( :uint8 )
313
+ g = FFI::MemoryPointer.new( :uint8 )
314
+ b = FFI::MemoryPointer.new( :uint8 )
315
+ __SDL_GetRGB( uint32, format, r, g, b )
316
+ return [r.get_uint8(0), g.get_uint8(0), b.get_uint8(0)]
317
+ end
318
+
319
+
320
+
321
+ func :__SDL_GetRGBA, "SDL_GetRGBA",
322
+ [ :uint32, :pointer, :pointer, :pointer, :pointer, :pointer ], :void
323
+
324
+ def self.GetRGBA( uint32, format )
325
+ r = FFI::MemoryPointer.new( :uint8 )
326
+ g = FFI::MemoryPointer.new( :uint8 )
327
+ b = FFI::MemoryPointer.new( :uint8 )
328
+ a = FFI::MemoryPointer.new( :uint8 )
329
+ __SDL_GetRGBA( uint32, format, r, g, b, a )
330
+ return [r.get_uint8(0), g.get_uint8(0), b.get_uint8(0), a.get_uint8(0)]
331
+ end
332
+
333
+
334
+
335
+ sdl_func :CreateRGBSurface,
336
+ [ :uint32, :int, :int, :int, :uint32, :uint32, :uint32, :uint32 ],
337
+ SDL::Surface.typed_pointer
338
+
339
+ sdl_func :CreateRGBSurfaceFrom,
340
+ [ :pointer, :int, :int, :int, :int,
341
+ :uint32, :uint32, :uint32, :uint32 ],
342
+ SDL::Surface.typed_pointer
343
+
344
+
345
+ sdl_func :FreeSurface, [ :pointer ], :void
346
+ sdl_func :LockSurface, [ :pointer ], :int
347
+ sdl_func :UnlockSurface, [ :pointer ], :void
348
+
349
+
350
+ sdl_func :LoadBMP_RW, [ :pointer, :int ], SDL::Surface.typed_pointer
351
+ sdl_func :SaveBMP_RW, [ :pointer, :pointer, :int ], :int
352
+
353
+
354
+ sdl_func :SetColorKey, [ :pointer, :uint32, :uint32 ], :int
355
+ sdl_func :SetAlpha, [ :pointer, :uint32, :uint8 ], :int
356
+
357
+
358
+
359
+ sdl_func :SetClipRect, [ :pointer, :pointer ], SDL::BOOL
360
+
361
+ func :__SDL_GetClipRect, "SDL_GetClipRect", [ :pointer, :pointer ], :void
362
+
363
+ def self.GetClipRect( surface )
364
+ mp = FFI::MemoryPointer.new( Rect )
365
+ __SDL_GetClipRect( surface, mp )
366
+ return Rect.new( mp )
367
+ end
368
+
369
+
370
+ sdl_func :ConvertSurface,
371
+ [ :pointer, :pointer, :uint32 ], SDL::Surface.typed_pointer
372
+
373
+
374
+ func :BlitSurface, "SDL_UpperBlit",
375
+ [ :pointer, :pointer, :pointer, :pointer ], :int
376
+
377
+
378
+ sdl_func :FillRect, [ :pointer, :pointer, :uint32 ], :int
379
+
380
+
381
+ sdl_func :DisplayFormat, [ :pointer ], SDL::Surface.typed_pointer
382
+ sdl_func :DisplayFormatAlpha, [ :pointer ], SDL::Surface.typed_pointer
383
+
384
+
385
+ sdl_func :CreateYUVOverlay, [ :int, :int, :uint32, :pointer ],
386
+ SDL::Overlay.typed_pointer
387
+
388
+ sdl_func :LockYUVOverlay, [ :pointer ], :int
389
+ sdl_func :UnlockYUVOverlay, [ :pointer ], :void
390
+ sdl_func :DisplayYUVOverlay, [ :pointer, :pointer ], :int
391
+ sdl_func :FreeYUVOverlay, [ :pointer ], :void
392
+
393
+
394
+ sdl_func :GL_LoadLibrary, [ :string ], :int
395
+ sdl_func :GL_GetProcAddress, [ :string ], :pointer
396
+ sdl_func :GL_SetAttribute, [ SDL::GLATTR, :int ], :int
397
+
398
+
399
+ func :__GL_GetAttribute, "SDL_GL_GetAttribute",
400
+ [ SDL::GLATTR, :pointer ], :int
401
+
402
+ def self.GL_GetAttribute( attrib )
403
+ value = FFI::Buffer.new( :int )
404
+ result = __GL_GetAttribute( attrib, value )
405
+ if( result == -1 )
406
+ return nil
407
+ else
408
+ return value
409
+ end
410
+ end
411
+
412
+
413
+ sdl_func :GL_SwapBuffers, [ ], :void
414
+ sdl_func :GL_UpdateRects, [ :int, :pointer ], :void
415
+ sdl_func :GL_Lock, [ ], :void
416
+ sdl_func :GL_Unlock, [ ], :void
417
+
418
+
419
+
420
+ sdl_func :WM_SetCaption, [ :string, :string ], :void
421
+
422
+ func :__SDL_WM_GetCaption, "SDL_WM_GetCaption",
423
+ [ :pointer, :pointer ], :void
424
+
425
+ def self.WM_GetCaption()
426
+ title = FFI::MemoryPointer.new( :pointer )
427
+ icont = FFI::MemoryPointer.new( :pointer )
428
+ __SDL_WM_GetCaption( title, icont )
429
+ return [ title.get_pointer(0).get_string(0),
430
+ icont.get_pointer(0).get_string(0) ]
431
+ end
432
+
433
+
434
+
435
+ sdl_func :WM_SetIcon, [ :pointer, :pointer ], :void
436
+ sdl_func :WM_IconifyWindow, [ ], :int
437
+ sdl_func :WM_ToggleFullScreen, [ :pointer ], :int
438
+
439
+
440
+ GRAB_QUERY = -1
441
+ GRAB_OFF = 0
442
+ GRAB_ON = 1
443
+ GRAB_FULLSCREEN = 2
444
+
445
+ sdl_func :WM_GrabInput, [ SDL::ENUM ], SDL::ENUM
446
+
447
+ end