summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Benediktsson <mrjbq7@gmail.com>2018-01-21 21:54:34 -0800
committerJohn Benediktsson <mrjbq7@gmail.com>2018-01-21 21:54:34 -0800
commita3ab20b56ce302af229d00311031e352c81c93f9 (patch)
tree3607b13f1de2c430dd918b805ba54538905703f5
parent630f8dec09985fe5376c253ca079bc0199457386 (diff)
frame-buffer: resurrected.
-rw-r--r--frame-buffer/frame-buffer.factor111
1 files changed, 0 insertions, 111 deletions
diff --git a/frame-buffer/frame-buffer.factor b/frame-buffer/frame-buffer.factor
deleted file mode 100644
index e8137fe..0000000
--- a/frame-buffer/frame-buffer.factor
+++ /dev/null
@@ -1,111 +0,0 @@
-
-USING: accessors alien.c-types combinators grouping kernel
- locals math math.geometry.rect math.vectors opengl.gl sequences
- ui.gadgets ui.render ;
-
-IN: frame-buffer
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-TUPLE: <frame-buffer> < gadget pixels last-dim ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: update-frame-buffer ( <frame-buffer> -- )
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: init-frame-buffer-pixels ( frame-buffer -- )
- dup
- rect-dim product "uint[4]" <c-array>
- >>pixels
- drop ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: frame-buffer ( -- <frame-buffer> ) <frame-buffer> new-gadget ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: draw-pixels ( FRAME-BUFFER -- )
-
- FRAME-BUFFER rect-dim first2
- GL_RGBA
- GL_UNSIGNED_INT
- FRAME-BUFFER pixels>>
- glDrawPixels ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: read-pixels ( FRAME-BUFFER -- )
-
- 0
- 0
- FRAME-BUFFER rect-dim first2
- GL_RGBA
- GL_UNSIGNED_INT
- FRAME-BUFFER pixels>>
- glReadPixels ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: copy-row ( OLD NEW -- )
-
- [let | LEN [ OLD NEW min-length ] |
-
- OLD LEN head-slice 0 NEW copy ] ;
-
-: copy-pixels ( old-pixels old-width new-pixels new-width -- )
- [ 16 * <groups> ] 2bi@ [ copy-row ] 2each ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: update-last-dim ( frame-buffer -- ) dup rect-dim >>last-dim drop ;
-
-M:: <frame-buffer> layout* ( FRAME-BUFFER -- )
-
- {
- {
- [ FRAME-BUFFER last-dim>> f = ]
- [
- FRAME-BUFFER init-frame-buffer-pixels
-
- FRAME-BUFFER update-last-dim
- ]
- }
- {
- [ FRAME-BUFFER [ rect-dim ] [ last-dim>> ] bi = not ]
- [
- [let | OLD-PIXELS [ FRAME-BUFFER pixels>> ]
- OLD-WIDTH [ FRAME-BUFFER last-dim>> first ] |
-
- FRAME-BUFFER init-frame-buffer-pixels
-
- FRAME-BUFFER update-last-dim
-
- [let | NEW-PIXELS [ FRAME-BUFFER pixels>> ]
- NEW-WIDTH [ FRAME-BUFFER last-dim>> first ] |
-
- OLD-PIXELS OLD-WIDTH NEW-PIXELS NEW-WIDTH copy-pixels ] ]
- ]
- }
- { [ t ] [ ] }
- }
- cond ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-M:: <frame-buffer> draw-gadget* ( FRAME-BUFFER -- )
-
- FRAME-BUFFER rect-dim { 0 1 } v* first2 glRasterPos2i
-
- FRAME-BUFFER draw-pixels
-
- FRAME-BUFFER update-frame-buffer
-
- glFlush
-
- FRAME-BUFFER read-pixels ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-