sdl2_ffi 0.0.6 → 0.0.7
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/.ruby-version +1 -1
- data/Gemfile +0 -6
- data/Guardfile +0 -45
- data/README.md +11 -21
- data/lib/bad_sdl.rb +4 -0
- data/lib/{sdl2 → bad_sdl}/application.rb +47 -35
- data/lib/{sdl2 → bad_sdl}/engine.rb +20 -3
- data/lib/{sdl2 → bad_sdl}/engine/block_engine.rb +2 -2
- data/lib/bad_sdl/engine/engines.rb +51 -0
- data/lib/enumerable_constants.rb +4 -2
- data/lib/sdl2.rb +26 -247
- data/lib/sdl2/blendmode.rb +18 -0
- data/lib/sdl2/color.rb +1 -3
- data/lib/sdl2/debug.rb +58 -0
- data/lib/sdl2/display.rb +30 -23
- data/lib/sdl2/error.rb +6 -4
- data/lib/sdl2/event.rb +229 -0
- data/lib/sdl2/event/abstract.rb +11 -0
- data/lib/sdl2/event/action.rb +19 -0
- data/lib/sdl2/event/common.rb +10 -0
- data/lib/sdl2/event/controller_axis.rb +20 -0
- data/lib/sdl2/event/controller_button.rb +17 -0
- data/lib/sdl2/event/controller_device.rb +14 -0
- data/lib/sdl2/event/dollar_gesture.rb +19 -0
- data/lib/sdl2/event/drop.rb +18 -0
- data/lib/sdl2/event/joy_axis.rb +20 -0
- data/lib/sdl2/event/joy_ball.rb +20 -0
- data/lib/sdl2/event/joy_button.rb +18 -0
- data/lib/sdl2/event/joy_device.rb +14 -0
- data/lib/sdl2/event/joy_hat.rb +18 -0
- data/lib/sdl2/event/keyboard.rb +18 -0
- data/lib/sdl2/event/mouse_button.rb +21 -0
- data/lib/sdl2/event/mouse_motion.rb +19 -0
- data/lib/sdl2/event/mouse_wheel.rb +17 -0
- data/lib/sdl2/event/multi_gesture.rb +20 -0
- data/lib/sdl2/event/os.rb +12 -0
- data/lib/sdl2/event/quit.rb +12 -0
- data/lib/sdl2/event/state.rb +13 -0
- data/lib/sdl2/event/sys_wm.rb +15 -0
- data/lib/sdl2/event/text_editing.rb +17 -0
- data/lib/sdl2/event/text_input.rb +15 -0
- data/lib/sdl2/event/touch_finger.rb +20 -0
- data/lib/sdl2/event/type.rb +62 -0
- data/lib/sdl2/event/user.rb +15 -0
- data/lib/sdl2/event/window.rb +19 -0
- data/lib/sdl2/events.rb +23 -538
- data/lib/sdl2/gem_version.rb +1 -1
- data/lib/sdl2/haptic.rb +3 -3
- data/lib/sdl2/hints.rb +3 -1
- data/lib/sdl2/image.rb +20 -20
- data/lib/sdl2/init.rb +5 -8
- data/lib/sdl2/joystick.rb +104 -78
- data/lib/sdl2/joystick/axes.rb +22 -0
- data/lib/sdl2/joystick/balls.rb +24 -0
- data/lib/sdl2/joystick/buttons.rb +22 -0
- data/lib/sdl2/joystick/components.rb +23 -0
- data/lib/sdl2/joystick/hats.rb +22 -0
- data/lib/sdl2/keyboard.rb +11 -10
- data/lib/sdl2/keycode.rb +70 -70
- data/lib/sdl2/library.rb +8 -7
- data/lib/sdl2/log.rb +6 -0
- data/lib/sdl2/managed_struct.rb +17 -0
- data/lib/sdl2/mixer.rb +16 -12
- data/lib/sdl2/mixer/chunk.rb +14 -3
- data/lib/sdl2/mouse.rb +21 -41
- data/lib/sdl2/pixel_format.rb +4 -4
- data/lib/sdl2/pixels.rb +59 -47
- data/lib/sdl2/power.rb +1 -1
- data/lib/sdl2/rect.rb +4 -5
- data/lib/sdl2/render.rb +85 -170
- data/lib/sdl2/renderer.rb +337 -20
- data/lib/sdl2/rwops.rb +89 -30
- data/lib/sdl2/stdinc.rb +18 -21
- data/lib/sdl2/struct.rb +184 -0
- data/lib/sdl2/struct_helper.rb +32 -0
- data/lib/sdl2/surface.rb +15 -14
- data/lib/sdl2/syswm.rb +26 -10
- data/lib/sdl2/syswm/msg.rb +22 -4
- data/lib/sdl2/texture.rb +106 -0
- data/lib/sdl2/touch.rb +16 -20
- data/lib/sdl2/ttf.rb +29 -29
- data/lib/sdl2/ttf/sdl_ttf_module.rb +1 -1
- data/lib/sdl2/typed_pointer.rb +45 -0
- data/lib/sdl2/union.rb +7 -0
- data/lib/sdl2/video.rb +97 -183
- data/lib/sdl2/window.rb +140 -90
- data/lib/struct_array.rb +42 -0
- data/sdl2_ffi.gemspec +3 -3
- data/spec/fixtures/approvals/lazyfoonet_lesson_03_advanced_timers/has_a_message.approved.png +0 -0
- data/spec/fixtures/approvals/lazyfoonet_lesson_07_true_type_fonts/draws_the_message_to_the_screen.approved.png +0 -0
- data/spec/fixtures/approvals/lazyfoonet_lesson_14_advanced_timers/has_a_message.approved.png +0 -0
- data/spec/fixtures/approvals/lazyfoonet_lesson_14_advanced_timers/has_drawn_something.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_clear.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_a_line_connecting_many_points.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_a_point.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_a_single_filled_rectangle.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_a_single_pixel_line.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_a_single_rectangle.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_many_filled_rectangles.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_many_rectangles_at_once.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_draw_points.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_render_textures.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_be_able_to_rotate_and_flip_while_rendering_textures.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2/sdl2_renderer/should_have_a_clip_rect.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_clear.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_a_line_connecting_many_points.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_a_point.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_a_single_filled_rectangle.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_a_single_pixel_line.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_a_single_rectangle.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_many_filled_rectangles.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_many_rectangles_at_once.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_draw_points.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_render_textures.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_be_able_to_rotate_and_flip_while_rendering_textures.approved.png +0 -0
- data/spec/fixtures/approvals/sdl2_renderer/should_have_a_clip_rect.approved.png +0 -0
- data/spec/fixtures/images/finger.png +0 -0
- data/spec/fixtures/music/beat.wav +0 -0
- data/spec/fixtures/sounds/high.wav +0 -0
- data/spec/fixtures/sounds/low.wav +0 -0
- data/spec/fixtures/sounds/medium.wav +0 -0
- data/spec/fixtures/sounds/scratch.wav +0 -0
- data/spec/functional/lazy_foo_tutorial/lazy_foo_01_hello_world_spec.rb +4 -6
- data/spec/functional/lazy_foo_tutorial/lazy_foo_02_optimized_images_spec.rb +3 -4
- data/spec/functional/lazy_foo_tutorial/lazy_foo_03_extension_libraries_spec.rb +2 -2
- data/spec/functional/lazy_foo_tutorial/lazy_foo_04_event_driven_programming_spec.rb +3 -3
- data/spec/functional/lazy_foo_tutorial/lazy_foo_05_color_keying_spec.rb +1 -1
- data/spec/functional/lazy_foo_tutorial/lazy_foo_06_clip_blitting_and_sprite_sheets_spec.rb +1 -1
- data/spec/functional/lazy_foo_tutorial/lazy_foo_07_true_type_fonts_spec.rb +3 -2
- data/spec/functional/lazy_foo_tutorial/lazy_foo_08_key_presses_spec.rb +9 -7
- data/spec/functional/lazy_foo_tutorial/lazy_foo_09_mouse_events_spec.rb +11 -8
- data/spec/functional/lazy_foo_tutorial/lazy_foo_10_key_states_spec.rb +5 -4
- data/spec/functional/lazy_foo_tutorial/lazy_foo_11_playing_sounds_spec.rb +17 -9
- data/spec/functional/lazy_foo_tutorial/lazy_foo_12_timing_spec.rb +8 -7
- data/spec/functional/lazy_foo_tutorial/lazy_foo_13_advanced_timers_spec.rb +85 -0
- data/spec/functional/lazy_foo_tutorial/lazy_foo_14_regulating_frame_rate_spec.rb +67 -0
- data/spec/functional/lazy_foo_tutorial/lazy_foo_15_calculating_frame_rate_spec.rb +48 -0
- data/spec/functional/lazy_foo_tutorial/lazy_foo_16_motion_spec.rb +95 -0
- data/spec/functional/lazy_foo_tutorial/lazy_foo_helper.rb +3 -1
- data/spec/functional/lazy_foo_tutorial/timer.rb +55 -0
- data/spec/lib/bad_sdl/application_spec.rb +22 -0
- data/spec/{unit → lib}/sdl2/color_spec.rb +5 -1
- data/spec/lib/sdl2/display_spec.rb +6 -0
- data/spec/lib/sdl2/event_spec.rb +102 -0
- data/spec/lib/sdl2/events_spec.rb +12 -0
- data/spec/lib/sdl2/joystick_spec.rb +130 -0
- data/spec/lib/sdl2/keyboard_spec.rb +22 -0
- data/spec/lib/sdl2/mouse_spec.rb +21 -0
- data/spec/lib/sdl2/render_spec.rb +62 -0
- data/spec/lib/sdl2/renderer_spec.rb +224 -0
- data/spec/lib/sdl2/sdl2_helper.rb +5 -0
- data/spec/lib/sdl2/texture_spec.rb +65 -0
- data/{test/unit/sdl2/test_video.rb → spec/lib/sdl2/video_spec.rb} +82 -57
- data/spec/lib/sdl2/window_spec.rb +42 -0
- data/spec/{unit → lib}/unit_helper.rb +0 -0
- data/spec/png_writer.rb +9 -1
- data/spec/spec_helper.rb +5 -3
- metadata +201 -132
- data/lib/sdl2/engine/engines.rb +0 -46
- data/test/approvals/clip_blitting_and_sprite_sheets.received.bmp +0 -0
- data/test/approvals/color_keying_example.approved.png +0 -0
- data/test/approvals/hello_world_example_hello.approved.png +0 -0
- data/test/approvals/hello_world_example_screen.approved.png +0 -0
- data/test/approvals/optimized_surface_loading.approved.png +0 -0
- data/test/fixtures/an_example.png +0 -0
- data/test/fixtures/background.bmp +0 -0
- data/test/fixtures/background.jpg +0 -0
- data/test/fixtures/color_bars.jpg +0 -0
- data/test/fixtures/foo.jpg +0 -0
- data/test/fixtures/hello.bmp +0 -0
- data/test/fixtures/sprites.jpg +0 -0
- data/test/fixtures/x.png +0 -0
- data/test/functional/examples/lazyfoo.net_s/test_clip_blitting_and_sprite_sheets.rb +0 -50
- data/test/functional/examples/lazyfoo.net_s/test_color_keying.rb +0 -42
- data/test/functional/examples/test_lazy_foo_examples.rb +0 -195
- data/test/functional/examples/test_readme_examples.rb +0 -15
- data/test/test_helper.rb +0 -13
- data/test/unit/sdl2/test_assert.rb +0 -10
- data/test/unit/sdl2/test_audio.rb +0 -9
- data/test/unit/sdl2/test_clipboard.rb +0 -13
- data/test/unit/sdl2/test_cpuinfo.rb +0 -11
- data/test/unit/sdl2/test_error.rb +0 -20
- data/test/unit/sdl2/test_events.rb +0 -31
- data/test/unit/sdl2/test_haptic.rb +0 -27
- data/test/unit/sdl2/test_hints.rb +0 -50
- data/test/unit/sdl2/test_image.rb +0 -9
- data/test/unit/sdl2/test_init.rb +0 -29
- data/test/unit/sdl2/test_keyboard.rb +0 -9
- data/test/unit/sdl2/test_log.rb +0 -80
- data/test/unit/sdl2/test_palette.rb +0 -26
- data/test/unit/sdl2/test_pixel_format.rb +0 -38
- data/test/unit/sdl2/test_pixels.rb +0 -24
- data/test/unit/sdl2/test_power.rb +0 -11
- data/test/unit/sdl2/test_rect.rb +0 -19
- data/test/unit/sdl2/test_render.rb +0 -58
- data/test/unit/sdl2/test_surface.rb +0 -88
- data/test/unit/sdl2/test_syswm.rb +0 -11
- data/test/unit/sdl2/test_timer.rb +0 -9
- data/test/unit/sdl2/test_ttf.rb +0 -11
- data/test/unit/sdl2/test_version.rb +0 -16
- data/test/unit/sdl2/test_window.rb +0 -155
- data/test/unit/test_scratch.rb +0 -19
- data/test/unit/test_sdl2.rb +0 -16
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/events'
|
|
4
|
-
|
|
5
|
-
describe SDL2 do
|
|
6
|
-
|
|
7
|
-
it 'has the SDL_events.h API' do
|
|
8
|
-
[
|
|
9
|
-
:peep_events,
|
|
10
|
-
:has_event,
|
|
11
|
-
:has_events,
|
|
12
|
-
:flush_event,
|
|
13
|
-
:flush_events,
|
|
14
|
-
:poll_event,
|
|
15
|
-
:wait_event,
|
|
16
|
-
:wait_event_timeout,
|
|
17
|
-
:push_event,
|
|
18
|
-
:set_event_filter,
|
|
19
|
-
:get_event_filter,
|
|
20
|
-
:add_event_watch,
|
|
21
|
-
:del_event_watch,
|
|
22
|
-
:filter_events,
|
|
23
|
-
:event_state,
|
|
24
|
-
:register_events
|
|
25
|
-
].each do |function|
|
|
26
|
-
assert_respond_to SDL2, function
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
require 'sdl2/haptic'
|
|
3
|
-
|
|
4
|
-
describe 'SDL2' do
|
|
5
|
-
|
|
6
|
-
it 'has the SDL_haptic.h API' do
|
|
7
|
-
skip 'Not yet implemented'
|
|
8
|
-
end
|
|
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
|
-
|
|
27
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/hints'
|
|
4
|
-
|
|
5
|
-
describe SDL2 do
|
|
6
|
-
|
|
7
|
-
it 'has hints' do
|
|
8
|
-
assert_respond_to SDL2, :clear_hints
|
|
9
|
-
assert_respond_to SDL2, :get_hint
|
|
10
|
-
assert_respond_to SDL2, :set_hint
|
|
11
|
-
|
|
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
|
-
|
|
20
|
-
assert SDL2.set_hint("My Hint", "My Value")
|
|
21
|
-
assert_kind_of String, SDL2.get_hint("My Hint")
|
|
22
|
-
assert_equal "My Value", SDL2.get_hint("My Hint")
|
|
23
|
-
|
|
24
|
-
[:default, :normal, :override].each do |priority|
|
|
25
|
-
assert SDL2.set_hint_with_priority("#{priority}Hint", "#{priority}Value", priority)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe SDL2::Hint do
|
|
31
|
-
|
|
32
|
-
it 'has hash access' do
|
|
33
|
-
assert SDL2::Hint.respond_to?(:[])
|
|
34
|
-
assert SDL2::Hint.respond_to?(:[]=)
|
|
35
|
-
|
|
36
|
-
assert_equal "My Value", SDL2::Hint["My Hint"] = "My Value"
|
|
37
|
-
assert_equal "My Value", SDL2::Hint["My Hint"]
|
|
38
|
-
|
|
39
|
-
[:default, :normal, :override].each do |priority|
|
|
40
|
-
assert_equal "#{priority}Value", SDL2::Hint.set_with_priority("#{priority}Hint","#{priority}Value",priority)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end
|
data/test/unit/sdl2/test_init.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/init'
|
|
4
|
-
|
|
5
|
-
describe SDL2 do
|
|
6
|
-
|
|
7
|
-
after do
|
|
8
|
-
SDL2.quit()
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it 'can initialize everything' do
|
|
12
|
-
assert_equal SDL2.init(SDL2::INIT::EVERYTHING), 0
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'can initialize, check, and quit subsystems' do
|
|
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
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'can quit' do
|
|
26
|
-
assert SDL2.respond_to?(:quit)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
data/test/unit/sdl2/test_log.rb
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/init'
|
|
4
|
-
require 'sdl2/log'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
describe SDL2 do
|
|
8
|
-
before do
|
|
9
|
-
SDL2.init(SDL2::INIT::EVERYTHING)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
after do
|
|
13
|
-
SDL2.quit()
|
|
14
|
-
end
|
|
15
|
-
it 'has the log API' do
|
|
16
|
-
[
|
|
17
|
-
:log, :log_critical, :log_debug, :log_error, :log_get_output_function,
|
|
18
|
-
:log_get_priority, :log_info, :log_message, :log_message_v, :log_reset_priorities,
|
|
19
|
-
:log_set_all_priority, :log_set_output_function, :log_set_priority, :log_verbose, :log_warn
|
|
20
|
-
].each do |function|
|
|
21
|
-
assert_respond_to SDL2, function
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'logs messages' do
|
|
26
|
-
SDL2.log('Hello World %d', :int, 6384) # API Version
|
|
27
|
-
SDL2::Log << 'Hello World' # Object Oriented Version
|
|
28
|
-
|
|
29
|
-
SDL2.log_critical(:application, 'Test %d', :int, 1234)
|
|
30
|
-
SDL2::Log.critical(:error, 'Test %f', :float, 2.0)
|
|
31
|
-
|
|
32
|
-
SDL2.log_debug(:assert, 'Test %s', :string, 'String')
|
|
33
|
-
SDL2::Log.debug(:system, 'Test %c', :char, 'C'.chr().to_i)
|
|
34
|
-
|
|
35
|
-
SDL2.log_error(:audio, 'Test %d', :int, 2)
|
|
36
|
-
SDL2::Log.error(:video, 'Test %f', :float, 63.84)
|
|
37
|
-
|
|
38
|
-
SDL2.log_warn(:render, 'Test %d', :int, 6)
|
|
39
|
-
SDL2::Log.warn(:input, 'Test %f', :float, 88.21212)
|
|
40
|
-
|
|
41
|
-
SDL2.log_verbose(:input, 'Test %d', :int, 8)
|
|
42
|
-
SDL2::Log.verbose(:test, 'Test %f', :float, 1234.5)
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
#
|
|
46
|
-
# it 'lets you get the output function and data pointer' do
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
# end
|
|
50
|
-
# @@called = false
|
|
51
|
-
# TestFunc = Proc.new do ||
|
|
52
|
-
# puts "Test Function Called!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
53
|
-
# @@called = true
|
|
54
|
-
# end
|
|
55
|
-
#
|
|
56
|
-
# TEST_DATA = FFI::Pointer.new :string, 1
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
# it 'lets you set the output function and data pointer' do
|
|
60
|
-
# SDL2.log_set_output_function(TestFunc, TEST_DATA)
|
|
61
|
-
# end
|
|
62
|
-
#
|
|
63
|
-
it 'lets you set the log priority' do
|
|
64
|
-
[
|
|
65
|
-
:application, :error, :assert, :system,
|
|
66
|
-
:audio, :video, :render, :input, :test, :custom
|
|
67
|
-
].each do |category|
|
|
68
|
-
[
|
|
69
|
-
:verbose, :debug, :info, :warn, :error, :critical
|
|
70
|
-
].each do |priority|
|
|
71
|
-
SDL2::Log.set_priority(category, priority)
|
|
72
|
-
assert_equal priority, SDL2::Log.get_priority(category)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
SDL2::Log.set_priority(:application, :verbose)
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/pixels' #defines SDL_Palette
|
|
4
|
-
|
|
5
|
-
describe SDL2::Palette do
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
@palette = SDL2::Palette.create(32)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after do
|
|
12
|
-
SDL2::Palette.release(@palette)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'can be created' do
|
|
16
|
-
refute @palette.null?
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'can set colors from a ruby array of arrays' do
|
|
20
|
-
@palette.set_colors([[255,0,0],[0,255,0],[0,0,255]])
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/pixels' # SDL_pixels.h defines SDL_PixelFormat
|
|
4
|
-
|
|
5
|
-
require 'sdl2/pixel_format'
|
|
6
|
-
|
|
7
|
-
describe SDL2::PixelFormat do
|
|
8
|
-
|
|
9
|
-
it 'can be created in all formats' do
|
|
10
|
-
|
|
11
|
-
SDL2::PIXELFORMAT.by_name.each do |format|
|
|
12
|
-
unless format == 0 # Skip "UNKOWN"
|
|
13
|
-
begin
|
|
14
|
-
pixel_format = SDL2::PixelFormat.create(format[1])
|
|
15
|
-
refute pixel_format.null?
|
|
16
|
-
assert_kind_of SDL2::PixelFormat, pixel_format
|
|
17
|
-
rescue RuntimeError => e
|
|
18
|
-
skip "Problem with SDL2::PIXELFORMAT.#{format[0]}" #TODO: Fix broken PIXELFORMATS
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
it 'can get the name of all formats' do
|
|
28
|
-
|
|
29
|
-
SDL2::PIXELFORMAT.by_name.each_pair do |k,v|
|
|
30
|
-
name = SDL2::PixelFormat.get_name(v)
|
|
31
|
-
#binding.pry
|
|
32
|
-
assert_includes name, k.to_s
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
require 'sdl2/pixels'
|
|
3
|
-
|
|
4
|
-
describe SDL2 do
|
|
5
|
-
it 'should have the SDL_pixels.h API' do
|
|
6
|
-
[
|
|
7
|
-
:get_pixel_format_name,
|
|
8
|
-
:pixel_format_enum_to_masks,
|
|
9
|
-
:masks_to_pixel_format_enum,
|
|
10
|
-
:alloc_format,
|
|
11
|
-
:free_format,
|
|
12
|
-
:alloc_palette,
|
|
13
|
-
:set_pixel_format_palette,
|
|
14
|
-
:set_palette_colors,
|
|
15
|
-
:free_palette,
|
|
16
|
-
:map_rgb,
|
|
17
|
-
:map_rgba,
|
|
18
|
-
:get_rgb,
|
|
19
|
-
:get_rgba,
|
|
20
|
-
].each do |function|
|
|
21
|
-
assert_respond_to SDL2, function
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
data/test/unit/sdl2/test_rect.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/rect'
|
|
4
|
-
|
|
5
|
-
describe SDL2 do
|
|
6
|
-
|
|
7
|
-
it 'has the SDL_rect.h API' do
|
|
8
|
-
[
|
|
9
|
-
:has_intersection,
|
|
10
|
-
:intersect_rect,
|
|
11
|
-
:enclose_points,
|
|
12
|
-
:intersect_rect_and_line
|
|
13
|
-
].each do |function|
|
|
14
|
-
assert_respond_to SDL2, function
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/render'
|
|
4
|
-
|
|
5
|
-
describe SDL2 do
|
|
6
|
-
SDL_render_H_API = [
|
|
7
|
-
:create_renderer,
|
|
8
|
-
:create_software_renderer,
|
|
9
|
-
:create_texture,
|
|
10
|
-
:create_texture_from_surface,
|
|
11
|
-
:create_window_and_renderer,
|
|
12
|
-
:destroy_renderer,
|
|
13
|
-
:destroy_texture,
|
|
14
|
-
:get_num_render_drivers,
|
|
15
|
-
:get_render_draw_blend_mode,
|
|
16
|
-
:get_render_draw_color,
|
|
17
|
-
:get_render_driver_info,
|
|
18
|
-
:get_renderer,
|
|
19
|
-
:get_renderer_info,
|
|
20
|
-
:get_texture_alpha_mod,
|
|
21
|
-
:get_texture_blend_mode,
|
|
22
|
-
:get_texture_color_mod,
|
|
23
|
-
:lock_texture,
|
|
24
|
-
:query_texture,
|
|
25
|
-
:render_clear,
|
|
26
|
-
:render_copy,
|
|
27
|
-
:render_copy_ex,
|
|
28
|
-
:render_draw_line,
|
|
29
|
-
:render_draw_lines,
|
|
30
|
-
:render_draw_point,
|
|
31
|
-
:render_draw_points,
|
|
32
|
-
:render_draw_rect,
|
|
33
|
-
:render_draw_rects,
|
|
34
|
-
:render_fill_rect,
|
|
35
|
-
:render_fill_rects,
|
|
36
|
-
:render_get_clip_rect,
|
|
37
|
-
:render_get_viewport,
|
|
38
|
-
:render_present,
|
|
39
|
-
:render_read_pixels,
|
|
40
|
-
:render_set_clip_rect,
|
|
41
|
-
:render_set_viewport,
|
|
42
|
-
:set_render_draw_blend_mode,
|
|
43
|
-
:set_render_draw_color,
|
|
44
|
-
:set_render_target,
|
|
45
|
-
:set_texture_alpha_mod,
|
|
46
|
-
:set_texture_blend_mode,
|
|
47
|
-
:set_texture_color_mod,
|
|
48
|
-
:unlock_texture,
|
|
49
|
-
:update_texture
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
it 'has the SDL_render.h api' do
|
|
53
|
-
assert_equal 43, SDL_render_H_API.count
|
|
54
|
-
SDL_render_H_API.each do |function|
|
|
55
|
-
assert_respond_to SDL2, function
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
require_relative '../../test_helper'
|
|
2
|
-
|
|
3
|
-
require 'sdl2/surface'
|
|
4
|
-
|
|
5
|
-
describe SDL2 do
|
|
6
|
-
it 'has the SDL_surface.h API' do
|
|
7
|
-
[
|
|
8
|
-
:create_rgb_surface,
|
|
9
|
-
:free_surface,
|
|
10
|
-
:set_surface_palette,
|
|
11
|
-
:lock_surface,
|
|
12
|
-
:unlock_surface,
|
|
13
|
-
:load_bmp_rw,
|
|
14
|
-
:load_bmp,
|
|
15
|
-
:save_bmp_rw,
|
|
16
|
-
:save_bmp,
|
|
17
|
-
:set_surface_rle,
|
|
18
|
-
:set_color_key,
|
|
19
|
-
:get_color_key,
|
|
20
|
-
:set_surface_color_mod,
|
|
21
|
-
:get_surface_color_mod,
|
|
22
|
-
:set_surface_alpha_mod,
|
|
23
|
-
:get_surface_alpha_mod,
|
|
24
|
-
:set_surface_blend_mode,
|
|
25
|
-
:get_surface_blend_mode,
|
|
26
|
-
:set_clip_rect,
|
|
27
|
-
:get_clip_rect,
|
|
28
|
-
:convert_surface,
|
|
29
|
-
:convert_surface_format,
|
|
30
|
-
:convert_pixels,
|
|
31
|
-
:fill_rect,
|
|
32
|
-
:fill_rects,
|
|
33
|
-
:upper_blit,
|
|
34
|
-
:blit_surface,
|
|
35
|
-
:lower_blit,
|
|
36
|
-
:soft_stretch,
|
|
37
|
-
:upper_blit_scaled,
|
|
38
|
-
:blit_scaled,
|
|
39
|
-
:lower_blit_scaled,
|
|
40
|
-
].each do |function|
|
|
41
|
-
assert_respond_to SDL2, function
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe SDL2::Surface do
|
|
47
|
-
|
|
48
|
-
it 'rejects invalid pixel formats' do
|
|
49
|
-
assert_raises RuntimeError do
|
|
50
|
-
# Try to create a 64bit depth image
|
|
51
|
-
SDL2::Surface.create_rgb(0, 100, 100, 64)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'can be created with valid arguments' do
|
|
56
|
-
surfaces =
|
|
57
|
-
[
|
|
58
|
-
SDL2::Surface.create_rgb(0, 100, 100, 4),
|
|
59
|
-
SDL2::Surface.create_rgb(0, 100, 100, 8),
|
|
60
|
-
SDL2::Surface.create_rgb(0,100,100,16)
|
|
61
|
-
]
|
|
62
|
-
surfaces.each do |surface|
|
|
63
|
-
refute surface.null?
|
|
64
|
-
assert_kind_of SDL2::Surface, surface
|
|
65
|
-
end
|
|
66
|
-
assert_equal 4, surfaces[0].format.bits_per_pixel
|
|
67
|
-
assert_equal 8, surfaces[1].format.bits_per_pixel
|
|
68
|
-
assert_equal 16, surfaces[2].format.bits_per_pixel
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'can be freed' do
|
|
72
|
-
surface = SDL2::Surface.create_rgb(0, 100, 100, 4)
|
|
73
|
-
surface.free
|
|
74
|
-
skip("Don't know how to test this")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'can get and set the palette' do
|
|
78
|
-
surface = SDL2::Surface.create_rgb(0, 100, 100, 4)
|
|
79
|
-
surface_palette = surface.palette
|
|
80
|
-
assert_kind_of SDL2::Palette, surface_palette
|
|
81
|
-
my_palette = SDL2::Palette.create(16)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
surface.palette = my_palette
|
|
85
|
-
|
|
86
|
-
assert_equal my_palette, surface.palette
|
|
87
|
-
end
|
|
88
|
-
end
|