sdl2-bindings 0.0.6 → 0.1.0

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +25 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +38 -19
  5. data/lib/sdl2.rb +56 -99
  6. data/lib/sdl2_audio.rb +62 -20
  7. data/lib/sdl2_blendmode.rb +28 -25
  8. data/lib/sdl2_clipboard.rb +9 -4
  9. data/lib/sdl2_cpuinfo.rb +31 -8
  10. data/lib/sdl2_error.rb +17 -10
  11. data/lib/sdl2_events.rb +152 -130
  12. data/lib/sdl2_filesystem.rb +8 -4
  13. data/lib/sdl2_framerate.rb +11 -4
  14. data/lib/sdl2_gamecontroller.rb +130 -55
  15. data/lib/sdl2_gesture.rb +10 -4
  16. data/lib/sdl2_gfxPrimitives.rb +65 -4
  17. data/lib/sdl2_haptic.rb +76 -44
  18. data/lib/sdl2_hidapi.rb +139 -0
  19. data/lib/sdl2_hints.rb +146 -113
  20. data/lib/sdl2_image.rb +54 -7
  21. data/lib/sdl2_imageFilter.rb +36 -4
  22. data/lib/sdl2_joystick.rb +102 -38
  23. data/lib/sdl2_keyboard.rb +23 -5
  24. data/lib/sdl2_keycode.rb +8 -5
  25. data/lib/sdl2_log.rb +48 -32
  26. data/lib/sdl2_main.rb +21 -14
  27. data/lib/sdl2_messagebox.rb +26 -22
  28. data/lib/sdl2_misc.rb +48 -0
  29. data/lib/sdl2_mixer.rb +86 -11
  30. data/lib/sdl2_mouse.rb +44 -25
  31. data/lib/sdl2_pixels.rb +115 -99
  32. data/lib/sdl2_platform.rb +7 -4
  33. data/lib/sdl2_power.rb +12 -9
  34. data/lib/sdl2_rect.rb +18 -11
  35. data/lib/sdl2_render.rb +135 -21
  36. data/lib/sdl2_rotozoom.rb +14 -4
  37. data/lib/sdl2_rwops.rb +69 -39
  38. data/lib/sdl2_scancode.rb +250 -248
  39. data/lib/sdl2_sensor.rb +115 -0
  40. data/lib/sdl2_shape.rb +17 -11
  41. data/lib/sdl2_stdinc.rb +213 -42
  42. data/lib/sdl2_surface.rb +62 -15
  43. data/lib/sdl2_syswm.rb +47 -41
  44. data/lib/sdl2_timer.rb +16 -4
  45. data/lib/sdl2_touch.rb +18 -9
  46. data/lib/sdl2_ttf.rb +180 -25
  47. data/lib/sdl2_version.rb +13 -8
  48. data/lib/sdl2_video.rb +232 -103
  49. data/lib/sdl2_vulkan.rb +12 -4
  50. metadata +21 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 533feab6661f4f13ec028b62c73801f5b8c44d3b204dcfd6acd4986c60297edf
4
- data.tar.gz: 1b0a21d7edb08c3faf2cb9fb6863376fefa15086ccd2dfcaa75ed83a6fc3dc1e
3
+ metadata.gz: 205a5a5f319071f5b61525129b0f9a9a087c33442e7edf846f23615c3f316cbd
4
+ data.tar.gz: b0ead4dcd9e8e44753c40fb2fb154abefda5c957e73d719c72c1b77e087d7a56
5
5
  SHA512:
6
- metadata.gz: 52d620b288f5f36afb018356f0788fd833cdaacd17bf20e79625ed1716cffbde8f5502b1e6d2e62b062dfc7546f763abf0b2c59b6c8e93a77b3de3718898bc50
7
- data.tar.gz: 9ebe4273355e338e24deff7b35850a15dcb47c30e1ee11c2b7ca48dbacea21509f946c9b3beda3309560a5bcf3de05c3e4f1964fa6bc41526008ba62767298c5
6
+ metadata.gz: acf2ce95e5c3639bb5c84bd49823885b1a2794232796ca1b97f2cc89dc4b106da2482425b37ee9b79ed9ac29d4ba6112b683557ae4040619bf9a92ebb1f769e7
7
+ data.tar.gz: d28d2655a06aa0f46011670fd0829d05cb7096212b6a9e50f6c66e00933364beb8416dfca730a5528f2d495136eb2b53c5a3de6b1a25211fe23c4b747433d2b5
data/ChangeLog CHANGED
@@ -1,3 +1,28 @@
1
+ 2022-01-26 vaiorabbit <http://twitter.com/vaiorabbit>
2
+
3
+ * test/test*.rb: Changed namespace
4
+ * load_lib: Now accepts argument 'output_error'
5
+
6
+ 2022-01-22 vaiorabbit <http://twitter.com/vaiorabbit>
7
+
8
+ * lib/sdl2_ttf.rb: Generated for version 2.0.18
9
+ * generator: Fixed wrong 'by_value' handling
10
+ * .gitignore: Added
11
+ * test/test_opengl.rb: Use opengl-bindings2
12
+
13
+ 2022-01-11 vaiorabbit <http://twitter.com/vaiorabbit>
14
+
15
+ * Added SDL 2.0.20 features ( https://github.com/libsdl-org/SDL/releases/tag/release-2.0.20 )
16
+
17
+ 2021-12-02 vaiorabbit <http://twitter.com/vaiorabbit>
18
+
19
+ * Added SDL 2.0.18 features ( https://github.com/libsdl-org/SDL/releases/tag/release-2.0.18 )
20
+
21
+ 2021-08-12 vaiorabbit <http://twitter.com/vaiorabbit>
22
+
23
+ * Added SDL 2.0.14 features (SDL_misc).
24
+ * Added SDL 2.0.16 features (SDL_sensor).
25
+
1
26
  2021-02-21 vaiorabbit <http://twitter.com/vaiorabbit>
2
27
 
3
28
  * Added defines from Audio, Mixer and TTF
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  sdl2-bindings : Yet another SDL2 wrapper for Ruby
2
- Copyright (c) 2015-2021 vaiorabbit <http://twitter.com/vaiorabbit>
2
+ Copyright (c) 2015-2022 vaiorabbit <http://twitter.com/vaiorabbit>
3
3
 
4
4
  This software is provided 'as-is', without any express or implied
5
5
  warranty. In no event will the authors be held liable for any damages
data/README.md CHANGED
@@ -2,10 +2,8 @@
2
2
 
3
3
  # sdl2-bindings : Yet another SDL2 wrapper for Ruby #
4
4
 
5
- [Notice] Experimental project.
6
-
7
5
  * Created : 2015-09-19
8
- * Last modified : 2021-02-21
6
+ * Last modified : 2022-01-26
9
7
 
10
8
  ## Features ##
11
9
 
@@ -13,32 +11,53 @@
13
11
  * Based on Ruby/FFI
14
12
  * No need to build C extension library
15
13
 
16
-
17
14
  ## Limitations ##
18
15
 
19
- * Some APIs provided by pre-processor cannot be imported.
16
+ * Several original APIs originally defined with pre-processor macro are unavailable in this library (e.g. `SDL_LoadBMP`)
17
+
18
+ ## Target version ##
19
+
20
+ * [2022-01-21]
21
+ * SDL : 2.0.20
22
+ * SDL_image : 2.0.5
23
+ * SDL_mixer : 2.0.4
24
+ * SDL_ttf : 2.0.18
25
+ * SDL2_gfx : 1.0.4
26
+
27
+ <details>
28
+ <summary>Older versions</summary>
29
+
30
+ * [2015-09-19] SDL 2.0.3
31
+ * [2016-04-03] SDL 2.0.4
32
+ * [2019-08-31] SDL 2.0.10
33
+ * [2020-03-22] SDL 2.0.12
34
+ * [2020-12-27] SDL 2.0.14
35
+ * [2021-08-12] SDL 2.0.16
36
+ * [2021-12-02] SDL 2.0.18
37
+
38
+ </details>
39
+
40
+ ## Supported Environments ##
41
+
42
+ * [2022-01-11] macOS Monterey (12.1), ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin20]
43
+
44
+ <details>
45
+ <summary>Older Environments</summary>
20
46
 
21
- ## Tested Environment ##
47
+ * [2021-12-02] macOS Big Sur (11.6), ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
48
+ * [2021-08-12] macOS Big Sur (11.5), ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
49
+ * [2020-12-27] macOS Big Sur (11.0.1), ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
50
+ * [2016-04-03] Mac OS X 10.11.4, ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
51
+ * [2015-09-19] Mac OS X 10.10.5, ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
22
52
 
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
- * [2020-03-22] SDL 2.0.12 (Installed via Homebrew)
33
- * [2020-12-27] SDL 2.0.14 (Installed via Homebrew)
34
- * macOS Big Sur (11.0.1), ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
53
+ </details>
35
54
 
36
55
  ## License ##
37
56
 
38
57
  The zlib/libpng License ( http://opensource.org/licenses/Zlib ).
39
58
 
40
59
  sdl2-bindings : Yet another SDL2 wrapper for Ruby
41
- Copyright (c) 2015-2021 vaiorabbit <http://twitter.com/vaiorabbit>
60
+ Copyright (c) 2015-2022 vaiorabbit <http://twitter.com/vaiorabbit>
42
61
 
43
62
  This software is provided 'as-is', without any express or implied
44
63
  warranty. In no event will the authors be held liable for any damages
data/lib/sdl2.rb CHANGED
@@ -20,6 +20,7 @@ require_relative 'sdl2_keyboard.rb'
20
20
  require_relative 'sdl2_keycode.rb'
21
21
  require_relative 'sdl2_log.rb'
22
22
  require_relative 'sdl2_messagebox.rb'
23
+ require_relative 'sdl2_misc.rb'
23
24
  require_relative 'sdl2_mouse.rb'
24
25
  require_relative 'sdl2_pixels.rb'
25
26
  require_relative 'sdl2_platform.rb'
@@ -28,6 +29,7 @@ require_relative 'sdl2_rect.rb'
28
29
  require_relative 'sdl2_render.rb'
29
30
  require_relative 'sdl2_rwops.rb'
30
31
  require_relative 'sdl2_scancode.rb'
32
+ require_relative 'sdl2_sensor.rb'
31
33
  require_relative 'sdl2_shape.rb'
32
34
  require_relative 'sdl2_stdinc.rb'
33
35
  require_relative 'sdl2_surface.rb'
@@ -38,19 +40,23 @@ require_relative 'sdl2_version.rb'
38
40
  require_relative 'sdl2_video.rb'
39
41
  require_relative 'sdl2_vulkan.rb'
40
42
 
43
+ # SDL2_gfx
41
44
  require_relative 'sdl2_framerate.rb'
42
45
  require_relative 'sdl2_gfxPrimitives.rb'
43
- require_relative 'sdl2_image.rb'
44
46
  require_relative 'sdl2_rotozoom.rb'
45
47
  require_relative 'sdl2_imageFilter.rb'
46
- require_relative 'sdl2_ttf.rb'
48
+ # SDL_image
49
+ require_relative 'sdl2_image.rb'
50
+ # SDL_mixer
47
51
  require_relative 'sdl2_mixer.rb'
52
+ # SDL_ttf
53
+ require_relative 'sdl2_ttf.rb'
48
54
 
49
- module SDL2
55
+ module SDL
50
56
  extend FFI::Library
51
57
 
52
58
  @@sdl2_import_done = false
53
- def self.load_lib(libpath, image_libpath: nil, ttf_libpath: nil, mixer_libpath: nil, gfx_libpath: nil)
59
+ def self.load_lib(libpath, output_error = false, image_libpath: nil, ttf_libpath: nil, mixer_libpath: nil, gfx_libpath: nil)
54
60
 
55
61
  unless @@sdl2_import_done
56
62
  # Ref.: Using Multiple and Alternate Libraries
@@ -60,111 +66,62 @@ module SDL2
60
66
 
61
67
  ffi_lib_flags :now, :global
62
68
  ffi_lib *lib_paths
63
- setup_symbols()
69
+ setup_symbols(output_error)
64
70
 
65
- if image_libpath != nil
66
- setup_image_symbols()
67
- end
68
-
69
- if ttf_libpath != nil
70
- setup_ttf_symbols()
71
- end
72
-
73
- if mixer_libpath != nil
74
- setup_mixer_symbols()
75
- end
71
+ setup_image_symbols(output_error) if image_libpath
72
+ setup_ttf_symbols(output_error) if ttf_libpath
73
+ setup_mixer_symbols(output_error) if mixer_libpath
76
74
 
77
75
  if gfx_libpath != nil
78
- setup_gfx_framerate_symbols()
79
- setup_gfx_primitives_symbols()
80
- setup_gfx_imagefilter_symbols()
81
- setup_gfx_rotozoom_symbols()
76
+ setup_gfx_framerate_symbols(output_error)
77
+ setup_gfx_primitives_symbols(output_error)
78
+ setup_gfx_imagefilter_symbols(output_error)
79
+ setup_gfx_rotozoom_symbols(output_error)
82
80
  end
83
81
  rescue => error
84
- puts error
82
+ $stderr.puts("[Warning] Failed to load libraries (#{error}).") if output_error
85
83
  end
86
84
  end
87
85
 
88
86
  end
89
87
 
90
- def self.setup_symbols()
91
- setup_main_symbols()
92
- setup_audio_symbols()
93
- setup_blendmode_symbols()
94
- setup_clipboard_symbols()
95
- setup_cpuinfo_symbols()
96
- setup_error_symbols()
97
- setup_events_symbols()
98
- setup_filesystem_symbols()
99
- setup_gamecontroller_symbols()
100
- setup_gesture_symbols()
101
- setup_haptic_symbols()
102
- setup_hints_symbols()
103
- setup_joystick_symbols()
104
- setup_keyboard_symbols()
105
- setup_keycode_symbols()
106
- setup_log_symbols()
107
- setup_messagebox_symbols()
108
- setup_mouse_symbols()
109
- setup_pixels_symbols()
110
- setup_platform_symbols()
111
- setup_power_symbols()
112
- setup_rect_symbols()
113
- setup_render_symbols()
114
- setup_rwops_symbols()
115
- setup_scancode_symbols()
116
- setup_shape_symbols()
117
- setup_surface_symbols()
118
- setup_syswm_symbols()
119
- setup_stdinc_symbols()
120
- setup_timer_symbols()
121
- setup_touch_symbols()
122
- setup_version_symbols()
123
- setup_video_symbols()
124
- setup_vulkan_symbols()
125
- end
126
-
127
- end
128
-
129
-
130
- if __FILE__ == $0
131
- # SDL2.load_lib('libSDL2.dylib')
132
- # p SDL2.SDL_Init(SDL2::SDL_INIT_EVERYTHING)
133
- SDL2.load_lib('libSDL2.dylib',
134
- gfx_libpath: '/usr/local/lib/libSDL2_gfx.dylib'
135
- )
136
- #SDL2.SDL_SetMainReady()
137
- success = SDL2.SDL_Init(SDL2::SDL_INIT_EVERYTHING)
138
- exit if success < 0
139
-
140
- WINDOW_W = 320
141
- WINDOW_H = 240
142
- window = SDL2.SDL_CreateWindow("1st SDL Window via sdl2-bindings", 0, 0, WINDOW_W, WINDOW_H, 0)
143
-
144
- fpsdelay = 100;
145
-
146
- count = 0
147
- event = SDL2::SDL_Event.new
148
- done = false
149
- while not done
150
- while SDL2.SDL_PollEvent(event) != 0
151
- # 'type' and 'timestamp' are common members for all SDL Event structs.
152
- event_type = event[:common][:type]
153
- event_timestamp = event[:common][:timestamp]
154
- puts "Event : type=0x#{event_type.to_s(16)}, timestamp=#{event_timestamp}"
155
-
156
- case event_type
157
- when SDL2::SDL_KEYDOWN
158
- if event[:key][:keysym][:sym] == SDL2::SDLK_SPACE
159
- puts "\tSPACE key pressed."
160
- end
161
- end
162
- end
163
-
164
- count += 1
165
- done = true if count >= 100
166
- SDL2.SDL_Delay(fpsdelay)
88
+ def self.setup_symbols(output_error = false)
89
+ setup_main_symbols(output_error)
90
+ setup_audio_symbols(output_error)
91
+ setup_blendmode_symbols(output_error)
92
+ setup_clipboard_symbols(output_error)
93
+ setup_cpuinfo_symbols(output_error)
94
+ setup_error_symbols(output_error)
95
+ setup_events_symbols(output_error)
96
+ setup_filesystem_symbols(output_error)
97
+ setup_gamecontroller_symbols(output_error)
98
+ setup_gesture_symbols(output_error)
99
+ setup_haptic_symbols(output_error)
100
+ setup_hints_symbols(output_error)
101
+ setup_joystick_symbols(output_error)
102
+ setup_keyboard_symbols(output_error)
103
+ setup_keycode_symbols(output_error)
104
+ setup_log_symbols(output_error)
105
+ setup_messagebox_symbols(output_error)
106
+ setup_misc_symbols(output_error)
107
+ setup_mouse_symbols(output_error)
108
+ setup_pixels_symbols(output_error)
109
+ setup_platform_symbols(output_error)
110
+ setup_power_symbols(output_error)
111
+ setup_rect_symbols(output_error)
112
+ setup_render_symbols(output_error)
113
+ setup_rwops_symbols(output_error)
114
+ setup_scancode_symbols(output_error)
115
+ setup_sensor_symbols(output_error)
116
+ setup_shape_symbols(output_error)
117
+ setup_surface_symbols(output_error)
118
+ setup_syswm_symbols(output_error)
119
+ setup_stdinc_symbols(output_error)
120
+ setup_timer_symbols(output_error)
121
+ setup_touch_symbols(output_error)
122
+ setup_version_symbols(output_error)
123
+ setup_video_symbols(output_error)
124
+ setup_vulkan_symbols(output_error)
167
125
  end
168
126
 
169
- SDL2.SDL_Quit()
170
127
  end
data/lib/sdl2_audio.rb CHANGED
@@ -6,14 +6,14 @@
6
6
 
7
7
  require 'ffi'
8
8
 
9
- module SDL2
9
+ module SDL
10
10
  extend FFI::Library
11
11
  # Define/Macro
12
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)
13
+ AUDIO_MASK_BITSIZE = 0xFF
14
+ AUDIO_MASK_DATATYPE = (1 << 8)
15
+ AUDIO_MASK_ENDIAN = (1 << 12)
16
+ AUDIO_MASK_SIGNED = (1 << 15)
17
17
  AUDIO_U8 = 0x0008
18
18
  AUDIO_S8 = 0x8008
19
19
  AUDIO_U16LSB = 0x0010
@@ -32,19 +32,19 @@ module SDL2
32
32
  AUDIO_S16SYS = AUDIO_S16LSB
33
33
  AUDIO_S32SYS = AUDIO_S32LSB
34
34
  AUDIO_F32SYS = AUDIO_F32LSB
35
- SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001
36
- SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002
37
- SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004
38
- SDL_AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008
39
- 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)
40
- SDL_AUDIOCVT_MAX_FILTERS = 9
41
- SDL_MIX_MAXVOLUME = 128
35
+ AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001
36
+ AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002
37
+ AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004
38
+ AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008
39
+ AUDIO_ALLOW_ANY_CHANGE = (AUDIO_ALLOW_FREQUENCY_CHANGE | AUDIO_ALLOW_FORMAT_CHANGE | AUDIO_ALLOW_CHANNELS_CHANGE | AUDIO_ALLOW_SAMPLES_CHANGE)
40
+ AUDIOCVT_MAX_FILTERS = 9
41
+ MIX_MAXVOLUME = 128
42
42
 
43
43
  # Enum
44
44
 
45
- SDL_AUDIO_STOPPED = 0
46
- SDL_AUDIO_PLAYING = 1
47
- SDL_AUDIO_PAUSED = 2
45
+ AUDIO_STOPPED = 0
46
+ AUDIO_PLAYING = 1
47
+ AUDIO_PAUSED = 2
48
48
 
49
49
  # Typedef
50
50
 
@@ -56,7 +56,7 @@ module SDL2
56
56
 
57
57
  # Struct
58
58
 
59
- class SDL_AudioSpec < FFI::Struct
59
+ class AudioSpec < FFI::Struct
60
60
  layout(
61
61
  :freq, :int,
62
62
  :format, :ushort,
@@ -70,7 +70,7 @@ module SDL2
70
70
  )
71
71
  end
72
72
 
73
- class SDL_AudioCVT < FFI::Struct
73
+ class AudioCVT < FFI::Struct
74
74
  layout(
75
75
  :needed, :int,
76
76
  :src_format, :ushort,
@@ -89,7 +89,7 @@ module SDL2
89
89
 
90
90
  # Function
91
91
 
92
- def self.setup_audio_symbols()
92
+ def self.setup_audio_symbols(output_error = false)
93
93
  symbols = [
94
94
  :SDL_GetNumAudioDrivers,
95
95
  :SDL_GetAudioDriver,
@@ -99,6 +99,7 @@ module SDL2
99
99
  :SDL_OpenAudio,
100
100
  :SDL_GetNumAudioDevices,
101
101
  :SDL_GetAudioDeviceName,
102
+ :SDL_GetAudioDeviceSpec,
102
103
  :SDL_OpenAudioDevice,
103
104
  :SDL_GetAudioStatus,
104
105
  :SDL_GetAudioDeviceStatus,
@@ -128,6 +129,45 @@ module SDL2
128
129
  :SDL_CloseAudio,
129
130
  :SDL_CloseAudioDevice,
130
131
  ]
132
+ apis = {
133
+ :SDL_GetNumAudioDrivers => :GetNumAudioDrivers,
134
+ :SDL_GetAudioDriver => :GetAudioDriver,
135
+ :SDL_AudioInit => :AudioInit,
136
+ :SDL_AudioQuit => :AudioQuit,
137
+ :SDL_GetCurrentAudioDriver => :GetCurrentAudioDriver,
138
+ :SDL_OpenAudio => :OpenAudio,
139
+ :SDL_GetNumAudioDevices => :GetNumAudioDevices,
140
+ :SDL_GetAudioDeviceName => :GetAudioDeviceName,
141
+ :SDL_GetAudioDeviceSpec => :GetAudioDeviceSpec,
142
+ :SDL_OpenAudioDevice => :OpenAudioDevice,
143
+ :SDL_GetAudioStatus => :GetAudioStatus,
144
+ :SDL_GetAudioDeviceStatus => :GetAudioDeviceStatus,
145
+ :SDL_PauseAudio => :PauseAudio,
146
+ :SDL_PauseAudioDevice => :PauseAudioDevice,
147
+ :SDL_LoadWAV_RW => :LoadWAV_RW,
148
+ :SDL_FreeWAV => :FreeWAV,
149
+ :SDL_BuildAudioCVT => :BuildAudioCVT,
150
+ :SDL_ConvertAudio => :ConvertAudio,
151
+ :SDL_NewAudioStream => :NewAudioStream,
152
+ :SDL_AudioStreamPut => :AudioStreamPut,
153
+ :SDL_AudioStreamGet => :AudioStreamGet,
154
+ :SDL_AudioStreamAvailable => :AudioStreamAvailable,
155
+ :SDL_AudioStreamFlush => :AudioStreamFlush,
156
+ :SDL_AudioStreamClear => :AudioStreamClear,
157
+ :SDL_FreeAudioStream => :FreeAudioStream,
158
+ :SDL_MixAudio => :MixAudio,
159
+ :SDL_MixAudioFormat => :MixAudioFormat,
160
+ :SDL_QueueAudio => :QueueAudio,
161
+ :SDL_DequeueAudio => :DequeueAudio,
162
+ :SDL_GetQueuedAudioSize => :GetQueuedAudioSize,
163
+ :SDL_ClearQueuedAudio => :ClearQueuedAudio,
164
+ :SDL_LockAudio => :LockAudio,
165
+ :SDL_LockAudioDevice => :LockAudioDevice,
166
+ :SDL_UnlockAudio => :UnlockAudio,
167
+ :SDL_UnlockAudioDevice => :UnlockAudioDevice,
168
+ :SDL_CloseAudio => :CloseAudio,
169
+ :SDL_CloseAudioDevice => :CloseAudioDevice,
170
+ }
131
171
  args = {
132
172
  :SDL_GetNumAudioDrivers => [],
133
173
  :SDL_GetAudioDriver => [:int],
@@ -137,6 +177,7 @@ module SDL2
137
177
  :SDL_OpenAudio => [:pointer, :pointer],
138
178
  :SDL_GetNumAudioDevices => [:int],
139
179
  :SDL_GetAudioDeviceName => [:int, :int],
180
+ :SDL_GetAudioDeviceSpec => [:int, :int, :pointer],
140
181
  :SDL_OpenAudioDevice => [:pointer, :int, :pointer, :pointer, :int],
141
182
  :SDL_GetAudioStatus => [],
142
183
  :SDL_GetAudioDeviceStatus => [:uint],
@@ -175,6 +216,7 @@ module SDL2
175
216
  :SDL_OpenAudio => :int,
176
217
  :SDL_GetNumAudioDevices => :int,
177
218
  :SDL_GetAudioDeviceName => :pointer,
219
+ :SDL_GetAudioDeviceSpec => :int,
178
220
  :SDL_OpenAudioDevice => :uint,
179
221
  :SDL_GetAudioStatus => :int,
180
222
  :SDL_GetAudioDeviceStatus => :int,
@@ -206,9 +248,9 @@ module SDL2
206
248
  }
207
249
  symbols.each do |sym|
208
250
  begin
209
- attach_function sym, args[sym], retvals[sym]
251
+ attach_function apis[sym], sym, args[sym], retvals[sym]
210
252
  rescue FFI::NotFoundError => error
211
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
253
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
212
254
  end
213
255
  end
214
256
  end
@@ -6,34 +6,34 @@
6
6
 
7
7
  require 'ffi'
8
8
 
9
- module SDL2
9
+ module SDL
10
10
  extend FFI::Library
11
11
  # Define/Macro
12
12
 
13
13
 
14
14
  # Enum
15
15
 
16
- SDL_BLENDMODE_NONE = 0
17
- SDL_BLENDMODE_BLEND = 1
18
- SDL_BLENDMODE_ADD = 2
19
- SDL_BLENDMODE_MOD = 4
20
- SDL_BLENDMODE_MUL = 8
21
- SDL_BLENDMODE_INVALID = 2147483647
22
- SDL_BLENDOPERATION_ADD = 1
23
- SDL_BLENDOPERATION_SUBTRACT = 2
24
- SDL_BLENDOPERATION_REV_SUBTRACT = 3
25
- SDL_BLENDOPERATION_MINIMUM = 4
26
- SDL_BLENDOPERATION_MAXIMUM = 5
27
- SDL_BLENDFACTOR_ZERO = 1
28
- SDL_BLENDFACTOR_ONE = 2
29
- SDL_BLENDFACTOR_SRC_COLOR = 3
30
- SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 4
31
- SDL_BLENDFACTOR_SRC_ALPHA = 5
32
- SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 6
33
- SDL_BLENDFACTOR_DST_COLOR = 7
34
- SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 8
35
- SDL_BLENDFACTOR_DST_ALPHA = 9
36
- SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 10
16
+ BLENDMODE_NONE = 0
17
+ BLENDMODE_BLEND = 1
18
+ BLENDMODE_ADD = 2
19
+ BLENDMODE_MOD = 4
20
+ BLENDMODE_MUL = 8
21
+ BLENDMODE_INVALID = 2147483647
22
+ BLENDOPERATION_ADD = 1
23
+ BLENDOPERATION_SUBTRACT = 2
24
+ BLENDOPERATION_REV_SUBTRACT = 3
25
+ BLENDOPERATION_MINIMUM = 4
26
+ BLENDOPERATION_MAXIMUM = 5
27
+ BLENDFACTOR_ZERO = 1
28
+ BLENDFACTOR_ONE = 2
29
+ BLENDFACTOR_SRC_COLOR = 3
30
+ BLENDFACTOR_ONE_MINUS_SRC_COLOR = 4
31
+ BLENDFACTOR_SRC_ALPHA = 5
32
+ BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 6
33
+ BLENDFACTOR_DST_COLOR = 7
34
+ BLENDFACTOR_ONE_MINUS_DST_COLOR = 8
35
+ BLENDFACTOR_DST_ALPHA = 9
36
+ BLENDFACTOR_ONE_MINUS_DST_ALPHA = 10
37
37
 
38
38
  # Typedef
39
39
 
@@ -46,10 +46,13 @@ module SDL2
46
46
 
47
47
  # Function
48
48
 
49
- def self.setup_blendmode_symbols()
49
+ def self.setup_blendmode_symbols(output_error = false)
50
50
  symbols = [
51
51
  :SDL_ComposeCustomBlendMode,
52
52
  ]
53
+ apis = {
54
+ :SDL_ComposeCustomBlendMode => :ComposeCustomBlendMode,
55
+ }
53
56
  args = {
54
57
  :SDL_ComposeCustomBlendMode => [:int, :int, :int, :int, :int, :int],
55
58
  }
@@ -58,9 +61,9 @@ module SDL2
58
61
  }
