sdl2-bindings 0.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +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_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
+
@@ -0,0 +1,212 @@
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_RGB444 = 353504258
66
+ SDL_PIXELFORMAT_RGB555 = 353570562
67
+ SDL_PIXELFORMAT_BGR555 = 357764866
68
+ SDL_PIXELFORMAT_ARGB4444 = 355602434
69
+ SDL_PIXELFORMAT_RGBA4444 = 356651010
70
+ SDL_PIXELFORMAT_ABGR4444 = 359796738
71
+ SDL_PIXELFORMAT_BGRA4444 = 360845314
72
+ SDL_PIXELFORMAT_ARGB1555 = 355667970
73
+ SDL_PIXELFORMAT_RGBA5551 = 356782082
74
+ SDL_PIXELFORMAT_ABGR1555 = 359862274
75
+ SDL_PIXELFORMAT_BGRA5551 = 360976386
76
+ SDL_PIXELFORMAT_RGB565 = 353701890
77
+ SDL_PIXELFORMAT_BGR565 = 357896194
78
+ SDL_PIXELFORMAT_RGB24 = 386930691
79
+ SDL_PIXELFORMAT_BGR24 = 390076419
80
+ SDL_PIXELFORMAT_RGB888 = 370546692
81
+ SDL_PIXELFORMAT_RGBX8888 = 371595268
82
+ SDL_PIXELFORMAT_BGR888 = 374740996
83
+ SDL_PIXELFORMAT_BGRX8888 = 375789572
84
+ SDL_PIXELFORMAT_ARGB8888 = 372645892
85
+ SDL_PIXELFORMAT_RGBA8888 = 373694468
86
+ SDL_PIXELFORMAT_ABGR8888 = 376840196
87
+ SDL_PIXELFORMAT_BGRA8888 = 377888772
88
+ SDL_PIXELFORMAT_ARGB2101010 = 372711428
89
+ SDL_PIXELFORMAT_RGBA32 = 376840196
90
+ SDL_PIXELFORMAT_ARGB32 = 377888772
91
+ SDL_PIXELFORMAT_BGRA32 = 372645892
92
+ SDL_PIXELFORMAT_ABGR32 = 373694468
93
+ SDL_PIXELFORMAT_YV12 = 842094169
94
+ SDL_PIXELFORMAT_IYUV = 1448433993
95
+ SDL_PIXELFORMAT_YUY2 = 844715353
96
+ SDL_PIXELFORMAT_UYVY = 1498831189
97
+ SDL_PIXELFORMAT_YVYU = 1431918169
98
+ SDL_PIXELFORMAT_NV12 = 842094158
99
+ SDL_PIXELFORMAT_NV21 = 825382478
100
+ SDL_PIXELFORMAT_EXTERNAL_OES = 542328143
101
+
102
+ # Typedef
103
+
104
+ typedef :int, :SDL_PixelFormatEnum
105
+
106
+ # Struct
107
+
108
+ class SDL_Color < FFI::Struct
109
+ layout(
110
+ :r, :uchar,
111
+ :g, :uchar,
112
+ :b, :uchar,
113
+ :a, :uchar,
114
+ )
115
+ end
116
+
117
+ class SDL_Palette < FFI::Struct
118
+ layout(
119
+ :ncolors, :int,
120
+ :colors, :pointer,
121
+ :version, :uint,
122
+ :refcount, :int,
123
+ )
124
+ end
125
+
126
+ class SDL_PixelFormat < FFI::Struct
127
+ layout(
128
+ :format, :uint,
129
+ :palette, :pointer,
130
+ :BitsPerPixel, :uchar,
131
+ :BytesPerPixel, :uchar,
132
+ :padding, [:uchar, 2],
133
+ :Rmask, :uint,
134
+ :Gmask, :uint,
135
+ :Bmask, :uint,
136
+ :Amask, :uint,
137
+ :Rloss, :uchar,
138
+ :Gloss, :uchar,
139
+ :Bloss, :uchar,
140
+ :Aloss, :uchar,
141
+ :Rshift, :uchar,
142
+ :Gshift, :uchar,
143
+ :Bshift, :uchar,
144
+ :Ashift, :uchar,
145
+ :refcount, :int,
146
+ :next, :pointer,
147
+ )
148
+ end
149
+
150
+
151
+ # Function
152
+
153
+ def self.setup_pixels_symbols()
154
+ symbols = [
155
+ :SDL_GetPixelFormatName,
156
+ :SDL_PixelFormatEnumToMasks,
157
+ :SDL_MasksToPixelFormatEnum,
158
+ :SDL_AllocFormat,
159
+ :SDL_FreeFormat,
160
+ :SDL_AllocPalette,
161
+ :SDL_SetPixelFormatPalette,
162
+ :SDL_SetPaletteColors,
163
+ :SDL_FreePalette,
164
+ :SDL_MapRGB,
165
+ :SDL_MapRGBA,
166
+ :SDL_GetRGB,
167
+ :SDL_GetRGBA,
168
+ :SDL_CalculateGammaRamp,
169
+ ]
170
+ args = {
171
+ :SDL_GetPixelFormatName => [:uint],
172
+ :SDL_PixelFormatEnumToMasks => [:uint, :pointer, :pointer, :pointer, :pointer, :pointer],
173
+ :SDL_MasksToPixelFormatEnum => [:int, :uint, :uint, :uint, :uint],
174
+ :SDL_AllocFormat => [:uint],
175
+ :SDL_FreeFormat => [:pointer],
176
+ :SDL_AllocPalette => [:int],
177
+ :SDL_SetPixelFormatPalette => [:pointer, :pointer],
178
+ :SDL_SetPaletteColors => [:pointer, :pointer, :int, :int],
179
+ :SDL_FreePalette => [:pointer],
180
+ :SDL_MapRGB => [:pointer, :uchar, :uchar, :uchar],
181
+ :SDL_MapRGBA => [:pointer, :uchar, :uchar, :uchar, :uchar],
182
+ :SDL_GetRGB => [:uint, :pointer, :pointer, :pointer, :pointer],
183
+ :SDL_GetRGBA => [:uint, :pointer, :pointer, :pointer, :pointer, :pointer],
184
+ :SDL_CalculateGammaRamp => [:float, :pointer],
185
+ }
186
+ retvals = {
187
+ :SDL_GetPixelFormatName => :pointer,
188
+ :SDL_PixelFormatEnumToMasks => :int,
189
+ :SDL_MasksToPixelFormatEnum => :uint,
190
+ :SDL_AllocFormat => :pointer,
191
+ :SDL_FreeFormat => :void,
192
+ :SDL_AllocPalette => :pointer,
193
+ :SDL_SetPixelFormatPalette => :int,
194
+ :SDL_SetPaletteColors => :int,
195
+ :SDL_FreePalette => :void,
196
+ :SDL_MapRGB => :uint,
197
+ :SDL_MapRGBA => :uint,
198
+ :SDL_GetRGB => :void,
199
+ :SDL_GetRGBA => :void,
200
+ :SDL_CalculateGammaRamp => :void,
201
+ }
202
+ symbols.each do |sym|
203
+ begin
204
+ attach_function sym, args[sym], retvals[sym]
205
+ rescue FFI::NotFoundError => error
206
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
207
+ end
208
+ end
209
+ end
210
+
211
+ end
212
+
@@ -0,0 +1,45 @@
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
+
14
+ # Enum
15
+
16
+
17
+ # Typedef
18
+
19
+
20
+ # Struct
21
+
22
+
23
+ # Function
24
+
25
+ def self.setup_platform_symbols()
26
+ symbols = [
27
+ :SDL_GetPlatform,
28
+ ]
29
+ args = {
30
+ :SDL_GetPlatform => [],
31
+ }
32
+ retvals = {
33
+ :SDL_GetPlatform => :pointer,
34
+ }
35
+ symbols.each do |sym|
36
+ begin
37
+ attach_function sym, args[sym], retvals[sym]
38
+ rescue FFI::NotFoundError => error
39
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+
@@ -0,0 +1,51 @@
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
+
14
+ # Enum
15
+
16
+ SDL_POWERSTATE_UNKNOWN = 0
17
+ SDL_POWERSTATE_ON_BATTERY = 1
18
+ SDL_POWERSTATE_NO_BATTERY = 2
19
+ SDL_POWERSTATE_CHARGING = 3
20
+ SDL_POWERSTATE_CHARGED = 4
21
+
22
+ # Typedef
23
+
24
+ typedef :int, :SDL_PowerState
25
+
26
+ # Struct
27
+
28
+
29
+ # Function
30
+
31
+ def self.setup_power_symbols()
32
+ symbols = [
33
+ :SDL_GetPowerInfo,
34
+ ]
35
+ args = {
36
+ :SDL_GetPowerInfo => [:pointer, :pointer],
37
+ }
38
+ retvals = {
39
+ :SDL_GetPowerInfo => :int,
40
+ }
41
+ symbols.each do |sym|
42
+ begin
43
+ attach_function sym, args[sym], retvals[sym]
44
+ rescue FFI::NotFoundError => error
45
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
@@ -0,0 +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 SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+
17
+ # Typedef
18
+
19
+
20
+ def SDL_PointInRect(p, r)
21
+ return ( (p.x >= r.x) && (p.x < (r.x + r.w)) && (p.y >= r.y) && (p.y < (r.y + r.h)) ) ? 1 : 0;
22
+ end
23
+
24
+ def SDL_RectEmpty(r)
25
+ return (!r.null? || (r.w <= 0) || (r.h <= 0)) ? 1 : 0
26
+ end
27
+
28
+ def SDL_RectEquals(a, b)
29
+ return (!a.null? && !b.null? && (a.x == b.x) && (a.y == b.y) && (a.w == b.w) && (a.h == b.h)) ? 1 : 0
30
+ end
31
+
32
+
33
+ # Struct
34
+
35
+ class SDL_Point < FFI::Struct
36
+ layout(
37
+ :x, :int,
38
+ :y, :int,
39
+ )
40
+ end
41
+
42
+ class SDL_FPoint < FFI::Struct
43
+ layout(
44
+ :x, :float,
45
+ :y, :float,
46
+ )
47
+ end
48
+
49
+ class SDL_Rect < FFI::Struct
50
+ layout(
51
+ :x, :int,
52
+ :y, :int,
53
+ :w, :int,
54
+ :h, :int,
55
+ )
56
+ end
57
+
58
+ class SDL_FRect < FFI::Struct
59
+ layout(
60
+ :x, :float,
61
+ :y, :float,
62
+ :w, :float,
63
+ :h, :float,
64
+ )
65
+ end
66
+
67
+
68
+ # Function
69
+
70
+ def self.setup_rect_symbols()
71
+ symbols = [
72
+ :SDL_HasIntersection,
73
+ :SDL_IntersectRect,
74
+ :SDL_UnionRect,
75
+ :SDL_EnclosePoints,
76
+ :SDL_IntersectRectAndLine,
77
+ ]
78
+ args = {
79
+ :SDL_HasIntersection => [:pointer, :pointer],
80
+ :SDL_IntersectRect => [:pointer, :pointer, :pointer],
81
+ :SDL_UnionRect => [:pointer, :pointer, :pointer],
82
+ :SDL_EnclosePoints => [:pointer, :int, :pointer, :pointer],
83
+ :SDL_IntersectRectAndLine => [:pointer, :pointer, :pointer, :pointer, :pointer],
84
+ }
85
+ retvals = {
86
+ :SDL_HasIntersection => :int,
87
+ :SDL_IntersectRect => :int,
88
+ :SDL_UnionRect => :void,
89
+ :SDL_EnclosePoints => :int,
90
+ :SDL_IntersectRectAndLine => :int,
91
+ }
92
+ symbols.each do |sym|
93
+ begin
94
+ attach_function sym, args[sym], retvals[sym]
95
+ rescue FFI::NotFoundError => error
96
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
97
+ end
98
+ end
99
+ end
100
+
101
+ end
102
+