SDLRuby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +12 -0
- data/lib/SDLRuby/audio.rb +65 -0
- data/lib/SDLRuby/cursor.rb +46 -0
- data/lib/SDLRuby/display.rb +79 -0
- data/lib/SDLRuby/event/accessor.rb +127 -0
- data/lib/SDLRuby/event/type.rb +75 -0
- data/lib/SDLRuby/event.rb +80 -0
- data/lib/SDLRuby/font.rb +227 -0
- data/lib/SDLRuby/hint.rb +36 -0
- data/lib/SDLRuby/image/image.rb +23 -0
- data/lib/SDLRuby/image/include/SDL_image.h.rb +61 -0
- data/lib/SDLRuby/image.rb +69 -0
- data/lib/SDLRuby/keyboard.rb +58 -0
- data/lib/SDLRuby/mixer/channel.rb +43 -0
- data/lib/SDLRuby/mixer/chunk.rb +49 -0
- data/lib/SDLRuby/mixer/controller.rb +44 -0
- data/lib/SDLRuby/mixer/include/SDL_mixer.h.rb +95 -0
- data/lib/SDLRuby/mixer/sdl_mixer.rb +60 -0
- data/lib/SDLRuby/mixer.rb +87 -0
- data/lib/SDLRuby/mouse.rb +52 -0
- data/lib/SDLRuby/music.rb +158 -0
- data/lib/SDLRuby/palette.rb +49 -0
- data/lib/SDLRuby/pixel_formatter.rb +67 -0
- data/lib/SDLRuby/rect.rb +11 -0
- data/lib/SDLRuby/renderer/accessor.rb +70 -0
- data/lib/SDLRuby/renderer/drawer.rb +107 -0
- data/lib/SDLRuby/renderer/renderer_info.rb +27 -0
- data/lib/SDLRuby/renderer.rb +101 -0
- data/lib/SDLRuby/rw_ops/rw_object.rb +128 -0
- data/lib/SDLRuby/rw_ops.rb +216 -0
- data/lib/SDLRuby/sdl/include/SDL.h.rb +33 -0
- data/lib/SDLRuby/sdl/include/SDL_audio.h.rb +49 -0
- data/lib/SDLRuby/sdl/include/SDL_blendmode.h.rb +6 -0
- data/lib/SDLRuby/sdl/include/SDL_clipboard.h.rb +10 -0
- data/lib/SDLRuby/sdl/include/SDL_config.h.rb +13 -0
- data/lib/SDLRuby/sdl/include/SDL_cpuinfo.h.rb +27 -0
- data/lib/SDLRuby/sdl/include/SDL_endian.h.rb +3 -0
- data/lib/SDLRuby/sdl/include/SDL_error.h.rb +9 -0
- data/lib/SDLRuby/sdl/include/SDL_events.h.rb +32 -0
- data/lib/SDLRuby/sdl/include/SDL_filesystem.h.rb +6 -0
- data/lib/SDLRuby/sdl/include/SDL_gamecontroller.h.rb +66 -0
- data/lib/SDLRuby/sdl/include/SDL_gesture.h.rb +12 -0
- data/lib/SDLRuby/sdl/include/SDL_guid.h.rb +7 -0
- data/lib/SDLRuby/sdl/include/SDL_hints.h.rb +14 -0
- data/lib/SDLRuby/sdl/include/SDL_joystick.h.rb +69 -0
- data/lib/SDLRuby/sdl/include/SDL_keyboard.h.rb +26 -0
- data/lib/SDLRuby/sdl/include/SDL_keycode.h.rb +7 -0
- data/lib/SDLRuby/sdl/include/SDL_locale.h.rb +6 -0
- data/lib/SDLRuby/sdl/include/SDL_main.h.rb +3 -0
- data/lib/SDLRuby/sdl/include/SDL_messagebox.h.rb +10 -0
- data/lib/SDLRuby/sdl/include/SDL_misc.h.rb +5 -0
- data/lib/SDLRuby/sdl/include/SDL_mouse.h.rb +26 -0
- data/lib/SDLRuby/sdl/include/SDL_pixels.h.rb +25 -0
- data/lib/SDLRuby/sdl/include/SDL_platform.h.rb +3 -0
- data/lib/SDLRuby/sdl/include/SDL_power.h.rb +6 -0
- data/lib/SDLRuby/sdl/include/SDL_rect.h.rb +17 -0
- data/lib/SDLRuby/sdl/include/SDL_render.h.rb +94 -0
- data/lib/SDLRuby/sdl/include/SDL_revision.h.rb +2 -0
- data/lib/SDLRuby/sdl/include/SDL_rwops.h.rb +34 -0
- data/lib/SDLRuby/sdl/include/SDL_scancode.h.rb +5 -0
- data/lib/SDLRuby/sdl/include/SDL_sensor.h.rb +25 -0
- data/lib/SDLRuby/sdl/include/SDL_shape.h.rb +13 -0
- data/lib/SDLRuby/sdl/include/SDL_stdinc.h.rb +24 -0
- data/lib/SDLRuby/sdl/include/SDL_surface.h.rb +37 -0
- data/lib/SDLRuby/sdl/include/SDL_system.h.rb +6 -0
- data/lib/SDLRuby/sdl/include/SDL_syswm.h.rb +16 -0
- data/lib/SDLRuby/sdl/include/SDL_timer.h.rb +13 -0
- data/lib/SDLRuby/sdl/include/SDL_touch.h.rb +15 -0
- data/lib/SDLRuby/sdl/include/SDL_types.h.rb +3 -0
- data/lib/SDLRuby/sdl/include/SDL_version.h.rb +6 -0
- data/lib/SDLRuby/sdl/include/SDL_video.h.rb +117 -0
- data/lib/SDLRuby/sdl/sdl.rb +55 -0
- data/lib/SDLRuby/sdl/sdl_audio.rb +75 -0
- data/lib/SDLRuby/sdl/sdl_blendmode.rb +10 -0
- data/lib/SDLRuby/sdl/sdl_error.rb +5 -0
- data/lib/SDLRuby/sdl/sdl_events.rb +470 -0
- data/lib/SDLRuby/sdl/sdl_hints.rb +9 -0
- data/lib/SDLRuby/sdl/sdl_keyboard.rb +12 -0
- data/lib/SDLRuby/sdl/sdl_locale.rb +8 -0
- data/lib/SDLRuby/sdl/sdl_message_box.rb +7 -0
- data/lib/SDLRuby/sdl/sdl_mouse.rb +32 -0
- data/lib/SDLRuby/sdl/sdl_palette.rb +12 -0
- data/lib/SDLRuby/sdl/sdl_pixels.rb +138 -0
- data/lib/SDLRuby/sdl/sdl_rect.rb +11 -0
- data/lib/SDLRuby/sdl/sdl_render.rb +35 -0
- data/lib/SDLRuby/sdl/sdl_rw_ops.rb +29 -0
- data/lib/SDLRuby/sdl/sdl_scancode.rb +255 -0
- data/lib/SDLRuby/sdl/sdl_surface.rb +27 -0
- data/lib/SDLRuby/sdl/sdl_version.rb +5 -0
- data/lib/SDLRuby/sdl/sdl_video.rb +104 -0
- data/lib/SDLRuby/sdl.rb +192 -0
- data/lib/SDLRuby/sdl_error.rb +8 -0
- data/lib/SDLRuby/surface/pixel_format.rb +51 -0
- data/lib/SDLRuby/surface/surface_renderer.rb +26 -0
- data/lib/SDLRuby/surface.rb +179 -0
- data/lib/SDLRuby/text_input.rb +38 -0
- data/lib/SDLRuby/texture.rb +93 -0
- data/lib/SDLRuby/ttf/include/SDL_ttf.h.rb +54 -0
- data/lib/SDLRuby/ttf/ttf.rb +41 -0
- data/lib/SDLRuby/ttf.rb +54 -0
- data/lib/SDLRuby/version.rb +5 -0
- data/lib/SDLRuby/window/accessor.rb +125 -0
- data/lib/SDLRuby/window/controller.rb +53 -0
- data/lib/SDLRuby/window/display_info.rb +48 -0
- data/lib/SDLRuby/window/flag.rb +42 -0
- data/lib/SDLRuby/window/hit_tester.rb +61 -0
- data/lib/SDLRuby/window/input.rb +68 -0
- data/lib/SDLRuby/window/shaper.rb +68 -0
- data/lib/SDLRuby/window/surfacer.rb +37 -0
- data/lib/SDLRuby/window/window_renderer.rb +31 -0
- data/lib/SDLRuby/window.rb +90 -0
- data/lib/SDLRuby.rb +16 -0
- data/sig/SDLRuby/event.rbs +104 -0
- data/sig/SDLRuby/pixel_formmater.rbs +24 -0
- data/sig/SDLRuby/rect.rbs +5 -0
- data/sig/SDLRuby/sdl.rbs +606 -0
- data/sig/SDLRuby.rbs +4 -0
- metadata +168 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module SDLRuby
|
2
|
+
module SDL
|
3
|
+
SDL_RENDERER_SOFTWARE = 0x00000001
|
4
|
+
SDL_RENDERER_ACCELERATED = 0x00000002
|
5
|
+
SDL_RENDERER_PRESENTVSYNC = 0x00000004
|
6
|
+
SDL_RENDERER_TARGETTEXTURE = 0x00000008
|
7
|
+
typealias "SDL_RendererFlags", "int"
|
8
|
+
|
9
|
+
SDL_RendererInfo = struct(
|
10
|
+
[
|
11
|
+
"const char *name",
|
12
|
+
"Uint32 flags",
|
13
|
+
"Uint32 num_texture_formats",
|
14
|
+
"Uint32 texture_formats[16]",
|
15
|
+
"int max_texture_width",
|
16
|
+
"int max_texture_height"
|
17
|
+
]
|
18
|
+
)
|
19
|
+
|
20
|
+
SDL_FLIP_NONE = 0x00000000
|
21
|
+
SDL_FLIP_HORIZONTAL = 0x00000001
|
22
|
+
SDL_FLIP_VERTICAL = 0x00000002
|
23
|
+
typealias "SDL_RendererFlip", "int"
|
24
|
+
|
25
|
+
SDL_SCALEMODE_NEAREST = 0
|
26
|
+
SDL_SCALEMODE_LINEAR = 1
|
27
|
+
SDL_SCALEMODE_BEST = 2
|
28
|
+
typealias "SDL_ScaleMode", "int"
|
29
|
+
|
30
|
+
SDL_TEXTUREACCESS_STATIC = 0
|
31
|
+
SDL_TEXTUREACCESS_STREAMING = 1
|
32
|
+
SDL_TEXTUREACCESS_TARGET = 2
|
33
|
+
typealias "SDL_TextureAccess", "int"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SDLRuby
|
2
|
+
module SDL
|
3
|
+
SDL_RWOPS_UNKNOWN = 0
|
4
|
+
SDL_RWOPS_WINFILE = 1
|
5
|
+
SDL_RWOPS_STDFILE = 2
|
6
|
+
SDL_RWOPS_JNIFILE = 3
|
7
|
+
SDL_RWOPS_MEMORY = 4
|
8
|
+
SDL_RWOPS_MEMORY_RO = 5
|
9
|
+
|
10
|
+
# アクセッサ用の構造体。実際のSDL_RWopsとは違い隠し領域のメンバーを含まない。
|
11
|
+
#
|
12
|
+
SDL_RWops = struct(
|
13
|
+
[
|
14
|
+
"void *size",
|
15
|
+
"void *seek",
|
16
|
+
"void *read",
|
17
|
+
"void *write",
|
18
|
+
"void *close",
|
19
|
+
"Uint32 type"
|
20
|
+
]
|
21
|
+
)
|
22
|
+
|
23
|
+
SDL_RWops.module_eval do
|
24
|
+
class << self
|
25
|
+
undef malloc
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
module SDLRuby
|
2
|
+
module SDL
|
3
|
+
SDL_SCANCODE_UNKNOWN = 0
|
4
|
+
SDL_SCANCODE_A = 4
|
5
|
+
SDL_SCANCODE_B = 5
|
6
|
+
SDL_SCANCODE_C = 6
|
7
|
+
SDL_SCANCODE_D = 7
|
8
|
+
SDL_SCANCODE_E = 8
|
9
|
+
SDL_SCANCODE_F = 9
|
10
|
+
SDL_SCANCODE_G = 10
|
11
|
+
SDL_SCANCODE_H = 11
|
12
|
+
SDL_SCANCODE_I = 12
|
13
|
+
SDL_SCANCODE_J = 13
|
14
|
+
SDL_SCANCODE_K = 14
|
15
|
+
SDL_SCANCODE_L = 15
|
16
|
+
SDL_SCANCODE_M = 16
|
17
|
+
SDL_SCANCODE_N = 17
|
18
|
+
SDL_SCANCODE_O = 18
|
19
|
+
SDL_SCANCODE_P = 19
|
20
|
+
SDL_SCANCODE_Q = 20
|
21
|
+
SDL_SCANCODE_R = 21
|
22
|
+
SDL_SCANCODE_S = 22
|
23
|
+
SDL_SCANCODE_T = 23
|
24
|
+
SDL_SCANCODE_U = 24
|
25
|
+
SDL_SCANCODE_V = 25
|
26
|
+
SDL_SCANCODE_W = 26
|
27
|
+
SDL_SCANCODE_X = 27
|
28
|
+
SDL_SCANCODE_Y = 28
|
29
|
+
SDL_SCANCODE_Z = 29
|
30
|
+
SDL_SCANCODE_1 = 30
|
31
|
+
SDL_SCANCODE_2 = 31
|
32
|
+
SDL_SCANCODE_3 = 32
|
33
|
+
SDL_SCANCODE_4 = 33
|
34
|
+
SDL_SCANCODE_5 = 34
|
35
|
+
SDL_SCANCODE_6 = 35
|
36
|
+
SDL_SCANCODE_7 = 36
|
37
|
+
SDL_SCANCODE_8 = 37
|
38
|
+
SDL_SCANCODE_9 = 38
|
39
|
+
SDL_SCANCODE_0 = 39
|
40
|
+
SDL_SCANCODE_RETURN = 40
|
41
|
+
SDL_SCANCODE_ESCAPE = 41
|
42
|
+
SDL_SCANCODE_BACKSPACE = 42
|
43
|
+
SDL_SCANCODE_TAB = 43
|
44
|
+
SDL_SCANCODE_SPACE = 44
|
45
|
+
SDL_SCANCODE_MINUS = 45
|
46
|
+
SDL_SCANCODE_EQUALS = 46
|
47
|
+
SDL_SCANCODE_LEFTBRACKET = 47
|
48
|
+
SDL_SCANCODE_RIGHTBRACKET = 48
|
49
|
+
SDL_SCANCODE_BACKSLASH = 49
|
50
|
+
SDL_SCANCODE_NONUSHASH = 50
|
51
|
+
SDL_SCANCODE_SEMICOLON = 51
|
52
|
+
SDL_SCANCODE_APOSTROPHE = 52
|
53
|
+
SDL_SCANCODE_GRAVE = 53
|
54
|
+
SDL_SCANCODE_COMMA = 54
|
55
|
+
SDL_SCANCODE_PERIOD = 55
|
56
|
+
SDL_SCANCODE_SLASH = 56
|
57
|
+
SDL_SCANCODE_CAPSLOCK = 57
|
58
|
+
SDL_SCANCODE_F1 = 58
|
59
|
+
SDL_SCANCODE_F2 = 59
|
60
|
+
SDL_SCANCODE_F3 = 60
|
61
|
+
SDL_SCANCODE_F4 = 61
|
62
|
+
SDL_SCANCODE_F5 = 62
|
63
|
+
SDL_SCANCODE_F6 = 63
|
64
|
+
SDL_SCANCODE_F7 = 64
|
65
|
+
SDL_SCANCODE_F8 = 65
|
66
|
+
SDL_SCANCODE_F9 = 66
|
67
|
+
SDL_SCANCODE_F10 = 67
|
68
|
+
SDL_SCANCODE_F11 = 68
|
69
|
+
SDL_SCANCODE_F12 = 69
|
70
|
+
SDL_SCANCODE_PRINTSCREEN = 70
|
71
|
+
SDL_SCANCODE_SCROLLLOCK = 71
|
72
|
+
SDL_SCANCODE_PAUSE = 72
|
73
|
+
SDL_SCANCODE_INSERT = 73
|
74
|
+
SDL_SCANCODE_HOME = 74
|
75
|
+
SDL_SCANCODE_PAGEUP = 75
|
76
|
+
SDL_SCANCODE_DELETE = 76
|
77
|
+
SDL_SCANCODE_END = 77
|
78
|
+
SDL_SCANCODE_PAGEDOWN = 78
|
79
|
+
SDL_SCANCODE_RIGHT = 79
|
80
|
+
SDL_SCANCODE_LEFT = 80
|
81
|
+
SDL_SCANCODE_DOWN = 81
|
82
|
+
SDL_SCANCODE_UP = 82
|
83
|
+
SDL_SCANCODE_NUMLOCKCLEAR = 83
|
84
|
+
SDL_SCANCODE_KP_DIVIDE = 84
|
85
|
+
SDL_SCANCODE_KP_MULTIPLY = 85
|
86
|
+
SDL_SCANCODE_KP_MINUS = 86
|
87
|
+
SDL_SCANCODE_KP_PLUS = 87
|
88
|
+
SDL_SCANCODE_KP_ENTER = 88
|
89
|
+
SDL_SCANCODE_KP_1 = 89
|
90
|
+
SDL_SCANCODE_KP_2 = 90
|
91
|
+
SDL_SCANCODE_KP_3 = 91
|
92
|
+
SDL_SCANCODE_KP_4 = 92
|
93
|
+
SDL_SCANCODE_KP_5 = 93
|
94
|
+
SDL_SCANCODE_KP_6 = 94
|
95
|
+
SDL_SCANCODE_KP_7 = 95
|
96
|
+
SDL_SCANCODE_KP_8 = 96
|
97
|
+
SDL_SCANCODE_KP_9 = 97
|
98
|
+
SDL_SCANCODE_KP_0 = 98
|
99
|
+
SDL_SCANCODE_KP_PERIOD = 99
|
100
|
+
SDL_SCANCODE_NONUSBACKSLASH = 100
|
101
|
+
SDL_SCANCODE_APPLICATION = 101
|
102
|
+
SDL_SCANCODE_POWER = 102
|
103
|
+
SDL_SCANCODE_KP_EQUALS = 103
|
104
|
+
SDL_SCANCODE_F13 = 104
|
105
|
+
SDL_SCANCODE_F14 = 105
|
106
|
+
SDL_SCANCODE_F15 = 106
|
107
|
+
SDL_SCANCODE_F16 = 107
|
108
|
+
SDL_SCANCODE_F17 = 108
|
109
|
+
SDL_SCANCODE_F18 = 109
|
110
|
+
SDL_SCANCODE_F19 = 110
|
111
|
+
SDL_SCANCODE_F20 = 111
|
112
|
+
SDL_SCANCODE_F21 = 112
|
113
|
+
SDL_SCANCODE_F22 = 113
|
114
|
+
SDL_SCANCODE_F23 = 114
|
115
|
+
SDL_SCANCODE_F24 = 115
|
116
|
+
SDL_SCANCODE_EXECUTE = 116
|
117
|
+
SDL_SCANCODE_HELP = 117
|
118
|
+
SDL_SCANCODE_MENU = 118
|
119
|
+
SDL_SCANCODE_SELECT = 119
|
120
|
+
SDL_SCANCODE_STOP = 120
|
121
|
+
SDL_SCANCODE_AGAIN = 121
|
122
|
+
SDL_SCANCODE_UNDO = 122
|
123
|
+
SDL_SCANCODE_CUT = 123
|
124
|
+
SDL_SCANCODE_COPY = 124
|
125
|
+
SDL_SCANCODE_PASTE = 125
|
126
|
+
SDL_SCANCODE_FIND = 126
|
127
|
+
SDL_SCANCODE_MUTE = 127
|
128
|
+
SDL_SCANCODE_VOLUMEUP = 128
|
129
|
+
SDL_SCANCODE_VOLUMEDOWN = 129
|
130
|
+
SDL_SCANCODE_LOCKINGCAPSLOCK = 130
|
131
|
+
SDL_SCANCODE_LOCKINGNUMLOCK = 131
|
132
|
+
SDL_SCANCODE_LOCKINGSCROLLLOCK = 132
|
133
|
+
SDL_SCANCODE_KP_COMMA = 133
|
134
|
+
SDL_SCANCODE_KP_EQUALSAS400 = 134
|
135
|
+
SDL_SCANCODE_INTERNATIONAL1 = 135
|
136
|
+
SDL_SCANCODE_INTERNATIONAL2 = 136
|
137
|
+
SDL_SCANCODE_INTERNATIONAL3 = 137
|
138
|
+
SDL_SCANCODE_INTERNATIONAL4 = 138
|
139
|
+
SDL_SCANCODE_INTERNATIONAL5 = 139
|
140
|
+
SDL_SCANCODE_INTERNATIONAL6 = 140
|
141
|
+
SDL_SCANCODE_INTERNATIONAL7 = 141
|
142
|
+
SDL_SCANCODE_INTERNATIONAL8 = 142
|
143
|
+
SDL_SCANCODE_INTERNATIONAL9 = 143
|
144
|
+
SDL_SCANCODE_LANG1 = 144
|
145
|
+
SDL_SCANCODE_LANG2 = 145
|
146
|
+
SDL_SCANCODE_LANG3 = 146
|
147
|
+
SDL_SCANCODE_LANG4 = 147
|
148
|
+
SDL_SCANCODE_LANG5 = 148
|
149
|
+
SDL_SCANCODE_LANG6 = 149
|
150
|
+
SDL_SCANCODE_LANG7 = 150
|
151
|
+
SDL_SCANCODE_LANG8 = 151
|
152
|
+
SDL_SCANCODE_LANG9 = 152
|
153
|
+
SDL_SCANCODE_ALTERASE = 153
|
154
|
+
SDL_SCANCODE_SYSREQ = 154
|
155
|
+
SDL_SCANCODE_CANCEL = 155
|
156
|
+
SDL_SCANCODE_CLEAR = 156
|
157
|
+
SDL_SCANCODE_PRIOR = 157
|
158
|
+
SDL_SCANCODE_RETURN2 = 158
|
159
|
+
SDL_SCANCODE_SEPARATOR = 159
|
160
|
+
SDL_SCANCODE_OUT = 160
|
161
|
+
SDL_SCANCODE_OPER = 161
|
162
|
+
SDL_SCANCODE_CLEARAGAIN = 162
|
163
|
+
SDL_SCANCODE_CRSEL = 163
|
164
|
+
SDL_SCANCODE_EXSEL = 164
|
165
|
+
SDL_SCANCODE_KP_00 = 176
|
166
|
+
SDL_SCANCODE_KP_000 = 177
|
167
|
+
SDL_SCANCODE_THOUSANDSSEPARATOR = 178
|
168
|
+
SDL_SCANCODE_DECIMALSEPARATOR = 179
|
169
|
+
SDL_SCANCODE_CURRENCYUNIT = 180
|
170
|
+
SDL_SCANCODE_CURRENCYSUBUNIT = 181
|
171
|
+
SDL_SCANCODE_KP_LEFTPAREN = 182
|
172
|
+
SDL_SCANCODE_KP_RIGHTPAREN = 183
|
173
|
+
SDL_SCANCODE_KP_LEFTBRACE = 184
|
174
|
+
SDL_SCANCODE_KP_RIGHTBRACE = 185
|
175
|
+
SDL_SCANCODE_KP_TAB = 186
|
176
|
+
SDL_SCANCODE_KP_BACKSPACE = 187
|
177
|
+
SDL_SCANCODE_KP_A = 188
|
178
|
+
SDL_SCANCODE_KP_B = 189
|
179
|
+
SDL_SCANCODE_KP_C = 190
|
180
|
+
SDL_SCANCODE_KP_D = 191
|
181
|
+
SDL_SCANCODE_KP_E = 192
|
182
|
+
SDL_SCANCODE_KP_F = 193
|
183
|
+
SDL_SCANCODE_KP_XOR = 194
|
184
|
+
SDL_SCANCODE_KP_POWER = 195
|
185
|
+
SDL_SCANCODE_KP_PERCENT = 196
|
186
|
+
SDL_SCANCODE_KP_LESS = 197
|
187
|
+
SDL_SCANCODE_KP_GREATER = 198
|
188
|
+
SDL_SCANCODE_KP_AMPERSAND = 199
|
189
|
+
SDL_SCANCODE_KP_DBLAMPERSAND = 200
|
190
|
+
SDL_SCANCODE_KP_VERTICALBAR = 201
|
191
|
+
SDL_SCANCODE_KP_DBLVERTICALBAR = 202
|
192
|
+
SDL_SCANCODE_KP_COLON = 203
|
193
|
+
SDL_SCANCODE_KP_HASH = 204
|
194
|
+
SDL_SCANCODE_KP_SPACE = 205
|
195
|
+
SDL_SCANCODE_KP_AT = 206
|
196
|
+
SDL_SCANCODE_KP_EXCLAM = 207
|
197
|
+
SDL_SCANCODE_KP_MEMSTORE = 208
|
198
|
+
SDL_SCANCODE_KP_MEMRECALL = 209
|
199
|
+
SDL_SCANCODE_KP_MEMCLEAR = 210
|
200
|
+
SDL_SCANCODE_KP_MEMADD = 211
|
201
|
+
SDL_SCANCODE_KP_MEMSUBTRACT = 212
|
202
|
+
SDL_SCANCODE_KP_MEMMULTIPLY = 213
|
203
|
+
SDL_SCANCODE_KP_MEMDIVIDE = 214
|
204
|
+
SDL_SCANCODE_KP_PLUSMINUS = 215
|
205
|
+
SDL_SCANCODE_KP_CLEAR = 216
|
206
|
+
SDL_SCANCODE_KP_CLEARENTRY = 217
|
207
|
+
SDL_SCANCODE_KP_BINARY = 218
|
208
|
+
SDL_SCANCODE_KP_OCTAL = 219
|
209
|
+
SDL_SCANCODE_KP_DECIMAL = 220
|
210
|
+
SDL_SCANCODE_KP_HEXADECIMAL = 221
|
211
|
+
SDL_SCANCODE_LCTRL = 224
|
212
|
+
SDL_SCANCODE_LSHIFT = 225
|
213
|
+
SDL_SCANCODE_LALT = 226
|
214
|
+
SDL_SCANCODE_LGUI = 227
|
215
|
+
SDL_SCANCODE_RCTRL = 228
|
216
|
+
SDL_SCANCODE_RSHIFT = 229
|
217
|
+
SDL_SCANCODE_RALT = 230
|
218
|
+
SDL_SCANCODE_RGUI = 231
|
219
|
+
SDL_SCANCODE_MODE = 257
|
220
|
+
SDL_SCANCODE_AUDIONEXT = 258
|
221
|
+
SDL_SCANCODE_AUDIOPREV = 259
|
222
|
+
SDL_SCANCODE_AUDIOSTOP = 260
|
223
|
+
SDL_SCANCODE_AUDIOPLAY = 261
|
224
|
+
SDL_SCANCODE_AUDIOMUTE = 262
|
225
|
+
SDL_SCANCODE_MEDIASELECT = 263
|
226
|
+
SDL_SCANCODE_WWW = 264
|
227
|
+
SDL_SCANCODE_MAIL = 265
|
228
|
+
SDL_SCANCODE_CALCULATOR = 266
|
229
|
+
SDL_SCANCODE_COMPUTER = 267
|
230
|
+
SDL_SCANCODE_AC_SEARCH = 268
|
231
|
+
SDL_SCANCODE_AC_HOME = 269
|
232
|
+
SDL_SCANCODE_AC_BACK = 270
|
233
|
+
SDL_SCANCODE_AC_FORWARD = 271
|
234
|
+
SDL_SCANCODE_AC_STOP = 272
|
235
|
+
SDL_SCANCODE_AC_REFRESH = 273
|
236
|
+
SDL_SCANCODE_AC_BOOKMARKS = 274
|
237
|
+
SDL_SCANCODE_BRIGHTNESSDOWN = 275
|
238
|
+
SDL_SCANCODE_BRIGHTNESSUP = 276
|
239
|
+
SDL_SCANCODE_DISPLAYSWITCH = 277
|
240
|
+
SDL_SCANCODE_KBDILLUMTOGGLE = 278
|
241
|
+
SDL_SCANCODE_KBDILLUMDOWN = 279
|
242
|
+
SDL_SCANCODE_KBDILLUMUP = 280
|
243
|
+
SDL_SCANCODE_EJECT = 281
|
244
|
+
SDL_SCANCODE_SLEEP = 282
|
245
|
+
SDL_SCANCODE_APP1 = 283
|
246
|
+
SDL_SCANCODE_APP2 = 284
|
247
|
+
SDL_SCANCODE_AUDIOREWIND = 285
|
248
|
+
SDL_SCANCODE_AUDIOFASTFORWARD = 286
|
249
|
+
SDL_SCANCODE_SOFTLEFT = 287
|
250
|
+
SDL_SCANCODE_SOFTRIGHT = 288
|
251
|
+
SDL_SCANCODE_CALL = 289
|
252
|
+
SDL_SCANCODE_ENDCALL = 290
|
253
|
+
SDL_NUM_SCANCODES = 512
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SDLRuby
|
2
|
+
module SDL
|
3
|
+
SDL_DONTFREE = 0x00000004
|
4
|
+
|
5
|
+
SDL_Surface = struct(
|
6
|
+
[
|
7
|
+
"Uint32 flags",
|
8
|
+
"SDL_PixelFormat* format",
|
9
|
+
"int w",
|
10
|
+
"int h",
|
11
|
+
"int pitch",
|
12
|
+
"void* pixels",
|
13
|
+
"void* userdata",
|
14
|
+
"int locked",
|
15
|
+
"void* list_blitmap",
|
16
|
+
{ clip_rect: SDL_Rect },
|
17
|
+
"SDL_BlitMap* map",
|
18
|
+
"int refcount"
|
19
|
+
]
|
20
|
+
)
|
21
|
+
|
22
|
+
extern "int SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
23
|
+
SDL_Surface * dst, SDL_Rect * dstrect)"
|
24
|
+
extern "int SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
25
|
+
SDL_Surface * dst, SDL_Rect * dstrect)"
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module SDLRuby
|
2
|
+
module SDL
|
3
|
+
# SDL_WindowFlags
|
4
|
+
#
|
5
|
+
SDL_WINDOW_FULLSCREEN = 0x00000001
|
6
|
+
SDL_WINDOW_OPENGL = 0x00000002
|
7
|
+
SDL_WINDOW_SHOWN = 0x00000004
|
8
|
+
SDL_WINDOW_HIDDEN = 0x00000008
|
9
|
+
SDL_WINDOW_BORDERLESS = 0x00000010
|
10
|
+
SDL_WINDOW_RESIZABLE = 0x00000020
|
11
|
+
SDL_WINDOW_MINIMIZED = 0x00000040
|
12
|
+
SDL_WINDOW_MAXIMIZED = 0x00000080
|
13
|
+
SDL_WINDOW_MOUSE_GRABBED = 0x00000100
|
14
|
+
SDL_WINDOW_INPUT_FOCUS = 0x00000200
|
15
|
+
SDL_WINDOW_MOUSE_FOCUS = 0x00000400
|
16
|
+
SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000
|
17
|
+
SDL_WINDOW_FOREIGN = 0x00000800
|
18
|
+
SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000
|
19
|
+
SDL_WINDOW_MOUSE_CAPTURE = 0x00004000
|
20
|
+
SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000
|
21
|
+
SDL_WINDOW_SKIP_TASKBAR = 0x00010000
|
22
|
+
SDL_WINDOW_UTILITY = 0x00020000
|
23
|
+
SDL_WINDOW_TOOLTIP = 0x00040000
|
24
|
+
SDL_WINDOW_POPUP_MENU = 0x00080000
|
25
|
+
SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000
|
26
|
+
SDL_WINDOW_VULKAN = 0x10000000
|
27
|
+
SDL_WINDOW_METAL = 0x20000000
|
28
|
+
SDL_WINDOW_INPUT_GRABBED = SDL_WINDOW_MOUSE_GRABBED
|
29
|
+
|
30
|
+
# Window position
|
31
|
+
#
|
32
|
+
SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000
|
33
|
+
SDL_WINDOWPOS_CENTERED = 0x2FFF0000
|
34
|
+
|
35
|
+
# SDL_HitTestResult
|
36
|
+
#
|
37
|
+
SDL_HITTEST_NORMAL = 0
|
38
|
+
SDL_HITTEST_DRAGGABLE = 1
|
39
|
+
SDL_HITTEST_RESIZE_TOPLEFT = 2
|
40
|
+
SDL_HITTEST_RESIZE_TOP = 3
|
41
|
+
SDL_HITTEST_RESIZE_TOPRIGHT = 4
|
42
|
+
SDL_HITTEST_RESIZE_RIGHT = 5
|
43
|
+
SDL_HITTEST_RESIZE_BOTTOMRIGHT = 6
|
44
|
+
SDL_HITTEST_RESIZE_BOTTOM = 7
|
45
|
+
SDL_HITTEST_RESIZE_BOTTOMLEFT = 8
|
46
|
+
SDL_HITTEST_RESIZE_LEFT = 9
|
47
|
+
|
48
|
+
# Display orientation
|
49
|
+
#
|
50
|
+
SDL_ORIENTATION_UNKNOWN = 0
|
51
|
+
SDL_ORIENTATION_LANDSCAPE = 1
|
52
|
+
SDL_ORIENTATION_LANDSCAPE_FLIPPED = 2
|
53
|
+
SDL_ORIENTATION_PORTRAIT = 3
|
54
|
+
SDL_ORIENTATION_PORTRAIT_FLIPPED = 4
|
55
|
+
|
56
|
+
# Window flash operation
|
57
|
+
#
|
58
|
+
SDL_FLASH_CANCEL = 0
|
59
|
+
SDL_FLASH_BRIEFLY = 1
|
60
|
+
SDL_FLASH_UNTIL_FOCUSED =2
|
61
|
+
|
62
|
+
SDL_DisplayMode = struct(
|
63
|
+
[
|
64
|
+
"Uint32 format",
|
65
|
+
"int w",
|
66
|
+
"int h",
|
67
|
+
"int refresh_rate",
|
68
|
+
"void *driverdata"
|
69
|
+
]
|
70
|
+
)
|
71
|
+
|
72
|
+
# SDL_shape.h
|
73
|
+
#
|
74
|
+
SDL_NONSHAPEABLE_WINDOW = -1
|
75
|
+
SDL_INVALID_SHAPE_ARGUMENT = -2
|
76
|
+
SDL_WINDOW_LACKS_SHAPE = -3
|
77
|
+
|
78
|
+
# WindowShapeMode
|
79
|
+
#
|
80
|
+
ShapeModeDefault = 0
|
81
|
+
ShapeModeBinarizeAlpha = 1
|
82
|
+
ShapeModeReverseBinarizeAlpha = 2
|
83
|
+
ShapeModeColorKey = 3
|
84
|
+
typealias "WindowShapeMode", "int"
|
85
|
+
|
86
|
+
SDL_SHAPEMODEALPHA = -> (mode) {
|
87
|
+
mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha
|
88
|
+
}
|
89
|
+
|
90
|
+
SDL_WindowShapeParams = union(
|
91
|
+
[
|
92
|
+
"Uint8 binarizationCutoff",
|
93
|
+
{ colorKey: SDL_Color }
|
94
|
+
]
|
95
|
+
)
|
96
|
+
|
97
|
+
SDL_WindowShapeMode = struct(
|
98
|
+
[
|
99
|
+
"WindowShapeMode mode",
|
100
|
+
{ parameters: SDL_WindowShapeParams }
|
101
|
+
]
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
data/lib/SDLRuby/sdl.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
require "fiddle/import"
|
2
|
+
|
3
|
+
module SDLRuby
|
4
|
+
module SDL
|
5
|
+
extend Fiddle::Importer
|
6
|
+
|
7
|
+
dlload "SDL2"
|
8
|
+
|
9
|
+
SDL_DESTROY_RENDERER = import_symbol("SDL_DestroyRenderer").to_int
|
10
|
+
SDL_DESTROY_TEXTURE = import_symbol("SDL_DestroyTexture").to_int
|
11
|
+
|
12
|
+
# SDL_freeはSDL_SetMemoryFunctionsで設定された関数を使用する。
|
13
|
+
# SDL側のメモリーを開放する場合はFiddle::PointerへSDL_FREEを設定してよい。
|
14
|
+
#
|
15
|
+
SDL_FREE = SDL.import_symbol("SDL_free").to_int
|
16
|
+
SDL_FREE_CURSOR = import_symbol("SDL_FreeCursor").to_int
|
17
|
+
SDL_FREE_FORMAT = import_symbol("SDL_FreeFormat").to_int
|
18
|
+
SDL_FREE_PALETTE = import_symbol("SDL_FreePalette").to_int
|
19
|
+
SDL_FREE_RW = import_symbol("SDL_FreeRW").to_int
|
20
|
+
SDL_FREE_SURFACE = import_symbol("SDL_FreeSurface").to_int
|
21
|
+
|
22
|
+
def self.tmp_value(*a, &)
|
23
|
+
raise ArgumentError if a.empty?
|
24
|
+
|
25
|
+
a.map { |ty|
|
26
|
+
st = create_value(ty)
|
27
|
+
st.to_ptr.free = Fiddle::RUBY_FREE
|
28
|
+
st
|
29
|
+
} => vals
|
30
|
+
|
31
|
+
v = vals.one? ? vals.first : vals
|
32
|
+
block_given? ? yield(*v) : v
|
33
|
+
end
|
34
|
+
|
35
|
+
require_relative 'sdl/sdl'
|
36
|
+
require_relative 'sdl_error'
|
37
|
+
|
38
|
+
require_relative 'audio'
|
39
|
+
require_relative 'cursor'
|
40
|
+
require_relative 'display'
|
41
|
+
require_relative 'event'
|
42
|
+
require_relative 'hint'
|
43
|
+
require_relative 'keyboard'
|
44
|
+
require_relative 'mouse'
|
45
|
+
require_relative 'palette'
|
46
|
+
require_relative 'pixel_formatter'
|
47
|
+
require_relative 'rect'
|
48
|
+
require_relative 'renderer'
|
49
|
+
require_relative 'rw_ops'
|
50
|
+
require_relative 'surface'
|
51
|
+
require_relative 'text_input'
|
52
|
+
require_relative 'texture'
|
53
|
+
require_relative 'window'
|
54
|
+
|
55
|
+
class << self
|
56
|
+
# sdl
|
57
|
+
#
|
58
|
+
def init(flags = nil)
|
59
|
+
err = SDL.SDL_Init(flags || SDL_INIT_EVERYTHING)
|
60
|
+
raise SDLError if err < 0
|
61
|
+
end
|
62
|
+
|
63
|
+
def init?(flags) = SDL.WasInit(flags).nonzero?
|
64
|
+
|
65
|
+
def quit = SDL.SDL_Quit
|
66
|
+
|
67
|
+
# clipboard
|
68
|
+
#
|
69
|
+
def clipboard_text
|
70
|
+
ptr = SDL.SDL_GetClipboardText
|
71
|
+
raise SDLError if ptr.null?
|
72
|
+
|
73
|
+
ptr.free = SDL_FREE
|
74
|
+
ptr.to_s.force_encoding("UTF-8")
|
75
|
+
end
|
76
|
+
|
77
|
+
def clipboard_text? = SDL.SDL_HasClipboardText == 1
|
78
|
+
|
79
|
+
def clipboard_text=(s)
|
80
|
+
err = SDL.SDL_SetClipboardText(s.encord("UTF-8"))
|
81
|
+
raise SDLError if err < 0
|
82
|
+
end
|
83
|
+
|
84
|
+
# cpu info
|
85
|
+
#
|
86
|
+
def cpu_cache_line_size = SDL.SDL_GetCPUCacheLineSize
|
87
|
+
|
88
|
+
def cpu_count = SDL.SDL_GetCPUCount
|
89
|
+
|
90
|
+
def system_ram = SDL.SDL_GetSystemRAM
|
91
|
+
|
92
|
+
# error
|
93
|
+
#
|
94
|
+
def last_error_message = SDL.SDL_GetError.to_s
|
95
|
+
|
96
|
+
def last_error_message=(s)
|
97
|
+
SDL.SDL_SetError(s.gsub(/%/, "%%"), nil)
|
98
|
+
end
|
99
|
+
|
100
|
+
# filesystem
|
101
|
+
#
|
102
|
+
def base_path
|
103
|
+
ptr = SDL.SDL_GetBasePath
|
104
|
+
raise SDLError if ptr.null?
|
105
|
+
|
106
|
+
ptr.free = SDL_FREE
|
107
|
+
ptr.to_s
|
108
|
+
end
|
109
|
+
|
110
|
+
# locale
|
111
|
+
#
|
112
|
+
# 失敗の時 nil を戻す。
|
113
|
+
#
|
114
|
+
def locales
|
115
|
+
ptr = SDL.SDL_GetPreferredLocales
|
116
|
+
return if ptr.null?
|
117
|
+
|
118
|
+
ptr.free = SDL_FREE
|
119
|
+
pitch = SDL_Locale.size
|
120
|
+
(0..).inject([]) do |memo, i|
|
121
|
+
st = SDL_Locale.new(ptr + i * pitch)
|
122
|
+
break memo if st.language.null?
|
123
|
+
memo << [st.language.to_s, st.country.to_s]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# message box
|
128
|
+
#
|
129
|
+
def alert(message, title = nil, flags: nil, window: nil)
|
130
|
+
err = SDL.SDL_ShowSimpleMessageBox(flags,
|
131
|
+
title.to_s.encode("UTF-8"),
|
132
|
+
message.to_s.encode("UTF-8"),
|
133
|
+
window)
|
134
|
+
raise SDLError if err < 0
|
135
|
+
end
|
136
|
+
|
137
|
+
def error_alert(message, title = "Error")
|
138
|
+
alert(message, title, flags: SDL_MESSAGEBOX_ERROR)
|
139
|
+
end
|
140
|
+
|
141
|
+
def warn_alert(message, title = "Warning")
|
142
|
+
alert(message, title, flags: SDL_MESSAGEBOX_WARNING)
|
143
|
+
end
|
144
|
+
|
145
|
+
def info_alert(message, title = "Information")
|
146
|
+
alert(message, title, flags: SDL_MESSAGEBOX_INFORMATION)
|
147
|
+
end
|
148
|
+
|
149
|
+
# misc
|
150
|
+
#
|
151
|
+
def open_url(url)
|
152
|
+
raise SDLError if SDL.SDL_OpenURL(url) < 0
|
153
|
+
end
|
154
|
+
|
155
|
+
# platform
|
156
|
+
#
|
157
|
+
def platform = SDL.SDL_GetPlatform.to_s
|
158
|
+
|
159
|
+
# timer
|
160
|
+
#
|
161
|
+
def ticks = SDL.SDL_GetTicks
|
162
|
+
|
163
|
+
# version
|
164
|
+
#
|
165
|
+
def revision = SDL.SDL_GetRevision.to_s
|
166
|
+
|
167
|
+
def version
|
168
|
+
st = SDL_version.malloc(Fiddle::RUBY_FREE)
|
169
|
+
SDL.SDL_GetVersion(st)
|
170
|
+
st.to_a.join(".")
|
171
|
+
end
|
172
|
+
|
173
|
+
# video
|
174
|
+
#
|
175
|
+
def video_driver
|
176
|
+
(ptr = SDL.SDL_GetCurrentVideoDriver).null? ? nil : ptr.to_s
|
177
|
+
end
|
178
|
+
|
179
|
+
def screen_saver=(b)
|
180
|
+
b ? SDL.SDL_EnableScreenSaver : SDL.SDL_DisableScreenSaver
|
181
|
+
end
|
182
|
+
|
183
|
+
def screen_saver? = SDL.SDL_IsScreenSaverEnabled != 0
|
184
|
+
|
185
|
+
def video_drivers
|
186
|
+
SDL.SDL_GetNumVideoDrivers.times.map do |i|
|
187
|
+
(ptr = SDL.SDL_GetVideoDriver(i)).null? ? nil : ptr.to_s
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module SDLRuby
|
2
|
+
class Surface
|
3
|
+
class PixelFormat
|
4
|
+
include SDL
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def initialize(ptr, add_ref: nil)
|
8
|
+
@st = SDL_PixelFormat.new(ptr, SDL_FREE_FORMAT)
|
9
|
+
@st.refcount += 1 if add_ref
|
10
|
+
end
|
11
|
+
|
12
|
+
def_delegators :@st, :format, :refcount, :to_ptr
|
13
|
+
|
14
|
+
def map(color)
|
15
|
+
if alpha?
|
16
|
+
r, g, b, a = *color, SDL_ALPHA_OPAQUE
|
17
|
+
SDL.SDL_MapRGBA(self, r, g, b, a)
|
18
|
+
else
|
19
|
+
r, g, b = *color
|
20
|
+
SDL.SDL_MapRGB(self, r, g, b)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
alias to_pixel map
|
25
|
+
|
26
|
+
def palette
|
27
|
+
ptr = @st.palette
|
28
|
+
return if ptr.null?
|
29
|
+
|
30
|
+
Palette.new(ptr, add_ref: true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def palette=(obj)
|
34
|
+
err = SDL.SDL_SetPixelFormatPalette(self, obj)
|
35
|
+
raise SDLError if err < 0
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_color(pixel)
|
39
|
+
if alpha?
|
40
|
+
r, g, b, a = SDL.tmp_value("Uint8", "Uint8", "Uint8", "Uint8")
|
41
|
+
SDL.SDL_GetRGBA(pixel, self, r, g, b, a)
|
42
|
+
[r.value, g.value, b.value, a.value]
|
43
|
+
else
|
44
|
+
r, g, b = SDL.tmp_value("Uint8", "Uint8", "Uint8")
|
45
|
+
SDL.SDL_GetRGB(pixel, self, r, g, b)
|
46
|
+
[r.value, g.value, b.value]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|