sdl2_ffi 0.0.2

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.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +4 -0
  6. data/Guardfile +33 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +83 -0
  9. data/Rakefile +7 -0
  10. data/bin/coderay +16 -0
  11. data/bin/guard +16 -0
  12. data/bin/pry +16 -0
  13. data/bin/rake +16 -0
  14. data/bin/thor +16 -0
  15. data/lib/sdl2/assert.rb +7 -0
  16. data/lib/sdl2/audio.rb +139 -0
  17. data/lib/sdl2/clipboard.rb +27 -0
  18. data/lib/sdl2/color.rb +12 -0
  19. data/lib/sdl2/cpuinfo.rb +18 -0
  20. data/lib/sdl2/display/mode.rb +53 -0
  21. data/lib/sdl2/display/modes.rb +36 -0
  22. data/lib/sdl2/display.rb +74 -0
  23. data/lib/sdl2/error.rb +9 -0
  24. data/lib/sdl2/events.rb +358 -0
  25. data/lib/sdl2/gamecontroller.rb +62 -0
  26. data/lib/sdl2/gem_version.rb +4 -0
  27. data/lib/sdl2/gesture.rb +15 -0
  28. data/lib/sdl2/haptic.rb +159 -0
  29. data/lib/sdl2/hints.rb +47 -0
  30. data/lib/sdl2/init.rb +54 -0
  31. data/lib/sdl2/joystick.rb +58 -0
  32. data/lib/sdl2/keyboard.rb +34 -0
  33. data/lib/sdl2/keycode.rb +294 -0
  34. data/lib/sdl2/log.rb +70 -0
  35. data/lib/sdl2/mouse.rb +54 -0
  36. data/lib/sdl2/palette.rb +15 -0
  37. data/lib/sdl2/pixel_format.rb +28 -0
  38. data/lib/sdl2/pixels.rb +35 -0
  39. data/lib/sdl2/point.rb +7 -0
  40. data/lib/sdl2/power.rb +9 -0
  41. data/lib/sdl2/rect.rb +38 -0
  42. data/lib/sdl2/render.rb +77 -0
  43. data/lib/sdl2/renderer.rb +34 -0
  44. data/lib/sdl2/renderer_info.rb +13 -0
  45. data/lib/sdl2/rwops.rb +127 -0
  46. data/lib/sdl2/scancode.rb +275 -0
  47. data/lib/sdl2/sdl_module.rb +8 -0
  48. data/lib/sdl2/surface.rb +83 -0
  49. data/lib/sdl2/syswm/info.rb +49 -0
  50. data/lib/sdl2/syswm/msg.rb +46 -0
  51. data/lib/sdl2/syswm.rb +20 -0
  52. data/lib/sdl2/texture.rb +9 -0
  53. data/lib/sdl2/timer.rb +17 -0
  54. data/lib/sdl2/touch.rb +24 -0
  55. data/lib/sdl2/version.rb +30 -0
  56. data/lib/sdl2/video.rb +154 -0
  57. data/lib/sdl2/window.rb +259 -0
  58. data/lib/sdl2.rb +99 -0
  59. data/lib/sdl2_ffi.rb +6 -0
  60. data/sdl2_ffi.gemspec +31 -0
  61. data/test/test_helper.rb +2 -0
  62. data/test/unit/sdl2/test_assert.rb +10 -0
  63. data/test/unit/sdl2/test_audio.rb +9 -0
  64. data/test/unit/sdl2/test_clipboard.rb +13 -0
  65. data/test/unit/sdl2/test_cpuinfo.rb +11 -0
  66. data/test/unit/sdl2/test_error.rb +20 -0
  67. data/test/unit/sdl2/test_events.rb +31 -0
  68. data/test/unit/sdl2/test_haptic.rb +10 -0
  69. data/test/unit/sdl2/test_hints.rb +50 -0
  70. data/test/unit/sdl2/test_init.rb +29 -0
  71. data/test/unit/sdl2/test_keyboard.rb +9 -0
  72. data/test/unit/sdl2/test_log.rb +80 -0
  73. data/test/unit/sdl2/test_pixels.rb +24 -0
  74. data/test/unit/sdl2/test_power.rb +11 -0
  75. data/test/unit/sdl2/test_rect.rb +19 -0
  76. data/test/unit/sdl2/test_render.rb +58 -0
  77. data/test/unit/sdl2/test_surface.rb +45 -0
  78. data/test/unit/sdl2/test_syswm.rb +11 -0
  79. data/test/unit/sdl2/test_timer.rb +9 -0
  80. data/test/unit/sdl2/test_version.rb +16 -0
  81. data/test/unit/sdl2/test_video.rb +170 -0
  82. data/test/unit/sdl2/test_window.rb +158 -0
  83. data/test/unit/test_sdl2.rb +16 -0
  84. metadata +280 -0
