sdl2-bindings 0.1.1 → 0.1.4

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +140 -124
  3. data/LICENSE.txt +0 -0
  4. data/README.md +93 -77
  5. data/lib/sdl2.rb +131 -131
  6. data/lib/sdl2_audio.rb +265 -261
  7. data/lib/sdl2_blendmode.rb +72 -72
  8. data/lib/sdl2_clipboard.rb +56 -56
  9. data/lib/sdl2_cpuinfo.rb +137 -129
  10. data/lib/sdl2_error.rb +71 -71
  11. data/lib/sdl2_events.rb +575 -564
  12. data/lib/sdl2_filesystem.rb +52 -52
  13. data/lib/sdl2_framerate.rb +74 -74
  14. data/lib/sdl2_gamecontroller.rb +345 -329
  15. data/lib/sdl2_gesture.rb +61 -61
  16. data/lib/sdl2_gfxPrimitives.rb +283 -283
  17. data/lib/sdl2_guid.rb +58 -0
  18. data/lib/sdl2_haptic.rb +301 -301
  19. data/lib/sdl2_hidapi.rb +139 -139
  20. data/lib/sdl2_hints.rb +240 -221
  21. data/lib/sdl2_image.rb +296 -232
  22. data/lib/sdl2_imageFilter.rb +164 -164
  23. data/lib/sdl2_joystick.rb +332 -294
  24. data/lib/sdl2_keyboard.rb +129 -125
  25. data/lib/sdl2_keycode.rb +311 -307
  26. data/lib/sdl2_log.rb +131 -131
  27. data/lib/sdl2_main.rb +74 -74
  28. data/lib/sdl2_messagebox.rb +102 -102
  29. data/lib/sdl2_misc.rb +48 -48
  30. data/lib/sdl2_mixer.rb +464 -392
  31. data/lib/sdl2_mouse.rb +136 -136
  32. data/lib/sdl2_pixels.rb +240 -240
  33. data/lib/sdl2_platform.rb +48 -48
  34. data/lib/sdl2_power.rb +54 -54
  35. data/lib/sdl2_rect.rb +145 -145
  36. data/lib/sdl2_render.rb +408 -408
  37. data/lib/sdl2_rotozoom.rb +76 -76
  38. data/lib/sdl2_rwops.rb +242 -238
  39. data/lib/sdl2_scancode.rb +293 -289
  40. data/lib/sdl2_sensor.rb +115 -115
  41. data/lib/sdl2_shape.rb +83 -83
  42. data/lib/sdl2_sound.rb +154 -154
  43. data/lib/sdl2_stdinc.rb +564 -556
  44. data/lib/sdl2_surface.rb +229 -229
  45. data/lib/sdl2_syswm.rb +160 -160
  46. data/lib/sdl2_timer.rb +74 -74
  47. data/lib/sdl2_touch.rb +86 -86
  48. data/lib/sdl2_ttf.rb +414 -358
  49. data/lib/sdl2_version.rb +67 -67
  50. data/lib/sdl2_video.rb +549 -540
  51. data/lib/sdl2_vulkan.rb +72 -72
  52. metadata +4 -3
