hybridgroup-ruby-sdl-ffi 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog.txt +2460 -0
- data/NEWS.rdoc +77 -0
- data/README.rdoc +84 -0
- data/lib/ruby-sdl-ffi/gfx/blitfunc.rb +56 -0
- data/lib/ruby-sdl-ffi/gfx/framerate.rb +51 -0
- data/lib/ruby-sdl-ffi/gfx/imagefilter.rb +176 -0
- data/lib/ruby-sdl-ffi/gfx/primitives.rb +251 -0
- data/lib/ruby-sdl-ffi/gfx/rotozoom.rb +108 -0
- data/lib/ruby-sdl-ffi/gfx.rb +56 -0
- data/lib/ruby-sdl-ffi/image.rb +90 -0
- data/lib/ruby-sdl-ffi/mixer.rb +215 -0
- data/lib/ruby-sdl-ffi/sdl/audio.rb +139 -0
- data/lib/ruby-sdl-ffi/sdl/cdrom.rb +87 -0
- data/lib/ruby-sdl-ffi/sdl/core.rb +129 -0
- data/lib/ruby-sdl-ffi/sdl/event.rb +375 -0
- data/lib/ruby-sdl-ffi/sdl/joystick.rb +73 -0
- data/lib/ruby-sdl-ffi/sdl/keyboard.rb +76 -0
- data/lib/ruby-sdl-ffi/sdl/keysyms.rb +282 -0
- data/lib/ruby-sdl-ffi/sdl/mac.rb +443 -0
- data/lib/ruby-sdl-ffi/sdl/mouse.rb +106 -0
- data/lib/ruby-sdl-ffi/sdl/mutex.rb +57 -0
- data/lib/ruby-sdl-ffi/sdl/rwops.rb +137 -0
- data/lib/ruby-sdl-ffi/sdl/timer.rb +47 -0
- data/lib/ruby-sdl-ffi/sdl/video.rb +513 -0
- data/lib/ruby-sdl-ffi/sdl.rb +81 -0
- data/lib/ruby-sdl-ffi/ttf.rb +257 -0
- data/lib/ruby-sdl-ffi.rb +56 -0
- metadata +95 -0
@@ -0,0 +1,108 @@
|
|
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
|
+
module Gfx
|
33
|
+
|
34
|
+
SMOOTHING_OFF = 0
|
35
|
+
SMOOTHING_ON = 1
|
36
|
+
|
37
|
+
|
38
|
+
class TColorRGBA < NiceFFI::Struct
|
39
|
+
layout( :r, :uint8,
|
40
|
+
:g, :uint8,
|
41
|
+
:b, :uint8,
|
42
|
+
:a, :uint8 )
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
class TColorY < NiceFFI::Struct
|
47
|
+
layout( :y, :uint8 )
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
func :rotozoomSurface,
|
53
|
+
[ :pointer, :double, :double, :int ],
|
54
|
+
SDL::Surface.typed_pointer
|
55
|
+
|
56
|
+
func :__rotozoomSurfaceSize, :rotozoomSurfaceSize,
|
57
|
+
[ :int, :int, :double, :double, :buffer_out, :buffer_out ], :void
|
58
|
+
|
59
|
+
def self.rotozoomSurfaceSize( width, height, angle, zoom )
|
60
|
+
w = FFI::Buffer.new( :int )
|
61
|
+
h = FFI::Buffer.new( :int )
|
62
|
+
__rotozoomSurfaceSize( width, height, angle, zoom, w, h )
|
63
|
+
return [w.get_int(0), h.get_int(0)]
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
func :rotozoomSurfaceXY,
|
68
|
+
[ :pointer, :double, :double, :double, :int ],
|
69
|
+
SDL::Surface.typed_pointer
|
70
|
+
|
71
|
+
func :__rotozoomSurfaceSizeXY, :rotozoomSurfaceSizeXY,
|
72
|
+
[ :int, :int, :double, :double, :double,
|
73
|
+
:buffer_out, :buffer_out ], :void
|
74
|
+
|
75
|
+
def self.rotozoomSurfaceSizeXY( width, height, angle, zoomx, zoomy )
|
76
|
+
w = FFI::Buffer.new( :int )
|
77
|
+
h = FFI::Buffer.new( :int )
|
78
|
+
__rotozoomSurfaceSizeXY( width, height, angle, zoomx, zoomy, w, h )
|
79
|
+
return [w.get_int(0), h.get_int(0)]
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
func :zoomSurface, [ :pointer, :double, :double, :int ],
|
85
|
+
SDL::Surface.typed_pointer
|
86
|
+
|
87
|
+
|
88
|
+
func :__zoomSurfaceSize, :zoomSurfaceSize,
|
89
|
+
[ :int, :int, :double, :double, :buffer_out, :buffer_out ], :void
|
90
|
+
|
91
|
+
def self.zoomSurfaceSize( width, height, zoomx, zoomy )
|
92
|
+
w = FFI::Buffer.new( :int )
|
93
|
+
h = FFI::Buffer.new( :int )
|
94
|
+
__zoomSurfaceSize( width, height, zoomx, zoomy, w, h )
|
95
|
+
return [w.get_int(0), h.get_int(0)]
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
optfunc :shrinkSurface, [ :pointer, :int, :int ],
|
101
|
+
SDL::Surface.typed_pointer
|
102
|
+
|
103
|
+
|
104
|
+
optfunc :rotateSurface90Degrees, [ :pointer, :int ],
|
105
|
+
SDL::Surface.typed_pointer
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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
|
+
this_dir = File.expand_path( File.dirname(__FILE__) )
|
32
|
+
|
33
|
+
|
34
|
+
require File.join( this_dir, "sdl" )
|
35
|
+
|
36
|
+
|
37
|
+
module SDL
|
38
|
+
module Gfx
|
39
|
+
extend NiceFFI::Library
|
40
|
+
load_library "SDL_gfx", SDL::LOAD_PATHS
|
41
|
+
|
42
|
+
def self.sdl_func( name, args, ret )
|
43
|
+
func name, "SDL_#{name}", args, ret
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
%w{
|
49
|
+
framerate
|
50
|
+
blitfunc
|
51
|
+
primitives
|
52
|
+
imagefilter
|
53
|
+
rotozoom
|
54
|
+
}.each do |f|
|
55
|
+
require File.join( this_dir, "gfx", f )
|
56
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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
|
+
this_dir = File.expand_path( File.dirname(__FILE__) )
|
32
|
+
|
33
|
+
require File.join( this_dir, "sdl" )
|
34
|
+
|
35
|
+
|
36
|
+
module SDL
|
37
|
+
module Image
|
38
|
+
extend NiceFFI::Library
|
39
|
+
load_library "SDL_image", SDL::LOAD_PATHS
|
40
|
+
|
41
|
+
|
42
|
+
def self.img_func( name, args, ret )
|
43
|
+
func name, "IMG_#{name}", args, ret
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
img_func :Linked_Version, [], SDL::Version.typed_pointer
|
48
|
+
|
49
|
+
|
50
|
+
img_func :LoadTyped_RW, [ :pointer, :int, :string ],
|
51
|
+
SDL::Surface.typed_pointer
|
52
|
+
|
53
|
+
img_func :Load, [ :string ], SDL::Surface.typed_pointer
|
54
|
+
img_func :Load_RW, [ :pointer, :int ], SDL::Surface.typed_pointer
|
55
|
+
|
56
|
+
|
57
|
+
img_func :InvertAlpha, [ :int ], :int
|
58
|
+
|
59
|
+
|
60
|
+
img_func :isBMP, [ :pointer ], :int
|
61
|
+
img_func :isGIF, [ :pointer ], :int
|
62
|
+
img_func :isJPG, [ :pointer ], :int
|
63
|
+
img_func :isLBM, [ :pointer ], :int
|
64
|
+
img_func :isPCX, [ :pointer ], :int
|
65
|
+
img_func :isPNG, [ :pointer ], :int
|
66
|
+
img_func :isPNM, [ :pointer ], :int
|
67
|
+
img_func :isTIF, [ :pointer ], :int
|
68
|
+
img_func :isXCF, [ :pointer ], :int
|
69
|
+
img_func :isXPM, [ :pointer ], :int
|
70
|
+
img_func :isXV, [ :pointer ], :int
|
71
|
+
|
72
|
+
|
73
|
+
img_func :LoadBMP_RW, [ :pointer ], SDL::Surface.typed_pointer
|
74
|
+
img_func :LoadGIF_RW, [ :pointer ], SDL::Surface.typed_pointer
|
75
|
+
img_func :LoadJPG_RW, [ :pointer ], SDL::Surface.typed_pointer
|
76
|
+
img_func :LoadLBM_RW, [ :pointer ], SDL::Surface.typed_pointer
|
77
|
+
img_func :LoadPCX_RW, [ :pointer ], SDL::Surface.typed_pointer
|
78
|
+
img_func :LoadPNG_RW, [ :pointer ], SDL::Surface.typed_pointer
|
79
|
+
img_func :LoadPNM_RW, [ :pointer ], SDL::Surface.typed_pointer
|
80
|
+
img_func :LoadTGA_RW, [ :pointer ], SDL::Surface.typed_pointer
|
81
|
+
img_func :LoadTIF_RW, [ :pointer ], SDL::Surface.typed_pointer
|
82
|
+
img_func :LoadXCF_RW, [ :pointer ], SDL::Surface.typed_pointer
|
83
|
+
img_func :LoadXPM_RW, [ :pointer ], SDL::Surface.typed_pointer
|
84
|
+
img_func :LoadXV_RW, [ :pointer ], SDL::Surface.typed_pointer
|
85
|
+
|
86
|
+
|
87
|
+
img_func :ReadXPMFromArray, [ :pointer ], SDL::Surface.typed_pointer
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,215 @@
|
|
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
|
+
this_dir = File.expand_path( File.dirname(__FILE__) )
|
32
|
+
|
33
|
+
require File.join( this_dir, "sdl" )
|
34
|
+
|
35
|
+
|
36
|
+
module SDL
|
37
|
+
module Mixer
|
38
|
+
extend NiceFFI::Library
|
39
|
+
load_library "SDL_mixer", SDL::LOAD_PATHS
|
40
|
+
|
41
|
+
|
42
|
+
def self.mix_func( name, args, ret )
|
43
|
+
func name, "Mix_#{name}", args, ret
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
mix_func :Linked_Version, [], SDL::Version.typed_pointer
|
48
|
+
|
49
|
+
|
50
|
+
CHANNELS = 8
|
51
|
+
DEFAULT_FREQUENCY = 22050
|
52
|
+
DEFAULT_CHANNELS = 2
|
53
|
+
|
54
|
+
DEFAULT_FORMAT = if( FFI::Platform::BYTE_ORDER ==
|
55
|
+
FFI::Platform::LITTLE_ENDIAN)
|
56
|
+
AUDIO_S16LSB
|
57
|
+
else
|
58
|
+
AUDIO_S16MSB
|
59
|
+
end
|
60
|
+
|
61
|
+
MAX_VOLUME = 128
|
62
|
+
|
63
|
+
|
64
|
+
class Chunk < NiceFFI::Struct
|
65
|
+
layout( :allocated, :int,
|
66
|
+
:abuf, :pointer,
|
67
|
+
:alen, :uint32,
|
68
|
+
:volume, :uint8 )
|
69
|
+
|
70
|
+
def self.release( pointer )
|
71
|
+
SDL::Mixer.FreeChunk( pointer )
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
class Music < NiceFFI::OpaqueStruct
|
78
|
+
#--
|
79
|
+
# Mix_Music struct (in C) has a hidden layout, which changes
|
80
|
+
# depending on which sound format libraries were available
|
81
|
+
# at compile time.
|
82
|
+
#++
|
83
|
+
|
84
|
+
def self.release( pointer )
|
85
|
+
SDL::Mixer.FreeMusic( pointer )
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
NO_FADING = 0
|
92
|
+
FADING_OUT = 1
|
93
|
+
FADING_IN = 2
|
94
|
+
|
95
|
+
MUS_NONE = 0
|
96
|
+
MUS_CMD = 1
|
97
|
+
MUS_WAV = 2
|
98
|
+
MUS_MOD = 3
|
99
|
+
MUS_MID = 4
|
100
|
+
MUS_OGG = 5
|
101
|
+
MUS_MP3 = 6
|
102
|
+
MUS_MP3_MAD = 7
|
103
|
+
|
104
|
+
|
105
|
+
mix_func :OpenAudio, [ :int, :uint16, :int, :int ], :int
|
106
|
+
mix_func :AllocateChannels, [ :int ], :int
|
107
|
+
mix_func :QuerySpec, [ :pointer, :pointer, :pointer ], :int
|
108
|
+
|
109
|
+
|
110
|
+
def self.LoadWAV( file )
|
111
|
+
LoadWAV_RW( SDL.RWFromFile(file, "rb"), 1 )
|
112
|
+
end
|
113
|
+
|
114
|
+
mix_func :LoadWAV_RW, [ :pointer, :int ], Chunk.typed_pointer
|
115
|
+
mix_func :LoadMUS, [ :string ], Music.typed_pointer
|
116
|
+
mix_func :LoadMUS_RW, [ :pointer ], Music.typed_pointer
|
117
|
+
mix_func :QuickLoad_WAV, [ :pointer ], Chunk.typed_pointer
|
118
|
+
mix_func :QuickLoad_RAW, [ :pointer, :uint32 ], Chunk.typed_pointer
|
119
|
+
|
120
|
+
|
121
|
+
mix_func :FreeChunk, [ :pointer ], :void
|
122
|
+
mix_func :FreeMusic, [ :pointer ], :void
|
123
|
+
|
124
|
+
|
125
|
+
mix_func :GetMusicType, [ :pointer ], :int
|
126
|
+
|
127
|
+
|
128
|
+
callback( :mix_hook_cb, [:pointer, :pointer, :int], :void)
|
129
|
+
|
130
|
+
mix_func :SetPostMix, [ :mix_hook_cb, :pointer ], :void
|
131
|
+
mix_func :HookMusic, [ :mix_hook_cb, :pointer ], :void
|
132
|
+
mix_func :HookMusicFinished, [ callback([], :void) ], :void
|
133
|
+
mix_func :GetMusicHookData, [ ], :pointer
|
134
|
+
mix_func :ChannelFinished, [ callback([:int], :void) ], :void
|
135
|
+
|
136
|
+
|
137
|
+
CHANNEL_POST = -2
|
138
|
+
|
139
|
+
|
140
|
+
callback(:mix_effectfunc_cb, [ :int, :pointer, :int, :pointer ], :void)
|
141
|
+
callback(:mix_effectdone_cb, [ :int, :pointer ], :void)
|
142
|
+
|
143
|
+
mix_func :RegisterEffect,
|
144
|
+
[ :int, :mix_effectfunc_cb, :mix_effectdone_cb, :pointer ], :int
|
145
|
+
|
146
|
+
mix_func :UnregisterEffect, [ :int, :mix_effectfunc_cb ], :int
|
147
|
+
mix_func :UnregisterAllEffects, [ :int ], :int
|
148
|
+
|
149
|
+
|
150
|
+
EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"
|
151
|
+
|
152
|
+
|
153
|
+
mix_func :SetPanning, [ :int, :uint8, :uint8 ], :int
|
154
|
+
mix_func :SetPosition, [ :int, :int16, :uint8 ], :int
|
155
|
+
mix_func :SetDistance, [ :int, :uint8 ], :int
|
156
|
+
mix_func :SetReverseStereo, [ :int, :int ], :int
|
157
|
+
|
158
|
+
|
159
|
+
mix_func :ReserveChannels, [ :int ], :int
|
160
|
+
mix_func :GroupChannel, [ :int, :int ], :int
|
161
|
+
mix_func :GroupChannels, [ :int, :int, :int ], :int
|
162
|
+
mix_func :GroupAvailable, [ :int ], :int
|
163
|
+
mix_func :GroupCount, [ :int ], :int
|
164
|
+
mix_func :GroupOldest, [ :int ], :int
|
165
|
+
mix_func :GroupNewer, [ :int ], :int
|
166
|
+
|
167
|
+
|
168
|
+
mix_func :PlayChannelTimed, [ :int, :pointer, :int, :int ], :int
|
169
|
+
mix_func :PlayMusic, [ :pointer, :int ], :int
|
170
|
+
mix_func :FadeInMusic, [ :pointer, :int, :int ], :int
|
171
|
+
mix_func :FadeInMusicPos, [ :pointer, :int, :int, :double ], :int
|
172
|
+
mix_func :FadeInChannelTimed, [ :int, :pointer, :int, :int, :int ], :int
|
173
|
+
|
174
|
+
|
175
|
+
mix_func :Volume, [ :int, :int ], :int
|
176
|
+
mix_func :VolumeChunk, [ :pointer, :int ], :int
|
177
|
+
mix_func :VolumeMusic, [ :int ], :int
|
178
|
+
|
179
|
+
|
180
|
+
mix_func :HaltChannel, [ :int ], :int
|
181
|
+
mix_func :HaltGroup, [ :int ], :int
|
182
|
+
mix_func :HaltMusic, [ ], :int
|
183
|
+
mix_func :ExpireChannel, [ :int, :int ], :int
|
184
|
+
|
185
|
+
|
186
|
+
mix_func :FadeOutChannel, [ :int, :int ], :int
|
187
|
+
mix_func :FadeOutGroup, [ :int, :int ], :int
|
188
|
+
mix_func :FadeOutMusic, [ :int ], :int
|
189
|
+
mix_func :FadingMusic, [ ], :int
|
190
|
+
mix_func :FadingChannel, [ :int ], :int
|
191
|
+
|
192
|
+
|
193
|
+
mix_func :Pause, [ :int ], :void
|
194
|
+
mix_func :Resume, [ :int ], :void
|
195
|
+
mix_func :Paused, [ :int ], :int
|
196
|
+
mix_func :PauseMusic, [ ], :void
|
197
|
+
mix_func :ResumeMusic, [ ], :void
|
198
|
+
mix_func :RewindMusic, [ ], :void
|
199
|
+
mix_func :PausedMusic, [ ], :int
|
200
|
+
|
201
|
+
|
202
|
+
mix_func :SetMusicPosition, [ :double ], :int
|
203
|
+
mix_func :Playing, [ :int ], :int
|
204
|
+
mix_func :PlayingMusic, [ ], :int
|
205
|
+
mix_func :SetMusicCMD, [ :string ], :int
|
206
|
+
|
207
|
+
mix_func :SetSynchroValue, [ :int ], :int
|
208
|
+
mix_func :GetSynchroValue, [ ], :int
|
209
|
+
|
210
|
+
mix_func :GetChunk, [ :int ], Chunk.typed_pointer
|
211
|
+
|
212
|
+
mix_func :CloseAudio, [ ], :void
|
213
|
+
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,139 @@
|
|
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 AudioSpec < NiceFFI::Struct
|
34
|
+
|
35
|
+
SDL::callback(:audiospec_cb, [ :pointer, :pointer, :int ], :void)
|
36
|
+
|
37
|
+
layout( :freq, :int,
|
38
|
+
:format, :uint16,
|
39
|
+
:channels, :uint8,
|
40
|
+
:silence, :uint8,
|
41
|
+
:samples, :uint16,
|
42
|
+
:padding, :uint16,
|
43
|
+
:size, :uint32,
|
44
|
+
:callback, :audiospec_cb,
|
45
|
+
:userdata, :pointer )
|
46
|
+
|
47
|
+
def callback=(cb)
|
48
|
+
@callback = cb
|
49
|
+
self[:callback] = @callback
|
50
|
+
end
|
51
|
+
|
52
|
+
def callback
|
53
|
+
@callback
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
AUDIO_U8 = 0x0008
|
60
|
+
AUDIO_S8 = 0x8008
|
61
|
+
AUDIO_U16LSB = 0x0010
|
62
|
+
AUDIO_S16LSB = 0x8010
|
63
|
+
AUDIO_U16MSB = 0x1010
|
64
|
+
AUDIO_S16MSB = 0x9010
|
65
|
+
AUDIO_U16 = 0x0010
|
66
|
+
AUDIO_S16 = 0x8010
|
67
|
+
|
68
|
+
if FFI::Platform::BYTE_ORDER == FFI::Platform::LITTLE_ENDIAN
|
69
|
+
AUDIO_U16SYS = AUDIO_U16LSB
|
70
|
+
AUDIO_S16SYS = AUDIO_S16LSB
|
71
|
+
else
|
72
|
+
AUDIO_U16SYS = AUDIO_U16MSB
|
73
|
+
AUDIO_S16SYS = AUDIO_U16MSB
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# callback( :filters_cb, [ :pointer, :uint16 ], :void)
|
78
|
+
|
79
|
+
# class AudioCVT < NiceFFI::Struct
|
80
|
+
# layout( :needed, :int,
|
81
|
+
# :src_format, :uint16,
|
82
|
+
# :dst_format, :uint16,
|
83
|
+
# :rate_incr, :double,
|
84
|
+
# :buf, :pointer,
|
85
|
+
# :len, :int,
|
86
|
+
# :len_cvt, :int,
|
87
|
+
# :len_mult, :int,
|
88
|
+
# :len_ratio, :double,
|
89
|
+
# :filters, [:filters_cb, 10],
|
90
|
+
# :filter_index, :int )
|
91
|
+
# end
|
92
|
+
|
93
|
+
|
94
|
+
sdl_func :AudioInit, [ :string ], :int
|
95
|
+
sdl_func :AudioQuit, [ ], :void
|
96
|
+
sdl_func :OpenAudio, [ :buffer_in, :buffer_out ], :int
|
97
|
+
|
98
|
+
|
99
|
+
func :__AudioDriverName, "SDL_AudioDriverName",
|
100
|
+
[:buffer_out, :int], :pointer
|
101
|
+
|
102
|
+
def self.AudioDriverName
|
103
|
+
b = FFI::Buffer.new(:char, 1024)
|
104
|
+
result = __AudioDriverName( b, 1024 )
|
105
|
+
if result.null?
|
106
|
+
nil
|
107
|
+
else
|
108
|
+
b.get_string(0,1024)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
AUDIO_STOPPED = 0
|
114
|
+
AUDIO_PLAYING = 1
|
115
|
+
AUDIO_PAUSED = 2
|
116
|
+
|
117
|
+
sdl_func :GetAudioStatus, [ ], SDL::ENUM
|
118
|
+
sdl_func :PauseAudio, [ :int ], :void
|
119
|
+
|
120
|
+
sdl_func :LoadWAV_RW,
|
121
|
+
[ :pointer, :int, :pointer, :pointer, :pointer ], :pointer
|
122
|
+
|
123
|
+
sdl_func :FreeWAV, [ :pointer ], :void
|
124
|
+
|
125
|
+
sdl_func :BuildAudioCVT,
|
126
|
+
[ :pointer, :uint16, :uint8, :int, :uint16, :uint8, :int ], :int
|
127
|
+
|
128
|
+
sdl_func :ConvertAudio, [ :pointer ], :int
|
129
|
+
|
130
|
+
|
131
|
+
MIX_MAXVOLUME = 128
|
132
|
+
|
133
|
+
sdl_func :MixAudio, [ :pointer, :pointer, :uint32, :int ], :void
|
134
|
+
|
135
|
+
sdl_func :LockAudio, [ ], :void
|
136
|
+
sdl_func :UnlockAudio, [ ], :void
|
137
|
+
sdl_func :CloseAudio, [ ], :void
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,87 @@
|
|
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
|
+
CD_ERROR = -1
|
34
|
+
CD_TRAYEMPTY = 0
|
35
|
+
CD_STOPPED = 1
|
36
|
+
CD_PLAYING = 2
|
37
|
+
CD_PAUSED = 3
|
38
|
+
|
39
|
+
AUDIO_TRACK = 0x00
|
40
|
+
DATA_TRACK = 0x04
|
41
|
+
|
42
|
+
MAX_TRACKS = 99
|
43
|
+
|
44
|
+
class CDtrack < NiceFFI::Struct
|
45
|
+
layout( :id, :uint8,
|
46
|
+
:type, :uint8,
|
47
|
+
:unused, :uint16,
|
48
|
+
:length, :uint32,
|
49
|
+
:offset, :uint32 )
|
50
|
+
|
51
|
+
hidden( :unused )
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
if RUBY_PLATFORM =~ /java/
|
57
|
+
# 2009-10-21: JRuby FFI does not support arrays of structs in structs.
|
58
|
+
# Attempting it can raise an un-rescuable NotImplementedError! :(
|
59
|
+
puts "Warning: Skipping class SDL::CD due to JRuby limitations."
|
60
|
+
else
|
61
|
+
|
62
|
+
class CD < NiceFFI::Struct
|
63
|
+
layout( :id, :int,
|
64
|
+
:status, SDL::ENUM,
|
65
|
+
:numtracks, :int,
|
66
|
+
:cur_track, :int,
|
67
|
+
:cur_frame, :int,
|
68
|
+
:track, [CDtrack.by_value, SDL::MAX_TRACKS+1] )
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
CD_FPS = 75
|
74
|
+
|
75
|
+
sdl_func :CDNumDrives, [ ], :int
|
76
|
+
sdl_func :CDName, [ :int ], :string
|
77
|
+
sdl_func :CDOpen, [ :int ], :pointer
|
78
|
+
sdl_func :CDStatus, [ :pointer ], SDL::ENUM
|
79
|
+
sdl_func :CDPlayTracks, [ :pointer, :int, :int, :int, :int ], :int
|
80
|
+
sdl_func :CDPlay, [ :pointer, :int, :int ], :int
|
81
|
+
sdl_func :CDPause, [ :pointer ], :int
|
82
|
+
sdl_func :CDResume, [ :pointer ], :int
|
83
|
+
sdl_func :CDStop, [ :pointer ], :int
|
84
|
+
sdl_func :CDEject, [ :pointer ], :int
|
85
|
+
sdl_func :CDClose, [ :pointer ], :void
|
86
|
+
|
87
|
+
end
|