sdl2-bindings 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +83 -79
  3. data/LICENSE.txt +1 -1
  4. data/README.md +49 -49
  5. data/lib/sdl2.rb +170 -170
  6. data/lib/sdl2_audio.rb +219 -201
  7. data/lib/sdl2_blendmode.rb +69 -69
  8. data/lib/sdl2_clipboard.rb +51 -51
  9. data/lib/sdl2_cpuinfo.rb +106 -106
  10. data/lib/sdl2_error.rb +64 -64
  11. data/lib/sdl2_events.rb +530 -530
  12. data/lib/sdl2_filesystem.rb +48 -48
  13. data/lib/sdl2_framerate.rb +67 -67
  14. data/lib/sdl2_gamecontroller.rb +254 -254
  15. data/lib/sdl2_gesture.rb +55 -55
  16. data/lib/sdl2_gfxPrimitives.rb +222 -222
  17. data/lib/sdl2_haptic.rb +269 -269
  18. data/lib/sdl2_hints.rb +174 -174
  19. data/lib/sdl2_image.rb +185 -185
  20. data/lib/sdl2_imageFilter.rb +132 -132
  21. data/lib/sdl2_joystick.rb +230 -230
  22. data/lib/sdl2_keyboard.rb +99 -99
  23. data/lib/sdl2_keycode.rb +304 -304
  24. data/lib/sdl2_log.rb +115 -115
  25. data/lib/sdl2_main.rb +67 -67
  26. data/lib/sdl2_messagebox.rb +98 -98
  27. data/lib/sdl2_mixer.rb +317 -307
  28. data/lib/sdl2_mouse.rb +117 -117
  29. data/lib/sdl2_pixels.rb +224 -224
  30. data/lib/sdl2_platform.rb +45 -45
  31. data/lib/sdl2_power.rb +51 -51
  32. data/lib/sdl2_rect.rb +102 -102
  33. data/lib/sdl2_render.rb +290 -290
  34. data/lib/sdl2_rotozoom.rb +66 -66
  35. data/lib/sdl2_rwops.rb +208 -208
  36. data/lib/sdl2_scancode.rb +287 -287
  37. data/lib/sdl2_shape.rb +77 -77
  38. data/lib/sdl2_stdinc.rb +393 -393
  39. data/lib/sdl2_surface.rb +182 -182
  40. data/lib/sdl2_syswm.rb +154 -154
  41. data/lib/sdl2_timer.rb +62 -62
  42. data/lib/sdl2_touch.rb +73 -73
  43. data/lib/sdl2_ttf.rb +202 -190
  44. data/lib/sdl2_version.rb +62 -62
  45. data/lib/sdl2_video.rb +411 -411
  46. data/lib/sdl2_vulkan.rb +64 -64
  47. metadata +6 -6
data/lib/sdl2_mouse.rb CHANGED
@@ -1,117 +1,117 @@
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_BUTTON_LEFT = 1
14
- SDL_BUTTON_MIDDLE = 2
15
- SDL_BUTTON_RIGHT = 3
16
- SDL_BUTTON_X1 = 4
17
- SDL_BUTTON_X2 = 5
18
-
19
- # Enum
20
-
21
- SDL_SYSTEM_CURSOR_ARROW = 0
22
- SDL_SYSTEM_CURSOR_IBEAM = 1
23
- SDL_SYSTEM_CURSOR_WAIT = 2
24
- SDL_SYSTEM_CURSOR_CROSSHAIR = 3
25
- SDL_SYSTEM_CURSOR_WAITARROW = 4
26
- SDL_SYSTEM_CURSOR_SIZENWSE = 5
27
- SDL_SYSTEM_CURSOR_SIZENESW = 6
28
- SDL_SYSTEM_CURSOR_SIZEWE = 7
29
- SDL_SYSTEM_CURSOR_SIZENS = 8
30
- SDL_SYSTEM_CURSOR_SIZEALL = 9
31
- SDL_SYSTEM_CURSOR_NO = 10
32
- SDL_SYSTEM_CURSOR_HAND = 11
33
- SDL_NUM_SYSTEM_CURSORS = 12
34
- SDL_MOUSEWHEEL_NORMAL = 0
35
- SDL_MOUSEWHEEL_FLIPPED = 1
36
-
37
- # Typedef
38
-
39
- typedef :int, :SDL_SystemCursor
40
- typedef :int, :SDL_MouseWheelDirection
41
-
42
- # Struct
43
-
44
-
45
- # Function
46
-
47
- def self.setup_mouse_symbols()
48
- symbols = [
49
- :SDL_GetMouseFocus,
50
- :SDL_GetMouseState,
51
- :SDL_GetGlobalMouseState,
52
- :SDL_GetRelativeMouseState,
53
- :SDL_WarpMouseInWindow,
54
- :SDL_WarpMouseGlobal,
55
- :SDL_SetRelativeMouseMode,
56
- :SDL_CaptureMouse,
57
- :SDL_GetRelativeMouseMode,
58
- :SDL_CreateCursor,
59
- :SDL_CreateColorCursor,
60
- :SDL_CreateSystemCursor,
61
- :SDL_SetCursor,
62
- :SDL_GetCursor,
63
- :SDL_GetDefaultCursor,
64
- :SDL_FreeCursor,
65
- :SDL_ShowCursor,
66
- ]
67
- args = {
68
- :SDL_GetMouseFocus => [],
69
- :SDL_GetMouseState => [:pointer, :pointer],
70
- :SDL_GetGlobalMouseState => [:pointer, :pointer],
71
- :SDL_GetRelativeMouseState => [:pointer, :pointer],
72
- :SDL_WarpMouseInWindow => [:pointer, :int, :int],
73
- :SDL_WarpMouseGlobal => [:int, :int],
74
- :SDL_SetRelativeMouseMode => [:int],
75
- :SDL_CaptureMouse => [:int],
76
- :SDL_GetRelativeMouseMode => [],
77
- :SDL_CreateCursor => [:pointer, :pointer, :int, :int, :int, :int],
78
- :SDL_CreateColorCursor => [:pointer, :int, :int],
79
- :SDL_CreateSystemCursor => [:int],
80
- :SDL_SetCursor => [:pointer],
81
- :SDL_GetCursor => [],
82
- :SDL_GetDefaultCursor => [],
83
- :SDL_FreeCursor => [:pointer],
84
- :SDL_ShowCursor => [:int],
85
- }
86
- retvals = {
87
- :SDL_GetMouseFocus => :pointer,
88
- :SDL_GetMouseState => :uint,
89
- :SDL_GetGlobalMouseState => :uint,
90
- :SDL_GetRelativeMouseState => :uint,
91
- :SDL_WarpMouseInWindow => :void,
92
- :SDL_WarpMouseGlobal => :int,
93
- :SDL_SetRelativeMouseMode => :int,
94
- :SDL_CaptureMouse => :int,
95
- :SDL_GetRelativeMouseMode => :int,
96
- :SDL_CreateCursor => :pointer,
97
- :SDL_CreateColorCursor => :pointer,
98
- :SDL_CreateSystemCursor => :pointer,
99
- :SDL_SetCursor => :void,
100
- :SDL_GetCursor => :pointer,
101
- :SDL_GetDefaultCursor => :pointer,
102
- :SDL_FreeCursor => :void,
103
- :SDL_ShowCursor => :int,
104
- }
105
- symbols.each do |sym|
106
- begin
107
- attach_function sym, args[sym], retvals[sym]
108
- rescue FFI::NotFoundError => error
109
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
110
- end
111
- end
112
- end
113
-
114
- end
115
-
116
- # TODO : def SDL_BUTTON(X); (1 << ((X)-1)); end;
117
-
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_BUTTON_LEFT = 1
14
+ SDL_BUTTON_MIDDLE = 2
15
+ SDL_BUTTON_RIGHT = 3
16
+ SDL_BUTTON_X1 = 4
17
+ SDL_BUTTON_X2 = 5
18
+
19
+ # Enum
20
+
21
+ SDL_SYSTEM_CURSOR_ARROW = 0
22
+ SDL_SYSTEM_CURSOR_IBEAM = 1
23
+ SDL_SYSTEM_CURSOR_WAIT = 2
24
+ SDL_SYSTEM_CURSOR_CROSSHAIR = 3
25
+ SDL_SYSTEM_CURSOR_WAITARROW = 4
26
+ SDL_SYSTEM_CURSOR_SIZENWSE = 5
27
+ SDL_SYSTEM_CURSOR_SIZENESW = 6
28
+ SDL_SYSTEM_CURSOR_SIZEWE = 7
29
+ SDL_SYSTEM_CURSOR_SIZENS = 8
30
+ SDL_SYSTEM_CURSOR_SIZEALL = 9
31
+ SDL_SYSTEM_CURSOR_NO = 10
32
+ SDL_SYSTEM_CURSOR_HAND = 11
33
+ SDL_NUM_SYSTEM_CURSORS = 12
34
+ SDL_MOUSEWHEEL_NORMAL = 0
35
+ SDL_MOUSEWHEEL_FLIPPED = 1
36
+
37
+ # Typedef
38
+
39
+ typedef :int, :SDL_SystemCursor
40
+ typedef :int, :SDL_MouseWheelDirection
41
+
42
+ # Struct
43
+
44
+
45
+ # Function
46
+
47
+ def self.setup_mouse_symbols()
48
+ symbols = [
49
+ :SDL_GetMouseFocus,
50
+ :SDL_GetMouseState,
51
+ :SDL_GetGlobalMouseState,
52
+ :SDL_GetRelativeMouseState,
53
+ :SDL_WarpMouseInWindow,
54
+ :SDL_WarpMouseGlobal,
55
+ :SDL_SetRelativeMouseMode,
56
+ :SDL_CaptureMouse,
57
+ :SDL_GetRelativeMouseMode,
58
+ :SDL_CreateCursor,
59
+ :SDL_CreateColorCursor,
60
+ :SDL_CreateSystemCursor,
61
+ :SDL_SetCursor,
62
+ :SDL_GetCursor,
63
+ :SDL_GetDefaultCursor,
64
+ :SDL_FreeCursor,
65
+ :SDL_ShowCursor,
66
+ ]
67
+ args = {
68
+ :SDL_GetMouseFocus => [],
69
+ :SDL_GetMouseState => [:pointer, :pointer],
70
+ :SDL_GetGlobalMouseState => [:pointer, :pointer],
71
+ :SDL_GetRelativeMouseState => [:pointer, :pointer],
72
+ :SDL_WarpMouseInWindow => [:pointer, :int, :int],
73
+ :SDL_WarpMouseGlobal => [:int, :int],
74
+ :SDL_SetRelativeMouseMode => [:int],
75
+ :SDL_CaptureMouse => [:int],
76
+ :SDL_GetRelativeMouseMode => [],
77
+ :SDL_CreateCursor => [:pointer, :pointer, :int, :int, :int, :int],
78
+ :SDL_CreateColorCursor => [:pointer, :int, :int],
79
+ :SDL_CreateSystemCursor => [:int],
80
+ :SDL_SetCursor => [:pointer],
81
+ :SDL_GetCursor => [],
82
+ :SDL_GetDefaultCursor => [],
83
+ :SDL_FreeCursor => [:pointer],
84
+ :SDL_ShowCursor => [:int],
85
+ }
86
+ retvals = {
87
+ :SDL_GetMouseFocus => :pointer,
88
+ :SDL_GetMouseState => :uint,
89
+ :SDL_GetGlobalMouseState => :uint,
90
+ :SDL_GetRelativeMouseState => :uint,
91
+ :SDL_WarpMouseInWindow => :void,
92
+ :SDL_WarpMouseGlobal => :int,
93
+ :SDL_SetRelativeMouseMode => :int,
94
+ :SDL_CaptureMouse => :int,
95
+ :SDL_GetRelativeMouseMode => :int,
96
+ :SDL_CreateCursor => :pointer,
97
+ :SDL_CreateColorCursor => :pointer,
98
+ :SDL_CreateSystemCursor => :pointer,
99
+ :SDL_SetCursor => :void,
100
+ :SDL_GetCursor => :pointer,
101
+ :SDL_GetDefaultCursor => :pointer,
102
+ :SDL_FreeCursor => :void,
103
+ :SDL_ShowCursor => :int,
104
+ }
105
+ symbols.each do |sym|
106
+ begin
107
+ attach_function sym, args[sym], retvals[sym]
108
+ rescue FFI::NotFoundError => error
109
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
110
+ end
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ # TODO : def SDL_BUTTON(X); (1 << ((X)-1)); end;
117
+
data/lib/sdl2_pixels.rb CHANGED
@@ -1,224 +1,224 @@
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_ALPHA_OPAQUE = 255
14
- SDL_ALPHA_TRANSPARENT = 0
15
-
16
- # Enum
17
-
18
- SDL_PIXELTYPE_UNKNOWN = 0
19
- SDL_PIXELTYPE_INDEX1 = 1
20
- SDL_PIXELTYPE_INDEX4 = 2
21
- SDL_PIXELTYPE_INDEX8 = 3
22
- SDL_PIXELTYPE_PACKED8 = 4
23
- SDL_PIXELTYPE_PACKED16 = 5
24
- SDL_PIXELTYPE_PACKED32 = 6
25
- SDL_PIXELTYPE_ARRAYU8 = 7
26
- SDL_PIXELTYPE_ARRAYU16 = 8
27
- SDL_PIXELTYPE_ARRAYU32 = 9
28
- SDL_PIXELTYPE_ARRAYF16 = 10
29
- SDL_PIXELTYPE_ARRAYF32 = 11
30
- SDL_BITMAPORDER_NONE = 0
31
- SDL_BITMAPORDER_4321 = 1
32
- SDL_BITMAPORDER_1234 = 2
33
- SDL_PACKEDORDER_NONE = 0
34
- SDL_PACKEDORDER_XRGB = 1
35
- SDL_PACKEDORDER_RGBX = 2
36
- SDL_PACKEDORDER_ARGB = 3
37
- SDL_PACKEDORDER_RGBA = 4
38
- SDL_PACKEDORDER_XBGR = 5
39
- SDL_PACKEDORDER_BGRX = 6
40
- SDL_PACKEDORDER_ABGR = 7
41
- SDL_PACKEDORDER_BGRA = 8
42
- SDL_ARRAYORDER_NONE = 0
43
- SDL_ARRAYORDER_RGB = 1
44
- SDL_ARRAYORDER_RGBA = 2
45
- SDL_ARRAYORDER_ARGB = 3
46
- SDL_ARRAYORDER_BGR = 4
47
- SDL_ARRAYORDER_BGRA = 5
48
- SDL_ARRAYORDER_ABGR = 6
49
- SDL_PACKEDLAYOUT_NONE = 0
50
- SDL_PACKEDLAYOUT_332 = 1
51
- SDL_PACKEDLAYOUT_4444 = 2
52
- SDL_PACKEDLAYOUT_1555 = 3
53
- SDL_PACKEDLAYOUT_5551 = 4
54
- SDL_PACKEDLAYOUT_565 = 5
55
- SDL_PACKEDLAYOUT_8888 = 6
56
- SDL_PACKEDLAYOUT_2101010 = 7
57
- SDL_PACKEDLAYOUT_1010102 = 8
58
- SDL_PIXELFORMAT_UNKNOWN = 0
59
- SDL_PIXELFORMAT_INDEX1LSB = 286261504
60
- SDL_PIXELFORMAT_INDEX1MSB = 287310080
61
- SDL_PIXELFORMAT_INDEX4LSB = 303039488
62
- SDL_PIXELFORMAT_INDEX4MSB = 304088064
63
- SDL_PIXELFORMAT_INDEX8 = 318769153
64
- SDL_PIXELFORMAT_RGB332 = 336660481
65
- SDL_PIXELFORMAT_XRGB4444 = 353504258
66
- SDL_PIXELFORMAT_RGB444 = 353504258
67
- SDL_PIXELFORMAT_XBGR4444 = 357698562
68
- SDL_PIXELFORMAT_BGR444 = 357698562
69
- SDL_PIXELFORMAT_XRGB1555 = 353570562
70
- SDL_PIXELFORMAT_RGB555 = 353570562
71
- SDL_PIXELFORMAT_XBGR1555 = 357764866
72
- SDL_PIXELFORMAT_BGR555 = 357764866
73
- SDL_PIXELFORMAT_ARGB4444 = 355602434
74
- SDL_PIXELFORMAT_RGBA4444 = 356651010
75
- SDL_PIXELFORMAT_ABGR4444 = 359796738
76
- SDL_PIXELFORMAT_BGRA4444 = 360845314
77
- SDL_PIXELFORMAT_ARGB1555 = 355667970
78
- SDL_PIXELFORMAT_RGBA5551 = 356782082
79
- SDL_PIXELFORMAT_ABGR1555 = 359862274
80
- SDL_PIXELFORMAT_BGRA5551 = 360976386
81
- SDL_PIXELFORMAT_RGB565 = 353701890
82
- SDL_PIXELFORMAT_BGR565 = 357896194
83
- SDL_PIXELFORMAT_RGB24 = 386930691
84
- SDL_PIXELFORMAT_BGR24 = 390076419
85
- SDL_PIXELFORMAT_XRGB8888 = 370546692
86
- SDL_PIXELFORMAT_RGB888 = 370546692
87
- SDL_PIXELFORMAT_RGBX8888 = 371595268
88
- SDL_PIXELFORMAT_XBGR8888 = 374740996
89
- SDL_PIXELFORMAT_BGR888 = 374740996
90
- SDL_PIXELFORMAT_BGRX8888 = 375789572
91
- SDL_PIXELFORMAT_ARGB8888 = 372645892
92
- SDL_PIXELFORMAT_RGBA8888 = 373694468
93
- SDL_PIXELFORMAT_ABGR8888 = 376840196
94
- SDL_PIXELFORMAT_BGRA8888 = 377888772
95
- SDL_PIXELFORMAT_ARGB2101010 = 372711428
96
- SDL_PIXELFORMAT_RGBA32 = 376840196
97
- SDL_PIXELFORMAT_ARGB32 = 377888772
98
- SDL_PIXELFORMAT_BGRA32 = 372645892
99
- SDL_PIXELFORMAT_ABGR32 = 373694468
100
- SDL_PIXELFORMAT_YV12 = 842094169
101
- SDL_PIXELFORMAT_IYUV = 1448433993
102
- SDL_PIXELFORMAT_YUY2 = 844715353
103
- SDL_PIXELFORMAT_UYVY = 1498831189
104
- SDL_PIXELFORMAT_YVYU = 1431918169
105
- SDL_PIXELFORMAT_NV12 = 842094158
106
- SDL_PIXELFORMAT_NV21 = 825382478
107
- SDL_PIXELFORMAT_EXTERNAL_OES = 542328143
108
-
109
- # Typedef
110
-
111
- typedef :int, :SDL_PixelType
112
- typedef :int, :SDL_BitmapOrder
113
- typedef :int, :SDL_PackedOrder
114
- typedef :int, :SDL_ArrayOrder
115
- typedef :int, :SDL_PackedLayout
116
- typedef :int, :SDL_PixelFormatEnum
117
-
118
- # Struct
119
-
120
- class SDL_Color < FFI::Struct
121
- layout(
122
- :r, :uchar,
123
- :g, :uchar,
124
- :b, :uchar,
125
- :a, :uchar,
126
- )
127
- end
128
-
129
- class SDL_Palette < FFI::Struct
130
- layout(
131
- :ncolors, :int,
132
- :colors, :pointer,
133
- :version, :uint,
134
- :refcount, :int,
135
- )
136
- end
137
-
138
- class SDL_PixelFormat < FFI::Struct
139
- layout(
140
- :format, :uint,
141
- :palette, :pointer,
142
- :BitsPerPixel, :uchar,
143
- :BytesPerPixel, :uchar,
144
- :padding, [:uchar, 2],
145
- :Rmask, :uint,
146
- :Gmask, :uint,
147
- :Bmask, :uint,
148
- :Amask, :uint,
149
- :Rloss, :uchar,
150
- :Gloss, :uchar,
151
- :Bloss, :uchar,
152
- :Aloss, :uchar,
153
- :Rshift, :uchar,
154
- :Gshift, :uchar,
155
- :Bshift, :uchar,
156
- :Ashift, :uchar,
157
- :refcount, :int,
158
- :next, :pointer,
159
- )
160
- end
161
-
162
-
163
- # Function
164
-
165
- def self.setup_pixels_symbols()
166
- symbols = [
167
- :SDL_GetPixelFormatName,
168
- :SDL_PixelFormatEnumToMasks,
169
- :SDL_MasksToPixelFormatEnum,
170
- :SDL_AllocFormat,
171
- :SDL_FreeFormat,
172
- :SDL_AllocPalette,
173
- :SDL_SetPixelFormatPalette,
174
- :SDL_SetPaletteColors,
175
- :SDL_FreePalette,
176
- :SDL_MapRGB,
177
- :SDL_MapRGBA,
178
- :SDL_GetRGB,
179
- :SDL_GetRGBA,
180
- :SDL_CalculateGammaRamp,
181
- ]
182
- args = {
183
- :SDL_GetPixelFormatName => [:uint],
184
- :SDL_PixelFormatEnumToMasks => [:uint, :pointer, :pointer, :pointer, :pointer, :pointer],
185
- :SDL_MasksToPixelFormatEnum => [:int, :uint, :uint, :uint, :uint],
186
- :SDL_AllocFormat => [:uint],
187
- :SDL_FreeFormat => [:pointer],
188
- :SDL_AllocPalette => [:int],
189
- :SDL_SetPixelFormatPalette => [:pointer, :pointer],
190
- :SDL_SetPaletteColors => [:pointer, :pointer, :int, :int],
191
- :SDL_FreePalette => [:pointer],
192
- :SDL_MapRGB => [:pointer, :uchar, :uchar, :uchar],
193
- :SDL_MapRGBA => [:pointer, :uchar, :uchar, :uchar, :uchar],
194
- :SDL_GetRGB => [:uint, :pointer, :pointer, :pointer, :pointer],
195
- :SDL_GetRGBA => [:uint, :pointer, :pointer, :pointer, :pointer, :pointer],
196
- :SDL_CalculateGammaRamp => [:float, :pointer],
197
- }
198
- retvals = {
199
- :SDL_GetPixelFormatName => :pointer,
200
- :SDL_PixelFormatEnumToMasks => :int,
201
- :SDL_MasksToPixelFormatEnum => :uint,
202
- :SDL_AllocFormat => :pointer,
203
- :SDL_FreeFormat => :void,
204
- :SDL_AllocPalette => :pointer,
205
- :SDL_SetPixelFormatPalette => :int,
206
- :SDL_SetPaletteColors => :int,
207
- :SDL_FreePalette => :void,
208
- :SDL_MapRGB => :uint,
209
- :SDL_MapRGBA => :uint,
210
- :SDL_GetRGB => :void,
211
- :SDL_GetRGBA => :void,
212
- :SDL_CalculateGammaRamp => :void,
213
- }
214
- symbols.each do |sym|
215
- begin
216
- attach_function sym, args[sym], retvals[sym]
217
- rescue FFI::NotFoundError => error
218
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
219
- end
220
- end
221
- end
222
-
223
- end
224
-
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_ALPHA_OPAQUE = 255
14
+ SDL_ALPHA_TRANSPARENT = 0
15
+
16
+ # Enum
17
+
18
+ SDL_PIXELTYPE_UNKNOWN = 0
19
+ SDL_PIXELTYPE_INDEX1 = 1
20
+ SDL_PIXELTYPE_INDEX4 = 2
21
+ SDL_PIXELTYPE_INDEX8 = 3
22
+ SDL_PIXELTYPE_PACKED8 = 4
23
+ SDL_PIXELTYPE_PACKED16 = 5
24
+ SDL_PIXELTYPE_PACKED32 = 6
25
+ SDL_PIXELTYPE_ARRAYU8 = 7
26
+ SDL_PIXELTYPE_ARRAYU16 = 8
27
+ SDL_PIXELTYPE_ARRAYU32 = 9
28
+ SDL_PIXELTYPE_ARRAYF16 = 10
29
+ SDL_PIXELTYPE_ARRAYF32 = 11
30
+ SDL_BITMAPORDER_NONE = 0
31
+ SDL_BITMAPORDER_4321 = 1
32
+ SDL_BITMAPORDER_1234 = 2
33
+ SDL_PACKEDORDER_NONE = 0
34
+ SDL_PACKEDORDER_XRGB = 1
35
+ SDL_PACKEDORDER_RGBX = 2
36
+ SDL_PACKEDORDER_ARGB = 3
37
+ SDL_PACKEDORDER_RGBA = 4
38
+ SDL_PACKEDORDER_XBGR = 5
39
+ SDL_PACKEDORDER_BGRX = 6
40
+ SDL_PACKEDORDER_ABGR = 7
41
+ SDL_PACKEDORDER_BGRA = 8
42
+ SDL_ARRAYORDER_NONE = 0
43
+ SDL_ARRAYORDER_RGB = 1
44
+ SDL_ARRAYORDER_RGBA = 2
45
+ SDL_ARRAYORDER_ARGB = 3
46
+ SDL_ARRAYORDER_BGR = 4
47
+ SDL_ARRAYORDER_BGRA = 5
48
+ SDL_ARRAYORDER_ABGR = 6
49
+ SDL_PACKEDLAYOUT_NONE = 0
50
+ SDL_PACKEDLAYOUT_332 = 1
51
+ SDL_PACKEDLAYOUT_4444 = 2
52
+ SDL_PACKEDLAYOUT_1555 = 3
53
+ SDL_PACKEDLAYOUT_5551 = 4
54
+ SDL_PACKEDLAYOUT_565 = 5
55
+ SDL_PACKEDLAYOUT_8888 = 6
56
+ SDL_PACKEDLAYOUT_2101010 = 7
57
+ SDL_PACKEDLAYOUT_1010102 = 8
58
+ SDL_PIXELFORMAT_UNKNOWN = 0
59
+ SDL_PIXELFORMAT_INDEX1LSB = 286261504
60
+ SDL_PIXELFORMAT_INDEX1MSB = 287310080
61
+ SDL_PIXELFORMAT_INDEX4LSB = 303039488
62
+ SDL_PIXELFORMAT_INDEX4MSB = 304088064
63
+ SDL_PIXELFORMAT_INDEX8 = 318769153
64
+ SDL_PIXELFORMAT_RGB332 = 336660481
65
+ SDL_PIXELFORMAT_XRGB4444 = 353504258
66
+ SDL_PIXELFORMAT_RGB444 = 353504258
67
+ SDL_PIXELFORMAT_XBGR4444 = 357698562
68
+ SDL_PIXELFORMAT_BGR444 = 357698562
69
+ SDL_PIXELFORMAT_XRGB1555 = 353570562
70
+ SDL_PIXELFORMAT_RGB555 = 353570562
71
+ SDL_PIXELFORMAT_XBGR1555 = 357764866
72
+ SDL_PIXELFORMAT_BGR555 = 357764866
73
+ SDL_PIXELFORMAT_ARGB4444 = 355602434
74
+ SDL_PIXELFORMAT_RGBA4444 = 356651010
75
+ SDL_PIXELFORMAT_ABGR4444 = 359796738
76
+ SDL_PIXELFORMAT_BGRA4444 = 360845314
77
+ SDL_PIXELFORMAT_ARGB1555 = 355667970
78
+ SDL_PIXELFORMAT_RGBA5551 = 356782082
79
+ SDL_PIXELFORMAT_ABGR1555 = 359862274
80
+ SDL_PIXELFORMAT_BGRA5551 = 360976386
81
+ SDL_PIXELFORMAT_RGB565 = 353701890
82
+ SDL_PIXELFORMAT_BGR565 = 357896194
83
+ SDL_PIXELFORMAT_RGB24 = 386930691
84
+ SDL_PIXELFORMAT_BGR24 = 390076419
85
+ SDL_PIXELFORMAT_XRGB8888 = 370546692
86
+ SDL_PIXELFORMAT_RGB888 = 370546692
87
+ SDL_PIXELFORMAT_RGBX8888 = 371595268
88
+ SDL_PIXELFORMAT_XBGR8888 = 374740996
89
+ SDL_PIXELFORMAT_BGR888 = 374740996
90
+ SDL_PIXELFORMAT_BGRX8888 = 375789572
91
+ SDL_PIXELFORMAT_ARGB8888 = 372645892
92
+ SDL_PIXELFORMAT_RGBA8888 = 373694468
93
+ SDL_PIXELFORMAT_ABGR8888 = 376840196
94
+ SDL_PIXELFORMAT_BGRA8888 = 377888772
95
+ SDL_PIXELFORMAT_ARGB2101010 = 372711428
96
+ SDL_PIXELFORMAT_RGBA32 = 376840196
97
+ SDL_PIXELFORMAT_ARGB32 = 377888772
98
+ SDL_PIXELFORMAT_BGRA32 = 372645892
99
+ SDL_PIXELFORMAT_ABGR32 = 373694468
100
+ SDL_PIXELFORMAT_YV12 = 842094169
101
+ SDL_PIXELFORMAT_IYUV = 1448433993
102
+ SDL_PIXELFORMAT_YUY2 = 844715353
103
+ SDL_PIXELFORMAT_UYVY = 1498831189
104
+ SDL_PIXELFORMAT_YVYU = 1431918169
105
+ SDL_PIXELFORMAT_NV12 = 842094158
106
+ SDL_PIXELFORMAT_NV21 = 825382478
107
+ SDL_PIXELFORMAT_EXTERNAL_OES = 542328143
108
+
109
+ # Typedef
110
+
111
+ typedef :int, :SDL_PixelType
112
+ typedef :int, :SDL_BitmapOrder
113
+ typedef :int, :SDL_PackedOrder
114
+ typedef :int, :SDL_ArrayOrder
115
+ typedef :int, :SDL_PackedLayout
116
+ typedef :int, :SDL_PixelFormatEnum
117
+
118
+ # Struct
119
+
120
+ class SDL_Color < FFI::Struct
121
+ layout(
122
+ :r, :uchar,
123
+ :g, :uchar,
124
+ :b, :uchar,
125
+ :a, :uchar,
126
+ )
127
+ end
128
+
129
+ class SDL_Palette < FFI::Struct
130
+ layout(
131
+ :ncolors, :int,
132
+ :colors, :pointer,
133
+ :version, :uint,
134
+ :refcount, :int,
135
+ )
136
+ end
137
+
138
+ class SDL_PixelFormat < FFI::Struct
139
+ layout(
140
+ :format, :uint,
141
+ :palette, :pointer,
142
+ :BitsPerPixel, :uchar,
143
+ :BytesPerPixel, :uchar,
144
+ :padding, [:uchar, 2],
145
+ :Rmask, :uint,
146
+ :Gmask, :uint,
147
+ :Bmask, :uint,
148
+ :Amask, :uint,
149
+ :Rloss, :uchar,
150
+ :Gloss, :uchar,
151
+ :Bloss, :uchar,
152
+ :Aloss, :uchar,
153
+ :Rshift, :uchar,
154
+ :Gshift, :uchar,
155
+ :Bshift, :uchar,
156
+ :Ashift, :uchar,
157
+ :refcount, :int,
158
+ :next, :pointer,
159
+ )
160
+ end
161
+
162
+
163
+ # Function
164
+
165
+ def self.setup_pixels_symbols()
166
+ symbols = [
167
+ :SDL_GetPixelFormatName,
168
+ :SDL_PixelFormatEnumToMasks,
169
+ :SDL_MasksToPixelFormatEnum,
170
+ :SDL_AllocFormat,
171
+ :SDL_FreeFormat,
172
+ :SDL_AllocPalette,
173
+ :SDL_SetPixelFormatPalette,
174
+ :SDL_SetPaletteColors,
175
+ :SDL_FreePalette,
176
+ :SDL_MapRGB,
177
+ :SDL_MapRGBA,
178
+ :SDL_GetRGB,
179
+ :SDL_GetRGBA,
180
+ :SDL_CalculateGammaRamp,
181
+ ]
182
+ args = {
183
+ :SDL_GetPixelFormatName => [:uint],
184
+ :SDL_PixelFormatEnumToMasks => [:uint, :pointer, :pointer, :pointer, :pointer, :pointer],
185
+ :SDL_MasksToPixelFormatEnum => [:int, :uint, :uint, :uint, :uint],
186
+ :SDL_AllocFormat => [:uint],
187
+ :SDL_FreeFormat => [:pointer],
188
+ :SDL_AllocPalette => [:int],
189
+ :SDL_SetPixelFormatPalette => [:pointer, :pointer],
190
+ :SDL_SetPaletteColors => [:pointer, :pointer, :int, :int],
191
+ :SDL_FreePalette => [:pointer],
192
+ :SDL_MapRGB => [:pointer, :uchar, :uchar, :uchar],
193
+ :SDL_MapRGBA => [:pointer, :uchar, :uchar, :uchar, :uchar],
194
+ :SDL_GetRGB => [:uint, :pointer, :pointer, :pointer, :pointer],
195
+ :SDL_GetRGBA => [:uint, :pointer, :pointer, :pointer, :pointer, :pointer],
196
+ :SDL_CalculateGammaRamp => [:float, :pointer],
197
+ }
198
+ retvals = {
199
+ :SDL_GetPixelFormatName => :pointer,
200
+ :SDL_PixelFormatEnumToMasks => :int,
201
+ :SDL_MasksToPixelFormatEnum => :uint,
202
+ :SDL_AllocFormat => :pointer,
203
+ :SDL_FreeFormat => :void,
204
+ :SDL_AllocPalette => :pointer,
205
+ :SDL_SetPixelFormatPalette => :int,
206
+ :SDL_SetPaletteColors => :int,
207
+ :SDL_FreePalette => :void,
208
+ :SDL_MapRGB => :uint,
209
+ :SDL_MapRGBA => :uint,
210
+ :SDL_GetRGB => :void,
211
+ :SDL_GetRGBA => :void,
212
+ :SDL_CalculateGammaRamp => :void,
213
+ }
214
+ symbols.each do |sym|
215
+ begin
216
+ attach_function sym, args[sym], retvals[sym]
217
+ rescue FFI::NotFoundError => error
218
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
219
+ end
220
+ end
221
+ end
222
+
223
+ end
224
+