data/lib/sdl2_log.rb CHANGED
@@ -1,131 +1,131 @@
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
- MAX_LOG_MESSAGE = 4096
14
-
15
- # Enum
16
-
17
- LOG_CATEGORY_APPLICATION = 0
18
- LOG_CATEGORY_ERROR = 1
19
- LOG_CATEGORY_ASSERT = 2
20
- LOG_CATEGORY_SYSTEM = 3
21
- LOG_CATEGORY_AUDIO = 4
22
- LOG_CATEGORY_VIDEO = 5
23
- LOG_CATEGORY_RENDER = 6
24
- LOG_CATEGORY_INPUT = 7
25
- LOG_CATEGORY_TEST = 8
26
- LOG_CATEGORY_RESERVED1 = 9
27
- LOG_CATEGORY_RESERVED2 = 10
28
- LOG_CATEGORY_RESERVED3 = 11
29
- LOG_CATEGORY_RESERVED4 = 12
30
- LOG_CATEGORY_RESERVED5 = 13
31
- LOG_CATEGORY_RESERVED6 = 14
32
- LOG_CATEGORY_RESERVED7 = 15
33
- LOG_CATEGORY_RESERVED8 = 16
34
- LOG_CATEGORY_RESERVED9 = 17
35
- LOG_CATEGORY_RESERVED10 = 18
36
- LOG_CATEGORY_CUSTOM = 19
37
- LOG_PRIORITY_VERBOSE = 1
38
- LOG_PRIORITY_DEBUG = 2
39
- LOG_PRIORITY_INFO = 3
40
- LOG_PRIORITY_WARN = 4
41
- LOG_PRIORITY_ERROR = 5
42
- LOG_PRIORITY_CRITICAL = 6
43
- NUM_LOG_PRIORITIES = 7
44
-
45
- # Typedef
46
-
47
- typedef :int, :SDL_LogCategory
48
- typedef :int, :SDL_LogPriority
49
- callback :SDL_LogOutputFunction, [:pointer, :int, :int, :pointer], :void
50
-
51
- # Struct
52
-
53
-
54
- # Function
55
-
56
- def self.setup_log_symbols(output_error = false)
57
- symbols = [
58
- :SDL_LogSetAllPriority,
59
- :SDL_LogSetPriority,
60
- :SDL_LogGetPriority,
61
- :SDL_LogResetPriorities,
62
- :SDL_Log,
63
- :SDL_LogVerbose,
64
- :SDL_LogDebug,
65
- :SDL_LogInfo,
66
- :SDL_LogWarn,
67
- :SDL_LogError,
68
- :SDL_LogCritical,
69
- :SDL_LogMessage,
70
- :SDL_LogGetOutputFunction,
71
- :SDL_LogSetOutputFunction,
72
- ]
73
- apis = {
74
- :SDL_LogSetAllPriority => :LogSetAllPriority,
75
- :SDL_LogSetPriority => :LogSetPriority,
76
- :SDL_LogGetPriority => :LogGetPriority,
77
- :SDL_LogResetPriorities => :LogResetPriorities,
78
- :SDL_Log => :Log,
79
- :SDL_LogVerbose => :LogVerbose,
80
- :SDL_LogDebug => :LogDebug,
81
- :SDL_LogInfo => :LogInfo,
82
- :SDL_LogWarn => :LogWarn,
83
- :SDL_LogError => :LogError,
84
- :SDL_LogCritical => :LogCritical,
85
- :SDL_LogMessage => :LogMessage,
86
- :SDL_LogGetOutputFunction => :LogGetOutputFunction,
87
- :SDL_LogSetOutputFunction => :LogSetOutputFunction,
88
- }
89
- args = {
90
- :SDL_LogSetAllPriority => [:int],
91
- :SDL_LogSetPriority => [:int, :int],
92
- :SDL_LogGetPriority => [:int],
93
- :SDL_LogResetPriorities => [],
94
- :SDL_Log => [:pointer],
95
- :SDL_LogVerbose => [:int, :pointer],
96
- :SDL_LogDebug => [:int, :pointer],
97
- :SDL_LogInfo => [:int, :pointer],
98
- :SDL_LogWarn => [:int, :pointer],
99
- :SDL_LogError => [:int, :pointer],
100
- :SDL_LogCritical => [:int, :pointer],
101
- :SDL_LogMessage => [:int, :int, :pointer],
102
- :SDL_LogGetOutputFunction => [:pointer, :pointer],
103
- :SDL_LogSetOutputFunction => [:SDL_LogOutputFunction, :pointer],
104
- }
105
- retvals = {
106
- :SDL_LogSetAllPriority => :void,
107
- :SDL_LogSetPriority => :void,
108
- :SDL_LogGetPriority => :int,
109
- :SDL_LogResetPriorities => :void,
110
- :SDL_Log => :void,
111
- :SDL_LogVerbose => :void,
112
- :SDL_LogDebug => :void,
113
- :SDL_LogInfo => :void,
114
- :SDL_LogWarn => :void,
115
- :SDL_LogError => :void,
116
- :SDL_LogCritical => :void,
117
- :SDL_LogMessage => :void,
118
- :SDL_LogGetOutputFunction => :void,
119
- :SDL_LogSetOutputFunction => :void,
120
- }
121
- symbols.each do |sym|
122
- begin
123
- attach_function apis[sym], sym, args[sym], retvals[sym]
124
- rescue FFI::NotFoundError => error
125
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
126
- end
127
- end
128
- end
129
-
130
- end
131
-
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
+ MAX_LOG_MESSAGE = 4096
14
+
15
+ # Enum
16
+
17
+ LOG_CATEGORY_APPLICATION = 0
18
+ LOG_CATEGORY_ERROR = 1
19
+ LOG_CATEGORY_ASSERT = 2
20
+ LOG_CATEGORY_SYSTEM = 3
21
+ LOG_CATEGORY_AUDIO = 4
22
+ LOG_CATEGORY_VIDEO = 5
23
+ LOG_CATEGORY_RENDER = 6
24
+ LOG_CATEGORY_INPUT = 7
25
+ LOG_CATEGORY_TEST = 8
26
+ LOG_CATEGORY_RESERVED1 = 9
27
+ LOG_CATEGORY_RESERVED2 = 10
28
+ LOG_CATEGORY_RESERVED3 = 11
29
+ LOG_CATEGORY_RESERVED4 = 12
30
+ LOG_CATEGORY_RESERVED5 = 13
31
+ LOG_CATEGORY_RESERVED6 = 14
32
+ LOG_CATEGORY_RESERVED7 = 15
33
+ LOG_CATEGORY_RESERVED8 = 16
34
+ LOG_CATEGORY_RESERVED9 = 17
35
+ LOG_CATEGORY_RESERVED10 = 18
36
+ LOG_CATEGORY_CUSTOM = 19
37
+ LOG_PRIORITY_VERBOSE = 1
38
+ LOG_PRIORITY_DEBUG = 2
39
+ LOG_PRIORITY_INFO = 3
40
+ LOG_PRIORITY_WARN = 4
41
+ LOG_PRIORITY_ERROR = 5
42
+ LOG_PRIORITY_CRITICAL = 6
43
+ NUM_LOG_PRIORITIES = 7
44
+
45
+ # Typedef
46
+
47
+ typedef :int, :SDL_LogCategory
48
+ typedef :int, :SDL_LogPriority
49
+ callback :SDL_LogOutputFunction, [:pointer, :int, :int, :pointer], :void
50
+
51
+ # Struct
52
+
53
+
54
+ # Function
55
+
56
+ def self.setup_log_symbols(output_error = false)
57
+ symbols = [
58
+ :SDL_LogSetAllPriority,
59
+ :SDL_LogSetPriority,
60
+ :SDL_LogGetPriority,
61
+ :SDL_LogResetPriorities,
62
+ :SDL_Log,
63
+ :SDL_LogVerbose,
64
+ :SDL_LogDebug,
65
+ :SDL_LogInfo,
66
+ :SDL_LogWarn,
67
+ :SDL_LogError,
68
+ :SDL_LogCritical,
69
+ :SDL_LogMessage,
70
+ :SDL_LogGetOutputFunction,
71
+ :SDL_LogSetOutputFunction,
72
+ ]
73
+ apis = {
74
+ :SDL_LogSetAllPriority => :LogSetAllPriority,
75
+ :SDL_LogSetPriority => :LogSetPriority,
76
+ :SDL_LogGetPriority => :LogGetPriority,
77
+ :SDL_LogResetPriorities => :LogResetPriorities,
78
+ :SDL_Log => :Log,
79
+ :SDL_LogVerbose => :LogVerbose,
80
+ :SDL_LogDebug => :LogDebug,
81
+ :SDL_LogInfo => :LogInfo,
82
+ :SDL_LogWarn => :LogWarn,
83
+ :SDL_LogError => :LogError,
84
+ :SDL_LogCritical => :LogCritical,
85
+ :SDL_LogMessage => :LogMessage,
86
+ :SDL_LogGetOutputFunction => :LogGetOutputFunction,
87
+ :SDL_LogSetOutputFunction => :LogSetOutputFunction,
88
+ }
89
+ args = {
90
+ :SDL_LogSetAllPriority => [:int],
91
+ :SDL_LogSetPriority => [:int, :int],
92
+ :SDL_LogGetPriority => [:int],
93
+ :SDL_LogResetPriorities => [],
94
+ :SDL_Log => [:pointer],
95
+ :SDL_LogVerbose => [:int, :pointer],
96
+ :SDL_LogDebug => [:int, :pointer],
97
+ :SDL_LogInfo => [:int, :pointer],
98
+ :SDL_LogWarn => [:int, :pointer],
99
+ :SDL_LogError => [:int, :pointer],
100
+ :SDL_LogCritical => [:int, :pointer],
101
+ :SDL_LogMessage => [:int, :int, :pointer],
102
+ :SDL_LogGetOutputFunction => [:pointer, :pointer],
103
+ :SDL_LogSetOutputFunction => [:SDL_LogOutputFunction, :pointer],
104
+ }
105
+ retvals = {
106
+ :SDL_LogSetAllPriority => :void,
107
+ :SDL_LogSetPriority => :void,
108
+ :SDL_LogGetPriority => :int,
109
+ :SDL_LogResetPriorities => :void,
110
+ :SDL_Log => :void,
111
+ :SDL_LogVerbose => :void,
112
+ :SDL_LogDebug => :void,
113
+ :SDL_LogInfo => :void,
114
+ :SDL_LogWarn => :void,
115
+ :SDL_LogError => :void,
116
+ :SDL_LogCritical => :void,
117
+ :SDL_LogMessage => :void,
118
+ :SDL_LogGetOutputFunction => :void,
119
+ :SDL_LogSetOutputFunction => :void,
120
+ }
121
+ symbols.each do |sym|
122
+ begin
123
+ attach_function apis[sym], sym, args[sym], retvals[sym]
124
+ rescue FFI::NotFoundError => error
125
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
126
+ end
127
+ end
128
+ end
129
+
130
+ end
131
+
data/lib/sdl2_main.rb CHANGED
@@ -1,74 +1,74 @@
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
- INIT_TIMER = 0x00000001
14
- INIT_AUDIO = 0x00000010
15
- INIT_VIDEO = 0x00000020
16
- INIT_JOYSTICK = 0x00000200
17
- INIT_HAPTIC = 0x00001000
18
- INIT_GAMECONTROLLER = 0x00002000
19
- INIT_EVENTS = 0x00004000
20
- INIT_SENSOR = 0x00008000
21
- INIT_NOPARACHUTE = 0x00100000
22
- INIT_EVERYTHING = ( INIT_TIMER | INIT_AUDIO | INIT_VIDEO | INIT_EVENTS | INIT_JOYSTICK | INIT_HAPTIC | INIT_GAMECONTROLLER | INIT_SENSOR )
23
-
24
- # Enum
25
-
26
-
27
- # Typedef
28
-
29
-
30
- # Struct
31
-
32
-
33
- # Function
34
-
35
- def self.setup_main_symbols(output_error = false)
36
- symbols = [
37
- :SDL_Init,
38
- :SDL_InitSubSystem,
39
- :SDL_QuitSubSystem,
40
- :SDL_WasInit,
41
- :SDL_Quit,
42
- ]
43
- apis = {
44
- :SDL_Init => :Init,
45
- :SDL_InitSubSystem => :InitSubSystem,
46
- :SDL_QuitSubSystem => :QuitSubSystem,
47
- :SDL_WasInit => :WasInit,
48
- :SDL_Quit => :Quit,
49
- }
50
- args = {
51
- :SDL_Init => [:uint],
52
- :SDL_InitSubSystem => [:uint],
53
- :SDL_QuitSubSystem => [:uint],
54
- :SDL_WasInit => [:uint],
55
- :SDL_Quit => [],
56
- }
57
- retvals = {
58
- :SDL_Init => :int,
59
- :SDL_InitSubSystem => :int,
60
- :SDL_QuitSubSystem => :void,
61
- :SDL_WasInit => :uint,
62
- :SDL_Quit => :void,
63
- }
64
- symbols.each do |sym|
65
- begin
66
- attach_function apis[sym], sym, args[sym], retvals[sym]
67
- rescue FFI::NotFoundError => error
68
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
69
- end
70
- end
71
- end
72
-
73
- end
74
-
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
+ INIT_TIMER = 0x00000001
14
+ INIT_AUDIO = 0x00000010
15
+ INIT_VIDEO = 0x00000020
16
+ INIT_JOYSTICK = 0x00000200
17
+ INIT_HAPTIC = 0x00001000
18
+ INIT_GAMECONTROLLER = 0x00002000
19
+ INIT_EVENTS = 0x00004000
20
+ INIT_SENSOR = 0x00008000
21
+ INIT_NOPARACHUTE = 0x00100000
22
+ INIT_EVERYTHING = ( INIT_TIMER | INIT_AUDIO | INIT_VIDEO | INIT_EVENTS | INIT_JOYSTICK | INIT_HAPTIC | INIT_GAMECONTROLLER | INIT_SENSOR )
23
+
24
+ # Enum
25
+
26
+
27
+ # Typedef
28
+
29
+
30
+ # Struct
31
+
32
+
33
+ # Function
34
+
35
+ def self.setup_main_symbols(output_error = false)
36
+ symbols = [
37
+ :SDL_Init,
38
+ :SDL_InitSubSystem,
39
+ :SDL_QuitSubSystem,
40
+ :SDL_WasInit,
41
+ :SDL_Quit,
42
+ ]
43
+ apis = {
44
+ :SDL_Init => :Init,
45
+ :SDL_InitSubSystem => :InitSubSystem,
46
+ :SDL_QuitSubSystem => :QuitSubSystem,
47
+ :SDL_WasInit => :WasInit,
48
+ :SDL_Quit => :Quit,
49
+ }
50
+ args = {
51
+ :SDL_Init => [:uint],
52
+ :SDL_InitSubSystem => [:uint],
53
+ :SDL_QuitSubSystem => [:uint],
54
+ :SDL_WasInit => [:uint],
55
+ :SDL_Quit => [],
56
+ }
57
+ retvals = {
58
+ :SDL_Init => :int,
59
+ :SDL_InitSubSystem => :int,
60
+ :SDL_QuitSubSystem => :void,
61
+ :SDL_WasInit => :uint,
62
+ :SDL_Quit => :void,
63
+ }
64
+ symbols.each do |sym|
65
+ begin
66
+ attach_function apis[sym], sym, args[sym], retvals[sym]
67
+ rescue FFI::NotFoundError => error
68
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
69
+ end
70
+ end
71
+ end
72
+
73
+ end
74
+
@@ -1,102 +1,102 @@
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
-
14
- # Enum
15
-
16
- MESSAGEBOX_ERROR = 16
17
- MESSAGEBOX_WARNING = 32
18
- MESSAGEBOX_INFORMATION = 64
19
- MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 128
20
- MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 256
21
- MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 1
22
- MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 2
23
- MESSAGEBOX_COLOR_BACKGROUND = 0
24
- MESSAGEBOX_COLOR_TEXT = 1
25
- MESSAGEBOX_COLOR_BUTTON_BORDER = 2
26
- MESSAGEBOX_COLOR_BUTTON_BACKGROUND = 3
27
- MESSAGEBOX_COLOR_BUTTON_SELECTED = 4
28
- MESSAGEBOX_COLOR_MAX = 5
29
-
30
- # Typedef
31
-
32
- typedef :int, :SDL_MessageBoxFlags
33
- typedef :int, :SDL_MessageBoxButtonFlags
34
- typedef :int, :SDL_MessageBoxColorType
35
-
36
- # Struct
37
-
38
- class MessageBoxButtonData < FFI::Struct
39
- layout(
40
- :flags, :uint,
41
- :buttonid, :int,
42
- :text, :pointer,
43
- )
44
- end
45
-
46
- class MessageBoxColor < FFI::Struct
47
- layout(
48
- :r, :uchar,
49
- :g, :uchar,
50
- :b, :uchar,
51
- )
52
- end
53
-
54
- class MessageBoxColorScheme < FFI::Struct
55
- layout(
56
- :colors, [MessageBoxColor, 5],
57
- )
58
- end
59
-
60
- class MessageBoxData < FFI::Struct
61
- layout(
62
- :flags, :uint,
63
- :window, :pointer,
64
- :title, :pointer,
65
- :message, :pointer,
66
- :numbuttons, :int,
67
- :buttons, :pointer,
68
- :colorScheme, :pointer,
69
- )
70
- end
71
-
72
-
73
- # Function
74
-
75
- def self.setup_messagebox_symbols(output_error = false)
76
- symbols = [
77
- :SDL_ShowMessageBox,
78
- :SDL_ShowSimpleMessageBox,
79
- ]
80
- apis = {
81
- :SDL_ShowMessageBox => :ShowMessageBox,
82
- :SDL_ShowSimpleMessageBox => :ShowSimpleMessageBox,
83
- }
84
- args = {
85
- :SDL_ShowMessageBox => [:pointer, :pointer],
86
- :SDL_ShowSimpleMessageBox => [:uint, :pointer, :pointer, :pointer],
87
- }
88
- retvals = {
89
- :SDL_ShowMessageBox => :int,
90
- :SDL_ShowSimpleMessageBox => :int,
91
- }
92
- symbols.each do |sym|
93
- begin
94
- attach_function apis[sym], sym, args[sym], retvals[sym]
95
- rescue FFI::NotFoundError => error
96
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
97
- end
98
- end
99
- end
100
-
101
- end
102
-
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
+
14
+ # Enum
15
+
16
+ MESSAGEBOX_ERROR = 16
17
+ MESSAGEBOX_WARNING = 32
18
+ MESSAGEBOX_INFORMATION = 64
19
+ MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 128
20
+ MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 256
21
+ MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 1
22
+ MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 2
23
+ MESSAGEBOX_COLOR_BACKGROUND = 0
24
+ MESSAGEBOX_COLOR_TEXT = 1
25
+ MESSAGEBOX_COLOR_BUTTON_BORDER = 2
26
+ MESSAGEBOX_COLOR_BUTTON_BACKGROUND = 3
27
+ MESSAGEBOX_COLOR_BUTTON_SELECTED = 4
28
+ MESSAGEBOX_COLOR_MAX = 5
29
+
30
+ # Typedef
31
+
32
+ typedef :int, :SDL_MessageBoxFlags
33
+ typedef :int, :SDL_MessageBoxButtonFlags
34
+ typedef :int, :SDL_MessageBoxColorType
35
+
36
+ # Struct
37
+
38
+ class MessageBoxButtonData < FFI::Struct
39
+ layout(
40
+ :flags, :uint,
41
+ :buttonid, :int,
42
+ :text, :pointer,
43
+ )
44
+ end
45
+
46
+ class MessageBoxColor < FFI::Struct
47
+ layout(
48
+ :r, :uchar,
49
+ :g, :uchar,
50
+ :b, :uchar,
51
+ )
52
+ end
53
+
54
+ class MessageBoxColorScheme < FFI::Struct
55
+ layout(
56
+ :colors, [MessageBoxColor, 5],
57
+ )
58
+ end
59
+
60
+ class MessageBoxData < FFI::Struct
61
+ layout(
62
+ :flags, :uint,
63
+ :window, :pointer,
64
+ :title, :pointer,
65
+ :message, :pointer,
66
+ :numbuttons, :int,
67
+ :buttons, :pointer,
68
+ :colorScheme, :pointer,
69
+ )
70
+ end
71
+
72
+
73
+ # Function
74
+
75
+ def self.setup_messagebox_symbols(output_error = false)
76
+ symbols = [
77
+ :SDL_ShowMessageBox,
78
+ :SDL_ShowSimpleMessageBox,
79
+ ]
80
+ apis = {
81
+ :SDL_ShowMessageBox => :ShowMessageBox,
82
+ :SDL_ShowSimpleMessageBox => :ShowSimpleMessageBox,
83
+ }
84
+ args = {
85
+ :SDL_ShowMessageBox => [:pointer, :pointer],
86
+ :SDL_ShowSimpleMessageBox => [:uint, :pointer, :pointer, :pointer],
87
+ }
88
+ retvals = {
89
+ :SDL_ShowMessageBox => :int,
90
+ :SDL_ShowSimpleMessageBox => :int,
91
+ }
92
+ symbols.each do |sym|
93
+ begin
94
+ attach_function apis[sym], sym, args[sym], retvals[sym]
95
+ rescue FFI::NotFoundError => error
96
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
97
+ end
98
+ end
99
+ end
100
+
101
+ end
102
+