sdl2-win93 1.0.0
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 +7 -0
 - data/.dir-locals.el +2 -0
 - data/.github/workflows/gempush.yml +29 -0
 - data/.gitignore +14 -0
 - data/COPYING.txt +165 -0
 - data/Gemfile +4 -0
 - data/Gemfile.lock +24 -0
 - data/Makefile +4 -0
 - data/README.md +36 -0
 - data/Rakefile +51 -0
 - data/doc/po/ja.po +10357 -0
 - data/ext/sdl2_ext/clipboard.c +61 -0
 - data/ext/sdl2_ext/color.c +103 -0
 - data/ext/sdl2_ext/color.h +4 -0
 - data/ext/sdl2_ext/event.c +1298 -0
 - data/ext/sdl2_ext/extconf.rb +22 -0
 - data/ext/sdl2_ext/filesystem.c +63 -0
 - data/ext/sdl2_ext/gamecontroller.c +408 -0
 - data/ext/sdl2_ext/gamecontroller.c.m4 +408 -0
 - data/ext/sdl2_ext/gl.c +351 -0
 - data/ext/sdl2_ext/gl.c.m4 +351 -0
 - data/ext/sdl2_ext/hint.c +99 -0
 - data/ext/sdl2_ext/joystick.c +339 -0
 - data/ext/sdl2_ext/joystick.c.m4 +339 -0
 - data/ext/sdl2_ext/key.c +1302 -0
 - data/ext/sdl2_ext/key.c.m4 +833 -0
 - data/ext/sdl2_ext/main.c +258 -0
 - data/ext/sdl2_ext/messagebox.c +233 -0
 - data/ext/sdl2_ext/mixer.c +1205 -0
 - data/ext/sdl2_ext/mixer.c.m4 +1205 -0
 - data/ext/sdl2_ext/mouse.c +286 -0
 - data/ext/sdl2_ext/rubysdl2_internal.h +127 -0
 - data/ext/sdl2_ext/timer.c +63 -0
 - data/ext/sdl2_ext/ttf.c +376 -0
 - data/ext/sdl2_ext/ttf.c.m4 +376 -0
 - data/ext/sdl2_ext/video.c +4093 -0
 - data/ext/sdl2_ext/video.c.m4 +3867 -0
 - data/lib/sdl2.rb +3 -0
 - data/lib/sdl2/event.rb +55 -0
 - data/lib/sdl2/version.rb +8 -0
 - data/sample/chunk_destroy.rb +16 -0
 - data/sample/gfxprimitives.rb +54 -0
 - data/sample/icon.bmp +0 -0
 - data/sample/memory_test/m1.rb +28 -0
 - data/sample/memory_test/m2.rb +18 -0
 - data/sample/memory_test/m3.rb +12 -0
 - data/sample/message_box.rb +33 -0
 - data/sample/music_player.rb +137 -0
 - data/sample/playwave.rb +19 -0
 - data/sample/primitives.rb +32 -0
 - data/sample/test_clipboard.rb +16 -0
 - data/sample/test_controller.rb +62 -0
 - data/sample/test_joystick.rb +53 -0
 - data/sample/test_keyboard.rb +52 -0
 - data/sample/test_mouse.rb +50 -0
 - data/sample/test_surface.rb +13 -0
 - data/sample/test_ttf.rb +82 -0
 - data/sample/test_video.rb +59 -0
 - data/sample/testgl.rb +175 -0
 - data/sample/testsprite.rb +296 -0
 - data/sample/testspriteminimal.rb +75 -0
 - data/sample/timer.rb +11 -0
 - data/sample/version.rb +12 -0
 - data/sample/video_info.rb +64 -0
 - data/sdl2-win93.gemspec +31 -0
 - metadata +158 -0
 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            p SDL2::GameController.axis_name_of(SDL2::GameController::Axis::LEFTY)
         
     | 
| 
      
 12 
     | 
    
         
            +
            p SDL2::GameController.axis_name_of(129) rescue p $!
         
     | 
| 
      
 13 
     | 
    
         
            +
            p SDL2::GameController.axis_from_name("rightx")
         
     | 
| 
      
 14 
     | 
    
         
            +
            p SDL2::GameController.button_name_of(SDL2::GameController::Button::Y)
         
     | 
| 
      
 15 
     | 
    
         
            +
            p SDL2::GameController.button_from_name("x")
         
     | 
| 
      
 16 
     | 
    
         
            +
            p SDL2::GameController.button_from_name("rightx") rescue p $!
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            if SDL2::Joystick.num_connected_joysticks == 0
         
     | 
| 
      
 19 
     | 
    
         
            +
              puts "You need to connect at least one joystick"
         
     | 
| 
      
 20 
     | 
    
         
            +
              exit
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            joystick = SDL2::Joystick.open(0)
         
     | 
| 
      
 24 
     | 
    
         
            +
            guid = joystick.GUID
         
     | 
| 
      
 25 
     | 
    
         
            +
            joystick.close
         
     | 
