Basic window open

based on 0c24a39748/ocaml/main.ml
This commit is contained in:
Elnu 2025-04-07 17:00:20 -07:00
parent e77e6c0174
commit c492499402
5 changed files with 38 additions and 3 deletions

View file

@ -1,4 +1,4 @@
(executable (executable
(public_name ocaml_pong) (public_name ocaml_pong)
(name main) (name main)
(libraries ocaml_pong)) (libraries ocaml_pong tsdl))

View file

@ -1 +1,31 @@
let () = print_endline "Hello, World!" open Tsdl
let run () =
let (let*) = Result.bind in
let* _ = Sdl.init Sdl.Init.everything in
let* w = Sdl.create_window "Hello World!"
~x:Sdl.Window.pos_centered
~y:Sdl.Window.pos_centered
~w:620
~h:387
Sdl.Window.shown in
let* r = Sdl.create_renderer w
~index:(-1)
~flags:Sdl.Renderer.software in
for _ = 0 to 20 do
ignore @@ Sdl.render_clear r;
Sdl.render_present r;
Sdl.delay (Int32.of_int 100);
done;
Sdl.destroy_renderer r;
Sdl.destroy_window w;
Sdl.quit ();
Ok ()
let () =
match run () with
| Ok _ -> exit 0
| Error (`Msg e) ->
Sdl.log "Error: %s" e;
exit 1

View file

@ -17,7 +17,10 @@
(name ocaml_pong) (name ocaml_pong)
(synopsis "An OCaml pong clone") (synopsis "An OCaml pong clone")
(description "An pong clone written in OCaml, using the TSDL SDL bindings") (description "An pong clone written in OCaml, using the TSDL SDL bindings")
(depends ocaml) (depends
ocaml
tsdl
)
(tags (tags
("game"))) ("game")))

View file

@ -32,6 +32,7 @@
pname = "ocaml_pong"; pname = "ocaml_pong";
version = "0.1.0"; version = "0.1.0";
src = ./.; src = ./.;
buildInputs = [ tsdl ];
inherit meta; inherit meta;
}; };
}; };

View file

@ -9,6 +9,7 @@ tags: ["game"]
depends: [ depends: [
"dune" {>= "3.18"} "dune" {>= "3.18"}
"ocaml" "ocaml"
"tsdl"
"odoc" {with-doc} "odoc" {with-doc}
] ]
build: [ build: [