sdl2-bindings 0.0.0.pre
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.
- checksums.yaml +7 -0
- data/ChangeLog +55 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/lib/sdl2.rb +166 -0
- data/lib/sdl2_audio.rb +201 -0
- data/lib/sdl2_blendmode.rb +68 -0
- data/lib/sdl2_clipboard.rb +51 -0
- data/lib/sdl2_cpuinfo.rb +100 -0
- data/lib/sdl2_error.rb +61 -0
- data/lib/sdl2_events.rb +499 -0
- data/lib/sdl2_filesystem.rb +48 -0
- data/lib/sdl2_framerate.rb +67 -0
- data/lib/sdl2_gamecontroller.rb +188 -0
- data/lib/sdl2_gesture.rb +55 -0
- data/lib/sdl2_gfxPrimitives.rb +222 -0
- data/lib/sdl2_haptic.rb +268 -0
- data/lib/sdl2_hints.rb +68 -0
- data/lib/sdl2_image.rb +185 -0
- data/lib/sdl2_imageFilter.rb +132 -0
- data/lib/sdl2_joystick.rb +193 -0
- data/lib/sdl2_keyboard.rb +99 -0
- data/lib/sdl2_keycode.rb +297 -0
- data/lib/sdl2_log.rb +114 -0
- data/lib/sdl2_main.rb +67 -0
- data/lib/sdl2_messagebox.rb +96 -0
- data/lib/sdl2_mixer.rb +304 -0
- data/lib/sdl2_mouse.rb +115 -0
- data/lib/sdl2_pixels.rb +212 -0
- data/lib/sdl2_platform.rb +45 -0
- data/lib/sdl2_power.rb +51 -0
- data/lib/sdl2_rect.rb +102 -0
- data/lib/sdl2_render.rb +277 -0
- data/lib/sdl2_rotozoom.rb +66 -0
- data/lib/sdl2_rwops.rb +208 -0
- data/lib/sdl2_scancode.rb +287 -0
- data/lib/sdl2_shape.rb +77 -0
- data/lib/sdl2_surface.rb +179 -0
- data/lib/sdl2_timer.rb +62 -0
- data/lib/sdl2_touch.rb +73 -0
- data/lib/sdl2_ttf.rb +190 -0
- data/lib/sdl2_version.rb +62 -0
- data/lib/sdl2_video.rb +408 -0
- data/lib/sdl2_vulkan.rb +64 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dff21b21106958f4db5399f9a5db1e6d77368c076630554d9c2f6eaf3fe3379a
|
4
|
+
data.tar.gz: d613101c0808dbe74ceb554da6c906bf9fbd9dcae26045f38d4c8699a617b49e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5fcd3d8eb266fd79019c646235f61f53cf305aa4ddeadba1b9abb6456ca12d58e6726ca91886c90c9d10f9258aa5b7a4718be9070a7fc07c592ef67bd71e711a
|
7
|
+
data.tar.gz: bd6a51dd22d647c0988ec0b22a3dd0da2ae62a01804f6d2245368a405bec01e9c252d031293c68e992c2a4d0522e3aea9bd5b42e81bc37b7b590fff9dac4fbd5
|
data/ChangeLog
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
2019-08-31 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
|
+
|
3
|
+
* Refactoring + Cleanup
|
4
|
+
* Some tests are usable again
|
5
|
+
|
6
|
+
2019-08-28 vaiorabbit <http://twitter.com/vaiorabbit>
|
7
|
+
|
8
|
+
* Exception-safety
|
9
|
+
|
10
|
+
2019-08-27 vaiorabbit <http://twitter.com/vaiorabbit>
|
11
|
+
|
12
|
+
* lib/sdl2_mixer.rb: Added (experimental)
|
13
|
+
|
14
|
+
2019-08-24 vaiorabbit <http://twitter.com/vaiorabbit>
|
15
|
+
|
16
|
+
* Added SDL 2.0.10 features.
|
17
|
+
* Added generator. Binding codes are generated semi-automatically.
|
18
|
+
* Now depends on Ruby/FFI. Note that some codes in 'test' directory are still not usable.
|
19
|
+
|
20
|
+
2016-04-03 vaiorabbit <http://twitter.com/vaiorabbit>
|
21
|
+
|
22
|
+
* lib/sdl2_gfx.rb, test/test_gfx.rb: Added.
|
23
|
+
|
24
|
+
2016-04-02 vaiorabbit <http://twitter.com/vaiorabbit>
|
25
|
+
|
26
|
+
* Added SDL 2.0.4 features.
|
27
|
+
* lib/version.rb: Added SDL_MAJOR_VERSION, etc.
|
28
|
+
|
29
|
+
2015-09-29 vaiorabbit <http://twitter.com/vaiorabbit>
|
30
|
+
|
31
|
+
* lib/sdl2_ttf.rb: Added.
|
32
|
+
|
33
|
+
2015-09-28 vaiorabbit <http://twitter.com/vaiorabbit>
|
34
|
+
|
35
|
+
* lib/sdl2_image.rb: Added.
|
36
|
+
* lib/sdl2_mixer.rb: Added.
|
37
|
+
|
38
|
+
2015-09-22 vaiorabbit <http://twitter.com/vaiorabbit>
|
39
|
+
|
40
|
+
* lib/pixels.rb, lib/gamecontroller.rb, lib/joystick.rb: Added.
|
41
|
+
* lib/rwops.rb, lib/syswm.rb, lib/surface.rb, lib/render.rb: Added.
|
42
|
+
* lib/cpuinfo.rb, lib/gesture.rb, lib/touch.rb, lib/audio.rb: Added.
|
43
|
+
|
44
|
+
2015-09-21 vaiorabbit <http://twitter.com/vaiorabbit>
|
45
|
+
|
46
|
+
* lib/events.rb, lib/timer.rb, lib/video.rb: Added.
|
47
|
+
* lib/keyboard.rb, lib/keycode.rb, lib/scancode.rb: Added.
|
48
|
+
* lib/error.rb: Added.
|
49
|
+
* lib/blendmode.rb, lib/clipboard.rb, lib/filesystem.rb, lib/version.rb: Added.
|
50
|
+
* lib/platform.rb, lib/rect.rb, lib/mouse.rb: Added.
|
51
|
+
* lib/messagebox.rb, lib/pixels.rb: Added.
|
52
|
+
|
53
|
+
2015-09-19 vaiorabbit <http://twitter.com/vaiorabbit>
|
54
|
+
|
55
|
+
* Project started.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
sdl2-bindings : Yet another SDL2 wrapper for Ruby
|
2
|
+
Copyright (c) 2015-2019 vaiorabbit <http://twitter.com/vaiorabbit>
|
3
|
+
|
4
|
+
This software is provided 'as-is', without any express or implied
|
5
|
+
warranty. In no event will the authors be held liable for any damages
|
6
|
+
arising from the use of this software.
|
7
|
+
|
8
|
+
Permission is granted to anyone to use this software for any purpose,
|
9
|
+
including commercial applications, and to alter it and redistribute it
|
10
|
+
freely, subject to the following restrictions:
|
11
|
+
|
12
|
+
1. The origin of this software must not be misrepresented; you must not
|
13
|
+
claim that you wrote the original software. If you use this software
|
14
|
+
in a product, an acknowledgment in the product documentation would be
|
15
|
+
appreciated but is not required.
|
16
|
+
|
17
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
18
|
+
misrepresented as being the original software.
|
19
|
+
|
20
|
+
3. This notice may not be removed or altered from any source
|
21
|
+
distribution.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
<!-- -*- mode:markdown; coding:utf-8; -*- -->
|
2
|
+
|
3
|
+
# sdl2-bindings : Yet another SDL2 wrapper for Ruby #
|
4
|
+
|
5
|
+
[Notice] Experimental project.
|
6
|
+
|
7
|
+
* Created : 2015-09-19
|
8
|
+
* Last modified : 2019-08-31
|
9
|
+
|
10
|
+
## Features ##
|
11
|
+
|
12
|
+
* Generated semi-automatically
|
13
|
+
* Based on Ruby/FFI
|
14
|
+
* No need to build C extension library
|
15
|
+
|
16
|
+
|
17
|
+
## Limitations ##
|
18
|
+
|
19
|
+
* Some APIs provided by pre-processor cannot be imported.
|
20
|
+
|
21
|
+
## Tested Environment ##
|
22
|
+
|
23
|
+
* [2015-09-19] SDL 2.0.3 (Installed via Homebrew)
|
24
|
+
* Mac OS X 10.10.5, ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
|
25
|
+
* [2016-04-03] SDL 2.0.4 (Installed via Homebrew)
|
26
|
+
* Mac OS X 10.11.4, ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
|
27
|
+
* sdl2_gfx : 1.0.1
|
28
|
+
* sdl2_image : 2.0.1
|
29
|
+
* sdl2_mixer : 2.0.1
|
30
|
+
* sdl2_ttf : 2.0.13
|
31
|
+
* [2019-08-31] SDL 2.0.10 (Installed via Homebrew)
|
32
|
+
|
33
|
+
## License ##
|
34
|
+
|
35
|
+
The zlib/libpng License ( http://opensource.org/licenses/Zlib ).
|
36
|
+
|
37
|
+
sdl2-bindings : Yet another SDL2 wrapper for Ruby
|
38
|
+
Copyright (c) 2015-2019 vaiorabbit <http://twitter.com/vaiorabbit>
|
39
|
+
|
40
|
+
This software is provided 'as-is', without any express or implied
|
41
|
+
warranty. In no event will the authors be held liable for any damages
|
42
|
+
arising from the use of this software.
|
43
|
+
|
44
|
+
Permission is granted to anyone to use this software for any purpose,
|
45
|
+
including commercial applications, and to alter it and redistribute it
|
46
|
+
freely, subject to the following restrictions:
|
data/lib/sdl2.rb
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
require_relative 'sdl2_main.rb'
|
7
|
+
require_relative 'sdl2_audio.rb'
|
8
|
+
require_relative 'sdl2_blendmode.rb'
|
9
|
+
require_relative 'sdl2_clipboard.rb'
|
10
|
+
require_relative 'sdl2_cpuinfo.rb'
|
11
|
+
require_relative 'sdl2_error.rb'
|
12
|
+
require_relative 'sdl2_events.rb'
|
13
|
+
require_relative 'sdl2_filesystem.rb'
|
14
|
+
require_relative 'sdl2_gamecontroller.rb'
|
15
|
+
require_relative 'sdl2_gesture.rb'
|
16
|
+
require_relative 'sdl2_haptic.rb'
|
17
|
+
require_relative 'sdl2_hints.rb'
|
18
|
+
require_relative 'sdl2_joystick.rb'
|
19
|
+
require_relative 'sdl2_keyboard.rb'
|
20
|
+
require_relative 'sdl2_keycode.rb'
|
21
|
+
require_relative 'sdl2_log.rb'
|
22
|
+
require_relative 'sdl2_messagebox.rb'
|
23
|
+
require_relative 'sdl2_mouse.rb'
|
24
|
+
require_relative 'sdl2_pixels.rb'
|
25
|
+
require_relative 'sdl2_platform.rb'
|
26
|
+
require_relative 'sdl2_power.rb'
|
27
|
+
require_relative 'sdl2_rect.rb'
|
28
|
+
require_relative 'sdl2_render.rb'
|
29
|
+
require_relative 'sdl2_rwops.rb'
|
30
|
+
require_relative 'sdl2_scancode.rb'
|
31
|
+
require_relative 'sdl2_shape.rb'
|
32
|
+
require_relative 'sdl2_surface.rb'
|
33
|
+
require_relative 'sdl2_timer.rb'
|
34
|
+
require_relative 'sdl2_touch.rb'
|
35
|
+
require_relative 'sdl2_version.rb'
|
36
|
+
require_relative 'sdl2_video.rb'
|
37
|
+
require_relative 'sdl2_vulkan.rb'
|
38
|
+
|
39
|
+
require_relative 'sdl2_framerate.rb'
|
40
|
+
require_relative 'sdl2_gfxPrimitives.rb'
|
41
|
+
require_relative 'sdl2_image.rb'
|
42
|
+
require_relative 'sdl2_rotozoom.rb'
|
43
|
+
require_relative 'sdl2_imageFilter.rb'
|
44
|
+
require_relative 'sdl2_ttf.rb'
|
45
|
+
require_relative 'sdl2_mixer.rb'
|
46
|
+
|
47
|
+
module SDL2
|
48
|
+
extend FFI::Library
|
49
|
+
|
50
|
+
@@sdl2_import_done = false
|
51
|
+
def self.load_lib(libpath, image_libpath: nil, ttf_libpath: nil, mixer_libpath: nil, gfx_libpath: nil)
|
52
|
+
|
53
|
+
unless @@sdl2_import_done
|
54
|
+
# Ref.: Using Multiple and Alternate Libraries
|
55
|
+
# https://github.com/ffi/ffi/wiki/Using-Multiple-and-Alternate-Libraries
|
56
|
+
begin
|
57
|
+
lib_paths = [libpath, image_libpath, ttf_libpath, mixer_libpath, gfx_libpath].compact
|
58
|
+
|
59
|
+
ffi_lib_flags :now, :global
|
60
|
+
ffi_lib *lib_paths
|
61
|
+
setup_symbols()
|
62
|
+
|
63
|
+
if image_libpath != nil
|
64
|
+
setup_image_symbols()
|
65
|
+
end
|
66
|
+
|
67
|
+
if ttf_libpath != nil
|
68
|
+
setup_ttf_symbols()
|
69
|
+
end
|
70
|
+
|
71
|
+
if mixer_libpath != nil
|
72
|
+
setup_mixer_symbols()
|
73
|
+
end
|
74
|
+
|
75
|
+
if gfx_libpath != nil
|
76
|
+
setup_gfx_framerate_symbols()
|
77
|
+
setup_gfx_primitives_symbols()
|
78
|
+
setup_gfx_imagefilter_symbols()
|
79
|
+
setup_gfx_rotozoom_symbols()
|
80
|
+
end
|
81
|
+
rescue => error
|
82
|
+
puts error
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.setup_symbols()
|
89
|
+
setup_main_symbols()
|
90
|
+
setup_audio_symbols()
|
91
|
+
setup_blendmode_symbols()
|
92
|
+
setup_clipboard_symbols()
|
93
|
+
setup_cpuinfo_symbols()
|
94
|
+
setup_error_symbols()
|
95
|
+
setup_events_symbols()
|
96
|
+
setup_filesystem_symbols()
|
97
|
+
setup_gamecontroller_symbols()
|
98
|
+
setup_gesture_symbols()
|
99
|
+
setup_haptic_symbols()
|
100
|
+
setup_hints_symbols()
|
101
|
+
setup_joystick_symbols()
|
102
|
+
setup_keyboard_symbols()
|
103
|
+
setup_keycode_symbols()
|
104
|
+
setup_log_symbols()
|
105
|
+
setup_messagebox_symbols()
|
106
|
+
setup_mouse_symbols()
|
107
|
+
setup_pixels_symbols()
|
108
|
+
setup_platform_symbols()
|
109
|
+
setup_power_symbols()
|
110
|
+
setup_rect_symbols()
|
111
|
+
setup_render_symbols()
|
112
|
+
setup_rwops_symbols()
|
113
|
+
setup_scancode_symbols()
|
114
|
+
setup_shape_symbols()
|
115
|
+
setup_surface_symbols()
|
116
|
+
setup_timer_symbols()
|
117
|
+
setup_touch_symbols()
|
118
|
+
setup_version_symbols()
|
119
|
+
setup_video_symbols()
|
120
|
+
setup_vulkan_symbols()
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
if __FILE__ == $0
|
127
|
+
# SDL2.load_lib('libSDL2.dylib')
|
128
|
+
# p SDL2.SDL_Init(SDL2::SDL_INIT_EVERYTHING)
|
129
|
+
SDL2.load_lib('libSDL2.dylib',
|
130
|
+
gfx_libpath: '/usr/local/lib/libSDL2_gfx.dylib'
|
131
|
+
)
|
132
|
+
#SDL2.SDL_SetMainReady()
|
133
|
+
success = SDL2.SDL_Init(SDL2::SDL_INIT_EVERYTHING)
|
134
|
+
exit if success < 0
|
135
|
+
|
136
|
+
WINDOW_W = 320
|
137
|
+
WINDOW_H = 240
|
138
|
+
window = SDL2.SDL_CreateWindow("1st SDL Window via sdl2-bindings", 0, 0, WINDOW_W, WINDOW_H, 0)
|
139
|
+
|
140
|
+
fpsdelay = 100;
|
141
|
+
|
142
|
+
count = 0
|
143
|
+
event = SDL2::SDL_Event.new
|
144
|
+
done = false
|
145
|
+
while not done
|
146
|
+
while SDL2.SDL_PollEvent(event) != 0
|
147
|
+
# 'type' and 'timestamp' are common members for all SDL Event structs.
|
148
|
+
event_type = event[:common][:type]
|
149
|
+
event_timestamp = event[:common][:timestamp]
|
150
|
+
puts "Event : type=0x#{event_type.to_s(16)}, timestamp=#{event_timestamp}"
|
151
|
+
|
152
|
+
case event_type
|
153
|
+
when SDL2::SDL_KEYDOWN
|
154
|
+
if event[:key][:keysym][:sym] == SDL2::SDLK_SPACE
|
155
|
+
puts "\tSPACE key pressed."
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
count += 1
|
161
|
+
done = true if count >= 100
|
162
|
+
SDL2.SDL_Delay(fpsdelay)
|
163
|
+
end
|
164
|
+
|
165
|
+
SDL2.SDL_Quit()
|
166
|
+
end
|
data/lib/sdl2_audio.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] This is an automatically generated file.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module SDL2
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
SDL_AUDIO_MASK_BITSIZE = ( 0xFF )
|
14
|
+
SDL_AUDIO_MASK_DATATYPE = ( 1 << 8 )
|
15
|
+
SDL_AUDIO_MASK_ENDIAN = ( 1 << 12 )
|
16
|
+
SDL_AUDIO_MASK_SIGNED = ( 1 << 15 )
|
17
|
+
SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001
|
18
|
+
SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002
|
19
|
+
SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004
|
20
|
+
SDL_AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008
|
21
|
+
SDL_AUDIO_ALLOW_ANY_CHANGE = ( SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_FORMAT_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE | SDL_AUDIO_ALLOW_SAMPLES_CHANGE )
|
22
|
+
SDL_AUDIOCVT_MAX_FILTERS = 9
|
23
|
+
SDL_MIX_MAXVOLUME = 128
|
24
|
+
|
25
|
+
# Enum
|
26
|
+
|
27
|
+
SDL_AUDIO_STOPPED = 0
|
28
|
+
SDL_AUDIO_PLAYING = 1
|
29
|
+
SDL_AUDIO_PAUSED = 2
|
30
|
+
|
31
|
+
# Typedef
|
32
|
+
|
33
|
+
typedef :ushort, :SDL_AudioFormat
|
34
|
+
callback :SDL_AudioCallback, [:pointer, :pointer, :int], :void
|
35
|
+
callback :SDL_AudioFilter, [:pointer, :ushort], :void
|
36
|
+
typedef :uint, :SDL_AudioDeviceID
|
37
|
+
typedef :int, :SDL_AudioStatus
|
38
|
+
|
39
|
+
# Struct
|
40
|
+
|
41
|
+
class SDL_AudioSpec < FFI::Struct
|
42
|
+
layout(
|
43
|
+
:freq, :int,
|
44
|
+
:format, :ushort,
|
45
|
+
:channels, :uchar,
|
46
|
+
:silence, :uchar,
|
47
|
+
:samples, :ushort,
|
48
|
+
:padding, :ushort,
|
49
|
+
:size, :uint,
|
50
|
+
:callback, :pointer,
|
51
|
+
:userdata, :pointer,
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
class SDL_AudioCVT < FFI::Struct
|
56
|
+
layout(
|
57
|
+
:needed, :int,
|
58
|
+
:src_format, :ushort,
|
59
|
+
:dst_format, :ushort,
|
60
|
+
:rate_incr, :double,
|
61
|
+
:buf, :pointer,
|
62
|
+
:len, :int,
|
63
|
+
:len_cvt, :int,
|
64
|
+
:len_mult, :int,
|
65
|
+
:len_ratio, :double,
|
66
|
+
:filters, [:pointer, 10],
|
67
|
+
:filter_index, :int,
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
# Function
|
73
|
+
|
74
|
+
def self.setup_audio_symbols()
|
75
|
+
symbols = [
|
76
|
+
:SDL_GetNumAudioDrivers,
|
77
|
+
:SDL_GetAudioDriver,
|
78
|
+
:SDL_AudioInit,
|
79
|
+
:SDL_AudioQuit,
|
80
|
+
:SDL_GetCurrentAudioDriver,
|
81
|
+
:SDL_OpenAudio,
|
82
|
+
:SDL_GetNumAudioDevices,
|
83
|
+
:SDL_GetAudioDeviceName,
|
84
|
+
:SDL_OpenAudioDevice,
|
85
|
+
:SDL_GetAudioStatus,
|
86
|
+
:SDL_GetAudioDeviceStatus,
|
87
|
+
:SDL_PauseAudio,
|
88
|
+
:SDL_PauseAudioDevice,
|
89
|
+
:SDL_LoadWAV_RW,
|
90
|
+
:SDL_FreeWAV,
|
91
|
+
:SDL_BuildAudioCVT,
|
92
|
+
:SDL_ConvertAudio,
|
93
|
+
:SDL_NewAudioStream,
|
94
|
+
:SDL_AudioStreamPut,
|
95
|
+
:SDL_AudioStreamGet,
|
96
|
+
:SDL_AudioStreamAvailable,
|
97
|
+
:SDL_AudioStreamFlush,
|
98
|
+
:SDL_AudioStreamClear,
|
99
|
+
:SDL_FreeAudioStream,
|
100
|
+
:SDL_MixAudio,
|
101
|
+
:SDL_MixAudioFormat,
|
102
|
+
:SDL_QueueAudio,
|
103
|
+
:SDL_DequeueAudio,
|
104
|
+
:SDL_GetQueuedAudioSize,
|
105
|
+
:SDL_ClearQueuedAudio,
|
106
|
+
:SDL_LockAudio,
|
107
|
+
:SDL_LockAudioDevice,
|
108
|
+
:SDL_UnlockAudio,
|
109
|
+
:SDL_UnlockAudioDevice,
|
110
|
+
:SDL_CloseAudio,
|
111
|
+
:SDL_CloseAudioDevice,
|
112
|
+
]
|
113
|
+
args = {
|
114
|
+
:SDL_GetNumAudioDrivers => [],
|
115
|
+
:SDL_GetAudioDriver => [:int],
|
116
|
+
:SDL_AudioInit => [:pointer],
|
117
|
+
:SDL_AudioQuit => [],
|
118
|
+
:SDL_GetCurrentAudioDriver => [],
|
119
|
+
:SDL_OpenAudio => [:pointer, :pointer],
|
120
|
+
:SDL_GetNumAudioDevices => [:int],
|
121
|
+
:SDL_GetAudioDeviceName => [:int, :int],
|
122
|
+
:SDL_OpenAudioDevice => [:pointer, :int, :pointer, :pointer, :int],
|
123
|
+
:SDL_GetAudioStatus => [],
|
124
|
+
:SDL_GetAudioDeviceStatus => [:uint],
|
125
|
+
:SDL_PauseAudio => [:int],
|
126
|
+
:SDL_PauseAudioDevice => [:uint, :int],
|
127
|
+
:SDL_LoadWAV_RW => [:pointer, :int, :pointer, :pointer, :pointer],
|
128
|
+
:SDL_FreeWAV => [:pointer],
|
129
|
+
:SDL_BuildAudioCVT => [:pointer, :ushort, :uchar, :int, :ushort, :uchar, :int],
|
130
|
+
:SDL_ConvertAudio => [:pointer],
|
131
|
+
:SDL_NewAudioStream => [:ushort, :uchar, :int, :ushort, :uchar, :int],
|
132
|
+
:SDL_AudioStreamPut => [:pointer, :pointer, :int],
|
133
|
+
:SDL_AudioStreamGet => [:pointer, :pointer, :int],
|
134
|
+
:SDL_AudioStreamAvailable => [:pointer],
|
135
|
+
:SDL_AudioStreamFlush => [:pointer],
|
136
|
+
:SDL_AudioStreamClear => [:pointer],
|
137
|
+
:SDL_FreeAudioStream => [:pointer],
|
138
|
+
:SDL_MixAudio => [:pointer, :pointer, :uint, :int],
|
139
|
+
:SDL_MixAudioFormat => [:pointer, :pointer, :ushort, :uint, :int],
|
140
|
+
:SDL_QueueAudio => [:uint, :pointer, :uint],
|
141
|
+
:SDL_DequeueAudio => [:uint, :pointer, :uint],
|
142
|
+
:SDL_GetQueuedAudioSize => [:uint],
|
143
|
+
:SDL_ClearQueuedAudio => [:uint],
|
144
|
+
:SDL_LockAudio => [],
|
145
|
+
:SDL_LockAudioDevice => [:uint],
|
146
|
+
:SDL_UnlockAudio => [],
|
147
|
+
:SDL_UnlockAudioDevice => [:uint],
|
148
|
+
:SDL_CloseAudio => [],
|
149
|
+
:SDL_CloseAudioDevice => [:uint],
|
150
|
+
}
|
151
|
+
retvals = {
|
152
|
+
:SDL_GetNumAudioDrivers => :int,
|
153
|
+
:SDL_GetAudioDriver => :pointer,
|
154
|
+
:SDL_AudioInit => :int,
|
155
|
+
:SDL_AudioQuit => :void,
|
156
|
+
:SDL_GetCurrentAudioDriver => :pointer,
|
157
|
+
:SDL_OpenAudio => :int,
|
158
|
+
:SDL_GetNumAudioDevices => :int,
|
159
|
+
:SDL_GetAudioDeviceName => :pointer,
|
160
|
+
:SDL_OpenAudioDevice => :uint,
|
161
|
+
:SDL_GetAudioStatus => :int,
|
162
|
+
:SDL_GetAudioDeviceStatus => :int,
|
163
|
+
:SDL_PauseAudio => :void,
|
164
|
+
:SDL_PauseAudioDevice => :void,
|
165
|
+
:SDL_LoadWAV_RW => :pointer,
|
166
|
+
:SDL_FreeWAV => :void,
|
167
|
+
:SDL_BuildAudioCVT => :int,
|
168
|
+
:SDL_ConvertAudio => :int,
|
169
|
+
:SDL_NewAudioStream => :pointer,
|
170
|
+
:SDL_AudioStreamPut => :int,
|
171
|
+
:SDL_AudioStreamGet => :int,
|
172
|
+
:SDL_AudioStreamAvailable => :int,
|
173
|
+
:SDL_AudioStreamFlush => :int,
|
174
|
+
:SDL_AudioStreamClear => :void,
|
175
|
+
:SDL_FreeAudioStream => :void,
|
176
|
+
:SDL_MixAudio => :void,
|
177
|
+
:SDL_MixAudioFormat => :void,
|
178
|
+
:SDL_QueueAudio => :int,
|
179
|
+
:SDL_DequeueAudio => :uint,
|
180
|
+
:SDL_GetQueuedAudioSize => :uint,
|
181
|
+
:SDL_ClearQueuedAudio => :void,
|
182
|
+
:SDL_LockAudio => :void,
|
183
|
+
:SDL_LockAudioDevice => :void,
|
184
|
+
:SDL_UnlockAudio => :void,
|
185
|
+
:SDL_UnlockAudioDevice => :void,
|
186
|
+
:SDL_CloseAudio => :void,
|
187
|
+
:SDL_CloseAudioDevice => :void,
|
188
|
+
}
|
189
|
+
symbols.each do |sym|
|
190
|
+
begin
|
191
|
+
attach_function sym, args[sym], retvals[sym]
|
192
|
+
rescue FFI::NotFoundError => error
|
193
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
# TODO : def SDL_LoadWAV
|
201
|
+
|