SDLRuby 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -22
- data/LICENSE.txt +21 -21
- data/README.md +31 -31
- data/Rakefile +12 -12
- data/SDLRuby.gemspec +38 -0
- data/examples/alert.rb +8 -0
- data/examples/window.rb +7 -0
- data/lib/SDLRuby/event/accessor.rb +2 -2
- data/lib/SDLRuby/event.rb +101 -101
- data/lib/SDLRuby/image/include/SDL_image.h.rb +61 -61
- data/lib/SDLRuby/mixer/include/SDL_mixer.h.rb +95 -95
- data/lib/SDLRuby/rw_ops/rw_object.rb +34 -34
- data/lib/SDLRuby/rw_ops.rb +91 -91
- data/lib/SDLRuby/sdl/include/SDL.h.rb +44 -44
- data/lib/SDLRuby/sdl/include/SDL_audio.h.rb +160 -160
- data/lib/SDLRuby/sdl/include/SDL_blendmode.h.rb +30 -30
- data/lib/SDLRuby/sdl/include/SDL_clipboard.h.rb +10 -10
- data/lib/SDLRuby/sdl/include/SDL_config.h.rb +13 -13
- data/lib/SDLRuby/sdl/include/SDL_cpuinfo.h.rb +27 -27
- data/lib/SDLRuby/sdl/include/SDL_endian.h.rb +12 -12
- data/lib/SDLRuby/sdl/include/SDL_error.h.rb +28 -28
- data/lib/SDLRuby/sdl/include/SDL_events.h.rb +472 -472
- data/lib/SDLRuby/sdl/include/SDL_filesystem.h.rb +6 -6
- data/lib/SDLRuby/sdl/include/SDL_gamecontroller.h.rb +147 -147
- data/lib/SDLRuby/sdl/include/SDL_gesture.h.rb +12 -12
- data/lib/SDLRuby/sdl/include/SDL_guid.h.rb +13 -13
- data/lib/SDLRuby/sdl/include/SDL_hints.h.rb +199 -199
- data/lib/SDLRuby/sdl/include/SDL_joystick.h.rb +131 -131
- data/lib/SDLRuby/sdl/include/SDL_keyboard.h.rb +35 -35
- data/lib/SDLRuby/sdl/include/SDL_keycode.h.rb +292 -292
- data/lib/SDLRuby/sdl/include/SDL_locale.h.rb +13 -13
- data/lib/SDLRuby/sdl/include/SDL_main.h.rb +3 -3
- data/lib/SDLRuby/sdl/include/SDL_messagebox.h.rb +58 -58
- data/lib/SDLRuby/sdl/include/SDL_misc.h.rb +5 -5
- data/lib/SDLRuby/sdl/include/SDL_mouse.h.rb +57 -57
- data/lib/SDLRuby/sdl/include/SDL_pixels.h.rb +285 -285
- data/lib/SDLRuby/sdl/include/SDL_platform.h.rb +3 -3
- data/lib/SDLRuby/sdl/include/SDL_power.h.rb +6 -6
- data/lib/SDLRuby/sdl/include/SDL_rect.h.rb +46 -46
- data/lib/SDLRuby/sdl/include/SDL_render.h.rb +131 -131
- data/lib/SDLRuby/sdl/include/SDL_revision.h.rb +2 -2
- data/lib/SDLRuby/sdl/include/SDL_rwops.h.rb +78 -78
- data/lib/SDLRuby/sdl/include/SDL_scancode.h.rb +252 -252
- data/lib/SDLRuby/sdl/include/SDL_sensor.h.rb +25 -25
- data/lib/SDLRuby/sdl/include/SDL_shape.h.rb +40 -40
- data/lib/SDLRuby/sdl/include/SDL_stdinc.h.rb +62 -62
- data/lib/SDLRuby/sdl/include/SDL_surface.h.rb +100 -100
- data/lib/SDLRuby/sdl/include/SDL_system.h.rb +6 -6
- data/lib/SDLRuby/sdl/include/SDL_syswm.h.rb +10 -10
- data/lib/SDLRuby/sdl/include/SDL_timer.h.rb +21 -21
- data/lib/SDLRuby/sdl/include/SDL_touch.h.rb +15 -15
- data/lib/SDLRuby/sdl/include/SDL_types.h.rb +3 -3
- data/lib/SDLRuby/sdl/include/SDL_version.h.rb +14 -14
- data/lib/SDLRuby/sdl/include/SDL_video.h.rb +264 -264
- data/lib/SDLRuby/sdl.rb +218 -218
- data/lib/SDLRuby/ttf/include/SDL_ttf.h.rb +54 -54
- data/lib/SDLRuby/version.rb +5 -5
- data/lib/SDLRuby/window/surfacer.rb +37 -37
- data/lib/SDLRuby.rb +32 -16
- data/sig/SDLRuby.rbs +4 -4
- data/sig/lib/SDLRuby/event/accessor.rbs +157 -157
- data/sig/lib/SDLRuby/event/type.rbs +67 -67
- data/sig/lib/SDLRuby/event.rbs +47 -47
- data/sig/lib/SDLRuby/keyboard.rbs +25 -25
- data/sig/lib/SDLRuby/mouse.rbs +35 -35
- data/sig/lib/SDLRuby/sdl.rbs +655 -655
- data/sig/lib/SDLRuby/timer.rbs +7 -7
- metadata +6 -3
data/lib/SDLRuby/sdl.rb
CHANGED
@@ -1,218 +1,218 @@
|
|
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 = 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 'timer'
|
54
|
-
require_relative 'window'
|
55
|
-
|
56
|
-
class << self
|
57
|
-
# sdl
|
58
|
-
#
|
59
|
-
def init(flags = nil)
|
60
|
-
err = SDL.SDL_Init(flags || SDL_INIT_EVERYTHING)
|
61
|
-
raise SDLError if err < 0
|
62
|
-
end
|
63
|
-
|
64
|
-
# Description:
|
65
|
-
#
|
66
|
-
# This method checks the initialization status of SDL subsystems based on
|
67
|
-
# the provided flags. You can specify the SDL subsystems you want to check
|
68
|
-
# by combining the SDL_INIT_* flags using bitwise OR.
|
69
|
-
#
|
70
|
-
# Parameters:
|
71
|
-
#
|
72
|
-
# flags (optional): An integer or a combination of SDL_INIT_* flags
|
73
|
-
# representing the SDL subsystems to check. Default is nil.
|
74
|
-
#
|
75
|
-
# Return Value:
|
76
|
-
#
|
77
|
-
# If all the specified SDL subsystems in flags are initialized,
|
78
|
-
# the method returns true.
|
79
|
-
# If any of the specified SDL subsystems are not initialized,
|
80
|
-
# it returns false.
|
81
|
-
# If flags is given as nil or 0,
|
82
|
-
# the method returns true if any of the SDL subsystems are initialized.
|
83
|
-
#
|
84
|
-
def init?(flags = nil)
|
85
|
-
if flags && flags != 0
|
86
|
-
SDL.SDL_WasInit(flags) == flags
|
87
|
-
else
|
88
|
-
SDL.SDL_WasInit(0) != 0
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def quit = SDL.SDL_Quit
|
93
|
-
|
94
|
-
# clipboard
|
95
|
-
#
|
96
|
-
def clipboard_text
|
97
|
-
ptr = SDL.SDL_GetClipboardText
|
98
|
-
raise SDLError if ptr.null?
|
99
|
-
|
100
|
-
ptr.free = SDL_FREE
|
101
|
-
ptr.to_s.force_encoding("UTF-8")
|
102
|
-
end
|
103
|
-
|
104
|
-
def clipboard_text? = SDL.SDL_HasClipboardText == 1
|
105
|
-
|
106
|
-
def clipboard_text=(s)
|
107
|
-
err = SDL.SDL_SetClipboardText(s.to_s.encode("UTF-8"))
|
108
|
-
raise SDLError if err < 0
|
109
|
-
end
|
110
|
-
|
111
|
-
# cpu info
|
112
|
-
#
|
113
|
-
def cpu_cache_line_size = SDL.SDL_GetCPUCacheLineSize
|
114
|
-
|
115
|
-
def cpu_count = SDL.SDL_GetCPUCount
|
116
|
-
|
117
|
-
def system_ram = SDL.SDL_GetSystemRAM
|
118
|
-
|
119
|
-
# error
|
120
|
-
#
|
121
|
-
def last_error_message = SDL.SDL_GetError.to_s
|
122
|
-
|
123
|
-
def last_error_message=(s)
|
124
|
-
SDL.SDL_SetError(s.to_s.gsub(/%/, "%%"))
|
125
|
-
end
|
126
|
-
|
127
|
-
# filesystem
|
128
|
-
#
|
129
|
-
def base_path
|
130
|
-
ptr = SDL.SDL_GetBasePath
|
131
|
-
raise SDLError if ptr.null?
|
132
|
-
|
133
|
-
ptr.free = SDL_FREE
|
134
|
-
ptr.to_s
|
135
|
-
end
|
136
|
-
|
137
|
-
# locale
|
138
|
-
#
|
139
|
-
def locales
|
140
|
-
ptr = SDL.SDL_GetPreferredLocales
|
141
|
-
return [] if ptr.null?
|
142
|
-
|
143
|
-
ptr.free = SDL_FREE
|
144
|
-
size = SDL_Locale.size
|
145
|
-
(0..).inject([]) do |memo, i|
|
146
|
-
st = SDL_Locale.new(ptr + i * size)
|
147
|
-
break memo if st.language.null?
|
148
|
-
memo << [st.language.to_s,
|
149
|
-
(c = st.country).null? ? nil : c.to_s]
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# message box
|
154
|
-
#
|
155
|
-
def alert(message, title = nil, flags: nil, window: nil)
|
156
|
-
err = SDL.SDL_ShowSimpleMessageBox(flags,
|
157
|
-
title.to_s.encode("UTF-8"),
|
158
|
-
message.to_s.encode("UTF-8"),
|
159
|
-
window)
|
160
|
-
raise SDLError if err < 0
|
161
|
-
end
|
162
|
-
|
163
|
-
def error_alert(message, title = "Error")
|
164
|
-
alert(message, title, flags: SDL_MESSAGEBOX_ERROR)
|
165
|
-
end
|
166
|
-
|
167
|
-
def warn_alert(message, title = "Warning")
|
168
|
-
alert(message, title, flags: SDL_MESSAGEBOX_WARNING)
|
169
|
-
end
|
170
|
-
|
171
|
-
def info_alert(message, title = "Information")
|
172
|
-
alert(message, title, flags: SDL_MESSAGEBOX_INFORMATION)
|
173
|
-
end
|
174
|
-
|
175
|
-
# misc
|
176
|
-
#
|
177
|
-
def open_url(url)
|
178
|
-
raise SDLError if SDL.SDL_OpenURL(url) < 0
|
179
|
-
end
|
180
|
-
|
181
|
-
# platform
|
182
|
-
#
|
183
|
-
def platform = SDL.SDL_GetPlatform.to_s
|
184
|
-
|
185
|
-
# timer
|
186
|
-
#
|
187
|
-
def ticks = Timer.ticks
|
188
|
-
|
189
|
-
# version
|
190
|
-
#
|
191
|
-
def revision = SDL.SDL_GetRevision.to_s
|
192
|
-
|
193
|
-
def version
|
194
|
-
st = SDL_version.malloc(Fiddle::RUBY_FREE)
|
195
|
-
SDL.SDL_GetVersion(st)
|
196
|
-
st.to_a.join(".")
|
197
|
-
end
|
198
|
-
|
199
|
-
# video
|
200
|
-
#
|
201
|
-
def video_driver
|
202
|
-
(ptr = SDL.SDL_GetCurrentVideoDriver).null? ? nil : ptr.to_s
|
203
|
-
end
|
204
|
-
|
205
|
-
def screen_saver=(b)
|
206
|
-
b ? SDL.SDL_EnableScreenSaver : SDL.SDL_DisableScreenSaver
|
207
|
-
end
|
208
|
-
|
209
|
-
def screen_saver? = SDL.SDL_IsScreenSaverEnabled != 0
|
210
|
-
|
211
|
-
def video_drivers
|
212
|
-
SDL.SDL_GetNumVideoDrivers.times.map do |i|
|
213
|
-
(ptr = SDL.SDL_GetVideoDriver(i)).null? ? nil : ptr.to_s
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
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 = 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 'timer'
|
54
|
+
require_relative 'window'
|
55
|
+
|
56
|
+
class << self
|
57
|
+
# sdl
|
58
|
+
#
|
59
|
+
def init(flags = nil)
|
60
|
+
err = SDL.SDL_Init(flags || SDL_INIT_EVERYTHING)
|
61
|
+
raise SDLError if err < 0
|
62
|
+
end
|
63
|
+
|
64
|
+
# Description:
|
65
|
+
#
|
66
|
+
# This method checks the initialization status of SDL subsystems based on
|
67
|
+
# the provided flags. You can specify the SDL subsystems you want to check
|
68
|
+
# by combining the SDL_INIT_* flags using bitwise OR.
|
69
|
+
#
|
70
|
+
# Parameters:
|
71
|
+
#
|
72
|
+
# flags (optional): An integer or a combination of SDL_INIT_* flags
|
73
|
+
# representing the SDL subsystems to check. Default is nil.
|
74
|
+
#
|
75
|
+
# Return Value:
|
76
|
+
#
|
77
|
+
# If all the specified SDL subsystems in flags are initialized,
|
78
|
+
# the method returns true.
|
79
|
+
# If any of the specified SDL subsystems are not initialized,
|
80
|
+
# it returns false.
|
81
|
+
# If flags is given as nil or 0,
|
82
|
+
# the method returns true if any of the SDL subsystems are initialized.
|
83
|
+
#
|
84
|
+
def init?(flags = nil)
|
85
|
+
if flags && flags != 0
|
86
|
+
SDL.SDL_WasInit(flags) == flags
|
87
|
+
else
|
88
|
+
SDL.SDL_WasInit(0) != 0
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def quit = SDL.SDL_Quit
|
93
|
+
|
94
|
+
# clipboard
|
95
|
+
#
|
96
|
+
def clipboard_text
|
97
|
+
ptr = SDL.SDL_GetClipboardText
|
98
|
+
raise SDLError if ptr.null?
|
99
|
+
|
100
|
+
ptr.free = SDL_FREE
|
101
|
+
ptr.to_s.force_encoding("UTF-8")
|
102
|
+
end
|
103
|
+
|
104
|
+
def clipboard_text? = SDL.SDL_HasClipboardText == 1
|
105
|
+
|
106
|
+
def clipboard_text=(s)
|
107
|
+
err = SDL.SDL_SetClipboardText(s.to_s.encode("UTF-8"))
|
108
|
+
raise SDLError if err < 0
|
109
|
+
end
|
110
|
+
|
111
|
+
# cpu info
|
112
|
+
#
|
113
|
+
def cpu_cache_line_size = SDL.SDL_GetCPUCacheLineSize
|
114
|
+
|
115
|
+
def cpu_count = SDL.SDL_GetCPUCount
|
116
|
+
|
117
|
+
def system_ram = SDL.SDL_GetSystemRAM
|
118
|
+
|
119
|
+
# error
|
120
|
+
#
|
121
|
+
def last_error_message = SDL.SDL_GetError.to_s
|
122
|
+
|
123
|
+
def last_error_message=(s)
|
124
|
+
SDL.SDL_SetError(s.to_s.gsub(/%/, "%%"))
|
125
|
+
end
|
126
|
+
|
127
|
+
# filesystem
|
128
|
+
#
|
129
|
+
def base_path
|
130
|
+
ptr = SDL.SDL_GetBasePath
|
131
|
+
raise SDLError if ptr.null?
|
132
|
+
|
133
|
+
ptr.free = SDL_FREE
|
134
|
+
ptr.to_s
|
135
|
+
end
|
136
|
+
|
137
|
+
# locale
|
138
|
+
#
|
139
|
+
def locales
|
140
|
+
ptr = SDL.SDL_GetPreferredLocales
|
141
|
+
return [] if ptr.null?
|
142
|
+
|
143
|
+
ptr.free = SDL_FREE
|
144
|
+
size = SDL_Locale.size
|
145
|
+
(0..).inject([]) do |memo, i|
|
146
|
+
st = SDL_Locale.new(ptr + i * size)
|
147
|
+
break memo if st.language.null?
|
148
|
+
memo << [st.language.to_s,
|
149
|
+
(c = st.country).null? ? nil : c.to_s]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# message box
|
154
|
+
#
|
155
|
+
def alert(message, title = nil, flags: nil, window: nil)
|
156
|
+
err = SDL.SDL_ShowSimpleMessageBox(flags.to_i,
|
157
|
+
title.to_s.encode("UTF-8"),
|
158
|
+
message.to_s.encode("UTF-8"),
|
159
|
+
window)
|
160
|
+
raise SDLError if err < 0
|
161
|
+
end
|
162
|
+
|
163
|
+
def error_alert(message, title = "Error")
|
164
|
+
alert(message, title, flags: SDL_MESSAGEBOX_ERROR)
|
165
|
+
end
|
166
|
+
|
167
|
+
def warn_alert(message, title = "Warning")
|
168
|
+
alert(message, title, flags: SDL_MESSAGEBOX_WARNING)
|
169
|
+
end
|
170
|
+
|
171
|
+
def info_alert(message, title = "Information")
|
172
|
+
alert(message, title, flags: SDL_MESSAGEBOX_INFORMATION)
|
173
|
+
end
|
174
|
+
|
175
|
+
# misc
|
176
|
+
#
|
177
|
+
def open_url(url)
|
178
|
+
raise SDLError if SDL.SDL_OpenURL(url) < 0
|
179
|
+
end
|
180
|
+
|
181
|
+
# platform
|
182
|
+
#
|
183
|
+
def platform = SDL.SDL_GetPlatform.to_s
|
184
|
+
|
185
|
+
# timer
|
186
|
+
#
|
187
|
+
def ticks = Timer.ticks
|
188
|
+
|
189
|
+
# version
|
190
|
+
#
|
191
|
+
def revision = SDL.SDL_GetRevision.to_s
|
192
|
+
|
193
|
+
def version
|
194
|
+
st = SDL_version.malloc(Fiddle::RUBY_FREE)
|
195
|
+
SDL.SDL_GetVersion(st)
|
196
|
+
st.to_a.join(".")
|
197
|
+
end
|
198
|
+
|
199
|
+
# video
|
200
|
+
#
|
201
|
+
def video_driver
|
202
|
+
(ptr = SDL.SDL_GetCurrentVideoDriver).null? ? nil : ptr.to_s
|
203
|
+
end
|
204
|
+
|
205
|
+
def screen_saver=(b)
|
206
|
+
b ? SDL.SDL_EnableScreenSaver : SDL.SDL_DisableScreenSaver
|
207
|
+
end
|
208
|
+
|
209
|
+
def screen_saver? = SDL.SDL_IsScreenSaverEnabled != 0
|
210
|
+
|
211
|
+
def video_drivers
|
212
|
+
SDL.SDL_GetNumVideoDrivers.times.map do |i|
|
213
|
+
(ptr = SDL.SDL_GetVideoDriver(i)).null? ? nil : ptr.to_s
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -1,54 +1,54 @@
|
|
1
|
-
module SDLRuby::TTF
|
2
|
-
typealias "TTF_Font", "struct _TTF_Font"
|
3
|
-
typealias "TTF_Direction", "int"
|
4
|
-
extern "const SDL_version * TTF_Linked_Version(void)"
|
5
|
-
extern "void TTF_GetFreeTypeVersion(int *major, int *minor, int *patch)"
|
6
|
-
extern "void TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch)"
|
7
|
-
extern "void TTF_ByteSwappedUNICODE(SDL_bool swapped)"
|
8
|
-
extern "int TTF_Init(void)"
|
9
|
-
extern "TTF_Font * TTF_OpenFont(const char *file, int ptsize)"
|
10
|
-
extern "TTF_Font * TTF_OpenFontIndex(const char *file, int ptsize, long index)"
|
11
|
-
extern "TTF_Font * TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize)"
|
12
|
-
extern "TTF_Font * TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index)"
|
13
|
-
extern "TTF_Font * TTF_OpenFontDPI(const char *file, int ptsize, unsigned int hdpi, unsigned int vdpi)"
|
14
|
-
extern "TTF_Font * TTF_OpenFontIndexDPI(const char *file, int ptsize, long index, unsigned int hdpi, unsigned int vdpi)"
|
15
|
-
extern "TTF_Font * TTF_OpenFontDPIRW(SDL_RWops *src, int freesrc, int ptsize, unsigned int hdpi, unsigned int vdpi)"
|
16
|
-
extern "TTF_Font * TTF_OpenFontIndexDPIRW(SDL_RWops *src, int freesrc, int ptsize, long index, unsigned int hdpi, unsigned int vdpi)"
|
17
|
-
extern "int TTF_SetFontSize(TTF_Font *font, int ptsize)"
|
18
|
-
extern "int TTF_SetFontSizeDPI(TTF_Font *font, int ptsize, unsigned int hdpi, unsigned int vdpi)"
|
19
|
-
extern "int TTF_GetFontStyle(const TTF_Font *font)"
|
20
|
-
extern "void TTF_SetFontStyle(TTF_Font *font, int style)"
|
21
|
-
extern "int TTF_GetFontOutline(const TTF_Font *font)"
|
22
|
-
extern "void TTF_SetFontOutline(TTF_Font *font, int outline)"
|
23
|
-
extern "int TTF_GetFontHinting(const TTF_Font *font)"
|
24
|
-
extern "void TTF_SetFontHinting(TTF_Font *font, int hinting)"
|
25
|
-
extern "int TTF_GetFontWrappedAlign(const TTF_Font *font)"
|
26
|
-
extern "void TTF_SetFontWrappedAlign(TTF_Font *font, int align)"
|
27
|
-
extern "int TTF_FontHeight(const TTF_Font *font)"
|
28
|
-
extern "int TTF_FontAscent(const TTF_Font *font)"
|
29
|
-
extern "int TTF_FontDescent(const TTF_Font *font)"
|
30
|
-
extern "int TTF_FontLineSkip(const TTF_Font *font)"
|
31
|
-
extern "int TTF_GetFontKerning(const TTF_Font *font)"
|
32
|
-
extern "void TTF_SetFontKerning(TTF_Font *font, int allowed)"
|
33
|
-
extern "long TTF_FontFaces(const TTF_Font *font)"
|
34
|
-
extern "int TTF_FontFaceIsFixedWidth(const TTF_Font *font)"
|
35
|
-
extern "const char * TTF_FontFaceFamilyName(const TTF_Font *font)"
|
36
|
-
extern "const char * TTF_FontFaceStyleName(const TTF_Font *font)"
|
37
|
-
extern "int TTF_GlyphIsProvided32(TTF_Font *font, Uint32 ch)"
|
38
|
-
extern "int TTF_GlyphMetrics32(TTF_Font *font, Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance)"
|
39
|
-
extern "int TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h)"
|
40
|
-
extern "int TTF_MeasureUTF8(TTF_Font *font, const char *text, int measure_width, int *extent, int *count)"
|
41
|
-
extern "SDL_Surface * TTF_RenderUTF8_Solid(TTF_Font *font, const char *text, SDL_Color fg)"
|
42
|
-
extern "SDL_Surface * TTF_RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength)"
|
43
|
-
extern "SDL_Surface * TTF_RenderUTF8_Shaded(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg)"
|
44
|
-
extern "SDL_Surface * TTF_RenderUTF8_Shaded_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength)"
|
45
|
-
extern "SDL_Surface * TTF_RenderUTF8_Blended(TTF_Font *font, const char *text, SDL_Color fg)"
|
46
|
-
extern "SDL_Surface * TTF_RenderUTF8_Blended_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength)"
|
47
|
-
extern "SDL_Surface * TTF_RenderUTF8_LCD(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg)"
|
48
|
-
extern "SDL_Surface * TTF_RenderUTF8_LCD_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength)"
|
49
|
-
extern "void TTF_CloseFont(TTF_Font *font)"
|
50
|
-
extern "void TTF_Quit(void)"
|
51
|
-
extern "int TTF_WasInit(void)"
|
52
|
-
extern "int TTF_SetFontDirection(TTF_Font *font, TTF_Direction direction)"
|
53
|
-
extern "int TTF_SetFontScriptName(TTF_Font *font, const char *script)"
|
54
|
-
end
|
1
|
+
module SDLRuby::TTF
|
2
|
+
typealias "TTF_Font", "struct _TTF_Font"
|
3
|
+
typealias "TTF_Direction", "int"
|
4
|
+
extern "const SDL_version * TTF_Linked_Version(void)"
|
5
|
+
extern "void TTF_GetFreeTypeVersion(int *major, int *minor, int *patch)"
|
6
|
+
extern "void TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch)"
|
7
|
+
extern "void TTF_ByteSwappedUNICODE(SDL_bool swapped)"
|
8
|
+
extern "int TTF_Init(void)"
|
9
|
+
extern "TTF_Font * TTF_OpenFont(const char *file, int ptsize)"
|
10
|
+
extern "TTF_Font * TTF_OpenFontIndex(const char *file, int ptsize, long index)"
|
11
|
+
extern "TTF_Font * TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize)"
|
12
|
+
extern "TTF_Font * TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index)"
|
13
|
+
extern "TTF_Font * TTF_OpenFontDPI(const char *file, int ptsize, unsigned int hdpi, unsigned int vdpi)"
|
14
|
+
extern "TTF_Font * TTF_OpenFontIndexDPI(const char *file, int ptsize, long index, unsigned int hdpi, unsigned int vdpi)"
|
15
|
+
extern "TTF_Font * TTF_OpenFontDPIRW(SDL_RWops *src, int freesrc, int ptsize, unsigned int hdpi, unsigned int vdpi)"
|
16
|
+
extern "TTF_Font * TTF_OpenFontIndexDPIRW(SDL_RWops *src, int freesrc, int ptsize, long index, unsigned int hdpi, unsigned int vdpi)"
|
17
|
+
extern "int TTF_SetFontSize(TTF_Font *font, int ptsize)"
|
18
|
+
extern "int TTF_SetFontSizeDPI(TTF_Font *font, int ptsize, unsigned int hdpi, unsigned int vdpi)"
|
19
|
+
extern "int TTF_GetFontStyle(const TTF_Font *font)"
|
20
|
+
extern "void TTF_SetFontStyle(TTF_Font *font, int style)"
|
21
|
+
extern "int TTF_GetFontOutline(const TTF_Font *font)"
|
22
|
+
extern "void TTF_SetFontOutline(TTF_Font *font, int outline)"
|
23
|
+
extern "int TTF_GetFontHinting(const TTF_Font *font)"
|
24
|
+
extern "void TTF_SetFontHinting(TTF_Font *font, int hinting)"
|
25
|
+
extern "int TTF_GetFontWrappedAlign(const TTF_Font *font)"
|
26
|
+
extern "void TTF_SetFontWrappedAlign(TTF_Font *font, int align)"
|
27
|
+
extern "int TTF_FontHeight(const TTF_Font *font)"
|
28
|
+
extern "int TTF_FontAscent(const TTF_Font *font)"
|
29
|
+
extern "int TTF_FontDescent(const TTF_Font *font)"
|
30
|
+
extern "int TTF_FontLineSkip(const TTF_Font *font)"
|
31
|
+
extern "int TTF_GetFontKerning(const TTF_Font *font)"
|
32
|
+
extern "void TTF_SetFontKerning(TTF_Font *font, int allowed)"
|
33
|
+
extern "long TTF_FontFaces(const TTF_Font *font)"
|
34
|
+
extern "int TTF_FontFaceIsFixedWidth(const TTF_Font *font)"
|
35
|
+
extern "const char * TTF_FontFaceFamilyName(const TTF_Font *font)"
|
36
|
+
extern "const char * TTF_FontFaceStyleName(const TTF_Font *font)"
|
37
|
+
extern "int TTF_GlyphIsProvided32(TTF_Font *font, Uint32 ch)"
|
38
|
+
extern "int TTF_GlyphMetrics32(TTF_Font *font, Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance)"
|
39
|
+
extern "int TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h)"
|
40
|
+
extern "int TTF_MeasureUTF8(TTF_Font *font, const char *text, int measure_width, int *extent, int *count)"
|
41
|
+
extern "SDL_Surface * TTF_RenderUTF8_Solid(TTF_Font *font, const char *text, SDL_Color fg)"
|
42
|
+
extern "SDL_Surface * TTF_RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength)"
|
43
|
+
extern "SDL_Surface * TTF_RenderUTF8_Shaded(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg)"
|
44
|
+
extern "SDL_Surface * TTF_RenderUTF8_Shaded_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength)"
|
45
|
+
extern "SDL_Surface * TTF_RenderUTF8_Blended(TTF_Font *font, const char *text, SDL_Color fg)"
|
46
|
+
extern "SDL_Surface * TTF_RenderUTF8_Blended_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength)"
|
47
|
+
extern "SDL_Surface * TTF_RenderUTF8_LCD(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg)"
|
48
|
+
extern "SDL_Surface * TTF_RenderUTF8_LCD_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength)"
|
49
|
+
extern "void TTF_CloseFont(TTF_Font *font)"
|
50
|
+
extern "void TTF_Quit(void)"
|
51
|
+
extern "int TTF_WasInit(void)"
|
52
|
+
extern "int TTF_SetFontDirection(TTF_Font *font, TTF_Direction direction)"
|
53
|
+
extern "int TTF_SetFontScriptName(TTF_Font *font, const char *script)"
|
54
|
+
end
|
data/lib/SDLRuby/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SDLRuby
|
4
|
-
VERSION = "0.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SDLRuby
|
4
|
+
VERSION = "0.4.0"
|
5
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
module SDLRuby
|
2
|
-
class Window
|
3
|
-
module Surfacer
|
4
|
-
include SDL
|
5
|
-
|
6
|
-
def destroy_surface
|
7
|
-
err = SDL.SDL_DestroyWindowSurface(self)
|
8
|
-
raise SDLError if err < 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def surface
|
12
|
-
ptr = SDL.SDL_GetWindowSurface(self)
|
13
|
-
raise SDLError if ptr.null?
|
14
|
-
|
15
|
-
# ウィンドウからのサーフェスにはSDL_DONTFREEフラグが設定されている。
|
16
|
-
# このためにSDL_FreeSurfaceではリファレンスカウンターを減じる事ができない。
|
17
|
-
# これはRubyのGC管理では問題になる(メモリーリークする)。
|
18
|
-
# そのためSDL_DONTFREEフラグを解除する!
|
19
|
-
#
|
20
|
-
st = SDL_Surface.new(ptr)
|
21
|
-
st.flags &= ~SDL_DONTFREE
|
22
|
-
|
23
|
-
Surface.new(ptr, add_ref: true)
|
24
|
-
end
|
25
|
-
|
26
|
-
# ウィンドウのサーフェスがvalidかどうか確認していない。
|
27
|
-
# リサイズなどで壊れていてもtrueを戻す。
|
28
|
-
#
|
29
|
-
def surface? = SDL.SDL_HasWindowSurface(self) == 1
|
30
|
-
|
31
|
-
def update_surface
|
32
|
-
err = SDL.SDL_UpdateWindowSurface(self)
|
33
|
-
raise SDLError if err < 0
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
module SDLRuby
|
2
|
+
class Window
|
3
|
+
module Surfacer
|
4
|
+
include SDL
|
5
|
+
|
6
|
+
def destroy_surface
|
7
|
+
err = SDL.SDL_DestroyWindowSurface(self)
|
8
|
+
raise SDLError if err < 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def surface
|
12
|
+
ptr = SDL.SDL_GetWindowSurface(self)
|
13
|
+
raise SDLError if ptr.null?
|
14
|
+
|
15
|
+
# ウィンドウからのサーフェスにはSDL_DONTFREEフラグが設定されている。
|
16
|
+
# このためにSDL_FreeSurfaceではリファレンスカウンターを減じる事ができない。
|
17
|
+
# これはRubyのGC管理では問題になる(メモリーリークする)。
|
18
|
+
# そのためSDL_DONTFREEフラグを解除する!
|
19
|
+
#
|
20
|
+
st = SDL_Surface.new(ptr)
|
21
|
+
st.flags &= ~SDL_DONTFREE
|
22
|
+
|
23
|
+
Surface.new(ptr, add_ref: true)
|
24
|
+
end
|
25
|
+
|
26
|
+
# ウィンドウのサーフェスがvalidかどうか確認していない。
|
27
|
+
# リサイズなどで壊れていてもtrueを戻す。
|
28
|
+
#
|
29
|
+
def surface? = SDL.SDL_HasWindowSurface(self) == 1
|
30
|
+
|
31
|
+
def update_surface
|
32
|
+
err = SDL.SDL_UpdateWindowSurface(self)
|
33
|
+
raise SDLError if err < 0
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|