sdl2_ffi 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +31 -17
- data/bin/yard +16 -0
- data/bin/yardoc +16 -0
- data/bin/yri +16 -0
- data/graph +566 -0
- data/lib/enumerable_constants.rb +82 -0
- data/lib/sdl2.rb +74 -117
- data/lib/sdl2/audio.rb +10 -7
- data/lib/sdl2/clipboard.rb +3 -3
- data/lib/sdl2/events.rb +228 -168
- data/lib/sdl2/gem_version.rb +1 -1
- data/lib/sdl2/haptic.rb +366 -55
- data/lib/sdl2/hints.rb +36 -24
- data/lib/sdl2/image.rb +4 -10
- data/lib/sdl2/init.rb +21 -31
- data/lib/sdl2/joystick.rb +15 -12
- data/lib/sdl2/keycode.rb +261 -261
- data/lib/sdl2/library.rb +96 -0
- data/lib/sdl2/mouse.rb +22 -17
- data/lib/sdl2/pixel_format.rb +2 -1
- data/lib/sdl2/pixels.rb +114 -161
- data/lib/sdl2/rect.rb +14 -10
- data/lib/sdl2/render.rb +29 -13
- data/lib/sdl2/renderer.rb +9 -2
- data/lib/sdl2/rwops.rb +11 -7
- data/lib/sdl2/scancode.rb +246 -245
- data/lib/sdl2/stdinc.rb +213 -0
- data/lib/sdl2/surface.rb +23 -7
- data/lib/sdl2/ttf.rb +23 -19
- data/lib/sdl2/version.rb +8 -2
- data/lib/sdl2/video.rb +64 -73
- data/lib/sdl2/window.rb +143 -36
- data/lib/sdl2_ffi.rb +2 -1
- data/sdl2_ffi.gemspec +3 -1
- data/test/fixtures/an_example.png +0 -0
- data/test/fixtures/background.bmp +0 -0
- data/test/fixtures/hello.bmp +0 -0
- data/test/functional/examples/test_lazy_foo_examples.rb +123 -0
- data/test/functional/examples/test_readme_examples.rb +15 -0
- data/test/unit/sdl2/test_haptic.rb +17 -0
- data/test/unit/sdl2/test_hints.rb +9 -9
- data/test/unit/sdl2/test_init.rb +8 -8
- data/test/unit/sdl2/test_log.rb +1 -1
- data/test/unit/sdl2/test_pixel_format.rb +3 -1
- data/test/unit/sdl2/test_video.rb +3 -3
- data/test/unit/sdl2/test_window.rb +4 -4
- data/test/unit/test_scratch.rb +2 -2
- metadata +37 -16
@@ -7,4 +7,21 @@ describe 'SDL2' do
|
|
7
7
|
skip 'Not yet implemented'
|
8
8
|
end
|
9
9
|
|
10
|
+
it 'can run the documented example: Haptic Direction' do
|
11
|
+
direction = SDL2::Haptic::Direction.new
|
12
|
+
|
13
|
+
# Cartesian directions
|
14
|
+
direction.type = SDL2::Haptic::CARTESIAN # Using cartesian direction encoding.
|
15
|
+
direction.dir[0] = 0 # X position
|
16
|
+
direction.dir[1] = 1 # Y position
|
17
|
+
|
18
|
+
# Polar directions
|
19
|
+
direction.type = SDL2::Haptic::POLAR #We'll be using polar direction encoding.
|
20
|
+
direction.dir[0] = 18000 # Polar only uses first parameter
|
21
|
+
|
22
|
+
# Spherical coordinates
|
23
|
+
direction.type = SDL2::Haptic::SPHERICAL # Spherical encoding
|
24
|
+
direction.dir[0] = 9000 # Since we only have two axes we don't need more parameters
|
25
|
+
end
|
26
|
+
|
10
27
|
end
|
@@ -9,20 +9,20 @@ describe SDL2 do
|
|
9
9
|
assert_respond_to SDL2, :get_hint
|
10
10
|
assert_respond_to SDL2, :set_hint
|
11
11
|
|
12
|
-
assert_equal 'constant', defined?(SDL2::
|
13
|
-
assert_equal 'constant', defined?(SDL2::
|
14
|
-
assert_equal 'constant', defined?(SDL2::
|
15
|
-
assert_equal 'constant', defined?(SDL2::
|
16
|
-
assert_equal 'constant', defined?(SDL2::
|
17
|
-
assert_equal 'constant', defined?(SDL2::
|
18
|
-
assert_equal 'constant', defined?(SDL2::
|
12
|
+
assert_equal 'constant', defined?(SDL2::HINT::FRAMEBUFFER_ACCELERATION)
|
13
|
+
assert_equal 'constant', defined?(SDL2::HINT::IDLE_TIMER_DISABLED)
|
14
|
+
assert_equal 'constant', defined?(SDL2::HINT::ORIENTATIONS)
|
15
|
+
assert_equal 'constant', defined?(SDL2::HINT::RENDER_DRIVER)
|
16
|
+
assert_equal 'constant', defined?(SDL2::HINT::RENDER_OPENGL_SHADERS)
|
17
|
+
assert_equal 'constant', defined?(SDL2::HINT::RENDER_SCALE_QUALITY)
|
18
|
+
assert_equal 'constant', defined?(SDL2::HINT::RENDER_VSYNC)
|
19
19
|
|
20
|
-
|
20
|
+
assert SDL2.set_hint("My Hint", "My Value")
|
21
21
|
assert_kind_of String, SDL2.get_hint("My Hint")
|
22
22
|
assert_equal "My Value", SDL2.get_hint("My Hint")
|
23
23
|
|
24
24
|
[:default, :normal, :override].each do |priority|
|
25
|
-
|
25
|
+
assert SDL2.set_hint_with_priority("#{priority}Hint", "#{priority}Value", priority)
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/test/unit/sdl2/test_init.rb
CHANGED
@@ -9,17 +9,17 @@ describe SDL2 do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'can initialize everything' do
|
12
|
-
assert_equal SDL2.init(SDL2::
|
12
|
+
assert_equal SDL2.init(SDL2::INIT::EVERYTHING), 0
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'can initialize, check, and quit subsystems' do
|
16
|
-
assert_equal SDL2.init(SDL2::
|
17
|
-
assert SDL2.was_init(SDL2::
|
18
|
-
refute SDL2.was_init(SDL2::
|
19
|
-
assert_equal SDL2.init_sub_system(SDL2::
|
20
|
-
assert SDL2.was_init(SDL2::
|
21
|
-
SDL2.quit_sub_system(SDL2::
|
22
|
-
refute SDL2.was_init(SDL2::
|
16
|
+
assert_equal SDL2.init(SDL2::INIT::VIDEO), 0 # Only turn on video.
|
17
|
+
assert SDL2.was_init(SDL2::INIT::VIDEO) != 0, 'Video is initialized.'
|
18
|
+
refute SDL2.was_init(SDL2::INIT::AUDIO) != 0, 'Audio is not initialized'
|
19
|
+
assert_equal SDL2.init_sub_system(SDL2::INIT::AUDIO), 0 #Then turn on audio.
|
20
|
+
assert SDL2.was_init(SDL2::INIT::AUDIO) != 0, 'Audio is initialized.'
|
21
|
+
SDL2.quit_sub_system(SDL2::INIT::VIDEO)
|
22
|
+
refute SDL2.was_init(SDL2::INIT::VIDEO) != 0, 'Video is not initialized'
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'can quit' do
|
data/test/unit/sdl2/test_log.rb
CHANGED
@@ -24,9 +24,11 @@ describe SDL2::PixelFormat do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
|
-
it 'can get the name of all formats' do
|
27
|
+
it 'can get the name of all formats' do
|
28
|
+
|
28
29
|
SDL2::PIXELFORMAT.by_name.each_pair do |k,v|
|
29
30
|
name = SDL2::PixelFormat.get_name(v)
|
31
|
+
#binding.pry
|
30
32
|
assert_includes name, k.to_s
|
31
33
|
end
|
32
34
|
end
|
@@ -84,7 +84,7 @@ VIDEO_API = [
|
|
84
84
|
|
85
85
|
describe SDL2 do
|
86
86
|
before do
|
87
|
-
assert(SDL2.init(SDL2::
|
87
|
+
assert(SDL2.init(SDL2::INIT::VIDEO) == 0, 'Video initialized.')
|
88
88
|
end
|
89
89
|
|
90
90
|
after do
|
@@ -100,9 +100,9 @@ describe SDL2 do
|
|
100
100
|
|
101
101
|
it 'can manage the screen saver' do
|
102
102
|
SDL2.disable_screen_saver
|
103
|
-
refute SDL2.is_screen_saver_enabled
|
103
|
+
refute SDL2.is_screen_saver_enabled
|
104
104
|
SDL2.enable_screen_saver
|
105
|
-
assert SDL2.is_screen_saver_enabled
|
105
|
+
assert SDL2.is_screen_saver_enabled
|
106
106
|
end
|
107
107
|
|
108
108
|
describe SDL2::Window do
|
@@ -6,7 +6,7 @@ require 'sdl2/video'
|
|
6
6
|
describe SDL2::Window do
|
7
7
|
|
8
8
|
before do
|
9
|
-
@window = SDL2::Window.create
|
9
|
+
@window = SDL2::Window.create
|
10
10
|
end
|
11
11
|
|
12
12
|
after do
|
@@ -14,7 +14,7 @@ describe SDL2::Window do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'can be created' do
|
17
|
-
window = SDL2::Window.create
|
17
|
+
window = SDL2::Window.create('My Title', 10, 20, 300, 400)
|
18
18
|
assert_kind_of SDL2::Window, window
|
19
19
|
SDL2.destroy_window(window)
|
20
20
|
end
|
@@ -25,7 +25,7 @@ describe SDL2::Window do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'has a current_size' do
|
28
|
-
window = SDL2::Window.create
|
28
|
+
window = SDL2::Window.create('Title', 10, 20, 300, 400)
|
29
29
|
assert_equal [300, 400], window.current_size
|
30
30
|
window.current_size = [640, 480]
|
31
31
|
assert_equal [640, 480], window.current_size
|
@@ -109,7 +109,7 @@ describe SDL2::Window do
|
|
109
109
|
|
110
110
|
it 'can update the window surface' do
|
111
111
|
surface = @window.surface
|
112
|
-
assert_equal 0, @window.update_surface
|
112
|
+
assert_equal 0, @window.update_surface
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'can update surface rects' do
|
data/test/unit/test_scratch.rb
CHANGED
@@ -4,9 +4,9 @@ require 'sdl2'
|
|
4
4
|
require 'sdl2/video'
|
5
5
|
require 'sdl2/image'
|
6
6
|
|
7
|
-
class TestScratch < MiniTest::
|
7
|
+
class TestScratch < MiniTest::Test
|
8
8
|
def test_a_game
|
9
|
-
window = SDL2::Window.create
|
9
|
+
window = SDL2::Window.create("My Window", 0, 0, 300, 300)
|
10
10
|
win_surface = window.surface
|
11
11
|
|
12
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdl2_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BadQuanta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: yinum
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: activesupport
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +122,20 @@ dependencies:
|
|
136
122
|
- - '>='
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
139
|
description: 'Foreign Function Interface to SDL2 in Ruby '
|
140
140
|
email:
|
141
141
|
- BadQuanta@Gmail.com
|
@@ -145,6 +145,9 @@ executables:
|
|
145
145
|
- pry
|
146
146
|
- rake
|
147
147
|
- thor
|
148
|
+
- yard
|
149
|
+
- yardoc
|
150
|
+
- yri
|
148
151
|
extensions: []
|
149
152
|
extra_rdoc_files: []
|
150
153
|
files:
|
@@ -161,6 +164,11 @@ files:
|
|
161
164
|
- bin/pry
|
162
165
|
- bin/rake
|
163
166
|
- bin/thor
|
167
|
+
- bin/yard
|
168
|
+
- bin/yardoc
|
169
|
+
- bin/yri
|
170
|
+
- graph
|
171
|
+
- lib/enumerable_constants.rb
|
164
172
|
- lib/sdl2.rb
|
165
173
|
- lib/sdl2/assert.rb
|
166
174
|
- lib/sdl2/audio.rb
|
@@ -183,6 +191,7 @@ files:
|
|
183
191
|
- lib/sdl2/joystick.rb
|
184
192
|
- lib/sdl2/keyboard.rb
|
185
193
|
- lib/sdl2/keycode.rb
|
194
|
+
- lib/sdl2/library.rb
|
186
195
|
- lib/sdl2/log.rb
|
187
196
|
- lib/sdl2/mouse.rb
|
188
197
|
- lib/sdl2/palette.rb
|
@@ -197,6 +206,7 @@ files:
|
|
197
206
|
- lib/sdl2/rwops.rb
|
198
207
|
- lib/sdl2/scancode.rb
|
199
208
|
- lib/sdl2/sdl_module.rb
|
209
|
+
- lib/sdl2/stdinc.rb
|
200
210
|
- lib/sdl2/surface.rb
|
201
211
|
- lib/sdl2/syswm.rb
|
202
212
|
- lib/sdl2/syswm/info.rb
|
@@ -211,7 +221,12 @@ files:
|
|
211
221
|
- lib/sdl2/window.rb
|
212
222
|
- lib/sdl2_ffi.rb
|
213
223
|
- sdl2_ffi.gemspec
|
224
|
+
- test/fixtures/an_example.png
|
225
|
+
- test/fixtures/background.bmp
|
214
226
|
- test/fixtures/color_bars.jpg
|
227
|
+
- test/fixtures/hello.bmp
|
228
|
+
- test/functional/examples/test_lazy_foo_examples.rb
|
229
|
+
- test/functional/examples/test_readme_examples.rb
|
215
230
|
- test/test_helper.rb
|
216
231
|
- test/unit/sdl2/test_assert.rb
|
217
232
|
- test/unit/sdl2/test_audio.rb
|
@@ -265,7 +280,12 @@ signing_key:
|
|
265
280
|
specification_version: 4
|
266
281
|
summary: Object Oriented wrapper for SDL2. Help me test & debug my interface.
|
267
282
|
test_files:
|
283
|
+
- test/fixtures/an_example.png
|
284
|
+
- test/fixtures/background.bmp
|
268
285
|
- test/fixtures/color_bars.jpg
|
286
|
+
- test/fixtures/hello.bmp
|
287
|
+
- test/functional/examples/test_lazy_foo_examples.rb
|
288
|
+
- test/functional/examples/test_readme_examples.rb
|
269
289
|
- test/test_helper.rb
|
270
290
|
- test/unit/sdl2/test_assert.rb
|
271
291
|
- test/unit/sdl2/test_audio.rb
|
@@ -294,3 +314,4 @@ test_files:
|
|
294
314
|
- test/unit/sdl2/test_window.rb
|
295
315
|
- test/unit/test_scratch.rb
|
296
316
|
- test/unit/test_sdl2.rb
|
317
|
+
has_rdoc:
|