2 USING: accessors alien.c-types combinators grouping kernel
3 locals math math.geometry.rect math.vectors opengl.gl sequences
8 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10 TUPLE: <frame-buffer> < gadget pixels last-dim ;
12 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14 GENERIC: update-frame-buffer ( <frame-buffer> -- )
16 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18 : init-frame-buffer-pixels ( frame-buffer -- )
20 rect-dim product "uint[4]" <c-array>
24 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 : frame-buffer ( -- <frame-buffer> ) <frame-buffer> new-gadget ;
28 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
30 :: draw-pixels ( FRAME-BUFFER -- )
32 FRAME-BUFFER rect-dim first2
38 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40 :: read-pixels ( FRAME-BUFFER -- )
44 FRAME-BUFFER rect-dim first2
50 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
52 :: copy-row ( OLD NEW -- )
54 [let | LEN [ OLD NEW min-length ] |
56 OLD LEN head-slice 0 NEW copy ] ;
58 : copy-pixels ( old-pixels old-width new-pixels new-width -- )
59 [ 16 * <sliced-groups> ] 2bi@
62 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
64 : update-last-dim ( frame-buffer -- ) dup rect-dim >>last-dim drop ;
66 M:: <frame-buffer> layout* ( FRAME-BUFFER -- )
70 [ FRAME-BUFFER last-dim>> f = ]
72 FRAME-BUFFER init-frame-buffer-pixels
74 FRAME-BUFFER update-last-dim
78 [ FRAME-BUFFER [ rect-dim ] [ last-dim>> ] bi = not ]
80 [let | OLD-PIXELS [ FRAME-BUFFER pixels>> ]
81 OLD-WIDTH [ FRAME-BUFFER last-dim>> first ] |
83 FRAME-BUFFER init-frame-buffer-pixels
85 FRAME-BUFFER update-last-dim
87 [let | NEW-PIXELS [ FRAME-BUFFER pixels>> ]
88 NEW-WIDTH [ FRAME-BUFFER last-dim>> first ] |
90 OLD-PIXELS OLD-WIDTH NEW-PIXELS NEW-WIDTH copy-pixels ] ]
97 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
99 M:: <frame-buffer> draw-gadget* ( FRAME-BUFFER -- )
101 FRAME-BUFFER rect-dim { 0 1 } v* first2 glRasterPos2i
103 FRAME-BUFFER draw-pixels
105 FRAME-BUFFER update-frame-buffer
109 FRAME-BUFFER read-pixels ;
111 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!