| 
      
 26 
     | 
    
         
            +
            SDL2::GameController.add_mapping([guid, "No1",
         
     | 
| 
      
 27 
     | 
    
         
            +
                                              "leftx:a0,lefty:a1",
         
     | 
| 
      
 28 
     | 
    
         
            +
                                              "a:b3,b:b2,x:b1,y:b0"
         
     | 
| 
      
 29 
     | 
    
         
            +
                                             ].join(","))
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            p SDL2::Joystick.game_controller?(0)
         
     | 
| 
      
 33 
     | 
    
         
            +
            p SDL2::GameController.device_names
         
     | 
| 
      
 34 
     | 
    
         
            +
            controller = SDL2::GameController.open(0)
         
     | 
| 
      
 35 
     | 
    
         
            +
            p controller.name
         
     | 
| 
      
 36 
     | 
    
         
            +
            p controller.attached?
         
     | 
| 
      
 37 
     | 
    
         
            +
            p controller.mapping
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            $window = SDL2::Window.create("test_controller", 0,0,640,480,0)
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 42 
     | 
    
         
            +
              while event = SDL2::Event.poll
         
     | 
| 
      
 43 
     | 
    
         
            +
                case event
         
     | 
| 
      
 44 
     | 
    
         
            +
                when SDL2::Event::Quit
         
     | 
| 
      
 45 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 46 
     | 
    
         
            +
                when SDL2::Event::KeyDown
         
     | 
| 
      
 47 
     | 
    
         
            +
                  exit if event.sym == SDL2::Key::ESCAPE
         
     | 
| 
      
 48 
     | 
    
         
            +
                when SDL2::Event::ControllerAxisMotion
         
     | 
| 
      
 49 
     | 
    
         
            +
                  p event
         
     | 
| 
      
 50 
     | 
    
         
            +
                  p controller.axis(SDL2::GameController::Axis::LEFTX)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  p controller.axis(SDL2::GameController::Axis::LEFTY)
         
     | 
| 
      
 52 
     | 
    
         
            +
                when SDL2::Event::ControllerButton
         
     | 
| 
      
 53 
     | 
    
         
            +
                  p event
         
     | 
| 
      
 54 
     | 
    
         
            +
                  p controller.button_pressed?(SDL2::GameController::Button::A)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  p controller.button_pressed?(SDL2::GameController::Button::B)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  p controller.button_pressed?(SDL2::GameController::Button::X)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  p controller.button_pressed?(SDL2::GameController::Button::Y)
         
     | 
| 
      
 58 
     | 
    
         
            +
                when SDL2::Event::ControllerDevice
         
     | 
| 
      
 59 
     | 
    
         
            +
                  p event
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 9 
     | 
    
         
            +
            SDL2::TTF.init
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            p SDL2::Joystick.num_connected_joysticks
         
     | 
| 
      
 12 
     | 
    
         
            +
            p SDL2::Joystick.devices
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            if SDL2::Joystick.num_connected_joysticks > 0
         
     | 
| 
      
 15 
     | 
    
         
            +
              $joystick = SDL2::Joystick.open(0)
         
     | 
| 
      
 16 
     | 
    
         
            +
              p $joystick.name
         
     | 
| 
      
 17 
     | 
    
         
            +
              p $joystick.num_axes
         
     | 
| 
      
 18 
     | 
    
         
            +
              p $joystick.num_hats
         
     | 
| 
      
 19 
     | 
    
         
            +
              p $joystick.num_buttons
         
     | 
| 
      
 20 
     | 
    
         
            +
              p $joystick.num_balls
         
     | 
| 
      
 21 
     | 
    
         
            +
              p $joystick.GUID
         
     | 
| 
      
 22 
     | 
    
         
            +
              p $joystick.attached?
         
     | 
