;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helpers for opengl rendering of fluidsym
(bind-func update_data_points
(lambda () ;;cube:fluidcube* point_data:float* color_data:float*)
(let ((vao DataVAO)
(cube (get_fluid_cube))
(vert_vbo (get_vbo vao 0))
(verts (data vert_vbo))
(vertsf (cast verts float*))
(colour_vbo (get_vbo vao 3))
(colours (data colour_vbo))
(coloursf (cast colours float*))
(densities (tref cube 5))
(ii:i64 0)
(jj:i64 0)
(Vx (tref cube 6))
(Vy (tref cube 7))
(size_x (tref cube 0))
(size_y (tref cube 10))
(cvar:float 0.0)
(cnt 0:i64)
(idx 0)
(red (dtof 1.0)) ;(dtof 0.3))
(blue (dtof 0.8))
(green (dtof 0.4))) ;(dtof .2)))
(dotimes (ii (- size_x 2))
(dotimes (jj (- size_y 2))
(set! idx (+ (+ ii 1) (* (+ jj 1) size_x)))
(pset! vertsf (+ 0 (* 4 cnt)) (- (* 2.0 (/ (i64tof ii) (i64tof CUBE_W))) 1.0))
(pset! vertsf (+ 1 (* 4 cnt)) (- (* 2.0 (/ (i64tof jj) (i64tof CUBE_H))) 1.0))
(pset! vertsf (+ 2 (* 4 cnt)) (* cvar 0.05))
(pset! vertsf (+ 3 (* 4 cnt)) 1.0)
(set! cvar (dtof (* 1.0 (pref densities idx))))
(pset! coloursf (+ 0 (* 4 cnt)) (* cvar red))
(pset! coloursf (+ 1 (* 4 cnt)) (* cvar green))
(pset! coloursf (+ 2 (* 4 cnt)) (* cvar blue))
;; (pset! coloursf (+ 2 (* 4 cnt)) (* cvar blue)) ;(* cvar (- 1.0 blue)))
(pset! coloursf (+ 3 (* 4 cnt)) cvar) ;1.0)
(set! cnt (+ cnt 1))))
(update vert_vbo)
(update colour_vbo))
void))