rename ~bb argument(s) to ~rect

This commit is contained in:
tali 2024-01-19 14:02:00 -05:00
parent 4983226b4a
commit 827c5eb0a6
2 changed files with 16 additions and 12 deletions

View File

@ -75,13 +75,13 @@ module Sprite_graph = struct
include (val Ohlog.logs "SG") include (val Ohlog.logs "SG")
type t = { type t = {
mutable list_rev : sprite list; mutable list_rev : node list;
mutable list : sprite list; mutable list : node list;
} }
and sprite = { and node = {
tf : mat2a; tf : mat2a;
bb : aabb; rect : aabb;
fill : color; fill : color;
(* mutable remove : bool; *) (* mutable remove : bool; *)
} }
@ -91,18 +91,22 @@ module Sprite_graph = struct
list = []; list = [];
} }
let add t ~tf ~bb ~fill = let push t node =
let sp = { tf; bb; fill } in
begin begin
t.list_rev <- sp :: t.list_rev; t.list_rev <- node :: t.list_rev;
t.list <- []; t.list <- [];
end end
let add t ~tf ~rect ~fill =
let node = { tf; rect; fill } in
push t node;
node
let rec render_rec ren = function let rec render_rec ren = function
| [] -> () | [] -> ()
| { tf; bb; fill } :: sps -> | { tf; rect; fill } :: nodes ->
S2.Renderer.draw_rect ren ~tf ~bb ~fill; S2.Renderer.draw_rect ren ~tf ~rect ~fill;
render_rec ren sps render_rec ren nodes
let render t ~ren = let render t ~ren =
if t.list = [] then if t.list = [] then

View File

@ -286,13 +286,13 @@ let clear _t (bg : color) =
Gl.clear Gl.color_buffer_bit; Gl.clear Gl.color_buffer_bit;
end end
let draw_rect t ~(tf : mat2a) ~(bb : aabb) ~(fill : color) = let draw_rect t ~(tf : mat2a) ~(rect : aabb) ~(fill : color) =
let sh = t.polygon in let sh = t.polygon in
begin begin
(* TODO: cache/store uniform locations in some way *) (* TODO: cache/store uniform locations in some way *)
use sh; use sh;
set_mat2a (uniform sh "Transform") tf; set_mat2a (uniform sh "Transform") tf;
set_aabb (uniform sh "BoundingBox") bb; set_aabb (uniform sh "BoundingBox") rect;
set_int (uniform sh "Border") 0; set_int (uniform sh "Border") 0;
set_color (uniform sh "Fill") fill; set_color (uniform sh "Fill") fill;
draw_geometry t.rect; draw_geometry t.rect;