@@ -0,0 +1,10 @@
1
+ require_relative '../../test_helper'
2
+ require 'sdl2/assert'
3
+
4
+ describe 'SDL2' do
5
+
6
+ it 'has the SDL_assert.h API' do
7
+ skip 'Not yet implemented'
8
+ end
9
+
10
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/audio'
4
+
5
+ describe SDL2 do
6
+ it 'has the SDL_audio.h API' do
7
+ skip('Not Yet Implemented')
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/clipboard'
4
+
5
+ describe SDL2 do
6
+
7
+ it 'has the SDL_clipboard.h API' do
8
+ [:set_clipboard_text, :get_clipboard_text, :has_clipboard_text].each do|func|
9
+ assert_respond_to SDL2, func
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/cpuinfo'
4
+
5
+ describe SDL2 do
6
+
7
+ it 'should have the SDL_cpuinfo.h API' do
8
+ skip "Not yet implemented."
9
+ end
10
+
11
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/error'
4
+
5
+ describe SDL2 do
6
+
7
+ it 'deals with errors' do
8
+
9
+ assert SDL2.respond_to?(:clear_error)
10
+ assert SDL2.respond_to?(:get_error)
11
+ assert SDL2.respond_to?(:set_error)
12
+
13
+ SDL2.clear_error()
14
+ assert_equal '', SDL2.get_error()
15
+ assert_equal -1, SDL2.set_error('My Error String %d', :int, 6384)
16
+ assert_equal 'My Error String 6384', SDL2.get_error()
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,10 @@
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
+ end
@@ -0,0 +1,50 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/hints'
4
+
5
+ describe SDL2 do
6
+
7
+ it 'has hints' do
8
+ assert SDL2.respond_to? :clear_hints
9
+ assert SDL2.respond_to? :get_hint
10
+ assert SDL2.respond_to? :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_equal :true, 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_equal :true, 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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,9 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/keyboard'
4
+
5
+ describe SDL2 do
6
+
7
+
8
+
9
+ end
@@ -0,0 +1,80 @@
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
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,11 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/power'
4
+
5
+ describe SDL2 do
6
+
7
+ it 'has the SDL_power.h API' do
8
+ assert_respond_to SDL2, :get_power_info
9
+ end
10
+
11
+ end
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,58 @@
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
@@ -0,0 +1,45 @@
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
+
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/syswm'
4
+
5
+ describe SDL2 do
6
+
7
+ it 'has the SDL_syswm.h API' do
8
+ assert_respond_to SDL2, :get_window_wm_info
9
+ end
10
+
11
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/timer'
4
+
5
+ describe SDL2 do
6
+ it 'has the SDL_timer.h API' do
7
+ skip('Not yet implemented')
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/init'
4
+ require 'sdl2/version'
5
+
6
+ describe SDL2 do
7
+
8
+ it 'has the version API' do
9
+ [:get_revision, :get_revision_number, :get_version].each do |function|
10
+ assert_respond_to SDL2, function
11
+ end
12
+ end
13
+
14
+ # I'll test further when I start to find bugs with this.
15
+
16
+ end
@@ -0,0 +1,170 @@
1
+ require_relative '../../test_helper'
2
+
3
+ require 'sdl2/init'
4
+ require 'sdl2/video'
5
+
6
+ # http://wiki.libsdl.org/CategoryVideo
7
+ # Aligned to line 10 to make coutning easy.
8
+ #
9
+ # What the Ruby version of the SDL_video.h API should look like
10
+ #
11
+ VIDEO_API = [
12
+ :get_num_video_drivers,
13
+ :get_video_driver,
14
+ :video_init,
15
+ :video_quit,
16
+ :get_current_video_driver,
17
+ :get_num_video_displays,
18
+ :get_display_name,
19
+ :get_display_bounds,
20
+ :get_num_display_modes,
21
+ :get_display_mode,
22
+ :get_desktop_display_mode,
23
+ :get_current_display_mode,
24
+ :get_closest_display_mode,
25
+ :get_window_display_index,
26
+ :set_window_display_mode,
27
+ :get_window_display_mode,
28
+ :get_window_pixel_format,
29
+ :create_window,
30
+ :create_window_from,
31
+ :get_window_from_id,
32
+ :get_window_id,
33
+ :get_window_flags,
34
+ :get_window_title,
35
+ :set_window_title,
36
+ :set_window_icon,
37
+ :set_window_data,
38
+ :get_window_data,
39
+ :set_window_position,
40
+ :get_window_position,
41
+ :set_window_size,
42
+ :get_window_size,
43
+ :set_window_maximum_size,
44
+ :get_window_maximum_size,
45
+ :set_window_minimum_size,
46
+ :get_window_minimum_size,
47
+ :set_window_bordered,
48
+ :show_window,
49
+ :hide_window,
50
+ :raise_window,
51
+ :maximize_window,
52
+ :minimize_window,
53
+ :restore_window,
54
+ :set_window_fullscreen,
55
+ :get_window_surface,
56
+ :update_window_surface,
57
+ :update_window_surface_rects,
58
+ :get_window_grab,
59
+ :set_window_grab,
60
+ :get_window_brightness,
61
+ :set_window_brightness,
62
+ :get_window_gamma_ramp,
63
+ :set_window_gamma_ramp,
64
+ :destroy_window,
65
+ :is_screen_saver_enabled,
66
+ :disable_screen_saver,
67
+ :enable_screen_saver,
68
+ :gl_load_library,
69
+ :gl_get_proc_address,
70
+ :gl_unload_library,
71
+ :gl_extension_supported,
72
+ :gl_set_attribute,
73
+ :gl_get_attribute,
74
+ :gl_create_context,
75
+ :gl_make_current,
76
+ :gl_get_current_window,
77
+ :gl_get_current_context,
78
+ :gl_set_swap_interval,
79
+ :gl_get_swap_interval,
80
+ :gl_delete_context,
81
+ :gl_swap_window
82
+
83
+ ]
84
+
85
+ describe SDL2 do
86
+ before do
87
+ assert(SDL2.init(SDL2::INIT_VIDEO) == 0, 'Video initialized.')
88
+ end
89
+
90
+ after do
91
+ SDL2.quit()
92
+ end
93
+
94
+ it 'has the video API' do
95
+ assert_equal 70, VIDEO_API.count
96
+ VIDEO_API.each do |function|
97
+ assert_respond_to SDL2, function
98
+ end
99
+ end
100
+
101
+ it 'can manage the screen saver' do
102
+ SDL2.disable_screen_saver
103
+ refute SDL2.is_screen_saver_enabled == :true
104
+ SDL2.enable_screen_saver
105
+ assert SDL2.is_screen_saver_enabled == :true
106
+ end
107
+
108
+ describe SDL2::Window do
109
+
110
+ end
111
+
112
+ it 'can query OpenGL Extension Support' do
113
+ skip 'not sure how to write this test right now.'
114
+ end
115
+
116
+ it 'can query and set OpenGL Attributes' do
117
+ skip 'for now.'
118
+ end
119
+
120
+ describe SDL2::Display do
121
+ it 'can count the displays attached' do
122
+ sdl_count = SDL2.get_num_video_displays()
123
+ assert_equal sdl_count, SDL2::Display.count
124
+ end
125
+
126
+ it 'can get the first display' do
127
+ assert_kind_of SDL2::Display, SDL2::Display.first
128
+ end
129
+
130
+ it 'can get the display bounds' do
131
+ assert_kind_of SDL2::Rect, SDL2::Display.first.bounds!
132
+ end
133
+
134
+ it 'has many display modes' do
135
+ assert SDL2::Display.first.modes.count > 0
136
+ assert_kind_of SDL2::Display::Mode, SDL2::Display.first().modes.first
137
+ end
138
+
139
+ end
140
+
141
+ it 'can get the closest display mode' do
142
+ closest_display_mode_found = nil # for now
143
+
144
+ SDL2::Display::Mode.new do |wanted|
145
+
146
+ wanted.format = 0 #SDL2::PIXELFORMAT_RGBA8888 #TODO: Import PIXELFORMAT
147
+ # constants?
148
+ wanted.w = 640
149
+ wanted.h = 480
150
+ wanted.refresh_rate = 60
151
+ wanted.driverdata = nil
152
+
153
+ closest_display_mode_found = SDL2::Display.first.closest_display_mode!(wanted)
154
+ end # This should automatically dispose of the display_mode struct we created
155
+ # as wanted
156
+ assert_kind_of SDL2::Display::Mode, closest_display_mode_found
157
+
158
+ end
159
+ #TODO: Redo GLContext testing
160
+ #describe SDL2::GLContext do
161
+ #
162
+ # it 'can create gl_context' do
163
+ # window = SDL2::Window.create!()
164
+ # context = SDL2::GLContext.create!(window)
165
+ # assert_kind_of SDL2::GLContext, context
166
+ # end
167
+ #
168
+ # end
169
+
170
+ end