lol replaced Lwd with Lwt_react basically seemlessly, hope the physical equality hack doesn't bite me in the ass

This commit is contained in:
cqc
2024-07-08 21:55:16 -05:00
parent b117b6916b
commit 0193c3e7f0
3 changed files with 171 additions and 49 deletions

View File

@ -76,8 +76,7 @@ let main =
in
let ui =
Ogui.Ui.window ctx ~window
(Lwd.var Gg.(Box2.v P2.o (P2.v 500. 500.)))
Ogui.Ui.window ctx ~window Gg.(Box2.v P2.o (P2.v 500. 500.))
in
load_fonts ui.gv;
@ -178,10 +177,12 @@ let main =
~style:
Style.{ default with margin = Margin.symmetric 10.0 10.0 }
(Lwd.var
[
TextEdit.multiline ui tb_init;
TextEdit.multiline ui to_init;
]))
~eq:(fun (a, _) (b, _) -> Int.equal a b)
( 0,
[
TextEdit.multiline ui tb_init;
TextEdit.multiline ui to_init;
] )))
>>= fun page ->
let page_root = Lwd.observe page in
@ -196,7 +197,7 @@ let main =
[ Custom ("toplevel_execute", fun () -> Lwt.return ()) ]);
let bindings =
ui.bindings |> Lwd.get |> Lwd.observe |> Lwd.quick_sample
ui.bindings |> Lwd.get |> Lwd.observe |> Lwd.quick_sample |> snd
in
F.epr "Bindings:@.%a" Ui.pp_bindings bindings;
@ -244,9 +245,19 @@ let main =
if not GLFW.(windowShouldClose ~window) then draw_loop ()
else Lwt.return_unit
in
draw_loop () >>= fun () ->
(try draw_loop ()
with e ->
F.epr "draw_loop Exception: %s@.Backtrace:@.%s@."
(Printexc.to_string e)
(Printexc.get_backtrace ())
|> Lwt.return)
>>= fun () ->
Printf.printf "MIN %.2f\n" !min_fps;
Printf.printf "MAX %.2f\n%!" !max_fps;
Lwt.return_unit
let () = Lwt_main.run main
let () =
try Lwt_main.run main
with e ->
F.epr "Exception: %s@.Backtrace:@.%s@." (Printexc.to_string e)
(Printexc.get_backtrace ())