it renders text, but wrong

This commit is contained in:
cqc
2022-09-02 19:22:06 -05:00
parent 7460b8f793
commit 6a484c3a06
5 changed files with 462 additions and 1123 deletions

View File

@ -40,7 +40,7 @@ let _ =
(* File in this case is actually the CSS font name *)
Text.create vg ~name:"sans" ~file:"sans" |> ignore ;
webgl_ctx##clearColor 0.3 0.3 0.32 1. ;
let rec render (time : float) =
let render ev =
webgl_ctx##clear
( webgl_ctx##._COLOR_BUFFER_BIT_
lor webgl_ctx##._DEPTH_BUFFER_BIT_
@ -49,7 +49,7 @@ let _ =
begin_frame vg ~width:canvas##.width ~height:canvas##.height
~device_ratio ;
Transform.scale vg ~x:device_ratio ~y:device_ratio ;
Human.Display.render vg canvas##.width canvas##.height ;
ignore Human.Panel.Ui.(panel vg Gg.P2.o test ev) ;
(*
Path.begin_ vg ;
Path.rect vg ~x:40. ~y:40. ~w:320. ~h:320. ;
@ -62,8 +62,11 @@ let _ =
Text.set_align vg ~align:Align.(center lor middle) ;
set_fill_color vg ~color:Color.white ;
Text.text vg ~x:0. ~y:0. "Hello World!" ; *)
NVG.end_frame vg ;
Dom_html.window##requestAnimationFrame (Js.wrap_callback render)
|> ignore in
Dom_html.window##requestAnimationFrame (Js.wrap_callback render)
|> ignore
NVG.end_frame vg in
Dom_html.window##requestAnimationFrame
(Js.wrap_callback (fun _ -> render Human.Event.empty))
|> ignore ;
Dom_html.document##.onkeydown
:= Dom.handler (fun (evt : Dom_html.keyboardEvent Js.t) ->
render (Human.Event_js.evt_of_jskey `Press evt) ;
Js._false )

17
dune
View File

@ -1,19 +1,26 @@
(env
(dev
(flags (:standard -warn-error -A))))
(dev (flags (:standard -warn-error -A))
(js_of_ocaml (flags --pretty --no-inline --source-map --debug-info) (compilation_mode separate)))
)
(executable
(name boot_js)
(modes byte js)
(preprocess (pps js_of_ocaml-ppx))
(modules boot_js backend backend_js human)
(modules boot_js human)
(libraries
fmt
graphv_webgl
js_of_ocaml
lwt
irmin-git
irmin-indexeddb
; irmin-git
; irmin-indexeddb
zed
gg
))

View File

@ -1,3 +1,2 @@
(lang dune 2.8)
(name komm)
(wrapped_executables false)
(lang dune 3.4)
(name boot)

1504
human.ml

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,8 @@ div {
}
canvas {
width: 400px;
height: 400px;
width: 100%;
height: 100%;
}
</style>
</head>