| 
      
 23 
     | 
    
         
            +
              p $joystick.index
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            window = SDL2::Window.create("testsprite",0, 0, 640, 480, 0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                                         
         
     | 
| 
      
 28 
     | 
    
         
            +
            renderer = window.create_renderer(-1, 0)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 32 
     | 
    
         
            +
              while ev = SDL2::Event.poll
         
     | 
| 
      
 33 
     | 
    
         
            +
                case ev
         
     | 
| 
      
 34 
     | 
    
         
            +
                when SDL2::Event::JoyButton, SDL2::Event::JoyAxisMotion
         
     | 
| 
      
 35 
     | 
    
         
            +
                  p ev
         
     | 
| 
      
 36 
     | 
    
         
            +
                when SDL2::Event::JoyDeviceAdded
         
     | 
| 
      
 37 
     | 
    
         
            +
                  p ev
         
     | 
| 
      
 38 
     | 
    
         
            +
                  $joystick = SDL2::Joystick.open(ev.which)
         
     | 
| 
      
 39 
     | 
    
         
            +
                when SDL2::Event::JoyDeviceRemoved
         
     | 
| 
      
 40 
     | 
    
         
            +
                  p ev
         
     | 
| 
      
 41 
     | 
    
         
            +
                  p $joystick.name
         
     | 
| 
      
 42 
     | 
    
         
            +
                when SDL2::Event::KeyDown
         
     | 
| 
      
 43 
     | 
    
         
            +
                  if ev.scancode == SDL2::Key::Scan::ESCAPE
         
     | 
| 
      
 44 
     | 
    
         
            +
                    exit
         
     | 
| 
      
 45 
     | 
    
         
            +
                  end
         
     | 
| 
      
 46 
     | 
    
         
            +
                when SDL2::Event::Quit
         
     | 
| 
      
 47 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              renderer.present
         
     | 
| 
      
 52 
     | 
    
         
            +
              sleep 0.1
         
     | 
| 
      
 53 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            window = SDL2::Window.create("testsprite", 0, 0, 640, 480, 0)
         
     | 
| 
      
 11 
     | 
    
         
            +
            renderer = window.create_renderer(-1, 0)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            puts "scancode of \"X\": #{SDL2::Key::Scan.from_name("X")}"
         
     | 
| 
      
 14 
     | 
    
         
            +
            puts "scancode of SDL2::Key::X: #{SDL2::Key::Scan.from_keycode(SDL2::Key::X)}"
         
     | 
| 
      
 15 
     | 
    
         
            +
            puts "keycode of \"X\": #{SDL2::Key.keycode_from_name("X")}"
         
     | 
| 
      
 16 
     | 
    
         
            +
            puts "keycode of SDL2::Key::Scan::X: #{SDL2::Key.keycode_from_scancode(SDL2::Key::Scan::X)}"
         
     | 
| 
      
 17 
     | 
    
         
            +
            SDL2::TextInput.rect = SDL2::Rect[20, 20, 200, 20]
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            def toggle_text_input
         
     | 
| 
      
 21 
     | 
    
         
            +
              if SDL2::TextInput.active?
         
     | 
| 
      
 22 
     | 
    
         
            +
                SDL2::TextInput.stop
         
     | 
| 
      
 23 
     | 
    
         
            +
              else
         
     | 
| 
      
 24 
     | 
    
         
            +
                SDL2::TextInput.start
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
              p SDL2::TextInput.active?
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 30 
     | 
    
         
            +
              while ev = SDL2::Event.poll
         
     | 
| 
      
 31 
     | 
    
         
            +
                case ev
         
     | 
| 
      
 32 
     | 
    
         
            +
                when SDL2::Event::Quit
         
     | 
| 
      
 33 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 34 
     | 
    
         
            +
                when SDL2::Event::TextInput
         
     | 
| 
      
 35 
     | 
    
         
            +
                  p ev
         
     | 
| 
      
 36 
     | 
    
         
            +
                  p ev.text
         
     | 
| 
      
 37 
     | 
    
         
            +
                when SDL2::Event::TextEditing
         
     | 
| 
      
 38 
     | 
    
         
            +
                  p ev
         
     | 
| 
      
 39 
     | 
    
         
            +
                when SDL2::Event::KeyDown
         
     | 
| 
      
 40 
     | 
    
         
            +
                  puts "scancode: #{ev.scancode}(#{SDL2::Key::Scan.name_of(ev.scancode)})"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  puts "keycode: #{ev.sym}(#{SDL2::Key.name_of(ev.sym)})"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  puts "mod: #{ev.mod}"
         
     | 
| 
      
 43 
     | 
    
         
            +
                  puts "mod(SDL2::Key::Mod.state): #{SDL2::Key::Mod.state}"
         
     | 
| 
      
 44 
     | 
    
         
            +
                  if ev.sym == SDL2::Key::RETURN
         
     | 
| 
      
 45 
     | 
    
         
            +
                    toggle_text_input
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              renderer.present
         
     | 
| 
      
 51 
     | 
    
         
            +
              sleep 0.01
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 10 
     | 
    
         
            +
            window = SDL2::Window.create("testsprite",0, 0, 640, 480, 0)
         
     | 
| 
      
 11 
     | 
    
         
            +
            renderer = window.create_renderer(-1, SDL2::Renderer::Flags::ACCELERATED)
         
     | 
| 
      
 12 
     | 
    
         
            +
            SDL2::TextInput.stop
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 15 
     | 
    
         
            +
              while ev = SDL2::Event.poll
         
     | 
| 
      
 16 
     | 
    
         
            +
                case ev
         
     | 
| 
      
 17 
     | 
    
         
            +
                when SDL2::Event::Quit
         
     | 
| 
      
 18 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 19 
     | 
    
         
            +
                when SDL2::Event::KeyDown
         
     | 
| 
      
 20 
     | 
    
         
            +
                  case ev.sym
         
     | 
| 
      
 21 
     | 
    
         
            +
                  when SDL2::Key::ESCAPE
         
     | 
| 
      
 22 
     | 
    
         
            +
                    exit
         
     | 
| 
      
 23 
     | 
    
         
            +
                  when SDL2::Key::S
         
     | 
| 
      
 24 
     | 
    
         
            +
                    state = SDL2::Mouse.state
         
     | 
| 
      
 25 
     | 
    
         
            +
                    p state
         
     | 
| 
      
 26 
     | 
    
         
            +
                    p [state.x, state.y, state.button_bits,
         
     | 
| 
      
 27 
     | 
    
         
            +
                       state.pressed?(1), state.pressed?(2), state.pressed?(3)]
         
     | 
| 
      
 28 
     | 
    
         
            +
                  when SDL2::Key::R
         
     | 
| 
      
 29 
     | 
    
         
            +
                    p SDL2::Mouse.relative_state        
         
     | 
| 
      
 30 
     | 
    
         
            +
                  when SDL2::Key::SPACE
         
     | 
| 
      
 31 
     | 
    
         
            +
                    SDL2::Mouse.relative_mode = ! SDL2::Mouse.relative_mode?
         
     | 
| 
      
 32 
     | 
    
         
            +
                  when SDL2::Key::T
         
     | 
| 
      
 33 
     | 
    
         
            +
                    if SDL2::Mouse::Cursor.shown?
         
     | 
| 
      
 34 
     | 
    
         
            +
                      SDL2::Mouse::Cursor.hide
         
     | 
| 
      
 35 
     | 
    
         
            +
                    else
         
     | 
| 
      
 36 
     | 
    
         
            +
                      SDL2::Mouse::Cursor.show
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
      
 38 
     | 
    
         
            +
                  when SDL2::Key::F
         
     | 
| 
      
 39 
     | 
    
         
            +
                    p SDL2::Mouse.focused_window
         
     | 
| 
      
 40 
     | 
    
         
            +
                  when SDL2::Key::W
         
     | 
| 
      
 41 
     | 
    
         
            +
                    SDL2::Mouse::Cursor.warp(window, 100, 20)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                when SDL2::Event::MouseButtonDown
         
     | 
| 
      
 44 
     | 
    
         
            +
                  p ev
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              renderer.present
         
     | 
| 
      
 49 
     | 
    
         
            +
              sleep 0.01
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            s = SDL2::Surface.load("icon.bmp")
         
     | 
| 
      
 9 
     | 
    
         
            +
            p s.w
         
     | 
| 
      
 10 
     | 
    
         
            +
            p s.h
         
     | 
| 
      
 11 
     | 
    
         
            +
            p s.pitch
         
     | 
| 
      
 12 
     | 
    
         
            +
            p s.bits_per_pixel
         
     | 
| 
      
 13 
     | 
    
         
            +
            s2 = SDL2::Surface.from_string(s.pixels, 32, 32, 24)
         
     | 
    
        data/sample/test_ttf.rb
    ADDED
    
    | 
         @@ -0,0 +1,82 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 9 
     | 
    
         
            +
            SDL2::TTF.init
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            window = SDL2::Window.create("testsprite",
         
     | 
| 
      
 13 
     | 
    
         
            +
                                         SDL2::Window::POS_CENTERED, SDL2::Window::POS_CENTERED,
         
     | 
| 
      
 14 
     | 
    
         
            +
                                         640, 480, 0)
         
     | 
| 
      
 15 
     | 
    
         
            +
            renderer = window.create_renderer(-1, 0)
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            font = SDL2::TTF.open("font.ttf", 40)
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            def draw_three_types(renderer, font, x, ybase)
         
     | 
| 
      
 20 
     | 
    
         
            +
              renderer.copy(renderer.create_texture_from(font.render_solid("Foo", [255, 255, 255])),
         
     | 
| 
      
 21 
     | 
    
         
            +
                            nil, SDL2::Rect.new(x, ybase, 100, 30))
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              renderer.copy(renderer.create_texture_from(font.render_shaded("Foo", [255, 255, 255], [0,0,0])),
         
     | 
| 
      
 24 
     | 
    
         
            +
                            nil, SDL2::Rect.new(x, ybase+40, 100, 30))
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              renderer.copy(renderer.create_texture_from(font.render_blended("Foo", [255, 255, 255])),
         
     | 
| 
      
 27 
     | 
    
         
            +
                            nil, SDL2::Rect.new(x, ybase+80, 100, 30))
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            p font.style
         
     | 
| 
      
 32 
     | 
    
         
            +
            p font.outline
         
     | 
| 
      
 33 
     | 
    
         
            +
            p font.hinting
         
     | 
| 
      
 34 
     | 
    
         
            +
            p font.kerning
         
     | 
| 
      
 35 
     | 
    
         
            +
            p font.height
         
     | 
| 
      
 36 
     | 
    
         
            +
            p font.ascent
         
     | 
| 
      
 37 
     | 
    
         
            +
            p font.descent
         
     | 
| 
      
 38 
     | 
    
         
            +
            p font.line_skip
         
     | 
| 
      
 39 
     | 
    
         
            +
            p font.num_faces
         
     | 
| 
      
 40 
     | 
    
         
            +
            p font.face_is_fixed_width?
         
     | 
| 
      
 41 
     | 
    
         
            +
            p font.face_family_name
         
     | 
| 
      
 42 
     | 
    
         
            +
            p font.face_style_name
         
     | 
| 
      
 43 
     | 
    
         
            +
            p font.size_text("Foo")
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            renderer.draw_color = [255,0,0]
         
     | 
| 
      
 46 
     | 
    
         
            +
            renderer.fill_rect(SDL2::Rect.new(0,0,640,480))
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            draw_three_types(renderer, font, 20, 50)
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            font.outline = 1
         
     | 
| 
      
 51 
     | 
    
         
            +
            draw_three_types(renderer, font, 150, 50)
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            font.outline = 0
         
     | 
| 
      
 54 
     | 
    
         
            +
            font.style = SDL2::TTF::Style::BOLD
         
     | 
| 
      
 55 
     | 
    
         
            +
            draw_three_types(renderer, font, 280, 50)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            font.style = 0
         
     | 
| 
      
 58 
     | 
    
         
            +
            font.hinting = SDL2::TTF::Hinting::MONO
         
     | 
| 
      
 59 
     | 
    
         
            +
            draw_three_types(renderer, font, 410, 50)
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            font.style = 0
         
     | 
| 
      
 62 
     | 
    
         
            +
            font.hinting = SDL2::TTF::Hinting::NORMAL
         
     | 
| 
      
 63 
     | 
    
         
            +
            font.kerning = false
         
     | 
| 
      
 64 
     | 
    
         
            +
            draw_three_types(renderer, font, 540, 50)
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 68 
     | 
    
         
            +
              while ev = SDL2::Event.poll
         
     | 
| 
      
 69 
     | 
    
         
            +
                case ev
         
     | 
| 
      
 70 
     | 
    
         
            +
                when SDL2::Event::KeyDown
         
     | 
| 
      
 71 
     | 
    
         
            +
                  if ev.scancode == SDL2::Key::Scan::ESCAPE
         
     | 
| 
      
 72 
     | 
    
         
            +
                    exit
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                when SDL2::Event::Quit
         
     | 
| 
      
 75 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              renderer.present
         
     | 
| 
      
 80 
     | 
    
         
            +
              #GC.start
         
     | 
| 
      
 81 
     | 
    
         
            +
              sleep 0.1
         
     | 
| 
      
 82 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,59 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'sdl2'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              $LOAD_PATH.unshift File.expand_path File.join(__dir__, '../lib')
         
     | 
| 
      
 5 
     | 
    
         
            +
              retry
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            window = SDL2::Window.create("testsprite",
         
     | 
| 
      
 12 
     | 
    
         
            +
                                         SDL2::Window::POS_CENTERED, SDL2::Window::POS_CENTERED,
         
     | 
| 
      
 13 
     | 
    
         
            +
                                         640, 480, 0)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            renderer = window.create_renderer(-1,
         
     | 
| 
      
 16 
     | 
    
         
            +
                                              SDL2::Renderer::Flags::ACCELERATED|SDL2::Renderer::Flags::TARGETTEXTURE)
         
     | 
| 
      
 17 
     | 
    
         
            +
            texture = renderer.load_texture("icon.bmp")
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            rect = SDL2::Rect.new(48, 128, 32, 32)
         
     | 
| 
      
 20 
     | 
    
         
            +
            renderer.copy(texture, nil, rect)
         
     | 
| 
      
 21 
     | 
    
         
            +
            renderer.copy_ex(texture, nil, SDL2::Rect[128, 256, 48, 48], 45, nil,
         
     | 
| 
      
 22 
     | 
    
         
            +
                             SDL2::Renderer::FLIP_NONE)
         
     | 
| 
      
 23 
     | 
    
         
            +
            texture.blend_mode = SDL2::BlendMode::ADD
         
     | 
| 
      
 24 
     | 
    
         
            +
            renderer.copy(texture, nil, SDL2::Rect[128, 294, 48, 48])
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            texture.blend_mode = SDL2::BlendMode::NONE
         
     | 
| 
      
 27 
     | 
    
         
            +
            texture.color_mod = [128, 128, 255]
         
     | 
| 
      
 28 
     | 
    
         
            +
            renderer.copy(texture, nil, SDL2::Rect[300, 420, 48, 48])
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            texture.blend_mode = SDL2::BlendMode::NONE
         
     | 
| 
      
 31 
     | 
    
         
            +
            texture.color_mod = [255, 255, 255]
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            if renderer.support_render_target?
         
     | 
| 
      
 34 
     | 
    
         
            +
              empty_texture = renderer.create_texture(renderer.info.texture_formats.first,
         
     | 
| 
      
 35 
     | 
    
         
            +
                                                      SDL2::Texture::ACCESS_TARGET, 128, 128)
         
     | 
| 
      
 36 
     | 
    
         
            +
              renderer.render_target = empty_texture
         
     | 
| 
      
 37 
     | 
    
         
            +
              renderer.draw_color = [255, 0, 255]
         
     | 
| 
      
 38 
     | 
    
         
            +
              renderer.draw_line(0, 0, 128, 128)
         
     | 
| 
      
 39 
     | 
    
         
            +
              renderer.reset_render_target
         
     | 
| 
      
 40 
     | 
    
         
            +
              renderer.copy(empty_texture, SDL2::Rect[0, 0, 128, 128], SDL2::Rect[420, 20, 128, 128])
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 44 
     | 
    
         
            +
              while ev = SDL2::Event.poll
         
     | 
| 
      
 45 
     | 
    
         
            +
                p ev
         
     | 
| 
      
 46 
     | 
    
         
            +
                case ev
         
     | 
| 
      
 47 
     | 
    
         
            +
                when SDL2::Event::KeyDown
         
     | 
| 
      
 48 
     | 
    
         
            +
                  if ev.scancode == SDL2::Key::Scan::ESCAPE
         
     | 
| 
      
 49 
     | 
    
         
            +
                    exit
         
     | 
| 
      
 50 
     | 
    
         
            +
                  else
         
     | 
| 
      
 51 
     | 
    
         
            +
                    p ev.scancode
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              renderer.present
         
     | 
| 
      
 57 
     | 
    
         
            +
              sleep 0.1
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
    
        data/sample/testgl.rb
    ADDED
    
    | 
         @@ -0,0 +1,175 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'sdl2'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'gl'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            include Gl
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            WINDOW_W = 640
         
     | 
| 
      
 7 
     | 
    
         
            +
            WINDOW_H = 480
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            shadedCube = true
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            SDL2.init(SDL2::INIT_EVERYTHING)
         
     | 
| 
      
 12 
     | 
    
         
            +
            SDL2::GL.set_attribute(SDL2::GL::RED_SIZE, 8)
         
     | 
| 
      
 13 
     | 
    
         
            +
            SDL2::GL.set_attribute(SDL2::GL::GREEN_SIZE, 8)
         
     | 
| 
      
 14 
     | 
    
         
            +
            SDL2::GL.set_attribute(SDL2::GL::BLUE_SIZE, 8)
         
     | 
| 
      
 15 
     | 
    
         
            +
            SDL2::GL.set_attribute(SDL2::GL::ALPHA_SIZE, 8)
         
     | 
| 
      
 16 
     | 
    
         
            +
            SDL2::GL.set_attribute(SDL2::GL::DOUBLEBUFFER, 1)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            window = SDL2::Window.create("testgl", 0, 0, WINDOW_W, WINDOW_H, SDL2::Window::Flags::OPENGL)
         
     | 
| 
      
 19 
     | 
    
         
            +
            context = SDL2::GL::Context.create(window)
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            printf("OpenGL version %d.%d\n",
         
     | 
| 
      
 22 
     | 
    
         
            +
                   SDL2::GL.get_attribute(SDL2::GL::CONTEXT_MAJOR_VERSION),
         
     | 
| 
      
 23 
     | 
    
         
            +
                   SDL2::GL.get_attribute(SDL2::GL::CONTEXT_MINOR_VERSION))
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            glViewport( 0, 0, 640, 400 )
         
     | 
| 
      
 26 
     | 
    
         
            +
            glMatrixMode( GL_PROJECTION )
         
     | 
| 
      
 27 
     | 
    
         
            +
            glLoadIdentity( )
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            glMatrixMode( GL_MODELVIEW )
         
     | 
| 
      
 30 
     | 
    
         
            +
            glLoadIdentity( )
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            glEnable(GL_DEPTH_TEST)
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            glDepthFunc(GL_LESS)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            glShadeModel(GL_SMOOTH)
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            color =
         
     | 
| 
      
 39 
     | 
    
         
            +
              [[ 1.0,  1.0,  0.0], 
         
     | 
| 
      
 40 
     | 
    
         
            +
               [ 1.0,  0.0,  0.0],
         
     | 
| 
      
 41 
     | 
    
         
            +
               [ 0.0,  0.0,  0.0],
         
     | 
| 
      
 42 
     | 
    
         
            +
               [ 0.0,  1.0,  0.0],
         
     | 
| 
      
 43 
     | 
    
         
            +
               [ 0.0,  1.0,  1.0],
         
     | 
| 
      
 44 
     | 
    
         
            +
               [ 1.0,  1.0,  1.0],
         
     | 
| 
      
 45 
     | 
    
         
            +
               [ 1.0,  0.0,  1.0],
         
     | 
| 
      
 46 
     | 
    
         
            +
               [ 0.0,  0.0,  1.0]]
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            cube =
         
     | 
| 
      
 49 
     | 
    
         
            +
              [[ 0.5,  0.5, -0.5], 
         
     | 
| 
      
 50 
     | 
    
         
            +
               [ 0.5, -0.5, -0.5],
         
     | 
| 
      
 51 
     | 
    
         
            +
               [-0.5, -0.5, -0.5],
         
     | 
| 
      
 52 
     | 
    
         
            +
               [-0.5,  0.5, -0.5],
         
     | 
| 
      
 53 
     | 
    
         
            +
               [-0.5,  0.5,  0.5],
         
     | 
| 
      
 54 
     | 
    
         
            +
               [ 0.5,  0.5,  0.5],
         
     | 
| 
      
 55 
     | 
    
         
            +
               [ 0.5, -0.5,  0.5],
         
     | 
| 
      
 56 
     | 
    
         
            +
               [-0.5, -0.5,  0.5]]
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              while event = SDL2::Event.poll
         
     | 
| 
      
 62 
     | 
    
         
            +
                case event
         
     | 
| 
      
 63 
     | 
    
         
            +
                when SDL2::Event::Quit, SDL2::Event::KeyDown
         
     | 
| 
      
 64 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              glClearColor(0.0, 0.0, 0.0, 1.0);
         
     | 
| 
      
 69 
     | 
    
         
            +
              glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              glBegin(GL_QUADS) 
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              if shadedCube then
         
     | 
| 
      
 75 
     | 
    
         
            +
                glColor(color[0])
         
     | 
| 
      
 76 
     | 
    
         
            +
                glVertex(cube[0])
         
     | 
| 
      
 77 
     | 
    
         
            +
                glColor(color[1])
         
     | 
| 
      
 78 
     | 
    
         
            +
                glVertex(cube[1])
         
     | 
| 
      
 79 
     | 
    
         
            +
                glColor(color[2])
         
     | 
| 
      
 80 
     | 
    
         
            +
                glVertex(cube[2])
         
     | 
| 
      
 81 
     | 
    
         
            +
                glColor(color[3])
         
     | 
| 
      
 82 
     | 
    
         
            +
                glVertex(cube[3])
         
     | 
| 
      
 83 
     | 
    
         
            +
                
         
     | 
| 
      
 84 
     | 
    
         
            +
                glColor(color[3])
         
     | 
| 
      
 85 
     | 
    
         
            +
                glVertex(cube[3])
         
     | 
| 
      
 86 
     | 
    
         
            +
                glColor(color[4])
         
     | 
| 
      
 87 
     | 
    
         
            +
                glVertex(cube[4])
         
     | 
| 
      
 88 
     | 
    
         
            +
                glColor(color[7])
         
     | 
| 
      
 89 
     | 
    
         
            +
                glVertex(cube[7])
         
     | 
| 
      
 90 
     | 
    
         
            +
                glColor(color[2])
         
     | 
| 
      
 91 
     | 
    
         
            +
                glVertex(cube[2])
         
     | 
| 
      
 92 
     | 
    
         
            +
                
         
     | 
| 
      
 93 
     | 
    
         
            +
                glColor(color[0])
         
     | 
| 
      
 94 
     | 
    
         
            +
                glVertex(cube[0])
         
     | 
| 
      
 95 
     | 
    
         
            +
                glColor(color[5])
         
     | 
| 
      
 96 
     | 
    
         
            +
                glVertex(cube[5])
         
     | 
| 
      
 97 
     | 
    
         
            +
                glColor(color[6])
         
     | 
| 
      
 98 
     | 
    
         
            +
                glVertex(cube[6])
         
     | 
| 
      
 99 
     | 
    
         
            +
                glColor(color[1])
         
     | 
| 
      
 100 
     | 
    
         
            +
                glVertex(cube[1])
         
     | 
| 
      
 101 
     | 
    
         
            +
                
         
     | 
| 
      
 102 
     | 
    
         
            +
                glColor(color[5])
         
     | 
| 
      
 103 
     | 
    
         
            +
                glVertex(cube[5])
         
     | 
| 
      
 104 
     | 
    
         
            +
                glColor(color[4])
         
     | 
| 
      
 105 
     | 
    
         
            +
                glVertex(cube[4])
         
     | 
| 
      
 106 
     | 
    
         
            +
                glColor(color[7])
         
     | 
| 
      
 107 
     | 
    
         
            +
                glVertex(cube[7])
         
     | 
| 
      
 108 
     | 
    
         
            +
                glColor(color[6])
         
     | 
| 
      
 109 
     | 
    
         
            +
                glVertex(cube[6])
         
     | 
| 
      
 110 
     | 
    
         
            +
                
         
     | 
| 
      
 111 
     | 
    
         
            +
                glColor(color[5])
         
     | 
| 
      
 112 
     | 
    
         
            +
                glVertex(cube[5])
         
     | 
| 
      
 113 
     | 
    
         
            +
                glColor(color[0])
         
     | 
| 
      
 114 
     | 
    
         
            +
                glVertex(cube[0])
         
     | 
| 
      
 115 
     | 
    
         
            +
                glColor(color[3])
         
     | 
| 
      
 116 
     | 
    
         
            +
                glVertex(cube[3])
         
     | 
| 
      
 117 
     | 
    
         
            +
                glColor(color[4])
         
     | 
| 
      
 118 
     | 
    
         
            +
                glVertex(cube[4])
         
     | 
| 
      
 119 
     | 
    
         
            +
                
         
     | 
| 
      
 120 
     | 
    
         
            +
                glColor(color[6])
         
     | 
| 
      
 121 
     | 
    
         
            +
                glVertex(cube[6])
         
     | 
| 
      
 122 
     | 
    
         
            +
                glColor(color[1])
         
     | 
| 
      
 123 
     | 
    
         
            +
                glVertex(cube[1])
         
     | 
| 
      
 124 
     | 
    
         
            +
                glColor(color[2])
         
     | 
| 
      
 125 
     | 
    
         
            +
                glVertex(cube[2])
         
     | 
| 
      
 126 
     | 
    
         
            +
                glColor(color[7])
         
     | 
| 
      
 127 
     | 
    
         
            +
                glVertex(cube[7])
         
     | 
| 
      
 128 
     | 
    
         
            +
                
         
     | 
| 
      
 129 
     | 
    
         
            +
              else
         
     | 
| 
      
 130 
     | 
    
         
            +
                glColor(1.0, 0.0, 0.0)
         
     | 
| 
      
 131 
     | 
    
         
            +
                glVertex(cube[0])
         
     | 
| 
      
 132 
     | 
    
         
            +
                glVertex(cube[1])
         
     | 
| 
      
 133 
     | 
    
         
            +
                glVertex(cube[2])
         
     | 
| 
      
 134 
     | 
    
         
            +
                glVertex(cube[3])
         
     | 
| 
      
 135 
     | 
    
         
            +
                
         
     | 
| 
      
 136 
     | 
    
         
            +
                glColor(0.0, 1.0, 0.0)
         
     | 
| 
      
 137 
     | 
    
         
            +
                glVertex(cube[3])
         
     | 
| 
      
 138 
     | 
    
         
            +
                glVertex(cube[4])
         
     | 
| 
      
 139 
     | 
    
         
            +
                glVertex(cube[7])
         
     | 
| 
      
 140 
     | 
    
         
            +
                glVertex(cube[2])
         
     | 
| 
      
 141 
     | 
    
         
            +
                
         
     | 
| 
      
 142 
     | 
    
         
            +
                glColor(0.0, 0.0, 1.0)
         
     | 
| 
      
 143 
     | 
    
         
            +
                glVertex(cube[0])
         
     | 
| 
      
 144 
     | 
    
         
            +
                glVertex(cube[5])
         
     | 
| 
      
 145 
     | 
    
         
            +
                glVertex(cube[6])
         
     | 
| 
      
 146 
     | 
    
         
            +
                glVertex(cube[1])
         
     | 
| 
      
 147 
     | 
    
         
            +
                
         
     | 
| 
      
 148 
     | 
    
         
            +
                glColor(0.0, 1.0, 1.0)
         
     | 
| 
      
 149 
     | 
    
         
            +
                glVertex(cube[5])
         
     | 
| 
      
 150 
     | 
    
         
            +
                glVertex(cube[4])
         
     | 
| 
      
 151 
     | 
    
         
            +
                glVertex(cube[7])
         
     | 
| 
      
 152 
     | 
    
         
            +
                glVertex(cube[6])
         
     | 
| 
      
 153 
     | 
    
         
            +
                
         
     | 
| 
      
 154 
     | 
    
         
            +
                glColor(1.0, 1.0, 0.0)
         
     | 
| 
      
 155 
     | 
    
         
            +
                glVertex(cube[5])
         
     | 
| 
      
 156 
     | 
    
         
            +
                glVertex(cube[0])
         
     | 
| 
      
 157 
     | 
    
         
            +
                glVertex(cube[3])
         
     | 
| 
      
 158 
     | 
    
         
            +
                glVertex(cube[4])
         
     | 
| 
      
 159 
     | 
    
         
            +
                
         
     | 
| 
      
 160 
     | 
    
         
            +
                glColor(1.0, 0.0, 1.0)
         
     | 
| 
      
 161 
     | 
    
         
            +
                glVertex(cube[6])
         
     | 
| 
      
 162 
     | 
    
         
            +
                glVertex(cube[1])
         
     | 
| 
      
 163 
     | 
    
         
            +
                glVertex(cube[2])
         
     | 
| 
      
 164 
     | 
    
         
            +
                glVertex(cube[7])
         
     | 
| 
      
 165 
     | 
    
         
            +
                
         
     | 
| 
      
 166 
     | 
    
         
            +
              end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
              glEnd()
         
     | 
| 
      
 169 
     | 
    
         
            +
              
         
     | 
| 
      
 170 
     | 
    
         
            +
              glMatrixMode(GL_MODELVIEW)
         
     | 
| 
      
 171 
     | 
    
         
            +
              glRotate(5.0, 1.0, 1.0, 1.0)
         
     | 
| 
      
 172 
     | 
    
         
            +
              
         
     | 
| 
      
 173 
     | 
    
         
            +
              window.gl_swap
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
            end
         
     |