sdl2-bindings 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +134 -108
- data/LICENSE.txt +0 -0
- data/README.md +86 -68
- data/lib/sdl2.rb +131 -127
- data/lib/sdl2_audio.rb +261 -261
- data/lib/sdl2_blendmode.rb +72 -72
- data/lib/sdl2_clipboard.rb +56 -56
- data/lib/sdl2_cpuinfo.rb +129 -129
- data/lib/sdl2_error.rb +71 -71
- data/lib/sdl2_events.rb +564 -552
- data/lib/sdl2_filesystem.rb +52 -52
- data/lib/sdl2_framerate.rb +74 -74
- data/lib/sdl2_gamecontroller.rb +329 -329
- data/lib/sdl2_gesture.rb +61 -61
- data/lib/sdl2_gfxPrimitives.rb +283 -283
- data/lib/sdl2_haptic.rb +301 -301
- data/lib/sdl2_hidapi.rb +139 -139
- data/lib/sdl2_hints.rb +221 -207
- data/lib/sdl2_image.rb +296 -232
- data/lib/sdl2_imageFilter.rb +164 -164
- data/lib/sdl2_joystick.rb +294 -294
- data/lib/sdl2_keyboard.rb +125 -117
- data/lib/sdl2_keycode.rb +307 -307
- data/lib/sdl2_log.rb +131 -131
- data/lib/sdl2_main.rb +74 -74
- data/lib/sdl2_messagebox.rb +102 -102
- data/lib/sdl2_misc.rb +48 -48
- data/lib/sdl2_mixer.rb +464 -392
- data/lib/sdl2_mouse.rb +136 -136
- data/lib/sdl2_pixels.rb +240 -240
- data/lib/sdl2_platform.rb +48 -48
- data/lib/sdl2_power.rb +54 -54
- data/lib/sdl2_rect.rb +145 -109
- data/lib/sdl2_render.rb +408 -404
- data/lib/sdl2_rotozoom.rb +76 -76
- data/lib/sdl2_rwops.rb +242 -238
- data/lib/sdl2_scancode.rb +289 -289
- data/lib/sdl2_sensor.rb +115 -115
- data/lib/sdl2_shape.rb +83 -83
- data/lib/sdl2_sound.rb +154 -0
- data/lib/sdl2_stdinc.rb +548 -564
- data/lib/sdl2_surface.rb +229 -229
- data/lib/sdl2_syswm.rb +160 -160
- data/lib/sdl2_timer.rb +74 -74
- data/lib/sdl2_touch.rb +86 -82
- data/lib/sdl2_ttf.rb +414 -357
- data/lib/sdl2_version.rb +67 -67
- data/lib/sdl2_video.rb +540 -540
- data/lib/sdl2_vulkan.rb +72 -72
- metadata +3 -2
data/lib/sdl2_rect.rb
CHANGED
@@ -1,109 +1,145 @@
|
|
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
|
-
|
17
|
-
# Typedef
|
18
|
-
|
19
|
-
|
20
|
-
def self.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 self.RectEmpty(r)
|
25
|
-
return (!r.null? || (r.w <= 0) || (r.h <= 0)) ? 1 : 0
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.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 Point < FFI::Struct
|
36
|
-
layout(
|
37
|
-
:x, :int,
|
38
|
-
:y, :int,
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
class FPoint < FFI::Struct
|
43
|
-
layout(
|
44
|
-
:x, :float,
|
45
|
-
:y, :float,
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
class Rect < FFI::Struct
|
50
|
-
layout(
|
51
|
-
:x, :int,
|
52
|
-
:y, :int,
|
53
|
-
:w, :int,
|
54
|
-
:h, :int,
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
class 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(output_error = false)
|
71
|
-
symbols = [
|
72
|
-
:SDL_HasIntersection,
|
73
|
-
:SDL_IntersectRect,
|
74
|
-
:SDL_UnionRect,
|
75
|
-
:SDL_EnclosePoints,
|
76
|
-
:SDL_IntersectRectAndLine,
|
77
|
-
|
78
|
-
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
|
92
|
-
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
+
|
17
|
+
# Typedef
|
18
|
+
|
19
|
+
|
20
|
+
def self.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 self.RectEmpty(r)
|
25
|
+
return (!r.null? || (r.w <= 0) || (r.h <= 0)) ? 1 : 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.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 Point < FFI::Struct
|
36
|
+
layout(
|
37
|
+
:x, :int,
|
38
|
+
:y, :int,
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
class FPoint < FFI::Struct
|
43
|
+
layout(
|
44
|
+
:x, :float,
|
45
|
+
:y, :float,
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
class Rect < FFI::Struct
|
50
|
+
layout(
|
51
|
+
:x, :int,
|
52
|
+
:y, :int,
|
53
|
+
:w, :int,
|
54
|
+
:h, :int,
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
class 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(output_error = false)
|
71
|
+
symbols = [
|
72
|
+
:SDL_HasIntersection,
|
73
|
+
:SDL_IntersectRect,
|
74
|
+
:SDL_UnionRect,
|
75
|
+
:SDL_EnclosePoints,
|
76
|
+
:SDL_IntersectRectAndLine,
|
77
|
+
:SDL_PointInFRect,
|
78
|
+
:SDL_FRectEmpty,
|
79
|
+
:SDL_FRectEqualsEpsilon,
|
80
|
+
:SDL_FRectEquals,
|
81
|
+
:SDL_HasIntersectionF,
|
82
|
+
:SDL_IntersectFRect,
|
83
|
+
:SDL_UnionFRect,
|
84
|
+
:SDL_EncloseFPoints,
|
85
|
+
:SDL_IntersectFRectAndLine,
|
86
|
+
]
|
87
|
+
apis = {
|
88
|
+
:SDL_HasIntersection => :HasIntersection,
|
89
|
+
:SDL_IntersectRect => :IntersectRect,
|
90
|
+
:SDL_UnionRect => :UnionRect,
|
91
|
+
:SDL_EnclosePoints => :EnclosePoints,
|
92
|
+
:SDL_IntersectRectAndLine => :IntersectRectAndLine,
|
93
|
+
:SDL_PointInFRect => :PointInFRect,
|
94
|
+
:SDL_FRectEmpty => :FRectEmpty,
|
95
|
+
:SDL_FRectEqualsEpsilon => :FRectEqualsEpsilon,
|
96
|
+
:SDL_FRectEquals => :FRectEquals,
|
97
|
+
:SDL_HasIntersectionF => :HasIntersectionF,
|
98
|
+
:SDL_IntersectFRect => :IntersectFRect,
|
99
|
+
:SDL_UnionFRect => :UnionFRect,
|
100
|
+
:SDL_EncloseFPoints => :EncloseFPoints,
|
101
|
+
:SDL_IntersectFRectAndLine => :IntersectFRectAndLine,
|
102
|
+
}
|
103
|
+
args = {
|
104
|
+
:SDL_HasIntersection => [:pointer, :pointer],
|
105
|
+
:SDL_IntersectRect => [:pointer, :pointer, :pointer],
|
106
|
+
:SDL_UnionRect => [:pointer, :pointer, :pointer],
|
107
|
+
:SDL_EnclosePoints => [:pointer, :int, :pointer, :pointer],
|
108
|
+
:SDL_IntersectRectAndLine => [:pointer, :pointer, :pointer, :pointer, :pointer],
|
109
|
+
:SDL_PointInFRect => [:pointer, :pointer],
|
110
|
+
:SDL_FRectEmpty => [:pointer],
|
111
|
+
:SDL_FRectEqualsEpsilon => [:pointer, :pointer, :float],
|
112
|
+
:SDL_FRectEquals => [:pointer, :pointer],
|
113
|
+
:SDL_HasIntersectionF => [:pointer, :pointer],
|
114
|
+
:SDL_IntersectFRect => [:pointer, :pointer, :pointer],
|
115
|
+
:SDL_UnionFRect => [:pointer, :pointer, :pointer],
|
116
|
+
:SDL_EncloseFPoints => [:pointer, :int, :pointer, :pointer],
|
117
|
+
:SDL_IntersectFRectAndLine => [:pointer, :pointer, :pointer, :pointer, :pointer],
|
118
|
+
}
|
119
|
+
retvals = {
|
120
|
+
:SDL_HasIntersection => :int,
|
121
|
+
:SDL_IntersectRect => :int,
|
122
|
+
:SDL_UnionRect => :void,
|
123
|
+
:SDL_EnclosePoints => :int,
|
124
|
+
:SDL_IntersectRectAndLine => :int,
|
125
|
+
:SDL_PointInFRect => :int,
|
126
|
+
:SDL_FRectEmpty => :int,
|
127
|
+
:SDL_FRectEqualsEpsilon => :int,
|
128
|
+
:SDL_FRectEquals => :int,
|
129
|
+
:SDL_HasIntersectionF => :int,
|
130
|
+
:SDL_IntersectFRect => :int,
|
131
|
+
:SDL_UnionFRect => :void,
|
132
|
+
:SDL_EncloseFPoints => :int,
|
133
|
+
:SDL_IntersectFRectAndLine => :int,
|
134
|
+
}
|
135
|
+
symbols.each do |sym|
|
136
|
+
begin
|
137
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
138
|
+
rescue FFI::NotFoundError => error
|
139
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|