sdl2-bindings 0.0.8 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +124 -92
  3. data/LICENSE.txt +1 -1
  4. data/README.md +77 -53
  5. data/lib/sdl2.rb +131 -172
  6. data/lib/sdl2_audio.rb +261 -222
  7. data/lib/sdl2_blendmode.rb +72 -69
  8. data/lib/sdl2_clipboard.rb +56 -51
  9. data/lib/sdl2_cpuinfo.rb +129 -106
  10. data/lib/sdl2_error.rb +71 -64
  11. data/lib/sdl2_events.rb +564 -533
  12. data/lib/sdl2_filesystem.rb +52 -48
  13. data/lib/sdl2_framerate.rb +74 -67
  14. data/lib/sdl2_gamecontroller.rb +329 -274
  15. data/lib/sdl2_gesture.rb +61 -55
  16. data/lib/sdl2_gfxPrimitives.rb +283 -222
  17. data/lib/sdl2_haptic.rb +301 -269
  18. data/lib/sdl2_hidapi.rb +139 -118
  19. data/lib/sdl2_hints.rb +221 -197
  20. data/lib/sdl2_image.rb +232 -185
  21. data/lib/sdl2_imageFilter.rb +164 -132
  22. data/lib/sdl2_joystick.rb +294 -239
  23. data/lib/sdl2_keyboard.rb +125 -99
  24. data/lib/sdl2_keycode.rb +307 -305
  25. data/lib/sdl2_log.rb +131 -115
  26. data/lib/sdl2_main.rb +74 -67
  27. data/lib/sdl2_messagebox.rb +102 -98
  28. data/lib/sdl2_misc.rb +48 -45
  29. data/lib/sdl2_mixer.rb +392 -317
  30. data/lib/sdl2_mouse.rb +136 -117
  31. data/lib/sdl2_pixels.rb +240 -224
  32. data/lib/sdl2_platform.rb +48 -45
  33. data/lib/sdl2_power.rb +54 -51
  34. data/lib/sdl2_rect.rb +145 -102
  35. data/lib/sdl2_render.rb +408 -322
  36. data/lib/sdl2_rotozoom.rb +76 -66
  37. data/lib/sdl2_rwops.rb +238 -208
  38. data/lib/sdl2_scancode.rb +289 -287
  39. data/lib/sdl2_sensor.rb +115 -97
  40. data/lib/sdl2_shape.rb +83 -77
  41. data/lib/sdl2_sound.rb +154 -0
  42. data/lib/sdl2_stdinc.rb +556 -439
  43. data/lib/sdl2_surface.rb +229 -188
  44. data/lib/sdl2_syswm.rb +160 -156
  45. data/lib/sdl2_timer.rb +74 -65
  46. data/lib/sdl2_touch.rb +86 -75
  47. data/lib/sdl2_ttf.rb +358 -202
  48. data/lib/sdl2_version.rb +67 -62
  49. data/lib/sdl2_video.rb +540 -446
  50. data/lib/sdl2_vulkan.rb +72 -64
  51. metadata +19 -4
