sdl2-bindings 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +12 -0
- data/README.md +39 -26
- data/lib/sdl2.rb +54 -99
- data/lib/sdl2_audio.rb +59 -20
- data/lib/sdl2_blendmode.rb +28 -25
- data/lib/sdl2_clipboard.rb +9 -4
- data/lib/sdl2_cpuinfo.rb +28 -5
- data/lib/sdl2_error.rb +17 -10
- data/lib/sdl2_events.rb +150 -131
- data/lib/sdl2_filesystem.rb +8 -4
- data/lib/sdl2_framerate.rb +11 -4
- data/lib/sdl2_gamecontroller.rb +112 -57
- data/lib/sdl2_gesture.rb +10 -4
- data/lib/sdl2_gfxPrimitives.rb +65 -4
- data/lib/sdl2_haptic.rb +76 -44
- data/lib/sdl2_hidapi.rb +26 -5
- data/lib/sdl2_hints.rb +146 -137
- data/lib/sdl2_image.rb +54 -7
- data/lib/sdl2_imageFilter.rb +36 -4
- data/lib/sdl2_joystick.rb +93 -38
- data/lib/sdl2_keyboard.rb +23 -5
- data/lib/sdl2_keycode.rb +6 -4
- data/lib/sdl2_log.rb +48 -32
- data/lib/sdl2_main.rb +21 -14
- data/lib/sdl2_messagebox.rb +26 -22
- data/lib/sdl2_misc.rb +7 -4
- data/lib/sdl2_mixer.rb +86 -11
- data/lib/sdl2_mouse.rb +44 -25
- data/lib/sdl2_pixels.rb +115 -99
- data/lib/sdl2_platform.rb +7 -4
- data/lib/sdl2_power.rb +12 -9
- data/lib/sdl2_rect.rb +18 -11
- data/lib/sdl2_render.rb +107 -25
- data/lib/sdl2_rotozoom.rb +14 -4
- data/lib/sdl2_rwops.rb +58 -28
- data/lib/sdl2_scancode.rb +250 -248
- data/lib/sdl2_sensor.rb +27 -9
- data/lib/sdl2_shape.rb +17 -11
- data/lib/sdl2_stdinc.rb +135 -10
- data/lib/sdl2_surface.rb +56 -15
- data/lib/sdl2_syswm.rb +47 -44
- data/lib/sdl2_timer.rb +13 -4
- data/lib/sdl2_touch.rb +18 -11
- data/lib/sdl2_ttf.rb +180 -25
- data/lib/sdl2_version.rb +13 -8
- data/lib/sdl2_video.rb +204 -110
- data/lib/sdl2_vulkan.rb +12 -4
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 205a5a5f319071f5b61525129b0f9a9a087c33442e7edf846f23615c3f316cbd
|
4
|
+
data.tar.gz: b0ead4dcd9e8e44753c40fb2fb154abefda5c957e73d719c72c1b77e087d7a56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acf2ce95e5c3639bb5c84bd49823885b1a2794232796ca1b97f2cc89dc4b106da2482425b37ee9b79ed9ac29d4ba6112b683557ae4040619bf9a92ebb1f769e7
|
7
|
+
data.tar.gz: d28d2655a06aa0f46011670fd0829d05cb7096212b6a9e50f6c66e00933364beb8416dfca730a5528f2d495136eb2b53c5a3de6b1a25211fe23c4b747433d2b5
|
data/ChangeLog
CHANGED
@@ -1,3 +1,15 @@
|
|
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
|
+
|
1
13
|
2022-01-11 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
14
|
|
3
15
|
* Added SDL 2.0.20 features ( https://github.com/libsdl-org/SDL/releases/tag/release-2.0.20 )
|
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 : 2022-01-
|
6
|
+
* Last modified : 2022-01-26
|
9
7
|
|
10
8
|
## Features ##
|
11
9
|
|
@@ -13,31 +11,46 @@
|
|
13
11
|
* Based on Ruby/FFI
|
14
12
|
* No need to build C extension library
|
15
13
|
|
16
|
-
|
17
14
|
## Limitations ##
|
18
15
|
|
19
|
-
*
|
20
|
-
|
21
|
-
##
|
22
|
-
|
23
|
-
* [
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
* [
|
34
|
-
|
35
|
-
* [
|
36
|
-
|
37
|
-
* [
|
38
|
-
|
39
|
-
* [
|
40
|
-
|
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>
|
46
|
+
|
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]
|
52
|
+
|
53
|
+
</details>
|
41
54
|
|
42
55
|
## License ##
|
43
56
|
|
data/lib/sdl2.rb
CHANGED
@@ -40,19 +40,23 @@ require_relative 'sdl2_version.rb'
|
|
40
40
|
require_relative 'sdl2_video.rb'
|
41
41
|
require_relative 'sdl2_vulkan.rb'
|
42
42
|
|
43
|
+
# SDL2_gfx
|
43
44
|
require_relative 'sdl2_framerate.rb'
|
44
45
|
require_relative 'sdl2_gfxPrimitives.rb'
|
45
|
-
require_relative 'sdl2_image.rb'
|
46
46
|
require_relative 'sdl2_rotozoom.rb'
|
47
47
|
require_relative 'sdl2_imageFilter.rb'
|
48
|
-
|
48
|
+
# SDL_image
|
49
|
+
require_relative 'sdl2_image.rb'
|
50
|
+
# SDL_mixer
|
49
51
|
require_relative 'sdl2_mixer.rb'
|
52
|
+
# SDL_ttf
|
53
|
+
require_relative 'sdl2_ttf.rb'
|
50
54
|
|
51
|
-
module
|
55
|
+
module SDL
|
52
56
|
extend FFI::Library
|
53
57
|
|
54
58
|
@@sdl2_import_done = false
|
55
|
-
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)
|
56
60
|
|
57
61
|
unless @@sdl2_import_done
|
58
62
|
# Ref.: Using Multiple and Alternate Libraries
|
@@ -62,111 +66,62 @@ module SDL2
|
|
62
66
|
|
63
67
|
ffi_lib_flags :now, :global
|
64
68
|
ffi_lib *lib_paths
|
65
|
-
setup_symbols()
|
66
|
-
|
67
|
-
if image_libpath != nil
|
68
|
-
setup_image_symbols()
|
69
|
-
end
|
69
|
+
setup_symbols(output_error)
|
70
70
|
|
71
|
-
if
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
if mixer_libpath != nil
|
76
|
-
setup_mixer_symbols()
|
77
|
-
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
|
78
74
|
|
79
75
|
if gfx_libpath != nil
|
80
|
-
setup_gfx_framerate_symbols()
|
81
|
-
setup_gfx_primitives_symbols()
|
82
|
-
setup_gfx_imagefilter_symbols()
|
83
|
-
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)
|
84
80
|
end
|
85
81
|
rescue => error
|
86
|
-
puts error
|
82
|
+
$stderr.puts("[Warning] Failed to load libraries (#{error}).") if output_error
|
87
83
|
end
|
88
84
|
end
|
89
85
|
|
90
86
|
end
|
91
87
|
|
92
|
-
def self.setup_symbols()
|
93
|
-
setup_main_symbols()
|
94
|
-
setup_audio_symbols()
|
95
|
-
setup_blendmode_symbols()
|
96
|
-
setup_clipboard_symbols()
|
97
|
-
setup_cpuinfo_symbols()
|
98
|
-
setup_error_symbols()
|
99
|
-
setup_events_symbols()
|
100
|
-
setup_filesystem_symbols()
|
101
|
-
setup_gamecontroller_symbols()
|
102
|
-
setup_gesture_symbols()
|
103
|
-
setup_haptic_symbols()
|
104
|
-
setup_hints_symbols()
|
105
|
-
setup_joystick_symbols()
|
106
|
-
setup_keyboard_symbols()
|
107
|
-
setup_keycode_symbols()
|
108
|
-
setup_log_symbols()
|
109
|
-
setup_messagebox_symbols()
|
110
|
-
setup_misc_symbols()
|
111
|
-
setup_mouse_symbols()
|
112
|
-
setup_pixels_symbols()
|
113
|
-
setup_platform_symbols()
|
114
|
-
setup_power_symbols()
|
115
|
-
setup_rect_symbols()
|
116
|
-
setup_render_symbols()
|
117
|
-
setup_rwops_symbols()
|
118
|
-
setup_scancode_symbols()
|
119
|
-
setup_sensor_symbols()
|
120
|
-
setup_shape_symbols()
|
121
|
-
setup_surface_symbols()
|
122
|
-
setup_syswm_symbols()
|
123
|
-
setup_stdinc_symbols()
|
124
|
-
setup_timer_symbols()
|
125
|
-
setup_touch_symbols()
|
126
|
-
setup_version_symbols()
|
127
|
-
setup_video_symbols()
|
128
|
-
setup_vulkan_symbols()
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
if __FILE__ == $0
|
135
|
-
SDL2.load_lib('libSDL2.dylib',
|
136
|
-
gfx_libpath: '/usr/local/lib/libSDL2_gfx.dylib'
|
137
|
-
)
|
138
|
-
|
139
|
-
success = SDL2.SDL_Init(SDL2::SDL_INIT_EVERYTHING)
|
140
|
-
exit if success < 0
|
141
|
-
|
142
|
-
WINDOW_W = 320
|
143
|
-
WINDOW_H = 240
|
144
|
-
window = SDL2.SDL_CreateWindow("1st SDL Window via sdl2-bindings", 0, 0, WINDOW_W, WINDOW_H, 0)
|
145
|
-
|
146
|
-
fpsdelay = 100;
|
147
|
-
|
148
|
-
count = 0
|
149
|
-
event = SDL2::SDL_Event.new
|
150
|
-
done = false
|
151
|
-
while not done
|
152
|
-
while SDL2.SDL_PollEvent(event) != 0
|
153
|
-
# 'type' and 'timestamp' are common members for all SDL Event structs.
|
154
|
-
event_type = event[:common][:type]
|
155
|
-
event_timestamp = event[:common][:timestamp]
|
156
|
-
puts "Event : type=0x#{event_type.to_s(16)}, timestamp=#{event_timestamp}"
|
157
|
-
|
158
|
-
case event_type
|
159
|
-
when SDL2::SDL_KEYDOWN
|
160
|
-
if event[:key][:keysym][:sym] == SDL2::SDLK_SPACE
|
161
|
-
puts "\tSPACE key pressed."
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
count += 1
|
167
|
-
done = true if count >= 100
|
168
|
-
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)
|
169
125
|
end
|
170
126
|
|
171
|
-
SDL2.SDL_Quit()
|
172
127
|
end
|
data/lib/sdl2_audio.rb
CHANGED
@@ -6,14 +6,14 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
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
|
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,
|
@@ -129,6 +129,45 @@ module SDL2
|
|
129
129
|
:SDL_CloseAudio,
|
130
130
|
:SDL_CloseAudioDevice,
|
131
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
|
+
}
|
132
171
|
args = {
|
133
172
|
:SDL_GetNumAudioDrivers => [],
|
134
173
|
:SDL_GetAudioDriver => [:int],
|
@@ -209,9 +248,9 @@ module SDL2
|
|
209
248
|
}
|
210
249
|
symbols.each do |sym|
|
211
250
|
begin
|
212
|
-
attach_function sym, args[sym], retvals[sym]
|
251
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
213
252
|
rescue FFI::NotFoundError => error
|
214
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
253
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
215
254
|
end
|
216
255
|
end
|
217
256
|
end
|
data/lib/sdl2_blendmode.rb
CHANGED
@@ -6,34 +6,34 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
13
13
|
|
14
14
|
# Enum
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
data/lib/sdl2_clipboard.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
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
|
data/lib/sdl2_cpuinfo.rb
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
13
|
-
|
13
|
+
CACHELINE_SIZE = 128
|
14
14
|
|
15
15
|
# Enum
|
16
16
|
|
@@ -23,7 +23,7 @@ module SDL2
|
|
23
23
|
|
24
24
|
# Function
|
25
25
|
|
26
|
-
def self.setup_cpuinfo_symbols()
|
26
|
+
def self.setup_cpuinfo_symbols(output_error = false)
|
27
27
|
symbols = [
|
28
28
|
:SDL_GetCPUCount,
|
29
29
|
:SDL_GetCPUCacheLineSize,
|
@@ -47,6 +47,29 @@ module SDL2
|
|
47
47
|
:SDL_SIMDRealloc,
|
48
48
|
:SDL_SIMDFree,
|
49
49
|
]
|
50
|
+
apis = {
|
51
|
+
:SDL_GetCPUCount => :GetCPUCount,
|
52
|
+
:SDL_GetCPUCacheLineSize => :GetCPUCacheLineSize,
|
53
|
+
:SDL_HasRDTSC => :HasRDTSC,
|
54
|
+
:SDL_HasAltiVec => :HasAltiVec,
|
55
|
+
:SDL_HasMMX => :HasMMX,
|
56
|
+
:SDL_Has3DNow => :Has3DNow,
|
57
|
+
:SDL_HasSSE => :HasSSE,
|
58
|
+
:SDL_HasSSE2 => :HasSSE2,
|
59
|
+
:SDL_HasSSE3 => :HasSSE3,
|
60
|
+
:SDL_HasSSE41 => :HasSSE41,
|
61
|
+
:SDL_HasSSE42 => :HasSSE42,
|
62
|
+
:SDL_HasAVX => :HasAVX,
|
63
|
+
:SDL_HasAVX2 => :HasAVX2,
|
64
|
+
:SDL_HasAVX512F => :HasAVX512F,
|
65
|
+
:SDL_HasARMSIMD => :HasARMSIMD,
|
66
|
+
:SDL_HasNEON => :HasNEON,
|
67
|
+
:SDL_GetSystemRAM => :GetSystemRAM,
|
68
|
+
:SDL_SIMDGetAlignment => :SIMDGetAlignment,
|
69
|
+
:SDL_SIMDAlloc => :SIMDAlloc,
|
70
|
+
:SDL_SIMDRealloc => :SIMDRealloc,
|
71
|
+
:SDL_SIMDFree => :SIMDFree,
|
72
|
+
}
|
50
73
|
args = {
|
51
74
|
:SDL_GetCPUCount => [],
|
52
75
|
:SDL_GetCPUCacheLineSize => [],
|
@@ -95,9 +118,9 @@ module SDL2
|
|
95
118
|
}
|
96
119
|
symbols.each do |sym|
|
97
120
|
begin
|
98
|
-
attach_function sym, args[sym], retvals[sym]
|
121
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
99
122
|
rescue FFI::NotFoundError => error
|
100
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
123
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
101
124
|
end
|
102
125
|
end
|
103
126
|
end
|
data/lib/sdl2_error.rb
CHANGED
@@ -6,19 +6,19 @@
|
|
6
6
|
|
7
7
|
require 'ffi'
|
8
8
|
|
9
|
-
module
|
9
|
+
module SDL
|
10
10
|
extend FFI::Library
|
11
11
|
# Define/Macro
|
12
12
|
|
13
13
|
|
14
14
|
# Enum
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
ENOMEM = 0
|
17
|
+
EFREAD = 1
|
18
|
+
EFWRITE = 2
|
19
|
+
EFSEEK = 3
|
20
|
+
UNSUPPORTED = 4
|
21
|
+
LASTERROR = 5
|
22
22
|
|
23
23
|
# Typedef
|
24
24
|
|
@@ -29,7 +29,7 @@ module SDL2
|
|
29
29
|
|
30
30
|
# Function
|
31
31
|
|
32
|
-
def self.setup_error_symbols()
|
32
|
+
def self.setup_error_symbols(output_error = false)
|
33
33
|
symbols = [
|
34
34
|
:SDL_SetError,
|
35
35
|
:SDL_GetError,
|
@@ -37,6 +37,13 @@ module SDL2
|
|
37
37
|
:SDL_ClearError,
|
38
38
|
:SDL_Error,
|
39
39
|
]
|
40
|
+
apis = {
|
41
|
+
:SDL_SetError => :SetError,
|
42
|
+
:SDL_GetError => :GetError,
|
43
|
+
:SDL_GetErrorMsg => :GetErrorMsg,
|
44
|
+
:SDL_ClearError => :ClearError,
|
45
|
+
:SDL_Error => :Error,
|
46
|
+
}
|
40
47
|
args = {
|
41
48
|
:SDL_SetError => [:pointer],
|
42
49
|
:SDL_GetError => [],
|
@@ -53,9 +60,9 @@ module SDL2
|
|
53
60
|
}
|
54
61
|
symbols.each do |sym|
|
55
62
|
begin
|
56
|
-
attach_function sym, args[sym], retvals[sym]
|
63
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
57
64
|
rescue FFI::NotFoundError => error
|
58
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
|
65
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
59
66
|
end
|
60
67
|
end
|
61
68
|
end
|