59
62
  symbols.each do |sym|
60
63
  begin
61
- attach_function sym, args[sym], retvals[sym]
64
+ attach_function apis[sym], sym, args[sym], retvals[sym]
62
65
  rescue FFI::NotFoundError => error
63
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
66
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
64
67
  end
65
68
  end
66
69
  end
@@ -6,7 +6,7 @@
6
6
 
7
7
  require 'ffi'
8
8
 
9
- module SDL2
9
+ module SDL
10
10
  extend FFI::Library
11
11
  # Define/Macro
12
12
 
@@ -22,12 +22,17 @@ module SDL2
22
22
 
23
23
  # Function
24
24
 
25
- def self.setup_clipboard_symbols()
25
+ def self.setup_clipboard_symbols(output_error = false)
26
26
  symbols = [
27
27
  :SDL_SetClipboardText,
28
28
  :SDL_GetClipboardText,
29
29
  :SDL_HasClipboardText,
30
30
  ]
31
+ apis = {
32
+ :SDL_SetClipboardText => :SetClipboardText,
33
+ :SDL_GetClipboardText => :GetClipboardText,
34
+ :SDL_HasClipboardText => :HasClipboardText,
35
+ }
31
36
  args = {
32
37
  :SDL_SetClipboardText => [:pointer],
33
38
  :SDL_GetClipboardText => [],
@@ -40,9 +45,9 @@ module SDL2
40
45
  }
41
46
  symbols.each do |sym|
42
47
  begin
43
- attach_function sym, args[sym], retvals[sym]
48
+ attach_function apis[sym], sym, args[sym], retvals[sym]
44
49
  rescue FFI::NotFoundError => error
45
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
50
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
46
51
  end
47
52
  end
48
53
  end