data/lib/sdl2_sensor.rb CHANGED
@@ -1,97 +1,115 @@
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_STANDARD_GRAVITY = 9.80665
14
-
15
- # Enum
16
-
17
- SDL_SENSOR_INVALID = -1
18
- SDL_SENSOR_UNKNOWN = 0
19
- SDL_SENSOR_ACCEL = 1
20
- SDL_SENSOR_GYRO = 2
21
-
22
- # Typedef
23
-
24
- typedef :int, :SDL_SensorID
25
- typedef :int, :SDL_SensorType
26
-
27
- # Struct
28
-
29
-
30
- # Function
31
-
32
- def self.setup_sensor_symbols()
33
- symbols = [
34
- :SDL_LockSensors,
35
- :SDL_UnlockSensors,
36
- :SDL_NumSensors,
37
- :SDL_SensorGetDeviceName,
38
- :SDL_SensorGetDeviceType,
39
- :SDL_SensorGetDeviceNonPortableType,
40
- :SDL_SensorGetDeviceInstanceID,
41
- :SDL_SensorOpen,
42
- :SDL_SensorFromInstanceID,
43
- :SDL_SensorGetName,
44
- :SDL_SensorGetType,
45
- :SDL_SensorGetNonPortableType,
46
- :SDL_SensorGetInstanceID,
47
- :SDL_SensorGetData,
48
- :SDL_SensorClose,
49
- :SDL_SensorUpdate,
50
- ]
51
- args = {
52
- :SDL_LockSensors => [],
53
- :SDL_UnlockSensors => [],
54
- :SDL_NumSensors => [],
55
- :SDL_SensorGetDeviceName => [:int],
56
- :SDL_SensorGetDeviceType => [:int],
57
- :SDL_SensorGetDeviceNonPortableType => [:int],
58
- :SDL_SensorGetDeviceInstanceID => [:int],
59
- :SDL_SensorOpen => [:int],
60
- :SDL_SensorFromInstanceID => [:int],
61
- :SDL_SensorGetName => [:pointer],
62
- :SDL_SensorGetType => [:pointer],
63
- :SDL_SensorGetNonPortableType => [:pointer],
64
- :SDL_SensorGetInstanceID => [:pointer],
65
- :SDL_SensorGetData => [:pointer, :pointer, :int],
66
- :SDL_SensorClose => [:pointer],
67
- :SDL_SensorUpdate => [],
68
- }
69
- retvals = {
70
- :SDL_LockSensors => :void,
71
- :SDL_UnlockSensors => :void,
72
- :SDL_NumSensors => :int,
73
- :SDL_SensorGetDeviceName => :pointer,
74
- :SDL_SensorGetDeviceType => :int,
75
- :SDL_SensorGetDeviceNonPortableType => :int,
76
- :SDL_SensorGetDeviceInstanceID => :int,
77
- :SDL_SensorOpen => :pointer,
78
- :SDL_SensorFromInstanceID => :pointer,
79
- :SDL_SensorGetName => :pointer,
80
- :SDL_SensorGetType => :int,
81
- :SDL_SensorGetNonPortableType => :int,
82
- :SDL_SensorGetInstanceID => :int,
83
- :SDL_SensorGetData => :int,
84
- :SDL_SensorClose => :void,
85
- :SDL_SensorUpdate => :void,
86
- }
87
- symbols.each do |sym|
88
- begin
89
- attach_function sym, args[sym], retvals[sym]
90
- rescue FFI::NotFoundError => error
91
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
92
- end
93
- end
94
- end
95
-
96
- end
97
-
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 SDL
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ STANDARD_GRAVITY = 9.80665
14
+
15
+ # Enum
16
+
17
+ SENSOR_INVALID = -1
18
+ SENSOR_UNKNOWN = 0
19
+ SENSOR_ACCEL = 1
20
+ SENSOR_GYRO = 2
21
+
22
+ # Typedef
23
+
24
+ typedef :int, :SDL_SensorID
25
+ typedef :int, :SDL_SensorType
26
+
27
+ # Struct
28
+
29
+
30
+ # Function
31
+
32
+ def self.setup_sensor_symbols(output_error = false)
33
+ symbols = [
34
+ :SDL_LockSensors,
35
+ :SDL_UnlockSensors,
36
+ :SDL_NumSensors,
37
+ :SDL_SensorGetDeviceName,
38
+ :SDL_SensorGetDeviceType,
39
+ :SDL_SensorGetDeviceNonPortableType,
40
+ :SDL_SensorGetDeviceInstanceID,
41
+ :SDL_SensorOpen,
42
+ :SDL_SensorFromInstanceID,
43
+ :SDL_SensorGetName,
44
+ :SDL_SensorGetType,
45
+ :SDL_SensorGetNonPortableType,
46
+ :SDL_SensorGetInstanceID,
47
+ :SDL_SensorGetData,
48
+ :SDL_SensorClose,
49
+ :SDL_SensorUpdate,
50
+ ]
51
+ apis = {
52
+ :SDL_LockSensors => :LockSensors,
53
+ :SDL_UnlockSensors => :UnlockSensors,
54
+ :SDL_NumSensors => :NumSensors,
55
+ :SDL_SensorGetDeviceName => :SensorGetDeviceName,
56
+ :SDL_SensorGetDeviceType => :SensorGetDeviceType,
57
+ :SDL_SensorGetDeviceNonPortableType => :SensorGetDeviceNonPortableType,
58
+ :SDL_SensorGetDeviceInstanceID => :SensorGetDeviceInstanceID,
59
+ :SDL_SensorOpen => :SensorOpen,
60
+ :SDL_SensorFromInstanceID => :SensorFromInstanceID,
61
+ :SDL_SensorGetName => :SensorGetName,
62
+ :SDL_SensorGetType => :SensorGetType,
63
+ :SDL_SensorGetNonPortableType => :SensorGetNonPortableType,
64
+ :SDL_SensorGetInstanceID => :SensorGetInstanceID,
65
+ :SDL_SensorGetData => :SensorGetData,
66
+ :SDL_SensorClose => :SensorClose,
67
+ :SDL_SensorUpdate => :SensorUpdate,
68
+ }
69
+ args = {
70
+ :SDL_LockSensors => [],
71
+ :SDL_UnlockSensors => [],
72
+ :SDL_NumSensors => [],
73
+ :SDL_SensorGetDeviceName => [:int],
74
+ :SDL_SensorGetDeviceType => [:int],
75
+ :SDL_SensorGetDeviceNonPortableType => [:int],
76
+ :SDL_SensorGetDeviceInstanceID => [:int],
77
+ :SDL_SensorOpen => [:int],
78
+ :SDL_SensorFromInstanceID => [:int],
79
+ :SDL_SensorGetName => [:pointer],
80
+ :SDL_SensorGetType => [:pointer],
81
+ :SDL_SensorGetNonPortableType => [:pointer],
82
+ :SDL_SensorGetInstanceID => [:pointer],
83
+ :SDL_SensorGetData => [:pointer, :pointer, :int],
84
+ :SDL_SensorClose => [:pointer],
85
+ :SDL_SensorUpdate => [],
86
+ }
87
+ retvals = {
88
+ :SDL_LockSensors => :void,
89
+ :SDL_UnlockSensors => :void,
90
+ :SDL_NumSensors => :int,
91
+ :SDL_SensorGetDeviceName => :pointer,
92
+ :SDL_SensorGetDeviceType => :int,
93
+ :SDL_SensorGetDeviceNonPortableType => :int,
94
+ :SDL_SensorGetDeviceInstanceID => :int,
95
+ :SDL_SensorOpen => :pointer,
96
+ :SDL_SensorFromInstanceID => :pointer,
97
+ :SDL_SensorGetName => :pointer,
98
+ :SDL_SensorGetType => :int,
99
+ :SDL_SensorGetNonPortableType => :int,
100
+ :SDL_SensorGetInstanceID => :int,
101
+ :SDL_SensorGetData => :int,
102
+ :SDL_SensorClose => :void,
103
+ :SDL_SensorUpdate => :void,
104
+ }
105
+ symbols.each do |sym|
106
+ begin
107
+ attach_function apis[sym], sym, args[sym], retvals[sym]
108
+ rescue FFI::NotFoundError => error
109
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
110
+ end
111
+ end
112
+ end
113
+
114
+ end
115
+
data/lib/sdl2_shape.rb CHANGED
@@ -1,77 +1,83 @@
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
- require_relative 'sdl2_pixels'
9
-
10
- module SDL2
11
- extend FFI::Library
12
- # Define/Macro
13
-
14
- SDL_NONSHAPEABLE_WINDOW = -1
15
- SDL_INVALID_SHAPE_ARGUMENT = -2
16
- SDL_WINDOW_LACKS_SHAPE = -3
17
-
18
- # Enum
19
-
20
- ShapeModeDefault = 0
21
- ShapeModeBinarizeAlpha = 1
22
- ShapeModeReverseBinarizeAlpha = 2
23
- ShapeModeColorKey = 3
24
-
25
- # Typedef
26
-
27
- typedef :int, :WindowShapeMode
28
-
29
- # Struct
30
-
31
- class SDL_WindowShapeParams < FFI::Union
32
- layout(
33
- :binarizationCutoff, :uchar,
34
- :colorKey, SDL_Color,
35
- )
36
- end
37
-
38
- class SDL_WindowShapeMode < FFI::Struct
39
- layout(
40
- :mode, :int,
41
- :parameters, SDL_WindowShapeParams,
42
- )
43
- end
44
-
45
-
46
- # Function
47
-
48
- def self.setup_shape_symbols()
49
- symbols = [
50
- :SDL_CreateShapedWindow,
51
- :SDL_IsShapedWindow,
52
- :SDL_SetWindowShape,
53
- :SDL_GetShapedWindowMode,
54
- ]
55
- args = {
56
- :SDL_CreateShapedWindow => [:pointer, :uint, :uint, :uint, :uint, :uint],
57
- :SDL_IsShapedWindow => [:pointer],
58
- :SDL_SetWindowShape => [:pointer, :pointer, :pointer],
59
- :SDL_GetShapedWindowMode => [:pointer, :pointer],
60
- }
61
- retvals = {
62
- :SDL_CreateShapedWindow => :pointer,
63
- :SDL_IsShapedWindow => :int,
64
- :SDL_SetWindowShape => :int,
65
- :SDL_GetShapedWindowMode => :int,
66
- }
67
- symbols.each do |sym|
68
- begin
69
- attach_function sym, args[sym], retvals[sym]
70
- rescue FFI::NotFoundError => error
71
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
72
- end
73
- end
74
- end
75
-
76
- end
77
-
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
+ require_relative 'sdl2_pixels'
9
+
10
+ module SDL
11
+ extend FFI::Library
12
+ # Define/Macro
13
+
14
+ NONSHAPEABLE_WINDOW = -1
15
+ INVALID_SHAPE_ARGUMENT = -2
16
+ WINDOW_LACKS_SHAPE = -3
17
+
18
+ # Enum
19
+
20
+ ShapeModeDefault = 0
21
+ ShapeModeBinarizeAlpha = 1
22
+ ShapeModeReverseBinarizeAlpha = 2
23
+ ShapeModeColorKey = 3
24
+
25
+ # Typedef
26
+
27
+ typedef :int, :WindowShapeMode
28
+
29
+ # Struct
30
+
31
+ class WindowShapeParams < FFI::Union
32
+ layout(
33
+ :binarizationCutoff, :uchar,
34
+ :colorKey, Color,
35
+ )
36
+ end
37
+
38
+ class WindowShapeMode < FFI::Struct
39
+ layout(
40
+ :mode, :int,
41
+ :parameters, WindowShapeParams,
42
+ )
43
+ end
44
+
45
+
46
+ # Function
47
+
48
+ def self.setup_shape_symbols(output_error = false)
49
+ symbols = [
50
+ :SDL_CreateShapedWindow,
51
+ :SDL_IsShapedWindow,
52
+ :SDL_SetWindowShape,
53
+ :SDL_GetShapedWindowMode,
54
+ ]
55
+ apis = {
56
+ :SDL_CreateShapedWindow => :CreateShapedWindow,
57
+ :SDL_IsShapedWindow => :IsShapedWindow,
58
+ :SDL_SetWindowShape => :SetWindowShape,
59
+ :SDL_GetShapedWindowMode => :GetShapedWindowMode,
60
+ }
61
+ args = {
62
+ :SDL_CreateShapedWindow => [:pointer, :uint, :uint, :uint, :uint, :uint],
63
+ :SDL_IsShapedWindow => [:pointer],
64
+ :SDL_SetWindowShape => [:pointer, :pointer, :pointer],
65
+ :SDL_GetShapedWindowMode => [:pointer, :pointer],
66
+ }
67
+ retvals = {
68
+ :SDL_CreateShapedWindow => :pointer,
69
+ :SDL_IsShapedWindow => :int,
70
+ :SDL_SetWindowShape => :int,
71
+ :SDL_GetShapedWindowMode => :int,
72
+ }
73
+ symbols.each do |sym|
74
+ begin
75
+ attach_function apis[sym], sym, args[sym], retvals[sym]
76
+ rescue FFI::NotFoundError => error
77
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
78
+ end
79
+ end
80
+ end
81
+
82
+ end
83
+
data/lib/sdl2_sound.rb ADDED
@@ -0,0 +1,154 @@
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 SDL
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ SOUND_VER_MAJOR = 2
14
+ SOUND_VER_MINOR = 0
15
+ SOUND_VER_PATCH = 1
16
+
17
+ # Enum
18
+
19
+ SOUND_SAMPLEFLAG_NONE = 0
20
+ SOUND_SAMPLEFLAG_CANSEEK = 1
21
+ SOUND_SAMPLEFLAG_EOF = 536870912
22
+ SOUND_SAMPLEFLAG_ERROR = 1073741824
23
+ SOUND_SAMPLEFLAG_EAGAIN = -2147483648
24
+
25
+ # Typedef
26
+
27
+ typedef :int, :Sound_SampleFlags
28
+
29
+ # Struct
30
+
31
+ class Sound_AudioInfo < FFI::Struct
32
+ layout(
33
+ :format, :ushort,
34
+ :channels, :uchar,
35
+ :rate, :uint,
36
+ )
37
+ end
38
+
39
+ class Sound_DecoderInfo < FFI::Struct
40
+ layout(
41
+ :extensions, :pointer,
42
+ :description, :pointer,
43
+ :author, :pointer,
44
+ :url, :pointer,
45
+ )
46
+ end
47
+
48
+ class Sound_Sample < FFI::Struct
49
+ layout(
50
+ :opaque, :pointer,
51
+ :decoder, :pointer,
52
+ :desired, Sound_AudioInfo,
53
+ :actual, Sound_AudioInfo,
54
+ :buffer, :pointer,
55
+ :buffer_size, :uint,
56
+ :flags, :int,
57
+ )
58
+ end
59
+
60
+ class Sound_Version < FFI::Struct
61
+ layout(
62
+ :major, :int,
63
+ :minor, :int,
64
+ :patch, :int,
65
+ )
66
+ end
67
+
68
+
69
+ # Function
70
+
71
+ def self.setup_sound_symbols(output_error = false)
72
+ symbols = [
73
+ :Sound_GetLinkedVersion,
74
+ :Sound_Init,
75
+ :Sound_Quit,
76
+ :Sound_AvailableDecoders,
77
+ :Sound_GetError,
78
+ :Sound_ClearError,
79
+ :Sound_NewSample,
80
+ :Sound_NewSampleFromMem,
81
+ :Sound_NewSampleFromFile,
82
+ :Sound_FreeSample,
83
+ :Sound_GetDuration,
84
+ :Sound_SetBufferSize,
85
+ :Sound_Decode,
86
+ :Sound_DecodeAll,
87
+ :Sound_Rewind,
88
+ :Sound_Seek,
89
+ ]
90
+ apis = {
91
+ :Sound_GetLinkedVersion => :Sound_GetLinkedVersion,
92
+ :Sound_Init => :Sound_Init,
93
+ :Sound_Quit => :Sound_Quit,
94
+ :Sound_AvailableDecoders => :Sound_AvailableDecoders,
95
+ :Sound_GetError => :Sound_GetError,
96
+ :Sound_ClearError => :Sound_ClearError,
97
+ :Sound_NewSample => :Sound_NewSample,
98
+ :Sound_NewSampleFromMem => :Sound_NewSampleFromMem,
99
+ :Sound_NewSampleFromFile => :Sound_NewSampleFromFile,
100
+ :Sound_FreeSample => :Sound_FreeSample,
101
+ :Sound_GetDuration => :Sound_GetDuration,
102
+ :Sound_SetBufferSize => :Sound_SetBufferSize,
103
+ :Sound_Decode => :Sound_Decode,
104
+ :Sound_DecodeAll => :Sound_DecodeAll,
105
+ :Sound_Rewind => :Sound_Rewind,
106
+ :Sound_Seek => :Sound_Seek,
107
+ }
108
+ args = {
109
+ :Sound_GetLinkedVersion => [:pointer],
110
+ :Sound_Init => [],
111
+ :Sound_Quit => [],
112
+ :Sound_AvailableDecoders => [],
113
+ :Sound_GetError => [],
114
+ :Sound_ClearError => [],
115
+ :Sound_NewSample => [:pointer, :pointer, :pointer, :uint],
116
+ :Sound_NewSampleFromMem => [:pointer, :uint, :pointer, :pointer, :uint],
117
+ :Sound_NewSampleFromFile => [:pointer, :pointer, :uint],
118
+ :Sound_FreeSample => [:pointer],
119
+ :Sound_GetDuration => [:pointer],
120
+ :Sound_SetBufferSize => [:pointer, :uint],
121
+ :Sound_Decode => [:pointer],
122
+ :Sound_DecodeAll => [:pointer],
123
+ :Sound_Rewind => [:pointer],
124
+ :Sound_Seek => [:pointer, :uint],
125
+ }
126
+ retvals = {
127
+ :Sound_GetLinkedVersion => :void,
128
+ :Sound_Init => :int,
129
+ :Sound_Quit => :int,
130
+ :Sound_AvailableDecoders => :pointer,
131
+ :Sound_GetError => :pointer,
132
+ :Sound_ClearError => :void,
133
+ :Sound_NewSample => :pointer,
134
+ :Sound_NewSampleFromMem => :pointer,
135
+ :Sound_NewSampleFromFile => :pointer,
136
+ :Sound_FreeSample => :void,
137
+ :Sound_GetDuration => :int,
138
+ :Sound_SetBufferSize => :int,
139
+ :Sound_Decode => :uint,
140
+ :Sound_DecodeAll => :uint,
141
+ :Sound_Rewind => :int,
142
+ :Sound_Seek => :int,
143
+ }
144
+ symbols.each do |sym|
145
+ begin
146
+ attach_function apis[sym], sym, args[sym], retvals[sym]
147
+ rescue FFI::NotFoundError => error
148
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
149
+ end
150
+ end
151
+ end
152
+
153
+ end
154
+