rename ~bb argument(s) to ~rect
This commit is contained in:
parent
4983226b4a
commit
827c5eb0a6
24
src/n2/n2.ml
24
src/n2/n2.ml
|
@ -75,13 +75,13 @@ module Sprite_graph = struct
|
|||
include (val Ohlog.logs "SG")
|
||||
|
||||
type t = {
|
||||
mutable list_rev : sprite list;
|
||||
mutable list : sprite list;
|
||||
mutable list_rev : node list;
|
||||
mutable list : node list;
|
||||
}
|
||||
|
||||
and sprite = {
|
||||
and node = {
|
||||
tf : mat2a;
|
||||
bb : aabb;
|
||||
rect : aabb;
|
||||
fill : color;
|
||||
(* mutable remove : bool; *)
|
||||
}
|
||||
|
@ -91,18 +91,22 @@ module Sprite_graph = struct
|
|||
list = [];
|
||||
}
|
||||
|
||||
let add t ~tf ~bb ~fill =
|
||||
let sp = { tf; bb; fill } in
|
||||
let push t node =
|
||||
begin
|
||||
t.list_rev <- sp :: t.list_rev;
|
||||
t.list_rev <- node :: t.list_rev;
|
||||
t.list <- [];
|
||||
end
|
||||
|
||||
let add t ~tf ~rect ~fill =
|
||||
let node = { tf; rect; fill } in
|
||||
push t node;
|
||||
node
|
||||
|
||||
let rec render_rec ren = function
|
||||
| [] -> ()
|
||||
| { tf; bb; fill } :: sps ->
|
||||
S2.Renderer.draw_rect ren ~tf ~bb ~fill;
|
||||
render_rec ren sps
|
||||
| { tf; rect; fill } :: nodes ->
|
||||
S2.Renderer.draw_rect ren ~tf ~rect ~fill;
|
||||
render_rec ren nodes
|
||||
|
||||
let render t ~ren =
|
||||
if t.list = [] then
|
||||
|
|
|
@ -286,13 +286,13 @@ let clear _t (bg : color) =
|
|||
Gl.clear Gl.color_buffer_bit;
|
||||
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
|
||||
begin
|
||||
(* TODO: cache/store uniform locations in some way *)
|
||||
use sh;
|
||||
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_color (uniform sh "Fill") fill;
|
||||
draw_geometry t.rect;
|
||||
|
|
Loading…
Reference in New Issue