diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-03-21 12:02:30 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-21 12:41:48 +0000 |
| commit | 36f651c4e01143790b398cda3b5862cd7128e888 (patch) | |
| tree | 3646609a745ebed9e8a07c20faecb5edf43c2cc4 /alv-lib | |
| parent | lib: separate glsl-view video/tsv-input ops (diff) | |
| download | alive-36f651c4e01143790b398cda3b5862cd7128e888.tar.gz alive-36f651c4e01143790b398cda3b5862cd7128e888.zip | |
lib: add love/tsv-output
Diffstat (limited to 'alv-lib')
| -rw-r--r-- | alv-lib/love.moon | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/alv-lib/love.moon b/alv-lib/love.moon index 2fa7742..68a402f 100644 --- a/alv-lib/love.moon +++ b/alv-lib/love.moon @@ -1,5 +1,8 @@ import Constant, Op, PureOp, Input, Error, T, Array, any, sig from require 'alv.base' import RTNode from require 'alv' +tsv = do + ok, mod = pcall require, 'texture-share-vk' + ok and mod unpack or= table.unpack @@ -44,6 +47,28 @@ draw = Constant.meta destroy: => COPILOT.drawlist[@state] = nil +tsv_output = Constant.meta + meta: + name: 'tsv-output' + summary: "send rendered output via texture_share_vk." + examples: { '(love/tsv-output name)' } + + value: class extends Op + setup: (inputs, scope) => + name = sig.str\match inputs + @state or= tsv.new! + + super + name: Input.hot name + size: Input.hot COPILOT.window_size + + tick: => + { :name, :size } = @unwrap_all! + COPILOT.tsv_canvas = @state\newSharedCanvas name, unpack size + + destroy: => + COPILOT.tsv_canvas = nil + no_shape = Constant.meta meta: name: 'no-shape' @@ -446,6 +471,20 @@ If `key` is passed, outputs a bang! stream." if event and event == key @out\set true +window_size = Constant.meta + meta: + name: 'window-size' + summary: "outputs window size." + examples: { '(love/window-size)' } + description: "vec2! stream of mouse wheel movements." + + value: class extends Op + setup: (inputs) => + assert #inputs == 0, Error "argument", "no arguments expected" + @out = COPILOT.window_size + super Input.hot @out + + poll: => key_down = Constant.meta meta: @@ -524,6 +563,8 @@ macro [->>][]: :translate, :rotate, :scale, :shear :color, 'line-width': line_width + 'tsv-output': if tsv then tsv_output + 'mouse-pos': mouse_pos 'mouse-delta': mouse_delta 'mouse-presses': mouse_presses |
