Last active
August 29, 2015 13:56
-
-
Save dbuenzli/9050445 to your computer and use it in GitHub Desktop.
Test case for spinning process with ctypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Spinning with 4.01.0 | |
Compile with: | |
ocamlfind ocamlc -package tsdl -linkpkg -o spin.byte spin.ml | |
ocamlfind ocamlopt -package tsdl -linkpkg -o spin.native spin.ml | |
*) | |
open Tsdl | |
let test () = | |
match Sdl.create_window "Test" ~w:640 ~h:480 Sdl.Window.resizable with | |
| `Error msg -> Sdl.log "%s" msg | |
| `Ok w -> | |
Printf.printf "Pump...\n%!"; | |
Sdl.pump_events (); | |
Printf.printf "Pumped !\n%!"; | |
let e = Sdl.Event.create () in | |
let s = Sdl.get_event_state Sdl.Event.window_event in | |
Printf.printf "Event state: %s" begin match s with | |
| s when s = Sdl.disable -> "disable" | |
| s when s = Sdl.enable -> "enable" | |
| _ -> assert false | |
end; | |
Printf.printf "Exit in 1ms!%!"; | |
ignore (Sdl.wait_event_timeout (Some e) 1); | |
Sdl.destroy_window w; | |
() | |
let main () = match Sdl.init Sdl.Init.(video + video + events) with | |
| `Error msg -> Sdl.log "%s" msg; exit 1 | |
| `Ok () -> test (); exit 0 | |
let () = main () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment