]> gitweb.factorcode.org Git - factor.git/commitdiff
frame-buffer: move to ui.gadgets.frame-buffer.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 21:51:32 +0000 (13:51 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 21:51:32 +0000 (13:51 -0800)
extra/bubble-chamber/bubble-chamber.factor
extra/frame-buffer/frame-buffer.factor [deleted file]
extra/ui/gadgets/frame-buffer/frame-buffer.factor [new file with mode: 0644]

index 2b642b13edec25b385f060bf7fb87235aa438691..dcbd776292489cbfabd203cc40020c1faf1482f6 100644 (file)
@@ -1,9 +1,9 @@
 USING: accessors arrays ascii calendar colors colors.gray
-combinators.short-circuit frame-buffer fry kernel locals math
-math.constants math.functions math.libm math.order math.points
-math.ranges math.vectors namespaces opengl processing.shapes
-quotations random sequences splitting threads timers ui
-ui.gadgets ui.gadgets.borders ui.gadgets.buttons
+combinators.short-circuit fry kernel locals math math.constants
+math.functions math.libm math.order math.points math.ranges
+math.vectors namespaces opengl processing.shapes quotations
+random sequences splitting threads timers ui ui.gadgets
+ui.gadgets.borders ui.gadgets.buttons ui.gadgets.frame-buffer
 ui.gadgets.packs ui.gestures ;
 
 IN: bubble-chamber
diff --git a/extra/frame-buffer/frame-buffer.factor b/extra/frame-buffer/frame-buffer.factor
deleted file mode 100644 (file)
index e2b13b1..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-USING: accessors alien.c-types alien.data combinators grouping
-kernel locals math math.vectors opengl opengl.gl sequences
-specialized-arrays ui.gadgets ui.render ;
-SPECIALIZED-ARRAY: uint
-IN: frame-buffer
-
-TUPLE: frame-buffer < gadget pixels last-dim ;
-
-: <frame-buffer> ( -- frame-buffer ) frame-buffer new ;
-
-GENERIC: update-frame-buffer ( frame-buffer -- )
-
-: init-frame-buffer-pixels ( frame-buffer -- )
-  dup dim>> [ gl-scale ] map product >integer 4 * uint <c-array> >>pixels
-  drop ;
-
-:: draw-pixels ( FRAME-BUFFER -- )
-    FRAME-BUFFER dim>> first2 [ gl-scale >fixnum ] bi@
-    GL_RGBA
-    GL_UNSIGNED_INT
-    FRAME-BUFFER pixels>>
-    glDrawPixels ;
-
-:: read-pixels ( FRAME-BUFFER -- )
-    0
-    0
-    FRAME-BUFFER dim>> first2 [ gl-scale >fixnum ] bi@
-    GL_RGBA
-    GL_UNSIGNED_INT
-    FRAME-BUFFER pixels>>
-    glReadPixels ;
-
-:: copy-row ( OLD NEW -- )
-    OLD NEW min-length :> LEN
-    OLD LEN head-slice 0 NEW copy ;
-
-: copy-pixels ( old-pixels old-width new-pixels new-width -- )
-    [ [ drop { } ] [ 16 * <groups> ] if-zero ] 2bi@
-    [ copy-row ] 2each ;
-
-M:: frame-buffer layout* ( FRAME-BUFFER -- )
-    FRAME-BUFFER last-dim>> [
-        FRAME-BUFFER dim>> = [
-            FRAME-BUFFER pixels>> :> OLD-PIXELS
-            FRAME-BUFFER last-dim>> first gl-scale >fixnum :> OLD-WIDTH
-            FRAME-BUFFER init-frame-buffer-pixels
-            FRAME-BUFFER [ dim>> ] [ last-dim<< ] bi
-            FRAME-BUFFER pixels>> :> NEW-PIXELS
-            FRAME-BUFFER last-dim>> first gl-scale >fixnum :> NEW-WIDTH
-            OLD-PIXELS OLD-WIDTH NEW-PIXELS NEW-WIDTH copy-pixels
-        ] unless
-    ] [
-        FRAME-BUFFER init-frame-buffer-pixels
-        FRAME-BUFFER [ dim>> ] [ last-dim<< ] bi
-    ] if* ;
-
-M:: frame-buffer draw-gadget* ( FRAME-BUFFER -- )
-    FRAME-BUFFER dim>> { 0 1 } v* first2 glRasterPos2i
-    FRAME-BUFFER draw-pixels
-    FRAME-BUFFER update-frame-buffer
-    glFlush
-    FRAME-BUFFER read-pixels ;
-
diff --git a/extra/ui/gadgets/frame-buffer/frame-buffer.factor b/extra/ui/gadgets/frame-buffer/frame-buffer.factor
new file mode 100644 (file)
index 0000000..c66945c
--- /dev/null
@@ -0,0 +1,63 @@
+USING: accessors alien.c-types alien.data combinators grouping
+kernel locals math math.vectors opengl opengl.gl sequences
+specialized-arrays ui.gadgets ui.render ;
+SPECIALIZED-ARRAY: uint
+IN: ui.gadgets.frame-buffer
+
+TUPLE: frame-buffer < gadget pixels last-dim ;
+
+: <frame-buffer> ( -- frame-buffer ) frame-buffer new ;
+
+GENERIC: update-frame-buffer ( frame-buffer -- )
+
+: init-frame-buffer-pixels ( frame-buffer -- )
+  dup dim>> [ gl-scale ] map product >integer 4 * uint <c-array> >>pixels
+  drop ;
+
+:: draw-pixels ( FRAME-BUFFER -- )
+    FRAME-BUFFER dim>> first2 [ gl-scale >fixnum ] bi@
+    GL_RGBA
+    GL_UNSIGNED_INT
+    FRAME-BUFFER pixels>>
+    glDrawPixels ;
+
+:: read-pixels ( FRAME-BUFFER -- )
+    0
+    0
+    FRAME-BUFFER dim>> first2 [ gl-scale >fixnum ] bi@
+    GL_RGBA
+    GL_UNSIGNED_INT
+    FRAME-BUFFER pixels>>
+    glReadPixels ;
+
+:: copy-row ( OLD NEW -- )
+    OLD NEW min-length :> LEN
+    OLD LEN head-slice 0 NEW copy ;
+
+: copy-pixels ( old-pixels old-width new-pixels new-width -- )
+    [ [ drop { } ] [ 16 * <groups> ] if-zero ] 2bi@
+    [ copy-row ] 2each ;
+
+M:: frame-buffer layout* ( FRAME-BUFFER -- )
+    FRAME-BUFFER last-dim>> [
+        FRAME-BUFFER dim>> = [
+            FRAME-BUFFER pixels>> :> OLD-PIXELS
+            FRAME-BUFFER last-dim>> first gl-scale >fixnum :> OLD-WIDTH
+            FRAME-BUFFER init-frame-buffer-pixels
+            FRAME-BUFFER [ dim>> ] [ last-dim<< ] bi
+            FRAME-BUFFER pixels>> :> NEW-PIXELS
+            FRAME-BUFFER last-dim>> first gl-scale >fixnum :> NEW-WIDTH
+            OLD-PIXELS OLD-WIDTH NEW-PIXELS NEW-WIDTH copy-pixels
+        ] unless
+    ] [
+        FRAME-BUFFER init-frame-buffer-pixels
+        FRAME-BUFFER [ dim>> ] [ last-dim<< ] bi
+    ] if* ;
+
+M:: frame-buffer draw-gadget* ( FRAME-BUFFER -- )
+    FRAME-BUFFER dim>> { 0 1 } v* first2 glRasterPos2i
+    FRAME-BUFFER draw-pixels
+    FRAME-BUFFER update-frame-buffer
+    glFlush
+    FRAME-BUFFER read-pixels ;
+