2 Commits

Author SHA1 Message Date
klemek 99a71e9833 forge (steel) v1.0.2
Clang Lint CI / lint-no-video (push) Successful in 1m0s
Clang Lint CI / lint-video (push) Successful in 2m0s
Clang Build CI / run-no-video (push) Successful in 1m59s
Clang Build CI / run-video (push) Successful in 1m11s
Clang Build CI / build-release (push) Successful in 3m3s
2026-05-13 16:32:28 +02:00
klemek 51c6429957 fix: PKGBUILD 2026-05-13 16:32:11 +02:00
57 changed files with 1401 additions and 2339 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ on:
- 'Makefile.am' - 'Makefile.am'
env: env:
GCC_ARGS: src/*.c src/*.h -lglfw -lGL -lm -lasound -Wno-format-truncation -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_NATIVE_INCLUDE_NONE GCC_ARGS: src/*.c src/*.h -lglfw -lGL -lm -lasound -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_NATIVE_INCLUDE_NONE
GCC_ARGS_VIDEO: -DGLFW_EXPOSE_NATIVE_EGL -DVIDEO_IN GCC_ARGS_VIDEO: -DGLFW_EXPOSE_NATIVE_EGL -DVIDEO_IN
PACKAGES: "libglfw3-dev libgl-dev libasound2-dev" PACKAGES: "libglfw3-dev libgl-dev libasound2-dev"
PACKAGES_VIDEO: "libv4l-dev" PACKAGES_VIDEO: "libv4l-dev"
-1
View File
@@ -28,4 +28,3 @@ conftest.*
error.glsl error.glsl
draft/ draft/
*.gch *.gch
*.out
+7 -6
View File
@@ -8,7 +8,7 @@ build build project into build/forge
run run project with test args run run project with test args
demo run project with demo mode demo run project with demo mode
valgrind valgrind analysis valgrind valgrind analysis
full-clean remove build files and untracked files clean-release remove autoconf/automake files
test-release try to build release test-release try to build release
release-% make full release of version % release-% make full release of version %
release-arch make arch-linux release package release-arch make arch-linux release package
@@ -20,7 +20,7 @@ release-arch make arch-linux release package
# make full build # make full build
make -f Makefile.dev release-1.0.0 make -f Makefile.dev release-1.0.0
# push release # push release
git push origin main --tags git push origin master --tags
# create release from tag on github # create release from tag on github
# attach .tar.gz to the github release # attach .tar.gz to the github release
make -f Makefile.dev release-arch make -f Makefile.dev release-arch
@@ -124,12 +124,13 @@ make -f Makefile.dev release-arch
- [x] (clean) static functions at top of files - [x] (clean) static functions at top of files
- [x] Configurable key codes - [x] Configurable key codes
- [x] Monitor improvements - [x] Monitor improvements
- [x] Ignore some values in auto random - [ ] Ignore some values in auto random
- [x] build without video in - [x] build without video in
- [ ] Auto discover video devices
- [ ] Update README monitor/keymap - [ ] Update README monitor/keymap
- [x] Auto reconnect midi input - [ ] Auto reconnect midi input
- [x] Auto reconnect video device - [ ] Auto reconnect video device
- [x] Key codes as inputs - [ ] Key codes as inputs
- [ ] Mouse position and scroll as inputs - [ ] Mouse position and scroll as inputs
- [ ] Joystick as input - [ ] Joystick as input
- [ ] Record show as text files - [ ] Record show as text files
+2 -2
View File
@@ -1,9 +1,9 @@
AUTOMAKE_OPTIONS = foreign subdir-objects -Wall AUTOMAKE_OPTIONS = foreign subdir-objects -Wall
bin_PROGRAMS = forge bin_PROGRAMS = forge
forge_SOURCES = src/args.c src/arr.c src/config_file.c src/file.c src/forge.c src/main.c src/midi.c src/project.c src/rand.c src/shaders.c src/state.c src/string.c src/tempo.c src/timer.c src/video.c src/window.c $(top_srcdir)/include/glad/gl.h $(top_srcdir)/include/glad/egl.h $(top_srcdir)/hashmap.c/hashmap.c $(top_srcdir)/log.c/src/log.c forge_SOURCES = src/args.c src/arr.c src/config_file.c src/file.c src/forge.c src/main.c src/midi.c src/project.c src/rand.c src/shaders.c src/shared.c src/state.c src/string.c src/tempo.c src/timer.c src/video.c src/window.c $(top_srcdir)/include/glad/gl.h $(top_srcdir)/include/glad/egl.h $(top_srcdir)/hashmap.c/hashmap.c $(top_srcdir)/log.c/src/log.c
forge_CFLAGS = -Ofast -march=native -flto -funroll-loops -fprefetch-loop-arrays -fno-exceptions -fopenmp -I$(top_srcdir)/include -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DLOG_USE_COLOR -DVIDEO_IN -DDATADIR=\"$(datadir)/$(PACKAGE)\" forge_CFLAGS = -Ofast -march=native -flto -funroll-loops -fprefetch-loop-arrays -fno-exceptions -fopenmp -I$(top_srcdir)/include -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DLOG_USE_COLOR -DVIDEO_IN -DDATADIR=\"$(datadir)/$(PACKAGE)\"
forge_LDADD = -lm -lGL -lglfw -lasound forge_LDADD = -lm -lGL -lglfw -lasound
include_HEADERS = src/args.h src/arr.h src/config.h src/config_file.h src/constants.h src/file.h src/forge.h src/main.h src/midi.h src/project.h src/rand.h src/shaders.h src/state.h src/string.h src/tempo.h src/timer.h src/types.h src/video.h src/window.h $(top_srcdir)/include/glad/gl.h $(top_srcdir)/include/glad/egl.h $(top_srcdir)/include/linmath.h $(top_srcdir)/include/hashmap.h $(top_srcdir)/include/log.h include_HEADERS = src/args.h src/arr.h src/config.h src/config_file.h src/constants.h src/file.h src/forge.h src/main.h src/midi.h src/project.h src/rand.h src/shaders.h src/shared.h src/state.h src/string.h src/tempo.h src/timer.h src/types.h src/video.h src/window.h $(top_srcdir)/include/glad/gl.h $(top_srcdir)/include/glad/egl.h $(top_srcdir)/include/linmath.h $(top_srcdir)/include/hashmap.h $(top_srcdir)/include/log.h
EXTRA_DIST = default/forge_project.cfg default/frag1.glsl default/frag10.glsl default/frag2.glsl default/frag3.glsl default/frag4.glsl default/frag5.glsl default/frag6.glsl default/frag7.glsl default/frag8.glsl default/frag9.glsl default/inc_cp437.glsl default/inc_debug.glsl default/inc_functions.glsl default/inc_fx.glsl default/inc_magic.glsl default/inc_rand.glsl default/inc_res.glsl default/inc_sentences.glsl default/inc_src.glsl default/inc_template.glsl default/inc_time.glsl default/inc_yuyv.glsl EXTRA_DIST = default/forge_project.cfg default/frag1.glsl default/frag10.glsl default/frag2.glsl default/frag3.glsl default/frag4.glsl default/frag5.glsl default/frag6.glsl default/frag7.glsl default/frag8.glsl default/frag9.glsl default/inc_cp437.glsl default/inc_debug.glsl default/inc_functions.glsl default/inc_fx.glsl default/inc_magic.glsl default/inc_rand.glsl default/inc_res.glsl default/inc_sentences.glsl default/inc_src.glsl default/inc_template.glsl default/inc_time.glsl default/inc_yuyv.glsl
confdir = $(prefix)/share/$(PACKAGE) confdir = $(prefix)/share/$(PACKAGE)
+19 -20
View File
@@ -1,13 +1,13 @@
TARGET ?= forge TARGET ?= forge
INSTALL_DIR ?= $(HOME)/.local/bin INSTALL_DIR ?= $(HOME)/.local/bin
RUN_ARGS ?= --help TEST_ARGS ?= --video-in=/dev/video0 --video-in=/dev/video1 --video-in=/dev/video2 --video-in=/dev/video3 --video-in=/dev/video4 --video-in=/dev/video5 --video-in=/dev/video6 --video-in=/dev/video7 --video-in=/dev/video8 --video-in=/dev/video9
SHELL := /bin/bash SHELL := /bin/bash
.PHONY: build .PHONY: build
clean: clean:
@rm -rf build @rm -rf build
build/$(TARGET): build:
@mkdir -p build @mkdir -p build
gcc \ gcc \
src/*.h src/*.c \ src/*.h src/*.c \
@@ -25,9 +25,6 @@ build/$(TARGET):
-o build/$(TARGET) \ -o build/$(TARGET) \
-g -Og -g -Og
.PHONY: build
build: build/$(TARGET)
.PHONY: build-no-video .PHONY: build-no-video
build-no-video: build-no-video:
@mkdir -p build @mkdir -p build
@@ -51,28 +48,30 @@ format:
clang-format -i src/* clang-format -i src/*
.PHONY: run .PHONY: run
run: build/$(TARGET) run: build
./build/$(TARGET) $(RUN_ARGS) ./build/$(TARGET) $(TEST_ARGS) --monitor-only --internal-size=480 --video-size=240 --hot-reload
.PHONY: demo
demo: build
./build/$(TARGET) $(TEST_ARGS) --demo
.PHONY: sample .PHONY: sample
sample: build/$(TARGET) sample: build
./build/$(TARGET) --project=sample $(RUN_ARGS) ./build/$(TARGET) --project=sample
.PHONY: valgrind .PHONY: valgrind
valgrind: build/$(TARGET) valgrind: build
valgrind \ valgrind \
--show-realloc-size-zero=no \ --show-realloc-size-zero=no \
--undef-value-errors=no \ --undef-value-errors=no \
./build/$(TARGET) $(RUN_ARGS) ./build/$(TARGET) $(TEST_ARGS)
.PHONY: full-clean .PHONY: clean-release
full-clean: clean-release:
git clean -f -x git clean -f -x
rm -rf */*/.deps
rm -rf */.deps
.PHONY: test-release .PHONY: test-release
test-release: clean full-clean test-release: clean clean-release
aclocal aclocal
autoconf autoconf
automake --add-missing automake --add-missing
@@ -82,8 +81,8 @@ test-release: clean full-clean
cp $(TARGET)-steel-*.tar.gz build/ cp $(TARGET)-steel-*.tar.gz build/
.PHONY: release-% .PHONY: release-%
release-%: clean full-clean release-%: clean clean-release
git pull origin main git pull origin master
sed -i -E "s/[0-9]+\\.[0-9]+\\.[0-9]+/$*/g" configure.ac sed -i -E "s/[0-9]+\\.[0-9]+\\.[0-9]+/$*/g" configure.ac
aclocal aclocal
autoconf autoconf
@@ -96,8 +95,8 @@ release-%: clean full-clean
sha256sum build/forge-steel-$*.tar.gz | cut -d' ' -f1 | xargs -I{} sed -i -E "s/sha256sums=\\('.*'\\)/sha256sums=\\('{}'\\)/g" PKGBUILD sha256sum build/forge-steel-$*.tar.gz | cut -d' ' -f1 | xargs -I{} sed -i -E "s/sha256sums=\\('.*'\\)/sha256sums=\\('{}'\\)/g" PKGBUILD
git add configure.ac PKGBUILD git add configure.ac PKGBUILD
git commit -am "forge (steel) v$*" git commit -am "forge (steel) v$*"
git tag v$* -m "FORGE steel-$*" git tag v$* -m "forge (steel) v$*"
@echo "Push release: git push origin main --tags" @echo "Push release: git push origin master --tags"
@echo "Rollback release: git reset HEAD~1 --hard && git tag -d v$*" @echo "Rollback release: git reset HEAD~1 --hard && git tag -d v$*"
+4 -4
View File
@@ -1,12 +1,12 @@
pkgname=forge-steel pkgname=forge-steel
pkgver=1.2.1 pkgver=1.0.2
pkgrel=1 pkgrel=1
pkgdesc="Fusion Of Real Time Generative Effects" pkgdesc="Fusion Of Real Time Generative Effects"
arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv7h' 'armv6h' 'aarch64' 'riscv64') arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv7h' 'armv6h' 'aarch64' 'riscv64')
depends=('glfw>=1:3', 'v4l-utils>=1.32', 'alsa-lib>=1.2', 'libglvnd>=1.7') depends=('glfw>=1:3', 'v4l-utils>=1.32', 'alsa-lib>=1.2', 'libglvnd>=1.7')
url="https://git.klemek.fr/klemek/forge-steel" url="https://github.com/klemek/forge-steel"
source=("${pkgname}-steel-${pkgver}.tar.gz::https://git.klemek.fr/klemek/forge-steel/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz") source=("${pkgname}-steel-${pkgver}.tar.gz::https://git.klemek.fr/klemek/forge-steel/releases/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('57559bde7a524e3c9e70de4bc9b675a5a086590a8d85697cebd80c0ebd09f149') sha256sums=('53d47f1099556597bf4d9e09d9874e465aad77b3aaa51b3259a1fb955e774f83')
srcdir=build srcdir=build
backup=("usr/share/${pkgname}") backup=("usr/share/${pkgname}")
+21 -59
View File
@@ -1,4 +1,4 @@
[![](https://git.klemek.fr/klemek/forge-steel/actions/workflows/lint.yml/badge.svg?branch=main&style=flat-square)](https://git.klemek.fr/klemek/forge-steel/actions?workflow=lint.yml) [![](https://git.klemek.fr/klemek/forge-steel/actions/workflows/build.yml/badge.svg?branch=main&style=flat-square)](https://git.klemek.fr/klemek/forge-steel/actions?workflow=build.yml) ![LOC](https://img.shields.io/badge/cloc-3.6k-blue?style=flat-square) [![](https://git.klemek.fr/klemek/forge-steel/actions/workflows/lint.yml/badge.svg?branch=main&style=flat-square)](https://git.klemek.fr/klemek/forge-steel/actions?workflow=lint.yml) [![](https://git.klemek.fr/klemek/forge-steel/actions/workflows/build.yml/badge.svg?branch=main&style=flat-square)](https://git.klemek.fr/klemek/forge-steel/actions?workflow=build.yml)
<!-- omit from toc --> <!-- omit from toc -->
# F.O.R.G.E. (Steel) # F.O.R.G.E. (Steel)
@@ -119,7 +119,7 @@ Here's a quick rundown of the process:
### From release ### From release
See [Releases](https://git.klemek.fr/klemek/forge-steel/releases) See [Releases](https://github.com/klemek/forge-steel/releases)
```shell ```shell
tar xvzf forge-steel-x.y.z.tar.gz tar xvzf forge-steel-x.y.z.tar.gz
@@ -132,7 +132,7 @@ make install
### From repository (PKGBUILD) ### From repository (PKGBUILD)
```shell ```shell
git clone --recursive https://git.klemek.fr/klemek/forge-steel git clone --recursive https://github.com/klemek/forge-steel
cd forge cd forge
makepkg -si makepkg -si
``` ```
@@ -141,7 +141,7 @@ makepkg -si
### From repository (dev version) ### From repository (dev version)
```shell ```shell
git clone --recursive https://git.klemek.fr/klemek/forge-steel git clone --recursive https://github.com/klemek/forge-steel
cd forge cd forge
aclocal aclocal
autoconf autoconf
@@ -176,7 +176,7 @@ These are configurable in the [`forge_project.cfg`](#forge_projectcfg).
```txt ```txt
forge steel-dev forge steel-dev
usage: forge [-h] [-v] [-p=PROJECT_PATH] [-c=CFG_FILE] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-w] [-t=TEMPO] [-d] [-ar / -nar] [-arc=CYCLES] [-vi=FILE] [-vs=SIZE] [-vb=COUNT] [-vr / -nvr] [-vf=FOURCC] [-is=SIZE] [-ls / -nls] [-ss / -nss] [-mr / -nmr] [-tm] [-tf] usage: forge [-h] [-v] [-p=PROJECT_PATH] [-c=CFG_FILE] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-w] [-t=TEMPO] [-d] [-ar / -nar] [-arc=CYCLES] [-vi=FILE] [-vs=SIZE] [-vr / -nvr] [-is=SIZE] [-ls / -nls] [-ss / -nss] [-tm] [-tf]
Fusion Of Real-time Generative Effects. Fusion Of Real-time Generative Effects.
@@ -196,18 +196,14 @@ options:
-nar, --no-auto-random do not randomize state (default) -nar, --no-auto-random do not randomize state (default)
-arc, --auto-random-cycle auto random cycle length (default: 4) -arc, --auto-random-cycle auto random cycle length (default: 4)
-vi, --video-in path to video capture device (multiple allowed) -vi, --video-in path to video capture device (multiple allowed)
-vb, --video-buffers number of video buffers to use (default: 1)
-vs, --video-size video capture desired height (default: internal texture height) -vs, --video-size video capture desired height (default: internal texture height)
-vr, --video-reconnect auto-reconnect video (default) -vr, --video-reconnect auto-reconnect video (default)
-nvr, --no-video-reconnect do not auto-reconnect video -nvr, --no-video-reconnect do not auto-reconnect video
-vf, --video-fourcc video codec fourcc (default: YUYV)
-is, --internal-size internal texture height (default: 720) -is, --internal-size internal texture height (default: 720)
-ls, --load-state load saved state (default) -ls, --load-state load saved state (default)
-nls, --no-load-state do not load saved state -nls, --no-load-state do not load saved state
-ss, --save-state save state (default) -ss, --save-state save state (default)
-nss, --no-save-state do not save state -nss, --no-save-state do not save state
-mr, --midi-reconnect auto-reconnect midi (default)
-nmr, --no-midi-reconnect do not auto-reconnect midi
-tm, --trace-midi print midi code and values -tm, --trace-midi print midi code and values
-tf, --trace-fps print fps status of subsystems -tf, --trace-fps print fps status of subsystems
``` ```
@@ -248,7 +244,7 @@ Working with pages and items, you can use the following predefined sources and e
| **1** | **0** | Feedback + Thru | _Hue_ | _Saturation_ | _Light_ | Thru | _Hue_ | _Saturation_ | _Light_ | | **1** | **0** | Feedback + Thru | _Hue_ | _Saturation_ | _Light_ | Thru | _Hue_ | _Saturation_ | _Light_ |
| | **1** | Lines | _Thick. / Dezoom_ | _Rotation_ | _Distortion_ | Feedback + Shift | _Zoom / Dezoom_ | _X Shift_ | _Y Shift_ | | | **1** | Lines | _Thick. / Dezoom_ | _Rotation_ | _Distortion_ | Feedback + Shift | _Zoom / Dezoom_ | _X Shift_ | _Y Shift_ |
| | **2** | Dots | _Zoom_ | _Rotation_ | _Lens_ | Shift | _Zoom / Dezoom_ | _X Shift_ | _Y Shift_ | | | **2** | Dots | _Zoom_ | _Rotation_ | _Lens_ | Shift | _Zoom / Dezoom_ | _X Shift_ | _Y Shift_ |
| | **3** | Bacteria | _Zoom_ | _Details_ | _Delta details_ | Colorize | _Black Color_ | _White Color_ | _Shift_ | | | **3** | Circuit | _Zoom_ | _H. connect_ | _V. connect_ | Colorize | _Black Color_ | _White Color_ | _Shift_ |
| | **4** | Noise | _Zoom_ | _Voronoi dist._ | _Details_ | Quantize | _Pixel Size_ | _Bit Depth_ | _Blur_ | | | **4** | Noise | _Zoom_ | _Voronoi dist._ | _Details_ | Quantize | _Pixel Size_ | _Bit Depth_ | _Blur_ |
| **2** | **5** | Video In 1 + Thru | _Hue_ | _Saturation_ | _Light_ | Dithering | _Pixel Size_ | _Bit Depth_ | _Blur_ | | **2** | **5** | Video In 1 + Thru | _Hue_ | _Saturation_ | _Light_ | Dithering | _Pixel Size_ | _Bit Depth_ | _Blur_ |
| | **6** | CP437 | _Zoom_ | _Charset_ | _Char. Delta_ | TV | _Lens_ | _Horz. Noise_ | _Dezoom_ | | | **6** | CP437 | _Zoom_ | _Charset_ | _Char. Delta_ | TV | _Lens_ | _Horz. Noise_ | _Dezoom_ |
@@ -263,28 +259,6 @@ Working with pages and items, you can use the following predefined sources and e
See the [printable version](./docs/forge_default_mapping.pdf). See the [printable version](./docs/forge_default_mapping.pdf).
### Available hotkeys
| Hotkey | Function |
| ------ | -------- |
| <kbd>Shift</kbd> + <kbd>F</kbd> | Switch between shader-decoded or hardware decoded YUYV |
| <kbd>M</kbd> | Projection mapping 1 |
| <kbd>Shift</kbd> + <kbd>M</kbd> | Projection mapping 2 |
| <kbd>Ctrl</kbd> + <kbd>M</kbd> | Projection mapping 3 |
| <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>M</kbd> | Projection mapping 4 |
### Projection Mappings
In any of the projection mapping mode, use the nanoKONTROL2 last 4 columns to control 4 on-screen points:
| Midi Control | Function |
| ------ | -------- |
| Fader N | point N - X position |
| Knob N | point N - Y position |
| Last column top button | activate projection mapping |
| Last column middle button | invert projection mapping |
| Last column bottom button | show projection borders |
## Making your own FORGE project ## Making your own FORGE project
You want to embrace the "user" in "user-defined"? It's time to make your own project. You want to embrace the "user" in "user-defined"? It's time to make your own project.
@@ -306,28 +280,16 @@ We will not dig down all the variables here but feel free to read either:
* [sample/forge_project.cfg](./sample/forge_project.cfg) (beginner oriented) * [sample/forge_project.cfg](./sample/forge_project.cfg) (beginner oriented)
* [default/forge_project.cfg](./default/forge_project.cfg) (more complete) * [default/forge_project.cfg](./default/forge_project.cfg) (more complete)
#### Input codes #### Midi groups
Each input code can be either a midi event or a key code. FORGE allows you to send the midi data in the form of groups.
* 0 - 999 -> midi event
* Keyboard modifiers are encoded like this:
* 1000 -> keyboard event
* 10000 -> shift
* 100000 -> control
* 1000000 -> alt
* (This means 111082 is control+alt+R)
#### Input groups
FORGE allows you to send the midi/keyboard data in the form of groups.
Each group has the following properties: Each group has the following properties:
* A number of layers with `GROUP_X_ACTIVE_COUNT` (default: `1`) * A number of layers with `MIDI_X_ACTIVE_COUNT` (default: `1`)
* Each midi/keyboard code controlling how to change the active layer with `GROUP_X_ACTIVE_Y` * Each midi code controlling how to change the active layer with `MIDI_X_ACTIVE_Y`
* A number of codes with `GROUP_X_COUNT` * A number of codes with `MIDI_X_COUNT`
* Each midi/keyboard code controlling the active layer with `GROUP_X_Y` (as a `vec3`: `_X` / `_Y` / `_Z`) * Each midi code controlling the active layer with `MIDI_X_Y` (as a `vec3`: `_X` / `_Y` / `_Z`)
#### States #### States
@@ -335,9 +297,9 @@ FORGE allows to define a "state" to a fragment shader.
This combines several parameters: This combines several parameters:
* `SELECT_PAGE_COUNT` (default: `1`) + `SELECT_PAGE_X`: define midi/keyboard codes for pages of item. * `SELECT_PAGE_COUNT` (default: `1`) + `SELECT_PAGE_X`: define midi codes for pages of item.
* `SELECT_ITEM_COUNT` + `SELECT_ITEM_X`: define midi/keyboard codes for items per page. * `SELECT_ITEM_COUNT` + `SELECT_ITEM_X`: define midi codes for items per page.
* `SELECT_FRAG_X`: define midi/keyboard codes to "select" a fragment shader. * `SELECT_FRAG_X`: define midi codes to "select" a fragment shader.
The selected fragment shader will have its state updated with either: The selected fragment shader will have its state updated with either:
@@ -378,8 +340,8 @@ uniform float iTime; // the current time
uniform sampler2D iTex0; // texture 1 (0-based) uniform sampler2D iTex0; // texture 1 (0-based)
uniform sampler2D iTex9; // texture 10 uniform sampler2D iTex9; // texture 10
uniform int iSeed1; uniform int iSeed1;
uniform vec3 iGroup2_3[7]; // midi group 2, layer 3, size 7 uniform vec3 iMidi2_3[7]; // midi group 2, layer 3, size 7
uniform vec3 iGroup3_1[2]; uniform vec3 iMidi3_1[2];
``` ```
#### Working with `#include` #### Working with `#include`
@@ -495,11 +457,11 @@ FORGE (steel) describe the linux version.
Verify you have the correct [requirements](#requirements) installed. Verify you have the correct [requirements](#requirements) installed.
Then if you continue to have problems, you can [open an issue](https://git.klemek.fr/klemek/forge-steel/issues). Then if you continue to have problems, you can [open an issue](https://github.com/klemek/forge-steel/issues).
### I didn't understand everything about your tutorial ### I didn't understand everything about your tutorial
Please [open an issue](https://git.klemek.fr/klemek/forge-steel/issues) describing what your having trouble with, Please [open an issue](https://github.com/klemek/forge-steel/issues) describing what your having trouble with,
I'll try to answer and update the README. I'll try to answer and update the README.
### My nanoKontrol2 is acting strange ### My nanoKontrol2 is acting strange
@@ -510,7 +472,7 @@ Use the [KORG KONTROL Editor](https://www.korg.com/us/support/download/software/
### How do I report a bug? ### How do I report a bug?
You're free to open a new issue in the [Issues page](https://git.klemek.fr/klemek/forge-steel/issues). You're free to open a new issue in the [Issues page](https://github.com/klemek/forge-steel/issues).
Don't forget to add all information available to your bug (version, operating system, etc.). Don't forget to add all information available to your bug (version, operating system, etc.).
@@ -522,7 +484,7 @@ You can check your device real FPS on [V4L2 UCP](https://github.com/HedgeHawk/v4
### My video feed got strange lines ### My video feed got strange lines
You may need to decode the [V4L2 YUYV format](https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-yuyv.html). You need to decode the [V4L2 YUYV format](https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-yuyv.html).
The code is available in the default project [default/inc_yuyv.glsl](./default/inc_yuyv.glsl) The code is available in the default project [default/inc_yuyv.glsl](./default/inc_yuyv.glsl)
-2
View File
@@ -3,5 +3,3 @@
-DGLFW_EXPOSE_NATIVE_EGL -DGLFW_EXPOSE_NATIVE_EGL
-DGLFW_NATIVE_INCLUDE_NONE -DGLFW_NATIVE_INCLUDE_NONE
-DVIDEO_IN -DVIDEO_IN
-DEGL_DEBUG
-DGL_DEBUG
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT([forge], [steel-1.2.1], [klemek.dev@proton.me]) AC_INIT([forge], [steel-1.0.2], [klemek.dev@proton.me])
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_PROG_CC AC_PROG_CC
@@ -11,6 +11,7 @@ AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([sys/ioctl.h]) AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([sys/mman.h]) AC_CHECK_HEADERS([sys/mman.h])
AC_CHECK_HEADERS([sys/stat.h]) AC_CHECK_HEADERS([sys/stat.h])
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([sys/types.h]) AC_CHECK_HEADERS([sys/types.h])
AC_CHECK_HEADERS([sys/wait.h]) AC_CHECK_HEADERS([sys/wait.h])
@@ -21,7 +22,6 @@ AC_CHECK_HEADERS([math.h])
AC_CHECK_HEADERS([string.h]) AC_CHECK_HEADERS([string.h])
AC_CHECK_HEADERS([time.h]) AC_CHECK_HEADERS([time.h])
AC_CHECK_HEADERS([unistd.h]) AC_CHECK_HEADERS([unistd.h])
AC_CHECK_HEADERS([pthread.h])
AC_CHECK_HEADERS([linux/videodev2.h]) AC_CHECK_HEADERS([linux/videodev2.h])
+112 -179
View File
@@ -6,7 +6,7 @@
# (shaders, video devices, textures, midi inputs, etc.) # (shaders, video devices, textures, midi inputs, etc.)
# Every number based constant will be "one-based" (1,2,3,etc.) # Every number based constant will be "one-based" (1,2,3,etc.)
# To read more, go to # To read more, go to
# https://git.klemek.fr/klemek/forge-steel # https://github.com/klemek/forge-steel
# ================ # ================
@@ -51,6 +51,8 @@ UNIFORM_STATE_PREFIX=iState
UNIFORM_ACTIVE_PREFIX=iActive UNIFORM_ACTIVE_PREFIX=iActive
# Input X format raw integer value # Input X format raw integer value
UNIFORM_IN_FORMAT_PREFIX=iInputFormat UNIFORM_IN_FORMAT_PREFIX=iInputFormat
# Input X should use swap texture or not (0/1)
UNIFORM_IN_SWAP_PREFIX=iInputSwap
# --- uniform vec2 --- # --- uniform vec2 ---
@@ -64,8 +66,8 @@ UNIFORM_IN_RESOLUTION_PREFIX=iInputResolution
# --- uniform vec3 --- # --- uniform vec3 ---
# Midi group X layer Y (beware of group size) # Midi group X layer Y (beware of group size)
# Injected as "iGroupX_Y[Z]" # Injected as "iMidiX_Y[Z]"
UNIFORM_GROUP_PREFIX=iGroup UNIFORM_MIDI_PREFIX=iMidi
# --- uniform sampler2D --- # --- uniform sampler2D ---
@@ -104,6 +106,9 @@ IN_COUNT=2
# To which texture will be bound video device X # To which texture will be bound video device X
IN_1_OUT=1 IN_1_OUT=1
IN_2_OUT=2 IN_2_OUT=2
# To which texture will be bound swap buffers (for double-buffering)
IN_1_SWAP_OUT=3
IN_2_SWAP_OUT=4
# === FRAGMENT SHADERS # === FRAGMENT SHADERS
# Fragment shaders will be read from the CLI directory as "fragX.glsl" # Fragment shaders will be read from the CLI directory as "fragX.glsl"
@@ -115,13 +120,13 @@ FRAG_FILE_PREFIX=frag
FRAG_COUNT=10 FRAG_COUNT=10
# To which texture will the shader fragX.glsl will render to # To which texture will the shader fragX.glsl will render to
FRAG_1_OUT=3 FRAG_1_OUT=5
FRAG_2_OUT=4 FRAG_2_OUT=6
FRAG_3_OUT=5 FRAG_3_OUT=7
FRAG_4_OUT=6 FRAG_4_OUT=8
FRAG_5_OUT=7 FRAG_5_OUT=9
FRAG_6_OUT=8 FRAG_6_OUT=10
FRAG_7_OUT=9 FRAG_7_OUT=11
FRAG_8_OUT=0 FRAG_8_OUT=0
# Which fragment shader renders to output window # Which fragment shader renders to output window
FRAG_OUTPUT=9 FRAG_OUTPUT=9
@@ -129,17 +134,10 @@ FRAG_OUTPUT=9
FRAG_MONITOR=10 FRAG_MONITOR=10
# ========== # ========
# I/O Inputs # MIDI I/O
# ========== # ========
# Each code either maps to a midi event or a key code
# 0 - 999 -> midi event
# Keyboard modifiers are encoded like this:
# 1000 -> keyboard event
# 10000 -> shift
# 100000 -> control
# 1000000 -> alt
# This means 111082 is control+alt+R
# The recognized ALSA name of the midi device # The recognized ALSA name of the midi device
MIDI_HW=hw:CARD=nanoKONTROL2 MIDI_HW=hw:CARD=nanoKONTROL2
@@ -195,8 +193,8 @@ SELECT_ITEM_3=42
SELECT_ITEM_4=41 SELECT_ITEM_4=41
SELECT_ITEM_5=45 SELECT_ITEM_5=45
# === GROUP INPUT STATES # === MIDI INPUT STATES
# Inputs will control FORGE's state as follows # Midi inputs will control FORGE's state as follows
# X groups of Y layers sized Z # X groups of Y layers sized Z
# You can manipulate only 1 layer at a time # You can manipulate only 1 layer at a time
# Every layer of every groups will be send as uniforms # Every layer of every groups will be send as uniforms
@@ -204,141 +202,72 @@ SELECT_ITEM_5=45
# with the same codes for nice display # with the same codes for nice display
# Total number of groups # Total number of groups
GROUP_COUNT=3 MIDI_COUNT=3
# Total number of layers of group 1 # Total number of layers of group 1
GROUP_1_ACTIVE_COUNT=2 MIDI_1_ACTIVE_COUNT=2
# Midi codes to change layer of group 1 # Midi codes to change layer of group 1
GROUP_1_ACTIVE_1=32 MIDI_1_ACTIVE_1=32
GROUP_1_ACTIVE_2=64 MIDI_1_ACTIVE_2=64
# Size of group 1 # Size of group 1
GROUP_1_COUNT=6 MIDI_1_COUNT=6
# Every code of active layer manipulation of group 1 # Every code of active layer manipulation of group 1
GROUP_1_1_X=33 MIDI_1_1_X=33
GROUP_1_1_Y=49 MIDI_1_1_Y=49
GROUP_1_1_Z=65 MIDI_1_1_Z=65
GROUP_1_2_X=1 MIDI_1_2_X=1
GROUP_1_2_Y=17 MIDI_1_2_Y=17
GROUP_1_2_Z= MIDI_1_2_Z=
GROUP_1_3_X=34 MIDI_1_3_X=34
GROUP_1_3_Y=50 MIDI_1_3_Y=50
GROUP_1_3_Z=66 MIDI_1_3_Z=66
GROUP_1_4_X=2 MIDI_1_4_X=2
GROUP_1_4_Y=18 MIDI_1_4_Y=18
GROUP_1_4_Z= MIDI_1_4_Z=
GROUP_1_5_X=35 MIDI_1_5_X=35
GROUP_1_5_Y=51 MIDI_1_5_Y=51
GROUP_1_5_Z=67 MIDI_1_5_Z=67
GROUP_1_6_X=3 MIDI_1_6_X=3
GROUP_1_6_Y=19 MIDI_1_6_Y=19
GROUP_1_6_Z= MIDI_1_6_Z=
# Same for group 2 # Same for group 2
GROUP_2_ACTIVE_COUNT=7 MIDI_2_ACTIVE_COUNT=3
GROUP_2_ACTIVE_1=36 MIDI_2_ACTIVE_1=36
GROUP_2_ACTIVE_2=68 MIDI_2_ACTIVE_2=68
GROUP_2_ACTIVE_3=52 MIDI_2_ACTIVE_3=52
GROUP_2_ACTIVE_4=1077 MIDI_2_COUNT=7
GROUP_2_ACTIVE_5=11077 MIDI_2_1_X=37
GROUP_2_ACTIVE_6=101077 MIDI_2_1_Y=53
GROUP_2_ACTIVE_7=111077 MIDI_2_1_Z=69
GROUP_2_COUNT=7 MIDI_2_2_X=5
GROUP_2_1_X=37 MIDI_2_2_Y=21
GROUP_2_1_Y=53 MIDI_2_2_Z=
GROUP_2_1_Z=69 MIDI_2_3_X=38
GROUP_2_2_X=5 MIDI_2_3_Y=54
GROUP_2_2_Y=21 MIDI_2_3_Z=70
GROUP_2_2_Z= MIDI_2_4_X=6
GROUP_2_3_X=38 MIDI_2_4_Y=22
GROUP_2_3_Y=54 MIDI_2_4_Z=
GROUP_2_3_Z=70 MIDI_2_5_X=39
GROUP_2_4_X=6 MIDI_2_5_Y=55
GROUP_2_4_Y=22 MIDI_2_5_Z=71
GROUP_2_4_Z= MIDI_2_6_X=7
GROUP_2_5_X=39 MIDI_2_6_Y=23
GROUP_2_5_Y=55 MIDI_2_6_Z=
GROUP_2_5_Z=71 MIDI_2_7_X=4
GROUP_2_6_X=7 MIDI_2_7_Y=20
GROUP_2_6_Y=23 MIDI_2_7_Z=59
GROUP_2_6_Z=
GROUP_2_7_X=4
GROUP_2_7_Y=20
GROUP_2_7_Z=59
# Same for group 3 # Same for group 3
GROUP_3_COUNT=2 MIDI_3_COUNT=2
GROUP_3_1_X=48 MIDI_3_1_X=48
GROUP_3_1_Y=58 MIDI_3_1_Y=58
GROUP_3_1_Z= MIDI_3_1_Z=
GROUP_3_2_X=0 MIDI_3_2_X=0
GROUP_3_2_Y=16 MIDI_3_2_Y=16
GROUP_3_2_Z=11089 MIDI_3_2_Z=
# Auto-Random Ignore (ARI) prefixes
ARI_COUNT=62
ARI_1=GROUP_3_1_Y
ARI_2=GROUP_3_2_Z
ARI_3=GROUP_2_5_4
ARI_4=GROUP_2_5_4
ARI_5=GROUP_2_5_4
ARI_6=GROUP_2_2_X_4
ARI_7=GROUP_2_2_Y_4
ARI_8=GROUP_2_2_Z_4
ARI_9=GROUP_2_4_X_4
ARI_10=GROUP_2_4_Y_4
ARI_11=GROUP_2_4_Z_4
ARI_12=GROUP_2_6_X_4
ARI_13=GROUP_2_6_Y_4
ARI_14=GROUP_2_6_Z_4
ARI_15=GROUP_2_7_X_4
ARI_16=GROUP_2_7_Y_4
ARI_17=GROUP_2_7_Z_4
ARI_18=GROUP_2_5_5
ARI_19=GROUP_2_5_5
ARI_20=GROUP_2_5_5
ARI_21=GROUP_2_2_X_5
ARI_22=GROUP_2_2_Y_5
ARI_23=GROUP_2_2_Z_5
ARI_24=GROUP_2_4_X_5
ARI_25=GROUP_2_4_Y_5
ARI_26=GROUP_2_4_Z_5
ARI_27=GROUP_2_6_X_5
ARI_28=GROUP_2_6_Y_5
ARI_29=GROUP_2_6_Z_5
ARI_30=GROUP_2_7_X_5
ARI_31=GROUP_2_7_Y_5
ARI_32=GROUP_2_7_Z_5
ARI_33=GROUP_2_5_6
ARI_34=GROUP_2_5_6
ARI_35=GROUP_2_5_6
ARI_36=GROUP_2_2_X_6
ARI_37=GROUP_2_2_Y_6
ARI_38=GROUP_2_2_Z_6
ARI_39=GROUP_2_4_X_6
ARI_40=GROUP_2_4_Y_6
ARI_41=GROUP_2_4_Z_6
ARI_42=GROUP_2_6_X_6
ARI_43=GROUP_2_6_Y_6
ARI_44=GROUP_2_6_Z_6
ARI_45=GROUP_2_7_X_6
ARI_46=GROUP_2_7_Y_6
ARI_47=GROUP_2_7_Z_6
ARI_48=GROUP_2_5_7
ARI_49=GROUP_2_5_7
ARI_50=GROUP_2_5_7
ARI_51=GROUP_2_2_X_7
ARI_52=GROUP_2_2_Y_7
ARI_53=GROUP_2_2_Z_7
ARI_54=GROUP_2_4_X_7
ARI_55=GROUP_2_4_Y_7
ARI_56=GROUP_2_4_Z_7
ARI_57=GROUP_2_6_X_7
ARI_58=GROUP_2_6_Y_7
ARI_59=GROUP_2_6_Z_7
ARI_60=GROUP_2_7_X_7
ARI_61=GROUP_2_7_Y_7
ARI_62=GROUP_2_7_Z_7
# ===== # =====
# OTHER # OTHER
@@ -350,51 +279,55 @@ SAVE_FILE_PREFIX=forge_default_save
# === HOTKEYS # === HOTKEYS
# You can change the default keycodes used on runtime # You can change the default keycodes used on runtime
# Modifiers are encoded like this:
# 1000 -> shift
# 10000 -> control
# 100000 -> alt
# This means 110082 is control+alt+R
# R on (qwerty) # R on (qwerty)
KEY_RANDOMIZE=1082 HOTKEY_RANDOMIZE=82
# SHIFT+R (qwerty) # SHIFT+R (qwerty)
KEY_RESET=11082 HOTKEY_RESET=1082
# D (qwerty) # D (qwerty)
KEY_DEMO=1068 HOTKEY_DEMO=68
# A (qwerty) # A (qwerty)
KEY_AUTORAND=1065 HOTKEY_AUTORAND=65
# Left arrow # Left arrow
KEY_AUTORAND_DOWN=1263 HOTKEY_AUTORAND_DOWN=263
# Right arrow # Right arrow
KEY_AUTORAND_UP=1262 HOTKEY_AUTORAND_UP=262
# Down arrow # Down arrow
KEY_TEMPO_DOWN=1264 HOTKEY_TEMPO_DOWN=264
# Up arrow # Up arrow
KEY_TEMPO_UP=1265 HOTKEY_TEMPO_UP=265
# Number of load states keys # Number of load states keys
KEY_LOAD_COUNT=10 HOTKEY_LOAD_COUNT=10
# 1 to 9 then 0 keys # 1 to 9 then 0 keys
KEY_LOAD_1=1049 HOTKEY_LOAD_1=49
KEY_LOAD_2=1050 HOTKEY_LOAD_2=50
KEY_LOAD_3=1051 HOTKEY_LOAD_3=51
KEY_LOAD_4=1052 HOTKEY_LOAD_4=52
KEY_LOAD_5=1053 HOTKEY_LOAD_5=53
KEY_LOAD_6=1054 HOTKEY_LOAD_6=54
KEY_LOAD_7=1055 HOTKEY_LOAD_7=55
KEY_LOAD_8=1056 HOTKEY_LOAD_8=56
KEY_LOAD_9=1057 HOTKEY_LOAD_9=57
KEY_LOAD_10=1048 HOTKEY_LOAD_10=48
# Number of save states keys # Number of save states keys
KEY_SAVE_COUNT=10 HOTKEY_SAVE_COUNT=10
# 1 to 9 then 0 keys with shift # 1 to 9 then 0 keys with shift
KEY_SAVE_1=11049 HOTKEY_SAVE_1=1049
KEY_SAVE_2=11050 HOTKEY_SAVE_2=1050
KEY_SAVE_3=11051 HOTKEY_SAVE_3=1051
KEY_SAVE_4=11052 HOTKEY_SAVE_4=1052
KEY_SAVE_5=11053 HOTKEY_SAVE_5=1053
KEY_SAVE_6=11054 HOTKEY_SAVE_6=1054
KEY_SAVE_7=11055 HOTKEY_SAVE_7=1055
KEY_SAVE_8=11056 HOTKEY_SAVE_8=1056
KEY_SAVE_9=11057 HOTKEY_SAVE_9=1057
KEY_SAVE_10=11048 HOTKEY_SAVE_10=1048
+9 -7
View File
@@ -2,8 +2,8 @@
// VIDEO 1 // VIDEO 1
// ----------- // -----------
// IN: 1 (RAW IN A) // IN: 1+3 (RAW IN A)
// OUT: 3 (IN A) // OUT: 5 (IN A)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
@@ -14,14 +14,16 @@ uniform sampler2D iTex0;
uniform sampler2D iTex1; uniform sampler2D iTex1;
uniform sampler2D iTex3; uniform sampler2D iTex3;
uniform int iInputFormat1; uniform int iInputFormat1;
uniform int iInputSwap1;
uniform vec2 iInputResolution1; uniform vec2 iInputResolution1;
uniform vec3 iGroup3_1[2];
void main() { void main() {
if (iGroup3_1[1].z > 0) { if (iInputFormat1 == YUYV_FOURCC) {
fragColor = texture(iTex1, vUV * vec2(1, -1)); if (iInputSwap1 > 0) {
} else if (iInputFormat1 == YUYV_FOURCC) { fragColor = yuyvTex(iTex3, vUV, int(iInputResolution1.x));
fragColor = yuyvTex(iTex1, vUV, int(iInputResolution1.x)); } else {
fragColor = yuyvTex(iTex1, vUV, int(iInputResolution1.x));
}
} else { } else {
fragColor = texture(iTex0, vUV); fragColor = texture(iTex0, vUV);
} }
+22 -94
View File
@@ -9,13 +9,13 @@ out vec4 fragColor;
#include inc_debug.glsl #include inc_debug.glsl
uniform sampler2D iTex0; uniform sampler2D iTex0;
uniform sampler2D iTex3;
uniform sampler2D iTex4;
uniform sampler2D iTex5; uniform sampler2D iTex5;
uniform sampler2D iTex6; uniform sampler2D iTex6;
uniform sampler2D iTex7; uniform sampler2D iTex7;
uniform sampler2D iTex8; uniform sampler2D iTex8;
uniform sampler2D iTex9; uniform sampler2D iTex9;
uniform sampler2D iTex10;
uniform sampler2D iTex11;
uniform int iFPS; uniform int iFPS;
uniform int iInputFPS1; uniform int iInputFPS1;
uniform int iInputFPS2; uniform int iInputFPS2;
@@ -26,91 +26,19 @@ float s(vec2 uv, float x0, float y0) {
} }
const int texts[12][5] = { const int texts[12][5] = {
{ {0x49, 0x4E, 0x20, 0x41, 0x00}, // IN A
0x49, {0x49, 0x4E, 0x20, 0x42, 0x00}, // IN B
0x4E, {0x53, 0x52, 0x43, 0x20, 0x41}, // SRC A
0x20, {0x53, 0x52, 0x43, 0x20, 0x42}, // SRC B
0x41, {0x46, 0x58, 0x20, 0x41, 0x00}, // FX A
0x00 {0x46, 0x58, 0x20, 0x42, 0x00}, // FX B
}, // IN A {0x41, 0x2B, 0x42, 0x00, 0x00}, // A+B
{ {0x4D, 0x46, 0x58, 0x00, 0x00}, // MFX
0x49, {0x46, 0x50, 0x53, 0x00, 0x00}, // FPS
0x4E, {0x4F, 0x46, 0x46, 0x00, 0x00}, // OFF
0x20, {0x44, 0x45, 0x4D, 0x4F, 0x00}, // DEMO
0x42, {0x4C, 0x49, 0x56, 0x45, 0x00}, // LIVE
0x00 };
}, // IN B
{
0x53,
0x52,
0x43,
0x20,
0x41
}, // SRC A
{
0x53,
0x52,
0x43,
0x20,
0x42
}, // SRC B
{
0x46,
0x58,
0x20,
0x41,
0x00
}, // FX A
{
0x46,
0x58,
0x20,
0x42,
0x00
}, // FX B
{
0x41,
0x2B,
0x42,
0x00,
0x00
}, // A+B
{
0x4D,
0x46,
0x58,
0x00,
0x00
}, // MFX
{
0x46,
0x50,
0x53,
0x00,
0x00
}, // FPS
{
0x4F,
0x46,
0x46,
0x00,
0x00
}, // OFF
{
0x44,
0x45,
0x4D,
0x4F,
0x00
}, // DEMO
{
0x4C,
0x49,
0x56,
0x45,
0x00
}, // LIVE
};
void main() { void main() {
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
@@ -122,14 +50,14 @@ void main() {
vec4 c = vec4(0); vec4 c = vec4(0);
c += s(uv2, 1, 2) * texture(iTex5, uv2); c += s(uv2, 1, 2) * texture(iTex7, uv2);
c += s(uv2, 2, 2) * texture(iTex7, uv2); c += s(uv2, 2, 2) * texture(iTex9, uv2);
c += s(uv2, 1, 0) * texture(iTex6, uv2); c += s(uv2, 1, 0) * texture(iTex8, uv2);
c += s(uv2, 2, 0) * texture(iTex8, uv2); c += s(uv2, 2, 0) * texture(iTex10, uv2);
c += s(uv2, 0, 1) * debug(mod(uv2, 1)); c += s(uv2, 0, 1) * debug(mod(uv2, 1));
c += s(uv2, 1, 1) * texture(iTex9, uv2); c += s(uv2, 1, 1) * texture(iTex11, uv2);
c += s(uv2, 2, 1) * texture(iTex0, uv2); c += s(uv2, 2, 1) * texture(iTex0, uv2);
float sel = 0; float sel = 0;
@@ -149,7 +77,7 @@ void main() {
t += write_5(uv3, vec2(-37, 28), texts[0]); t += write_5(uv3, vec2(-37, 28), texts[0]);
if (iInputFormat1 == YUYV_FOURCC) { if (iInputFormat1 == YUYV_FOURCC) {
c += s(uv2, 0, 2) * texture(iTex3, uv2); c += s(uv2, 0, 2) * texture(iTex5, uv2);
f += rect(uv3, vec2(-35, 26.75), vec2(2.8, 0.7)); f += rect(uv3, vec2(-35, 26.75), vec2(2.8, 0.7));
t += write_int(uv3, vec2(-37.6, 26.1), iInputFPS1, 2); t += write_int(uv3, vec2(-37.6, 26.1), iInputFPS1, 2);
t += write_5(uv3, vec2(-35.1, 26.1), texts[8]); t += write_5(uv3, vec2(-35.1, 26.1), texts[8]);
@@ -162,7 +90,7 @@ void main() {
t += write_5(uv3, vec2(-37, -12), texts[1]); t += write_5(uv3, vec2(-37, -12), texts[1]);
if (iInputFormat2 == YUYV_FOURCC) { if (iInputFormat2 == YUYV_FOURCC) {
c += s(uv2, 0, 0) * texture(iTex4, uv2); c += s(uv2, 0, 0) * texture(iTex6, uv2);
f += rect(uv3, vec2(-35, -13.25), vec2(2.8, 0.7)); f += rect(uv3, vec2(-35, -13.25), vec2(2.8, 0.7));
t += write_int(uv3, vec2(-37.6, -13.9), iInputFPS2, 2); t += write_int(uv3, vec2(-37.6, -13.9), iInputFPS2, 2);
t += write_5(uv3, vec2(-35.1, -13.9), texts[8]); t += write_5(uv3, vec2(-35.1, -13.9), texts[8]);
+9 -7
View File
@@ -2,8 +2,8 @@
// VIDEO 2 // VIDEO 2
// ----------- // -----------
// IN: 2 (RAW IN B) // IN: 2+4 (RAW IN B)
// OUT: 4 (IN B) // OUT: 6 (IN B)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
@@ -14,14 +14,16 @@ uniform sampler2D iTex0;
uniform sampler2D iTex2; uniform sampler2D iTex2;
uniform sampler2D iTex4; uniform sampler2D iTex4;
uniform int iInputFormat2; uniform int iInputFormat2;
uniform int iInputSwap2;
uniform vec2 iInputResolution2; uniform vec2 iInputResolution2;
uniform vec3 iGroup3_1[2];
void main() { void main() {
if (iGroup3_1[1].z > 0) { if (iInputFormat2 == YUYV_FOURCC) {
fragColor = texture(iTex2, vUV * vec2(1, -1)); if (iInputSwap2 > 0) {
} else if (iInputFormat2 == YUYV_FOURCC) { fragColor = yuyvTex(iTex4, vUV, int(iInputResolution2.x));
fragColor = yuyvTex(iTex2, vUV, int(iInputResolution2.x)); } else {
fragColor = yuyvTex(iTex2, vUV, int(iInputResolution2.x));
}
} else { } else {
fragColor = texture(iTex0, vUV); fragColor = texture(iTex0, vUV);
} }
+3 -3
View File
@@ -3,7 +3,7 @@
// SRC A // SRC A
// ----------- // -----------
// OUT: 5 (FX A) // OUT: 7 (FX A)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
@@ -13,8 +13,8 @@ out vec4 fragColor;
subroutine uniform src_stage_sub src_stage; subroutine uniform src_stage_sub src_stage;
uniform int iSeed3; uniform int iSeed3;
uniform vec3 iGroup1_1[6]; uniform vec3 iMidi1_1[6];
void main() { void main() {
fragColor = src_stage(vUV, iSeed3, iGroup1_1[0], iGroup1_1[1].xy, iGroup1_1[2], iGroup1_1[3].xy, iGroup1_1[4], iGroup1_1[5].xy); fragColor = src_stage(vUV, iSeed3, iMidi1_1[0], iMidi1_1[1].xy, iMidi1_1[2], iMidi1_1[3].xy, iMidi1_1[4], iMidi1_1[5].xy);
} }
+3 -3
View File
@@ -2,7 +2,7 @@
// SRC B // SRC B
// ----------- // -----------
// OUT: 6 (FX B) // OUT: 8 (FX B)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
@@ -12,8 +12,8 @@ out vec4 fragColor;
subroutine uniform src_stage_sub src_stage; subroutine uniform src_stage_sub src_stage;
uniform int iSeed4; uniform int iSeed4;
uniform vec3 iGroup1_2[6]; uniform vec3 iMidi1_2[6];
void main() { void main() {
fragColor = src_stage(vUV, iSeed4, iGroup1_2[0], iGroup1_2[1].xy, iGroup1_2[2], iGroup1_2[3].xy, iGroup1_2[4], iGroup1_2[5].xy); fragColor = src_stage(vUV, iSeed4, iMidi1_2[0], iMidi1_2[1].xy, iMidi1_2[2], iMidi1_2[3].xy, iMidi1_2[4], iMidi1_2[5].xy);
} }
+6 -6
View File
@@ -2,20 +2,20 @@
// FX A // FX A
// ------------- // -------------
// IN: 5 (SRC A) // IN: 7 (SRC A)
// IN: 7 (FX A) // IN: 9 (FX A)
// OUT: 7 (A+B) // OUT: 9 (A+B)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
#include inc_fx.glsl #include inc_fx.glsl
uniform sampler2D iTex5;
uniform sampler2D iTex7; uniform sampler2D iTex7;
uniform sampler2D iTex9;
uniform int iSeed5; uniform int iSeed5;
uniform vec3 iGroup2_1[7]; uniform vec3 iMidi2_1[7];
void main() { void main() {
fragColor = fx_stage(vUV, iTex5, iTex7, iSeed5, iGroup2_1[0], iGroup2_1[1].xy, iGroup2_1[2], iGroup2_1[3].xy, iGroup2_1[4], iGroup2_1[5].xy, iGroup2_1[6]); fragColor = fx_stage(vUV, iTex7, iTex9, iSeed5, iMidi2_1[0], iMidi2_1[1].xy, iMidi2_1[2], iMidi2_1[3].xy, iMidi2_1[4], iMidi2_1[5].xy, iMidi2_1[6]);
} }
+6 -6
View File
@@ -2,20 +2,20 @@
// FX B // FX B
// ------------- // -------------
// IN: 6 (SRC B) // IN: 8 (SRC B)
// IN: 8 (FX B) // IN: 10 (FX B)
// OUT: 8 (A+B) // OUT: 10 (A+B)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
#include inc_fx.glsl #include inc_fx.glsl
uniform sampler2D iTex6;
uniform sampler2D iTex8; uniform sampler2D iTex8;
uniform sampler2D iTex10;
uniform int iSeed6; uniform int iSeed6;
uniform vec3 iGroup2_2[7]; uniform vec3 iMidi2_2[7];
void main() { void main() {
fragColor = fx_stage(vUV, iTex6, iTex8, iSeed6, iGroup2_2[0], iGroup2_2[1].xy, iGroup2_2[2], iGroup2_2[3].xy, iGroup2_2[4], iGroup2_2[5].xy, iGroup2_2[6]); fragColor = fx_stage(vUV, iTex8, iTex10, iSeed6, iMidi2_2[0], iMidi2_2[1].xy, iMidi2_2[2], iMidi2_2[3].xy, iMidi2_2[4], iMidi2_2[5].xy, iMidi2_2[6]);
} }
+10 -10
View File
@@ -2,9 +2,9 @@
// A+B // A+B
// ------------ // ------------
// IN: 7 (FX A) // IN: 9 (FX A)
// IN: 8 (FX B) // IN: 10 (FX B)
// OUT: 9 (MFX) // OUT: 11 (MFX)
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
@@ -13,17 +13,17 @@ out vec4 fragColor;
#include inc_functions.glsl #include inc_functions.glsl
uniform int iDemo; uniform int iDemo;
uniform sampler2D iTex7; uniform sampler2D iTex9;
uniform sampler2D iTex8; uniform sampler2D iTex10;
uniform int iSeed7; uniform int iSeed7;
uniform vec3 iGroup3_1[2]; uniform vec3 iMidi3_1[2];
void main() { void main() {
float mix_value = magic(iGroup3_1[1].xy, vec3(1, 0, 0), iSeed7); float mix_value = magic(iMidi3_1[1].xy, vec3(1, 0, 0), iSeed7);
bool mix_type = magic_trigger(vec3(iGroup3_1[0].x, 0, 0), iSeed7 + 10); bool mix_type = magic_trigger(vec3(iMidi3_1[0].x, 0, 0), iSeed7 + 10);
vec4 color_a = texture(iTex7, vUV); vec4 color_a = texture(iTex9, vUV);
vec4 color_b = texture(iTex8, vUV); vec4 color_b = texture(iTex10, vUV);
float k = mean(color_a); float k = mean(color_a);
+10 -6
View File
@@ -2,7 +2,7 @@
// MFX // MFX
// ------------ // ------------
// IN: 9 (A+B) // IN: 11 (A+B)
// IN: 0 (OUT) // IN: 0 (OUT)
// OUT: 0 (OUT) // OUT: 0 (OUT)
@@ -11,16 +11,20 @@ out vec4 fragColor;
#include inc_fx.glsl #include inc_fx.glsl
uniform sampler2D iTex9; uniform sampler2D iTex11;
uniform sampler2D iTex0; uniform sampler2D iTex0;
uniform int iSeed8; uniform int iSeed8;
uniform vec3 iGroup2_3[7]; uniform vec3 iMidi2_3[7];
uniform vec3 iGroup3_1[2]; uniform vec3 iMidi3_1[2];
uniform int iDemo;
uniform int iAutoRand;
void main() { void main() {
vec4 color = fx_stage(vUV, iTex9, iTex0, iSeed8, iGroup2_3[0], iGroup2_3[1].xy, iGroup2_3[2], iGroup2_3[3].xy, iGroup2_3[4], iGroup2_3[5].xy, iGroup2_3[6]); vec4 color = fx_stage(vUV, iTex11, iTex0, iSeed8, iMidi2_3[0], iMidi2_3[1].xy, iMidi2_3[2], iMidi2_3[3].xy, iMidi2_3[4], iMidi2_3[5].xy, iMidi2_3[6]);
color = mix(color, vec4(0), iGroup3_1[0].y); if (iDemo < 1 && iAutoRand < 1) {
color = mix(color, vec4(0), iMidi3_1[0].y);
}
fragColor = color; fragColor = color;
} }
+1 -102
View File
@@ -6,109 +6,8 @@
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
#include inc_map.glsl
uniform sampler2D iTex0; uniform sampler2D iTex0;
uniform vec3 iGroup2_4[7];
uniform vec3 iGroup2_5[7];
uniform vec3 iGroup2_6[7];
uniform vec3 iGroup2_7[7];
void main() { void main() {
bool visible = (iGroup2_4[4].x + iGroup2_5[4].x + iGroup2_6[4].x + iGroup2_7[4].x) > 0; fragColor = texture(iTex0, vUV);
bool invert = (iGroup2_4[4].y + iGroup2_5[4].y + iGroup2_6[4].y + iGroup2_7[4].y) > 0;
float rect = clamp(iGroup2_4[4].z + iGroup2_5[4].z + iGroup2_6[4].z + iGroup2_7[4].z, 0, 1);
bool modified = false;
vec2 uv = mix(vec2(0), vUV, base_mask(vUV));
if (iGroup2_4[4].x > 0) {
vec2 p11 = vec2(iGroup2_4[6].xy);
vec2 p12 = vec2(iGroup2_4[1].xy);
vec2 p13 = vec2(iGroup2_4[3].xy);
vec2 p14 = vec2(iGroup2_4[5].xy);
p12.x = 1 - p12.x;
p13.y = 1 - p13.y;
p14.x = 1 - p14.x;
p14.y = 1 - p14.y;
vec2 uv1 = project_4p(vUV, p11, p12, p13, p14);
uv1 = mix(vec2(0), uv1, base_mask(uv1));
uv = uv1;
modified = true;
}
if (iGroup2_5[4].x > 0) {
vec2 p21 = vec2(iGroup2_5[6].xy);
vec2 p22 = vec2(iGroup2_5[1].xy);
vec2 p23 = vec2(iGroup2_5[3].xy);
vec2 p24 = vec2(iGroup2_5[5].xy);
p22.x = 1 - p22.x;
p23.y = 1 - p23.y;
p24.x = 1 - p24.x;
p24.y = 1 - p24.y;
vec2 uv2 = project_4p(vUV, p21, p22, p23, p24);
uv2 = mix(vec2(0), uv2, base_mask(uv2));
if (modified) {
uv = mix(uv, uv2, step(0.0001, length(uv2)));
} else {
uv = uv2;
}
modified = true;
}
if (iGroup2_6[4].x > 0) {
vec2 p31 = vec2(iGroup2_6[6].xy);
vec2 p32 = vec2(iGroup2_6[1].xy);
vec2 p33 = vec2(iGroup2_6[3].xy);
vec2 p34 = vec2(iGroup2_6[5].xy);
p32.x = 1 - p32.x;
p33.y = 1 - p33.y;
p34.x = 1 - p34.x;
p34.y = 1 - p34.y;
vec2 uv3 = project_4p(vUV, p31, p32, p33, p34);
uv3 = mix(vec2(0), uv3, base_mask(uv3));
if (modified) {
uv = mix(uv, uv3, step(0.0001, length(uv3)));
} else {
uv = uv3;
}
modified = true;
}
if (iGroup2_7[4].x > 0) {
vec2 p41 = vec2(iGroup2_7[6].xy);
vec2 p42 = vec2(iGroup2_7[1].xy);
vec2 p43 = vec2(iGroup2_7[3].xy);
vec2 p44 = vec2(iGroup2_7[5].xy);
p42.x = 1 - p42.x;
p43.y = 1 - p43.y;
p44.x = 1 - p44.x;
p44.y = 1 - p44.y;
vec2 uv4 = project_4p(vUV, p41, p42, p43, p44);
uv4 = mix(vec2(0), uv4, base_mask(uv4));
if (modified) {
uv = mix(uv, uv4, step(0.0001, length(uv4)));
} else {
uv = uv4;
}
modified = true;
}
vec4 color = texture(iTex0, invert ? vUV : uv);
if (visible) {
float mask = step(0.0001, length(uv));
color *= mix(mask, 1 - mask, invert ? 1 : 0);
color = mix(color, color + mask * vec4(1), rect * (step(uv.x, 0.01) + step(uv.y, 0.01) + step(1 - uv.y, 0.01) + step(1 - uv.x, 0.01)));
}
fragColor = color;
} }
+50 -108
View File
@@ -35,16 +35,17 @@ uniform int iState8;
uniform int iActive1; uniform int iActive1;
uniform int iActive2; uniform int iActive2;
uniform vec3 iGroup2_1[7]; uniform vec3 iMidi2_1[7];
uniform vec3 iGroup2_2[7]; uniform vec3 iMidi2_2[7];
uniform vec3 iGroup2_3[7]; uniform vec3 iMidi2_3[7];
uniform vec3 iGroup3_1[2]; uniform vec3 iMidi3_1[2];
vec4 debug(vec2 vUV) vec4 debug(vec2 vUV)
{ {
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
float ratio = iResolution.x / iResolution.y; float ratio = iResolution.x / iResolution.y;
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1); vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
@@ -91,90 +92,30 @@ vec4 debug(vec2 vUV)
if (random_mfx) { if (random_mfx) {
selected_mfx = int(randTime(iSeed8 + 100) * 14); selected_mfx = int(randTime(iSeed8 + 100) * 14);
} }
float fxa_value = magic(iGroup2_1[6].xy, vec3(1, 0, 0), iSeed5); float fxa_value = magic(iMidi2_1[6].xy, vec3(1, 0, 0), iSeed5);
bool fxa_invert = magic_trigger(vec3(iGroup2_1[6].z, 0, 0), iSeed5); bool fxa_invert = magic_trigger(vec3(iMidi2_1[6].z, 0, 0), iSeed5);
float fxb_value = magic(iGroup2_2[6].xy, vec3(1, 0, 0), iSeed6); float fxb_value = magic(iMidi2_2[6].xy, vec3(1, 0, 0), iSeed6);
bool fxb_invert = magic_trigger(vec3(iGroup2_2[6].z, 0, 0), iSeed6); bool fxb_invert = magic_trigger(vec3(iMidi2_2[6].z, 0, 0), iSeed6);
float mfx_value = magic(iGroup2_3[6].xy, vec3(1, 0, 0), iSeed8); float mfx_value = magic(iMidi2_3[6].xy, vec3(1, 0, 0), iSeed8);
bool mfx_invert = magic_trigger(vec3(iGroup2_3[6].z, 0, 0), iSeed8); bool mfx_invert = magic_trigger(vec3(iMidi2_3[6].z, 0, 0), iSeed8);
float mix_value = magic(iGroup3_1[1].xy, vec3(1, 0, 0), iSeed7); float mix_value = magic(iMidi3_1[1].xy, vec3(1, 0, 0), iSeed7);
mix_value = mix(mix_value, mix_value * 0.9 + 0.05, iDemo); mix_value = mix(mix_value, mix_value * 0.9 + 0.05, iDemo);
bool mix_type = magic_trigger(vec3(iGroup3_1[0].x, 0, 0), iSeed7 + 10); bool mix_type = magic_trigger(vec3(iMidi3_1[0].x, 0, 0), iSeed7 + 10);
// logic // logic
const int texts[10][5] = { const int texts[10][5] = {
{ {0x46, 0x50, 0x53, 0x00, 0x00}, // FPS
0x46, {0x54, 0x45, 0x4D, 0x50, 0x4F}, // TEMPO
0x50, {0x54, 0x49, 0x4D, 0x45, 0x00}, // TIME
0x53, {0x44, 0x45, 0x4D, 0x4F, 0x00}, // DEMO
0x00, {0x4C, 0x49, 0x56, 0x45, 0x00}, // LIVE
0x00 {0x52, 0x41, 0x4E, 0x44, 0x00}, // RAND
}, // FPS {0x53, 0x52, 0x43, 0x00, 0x00}, // SRC
{ {0x46, 0x58, 0x00, 0x00, 0x00}, // FX
0x54, {0x49, 0x4E, 0x00, 0x00, 0x00}, // IN
0x45, {0x4D, 0x46, 0x58, 0x00, 0x00}, // MFX
0x4D, };
0x50,
0x4F
}, // TEMPO
{
0x54,
0x49,
0x4D,
0x45,
0x00
}, // TIME
{
0x44,
0x45,
0x4D,
0x4F,
0x00
}, // DEMO
{
0x4C,
0x49,
0x56,
0x45,
0x00
}, // LIVE
{
0x52,
0x41,
0x4E,
0x44,
0x00
}, // RAND
{
0x53,
0x52,
0x43,
0x00,
0x00
}, // SRC
{
0x46,
0x58,
0x00,
0x00,
0x00
}, // FX
{
0x49,
0x4E,
0x00,
0x00,
0x00
}, // IN
{
0x4D,
0x46,
0x58,
0x00,
0x00
}, // MFX
};
vec2 uv2 = uv1; vec2 uv2 = uv1;
@@ -187,20 +128,21 @@ vec4 debug(vec2 vUV)
// base frame // base frame
float f = float f =
h_rect(uv2, vec2(-5, -2), vec2(1), 0.1) + h_rect(uv2, vec2(-5, -2), vec2(1), 0.1) +
h_rect(uv2, vec2(-2, -2), vec2(1), 0.1) + h_rect(uv2, vec2(-2, -2), vec2(1), 0.1) +
rect(uv2, vec2(-3.5, -2), vec2(0.5, 0.1)) + rect(uv2, vec2(-3.5, -2), vec2(0.5, 0.1)) +
h_rect(uv2, vec2(-5, 2), vec2(1), 0.1) + h_rect(uv2, vec2(-5, 2), vec2(1), 0.1) +
h_rect(uv2, vec2(-2, 2), vec2(1), 0.1) + h_rect(uv2, vec2(-2, 2), vec2(1), 0.1) +
rect(uv2, vec2(-3.5, 2), vec2(0.5, 0.1)) + rect(uv2, vec2(-3.5, 2), vec2(0.5, 0.1)) +
h_rect(uv2, vec2(2, 0), vec2(1), 0.1) + h_rect(uv2, vec2(2, 0), vec2(1), 0.1) +
h_rect(uv2, vec2(5, 0), vec2(1), 0.1) + h_rect(uv2, vec2(5, 0), vec2(1), 0.1) +
rect(uv2, vec2(3.5, 0), vec2(0.5, 0.1)) + rect(uv2, vec2(3.5, 0), vec2(0.5, 0.1)) +
rect(uv2, vec2(0.55, -2), vec2(1.5, 0.1)) + rect(uv2, vec2(0.55, -2), vec2(1.5, 0.1)) +
rect(uv2, vec2(2, -1.55), vec2(0.1, 0.55)) + rect(uv2, vec2(2, -1.55), vec2(0.1, 0.55)) +
rect(uv2, vec2(0.55, 2), vec2(1.5, 0.1)) + rect(uv2, vec2(0.55, 2), vec2(1.5, 0.1)) +
rect(uv2, vec2(2, 1.55), vec2(0.1, 0.55)) + rect(uv2, vec2(2, 1.55), vec2(0.1, 0.55)) +
rect(uv2, vec2(6.8, 0), vec2(0.75, 0.1)) + rect(uv2, vec2(6.8, 0), vec2(0.75, 0.1)) +
h_circle(uv2, vec2(7.8, 0), 0.3, 0.1); h_circle(uv2, vec2(7.8, 0), 0.3, 0.1)
;
if (iDemo < 1 && iInputFormat1 == YUYV_FOURCC) { if (iDemo < 1 && iInputFormat1 == YUYV_FOURCC) {
f += circle(uv2, vec2(-9, 2), 0.3); f += circle(uv2, vec2(-9, 2), 0.3);
@@ -241,14 +183,14 @@ vec4 debug(vec2 vUV)
// show src/fx // show src/fx
f += write_5(uv3 * 0.75, vec2(-11.6, -1.8), texts[6]); f += write_5(uv3 * 0.75, vec2(-11.6,-1.8), texts[6]);
f += write_5(uv3 * 0.75, vec2(-4.2, -1.8), texts[7]); f += write_5(uv3 * 0.75, vec2(-4.2,-1.8), texts[7]);
f += char_at(uv3 * 0.5, vec2(-11.5, 3.5), 0x41); f += char_at(uv3 * 0.5, vec2(-11.5, 3.5), 0x41);
f += char_at(uv3 * 0.5, vec2(-11.5, -6), 0x42); f += char_at(uv3 * 0.5, vec2(-11.5, -6), 0x42);
if (iDemo < 1 && (iInputFormat1 == YUYV_FOURCC || iInputFormat2 == YUYV_FOURCC)) { if (iDemo < 1 && (iInputFormat1 == YUYV_FOURCC || iInputFormat2 == YUYV_FOURCC)) {
f += write_5(uv3 * 0.75, vec2(-19.7, -1.8), texts[8]); f += write_5(uv3 * 0.75, vec2(-19.7,-1.8), texts[8]);
} }
f += write_5(uv3 * 0.75, vec2(10.9, 2), texts[9]); f += write_5(uv3 * 0.75, vec2(10.9,2), texts[9]);
// show inputs / feedback // show inputs / feedback
float line_a_a = rect(uv2, vec2(-7.5, 2), vec2(1.5, 0.1)); float line_a_a = rect(uv2, vec2(-7.5, 2), vec2(1.5, 0.1));
@@ -294,21 +236,21 @@ vec4 debug(vec2 vUV)
float x = 0; float x = 0;
x = -15; x = -15;
f += write_5(uv3, vec2(x - 4.5, 13), texts[1]); f += write_5(uv3, vec2(x - 4.5,13), texts[1]);
f += write_int(uv3, vec2(x + 1.5, 13), int(iTempo), 3); f += write_int(uv3, vec2(x + 1.5,13), int(iTempo), 3);
v = fract(iBeats); v = fract(iBeats);
f += h_rect(uv3, vec2(x, 12), vec2(4, 0.5), 0.2); f += h_rect(uv3, vec2(x, 12), vec2(4, 0.5), 0.2);
f += rect(uv3, vec2(x + 4 * v - 4, 12), vec2(4 * v, 0.4)); f += rect(uv3, vec2(x + 4 * v - 4, 12), vec2(4 * v, 0.4));
x = 15; x = 15;
if (iAutoRand > 0) { if (iAutoRand > 0) {
f += write_5(uv3, vec2(x - 4.5, 13), texts[5]); f += write_5(uv3, vec2(x - 4.5,13), texts[5]);
f += write_int(uv3, vec2(x - 0.5, 13), int(iAutoRandCycle), 5); f += write_int(uv3, vec2(x - 0.5,13), int(iAutoRandCycle), 5);
v = fract(iBeats / iAutoRandCycle); v = fract(iBeats / iAutoRandCycle);
} else { } else {
f += write_int(uv3, vec2(x - 0.5, 13), int(iTime), 5); f += write_int(uv3, vec2(x - 0.5,13), int(iTime), 5);
v = fract(iTime); v = fract(iTime);
f += write_5(uv3, vec2(x - 4.5, 13), texts[2]); f += write_5(uv3, vec2(x - 4.5,13), texts[2]);
} }
f += h_rect(uv3, vec2(x, 12), vec2(4, 0.5), 0.2); f += h_rect(uv3, vec2(x, 12), vec2(4, 0.5), 0.2);
f += rect(uv3, vec2(x + 4 * v - 4, 12), vec2(4 * v, 0.4)); f += rect(uv3, vec2(x + 4 * v - 4, 12), vec2(4 * v, 0.4));
+49 -55
View File
@@ -24,48 +24,48 @@ float iestep(float x, float y) {
} }
float ease(float x) { float ease(float x) {
return 0.5 - cos(max(min(x, 1.0), 0.0) * PI) * 0.5; return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5;
} }
vec2 ease(vec2 x) { vec2 ease(vec2 x) {
return 0.5 - cos(max(min(x, 1.0), 0.0) * PI) * 0.5; return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5;
} }
vec3 ease(vec3 x) { vec3 ease(vec3 x) {
return 0.5 - cos(max(min(x, 1.0), 0.0) * PI) * 0.5; return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5;
} }
float saw(float x) { float saw(float x){
return abs(mod(x + 1, 2) - 1); return abs(mod(x+1,2)-1);
} }
vec2 saw(vec2 x) { vec2 saw(vec2 x){
return abs(mod(x + 1, 2) - 1); return abs(mod(x+1,2)-1);
} }
vec3 saw(vec3 x) { vec3 saw(vec3 x){
return abs(mod(x + 1, 2) - 1); return abs(mod(x+1,2)-1);
} }
float cmod(float x, float k) { float cmod(float x, float k){
return mod(x + k * 0.5, k) - k * 0.5; return mod(x + k * 0.5, k) - k * 0.5;
} }
vec2 cmod(vec2 x, float k) { vec2 cmod(vec2 x, float k){
return mod(x + k * 0.5, k) - k * 0.5; return mod(x + k * 0.5, k) - k * 0.5;
} }
vec3 cmod(vec3 x, float k) { vec3 cmod(vec3 x, float k){
return mod(x + k * 0.5, k) - k * 0.5; return mod(x + k * 0.5, k) - k * 0.5;
} }
// COLORS // COLORS
vec3 col(float x) { vec3 col(float x){
return vec3( return vec3(
.5 * (sin(x * 2. * PI) + 1.), .5*(sin(x*2.*PI)+1.),
.5 * (sin(x * 2. * PI + 2. * PI / 3.) + 1.), .5*(sin(x*2.*PI+2.*PI/3.)+1.),
.5 * (sin(x * 2. * PI - 2. * PI / 3.) + 1.) .5*(sin(x*2.*PI-2.*PI/3.)+1.)
); );
} }
@@ -83,7 +83,8 @@ vec3 shift3(vec3 c, float f) {
vec3 mix3(vec3 c1, vec3 c2, vec3 c3, float x) { vec3 mix3(vec3 c1, vec3 c2, vec3 c3, float x) {
return istep(0.5, x) * mix(c1, c2, x * 2) return istep(0.5, x) * mix(c1, c2, x * 2)
+ step(0.5, x) * mix(c2, c3, x * 2 - 1); + step(0.5, x) * mix(c2, c3, x * 2 - 1)
;
} }
vec3 mix4(vec3 c1, vec3 c2, vec3 c3, vec3 c4, float x) { vec3 mix4(vec3 c1, vec3 c2, vec3 c3, vec3 c4, float x) {
@@ -97,7 +98,8 @@ vec3 mix5(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, float x) {
return istep(0.25, x) * mix(c1, c2, x * 4) return istep(0.25, x) * mix(c1, c2, x * 4)
+ step(0.25, x) * istep(0.5, x) * mix(c2, c3, x * 4 - 1) + step(0.25, x) * istep(0.5, x) * mix(c2, c3, x * 4 - 1)
+ step(0.5, x) * istep(0.75, x) * mix(c3, c4, x * 4 - 2) + step(0.5, x) * istep(0.75, x) * mix(c3, c4, x * 4 - 2)
+ step(0.75, x) * mix(c4, c5, x * 4 - 3); + step(0.75, x) * mix(c4, c5, x * 4 - 3)
;
} }
vec3 mix6(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, vec3 c6, float x) { vec3 mix6(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, vec3 c6, float x) {
@@ -105,7 +107,8 @@ vec3 mix6(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, vec3 c6, float x) {
+ step(0.2, x) * istep(0.4, x) * mix(c2, c3, x * 5 - 1) + step(0.2, x) * istep(0.4, x) * mix(c2, c3, x * 5 - 1)
+ step(0.4, x) * istep(0.6, x) * mix(c3, c4, x * 5 - 2) + step(0.4, x) * istep(0.6, x) * mix(c3, c4, x * 5 - 2)
+ step(0.6, x) * istep(0.8, x) * mix(c4, c5, x * 5 - 3) + step(0.6, x) * istep(0.8, x) * mix(c4, c5, x * 5 - 3)
+ step(0.8, x) * mix(c5, c6, x * 5 - 4); + step(0.8, x) * mix(c5, c6, x * 5 - 4)
;
} }
float mean(vec3 v) float mean(vec3 v)
@@ -120,10 +123,10 @@ float mean(vec4 v)
// OTHER // OTHER
mat2 rot(float angle) { mat2 rot(float angle){
return mat2( return mat2(
cos(angle * 2. * PI), -sin(angle * 2. * PI), cos(angle*2.*PI),-sin(angle*2.*PI),
sin(angle * 2. * PI), cos(angle * 2. * PI) sin(angle*2.*PI),cos(angle*2.*PI)
); );
} }
@@ -138,18 +141,18 @@ vec2 kal(vec2 uv, float n) {
float q = 3.0 / (2.0 * PI); float q = 3.0 / (2.0 * PI);
t = abs(mod(t + PI / (n), 2 * PI / n) - PI / (n)); t = abs(mod(t + PI / (n), 2 * PI / n) - PI / (n));
return length(uv) * vec2( return length(uv) * vec2(
cos(t), cos(t),
sin(t) sin(t)
); );
} }
vec2 kal2(vec2 uv, float n) { vec2 kal2(vec2 uv, float n) {
float t = atan(uv.y, uv.x) + PI * 0.5; float t = atan(uv.y, uv.x) + PI * 0.5;
float t2 = abs(mod(t + PI / n, 2 * PI / n) - PI / n); float t2 = abs(mod(t + PI / n, 2 * PI / n) - PI / n);
return length(uv) * vec2( return length(uv) * vec2(
cos(t2), cos(t2),
sin(t2) sin(t2)
); );
} }
// NOISE // NOISE
@@ -179,15 +182,15 @@ float v_index(vec2 uv) {
return floor(uv.x) + floor(uv.y) * 45; return floor(uv.x) + floor(uv.y) * 45;
} }
vec2 v_pos(float i, int seed, float time) { vec2 v_pos(float i) {
int iTimeId = int(time); int iTimeId = int(iBeats);
float iTimeV = time - iTimeId; float iTimeV = iBeats - iTimeId;
float x0 = rand(i + seed + iTimeId); float x0 = rand(i + 823 + iTimeId);
float y0 = rand(i + seed + 10 + iTimeId); float y0 = rand(i + 328 + iTimeId);
float x1 = rand(i + seed + iTimeId + 1); float x1 = rand(i + 823 + iTimeId + 1);
float y1 = rand(i + seed + 10 + iTimeId + 1); float y1 = rand(i + 328 + iTimeId + 1);
return vec2( return vec2(
mix(x0, x1, ease(ease(iTimeV))), mix(x0, x1, ease(ease(iTimeV))),
@@ -195,7 +198,7 @@ vec2 v_pos(float i, int seed, float time) {
); );
} }
vec4 voronoi(vec2 uv, float dist, int seed, float time) { vec4 voronoi(vec2 uv, float dist) {
vec4 o = vec4(0, 0, 2, 0); vec4 o = vec4(0, 0, 2, 0);
vec4 t = vec4(0, 0, 2, 0); vec4 t = vec4(0, 0, 2, 0);
float d, i; float d, i;
@@ -204,7 +207,7 @@ vec4 voronoi(vec2 uv, float dist, int seed, float time) {
for (int dy = -1; dy <= 1; dy++) { for (int dy = -1; dy <= 1; dy++) {
uv2 = vec2(floor(uv.x) + dx, floor(uv.y) + dy); uv2 = vec2(floor(uv.x) + dx, floor(uv.y) + dy);
i = v_index(uv2); i = v_index(uv2);
p = uv2 + v_pos(i, seed, time) * dist; p = uv2 + v_pos(i) * dist;
d = length(p - uv); d = length(p - uv);
if (d < o.z) { if (d < o.z) {
t = o; t = o;
@@ -257,9 +260,9 @@ float line(vec2 uv, vec2 p1, vec2 p2, float thick) {
if (abs(p.y) > abs(p.x)) { if (abs(p.y) > abs(p.x)) {
k = vec2( k = vec2(
uv.x - p.x * uv.y / p.y, uv.x - p.x * uv.y / p.y,
uv.y / p.y uv.y / p.y
); );
return step(k.x, thick * 0.5) return step(k.x, thick * 0.5)
* step(-k.x, thick * 0.5) * step(-k.x, thick * 0.5)
@@ -267,9 +270,9 @@ float line(vec2 uv, vec2 p1, vec2 p2, float thick) {
* (1 - step(k.y, 0)); * (1 - step(k.y, 0));
} else { } else {
k = vec2( k = vec2(
uv.x / p.x, uv.x / p.x,
uv.y - p.y * uv.x / p.x uv.y - p.y * uv.x / p.x
); );
return step(k.y, thick * 0.5) return step(k.y, thick * 0.5)
* step(-k.y, thick * 0.5) * step(-k.y, thick * 0.5)
@@ -278,16 +281,7 @@ float line(vec2 uv, vec2 p1, vec2 p2, float thick) {
} }
} }
const mat2x2 ISOMETRIC_MATRIX = { const mat2x2 ISOMETRIC_MATRIX = {{0.5, 1}, {0.5, -1}};
{
0.5,
1
},
{
0.5,
-1
}
};
vec2 iso(vec2 p) { vec2 iso(vec2 p) {
return p * ISOMETRIC_MATRIX; return p * ISOMETRIC_MATRIX;
@@ -308,14 +302,14 @@ vec2 iso(vec3 uv) {
vec4 reframe(sampler2D tex, vec2 uv) vec4 reframe(sampler2D tex, vec2 uv)
{ {
uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5; uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5;
uv = saw(uv); uv = saw(uv);
return texture(tex, uv); return texture(tex, uv);
} }
vec4 reframe_b(sampler2D tex, vec2 uv) vec4 reframe_b(sampler2D tex, vec2 uv)
{ {
uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5; uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5;
return texture(tex, uv); return texture(tex, uv);
} }
-30
View File
@@ -1,30 +0,0 @@
#ifndef INC_MAP
#define INC_MAP
vec2 project_4p(vec2 uv, vec2 p1, vec2 p2, vec2 p3, vec2 p4) {
float k1 = (p4.y - p3.y) / (p2.y - p3.y);
float k2 = (p3.y - p1.y) / (p2.y - p3.y);
float a = (p4.x - p3.x + k1 * p3.x - k1 * p2.x) / (p1.x - p3.x - k2 * p3.x + k2 * p2.x);
float b = k1 + a * k2;
float c = 1 - a - b;
// https://math.stackexchange.com/questions/296794/finding-the-transform-matrix-from-4-projected-points-with-javascript/339033#339033
mat3 projection_a = mat3(
a * p1.x, a * p1.y, a,
b * p2.x, b * p2.y, b,
c * p3.x, c * p3.y, c
);
mat3 projection_a_prime = inverse(projection_a);
mat3 projection_b = mat3(
0, 0, -1,
1, 0, 1,
0, 1, 1
);
vec3 tmp = projection_b * projection_a_prime * vec3(uv, 1);
return tmp.xy / tmp.z;
}
float base_mask(vec2 uv) {
return step(0, uv.x) * step(-1, -uv.x) * step(0, uv.y) * step(-1, -uv.y);
}
#endif
+117 -145
View File
@@ -8,8 +8,8 @@
uniform int iDemo; uniform int iDemo;
uniform sampler2D iTex0; uniform sampler2D iTex0;
uniform sampler2D iTex3; uniform sampler2D iTex5;
uniform sampler2D iTex4; uniform sampler2D iTex6;
subroutine vec4 src_stage_sub(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3); subroutine vec4 src_stage_sub(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3);
@@ -101,139 +101,7 @@ subroutine ( src_stage_sub ) vec4 src_3(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
return vec4(f); return vec4(f);
} }
// // SRC 4 : circuit // SRC 4 : circuit
// subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
// {
// // start
// vec2 uv0 = vUV.st;
// float ratio = iResolution.x / iResolution.y;
// vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
// // controls
// float z = 10 + magic(f1, b1, 123) * 20;
// float h = magic(f2, b2, seed + 20) * 0.8 + 0.1;
// float v = magic_reverse(f3, b3, seed + 30) * 0.8 + 0.1;
// // logic
// uv1 *= z;
// uv1 += iBeats;
// float s0 = rand(floor(mod(uv1, 1000))) * 1000;
// float s1 = rand(floor(mod(uv1 + vec2(0, 1), 1000))) * 1000;
// float s2 = rand(floor(mod(uv1 - vec2(1, 0), 1000))) * 1000;
// bool up = rand(s1 + 1) < h;
// bool left = rand(s2 + 2) < v;
// bool down = rand(s0 + 1) < h;
// bool right = rand(s0 + 2) < v;
// bool up_down = up && down;
// bool left_right = left && right;
// uv1 = mod(uv1, 1.0) - 0.5;
// const float t = 0.1;
// float f = 0;
// int c = 0;
// if (up) {
// f += stripe(uv1.x, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.y);
// c += 1;
// }
// if (down) {
// f += stripe(uv1.x, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.y);
// c += 1;
// }
// if (left) {
// f += stripe(uv1.y, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.x);
// c += 1;
// }
// if (right) {
// f += stripe(uv1.y, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.x);
// c += 1;
// }
// if (c == 1) {
// f += istep(t, length(uv1));
// }
// f = min(f, 1);
// if ((up_down ^^ left_right) && c == 2) {
// if (up_down) {
// uv1.xy = uv1.yx;
// }
// if (rand(s0 + 3) < 0.5) {
// uv1.x = -uv1.x;
// }
// float k = rand(s0 + 4) * 60;
// f -= rect(uv1, vec2(0), vec2(t * 3, t));
// f = max(0, f);
// if (k < 10) { // resistor
// f += line(uv1, vec2(-t * 3.25, -t * 0.5), vec2(-t * 2.5, t * 2), t * 0.75);
// f += line(uv1, vec2(-t * 2.5, t * 2), vec2(-t * 1.5, -t * 2), t * 0.75);
// f += line(uv1, vec2(-t * 1.5, -t * 2), vec2(-t * 0.5, t * 2), t * 0.75);
// f += line(uv1, vec2(-t * 0.5, t * 2), vec2(t * 0.5, -t * 2), t * 0.75);
// f += line(uv1, vec2(t * 0.5, -t * 2), vec2(t * 1.5, t * 2), t * 0.75);
// f += line(uv1, vec2(t * 1.5, t * 2), vec2(t * 2.5, -t * 2), t * 0.75);
// f += line(uv1, vec2(t * 2.5, -t * 2), vec2(t * 3.25, t * 0.5), t * 0.75);
// } else if (k < 20) { // capacitor
// f += rect(uv1, vec2(-t * 2, 0), vec2(t, t * 0.5));
// f += rect(uv1, vec2(t * 2, 0), vec2(t, t * 0.5));
// f += rect(uv1, vec2(t, 0), vec2(t * 0.5, t * 3.5));
// f += rect(uv1, vec2(-t, 0), vec2(t * 0.5, t * 3.5));
// } else if (k < 30) { // diode
// f += line(uv1, vec2(-t * 2, t * 2.5), vec2(t * 2, 0), t);
// f += line(uv1, vec2(-t * 2, -t * 2.5), vec2(t * 2, 0), t);
// f += rect(uv1, vec2(t * 2.5, 0), vec2(t * 0.5, t * 3));
// f += rect(uv1, vec2(-t * 2.5, 0), vec2(t * 0.5, t * 3));
// } else if (k < 40) { // lamp
// f += istep(t * 3.5, length(uv1));
// f -= istep(t * 2.5, length(uv1));
// f += line(uv1, vec2(-t * 2), vec2(t * 2), t);
// f += line(uv1, vec2(-t * 2, t * 2), vec2(t * 2, -t * 2), t);
// } else if (k < 50) { // inductor
// f += istep(t * 2, length(uv1 - vec2(t * 2.5, 0)));
// f += istep(t * 2, length(uv1 - vec2(0, 0)));
// f += istep(t * 2, length(uv1 - vec2(-t * 2.5, 0)));
// f -= 2 * istep(t, length(uv1 - vec2(t * 2.5, 0)));
// f -= 2 * istep(t, length(uv1 - vec2(0, 0)));
// f -= 2 * istep(t, length(uv1 - vec2(-t * 2.5, 0)));
// f *= step(-t * 0.5, uv1.y);
// } else if (k < 60) { // switch
// f += istep(t, length(uv1 - vec2(t * 2.5, 0)));
// f += istep(t, length(uv1 + vec2(t * 2.5, 0)));
// f += line(uv1, vec2(t * 2, 0), vec2(-t * 2.5, t * (k < 55 ? 3 : 1)), t);
// }
// } else if (c == 3) {
// if (left_right) {
// uv1.xy = uv1.yx;
// if (up) {
// uv1.x = -uv1.x;
// }
// } else if (right) {
// uv1.x = -uv1.x;
// }
// float k = rand(s0 + 4) * 20;
// if (k < 10) {
// f -= rect(uv1, vec2(0), vec2(t * 3));
// f = max(0, f);
// f += rect(uv1, vec2(-t * 3, 0), vec2(t * 0.5, t * 3));
// f += line(uv1, vec2(t * 0.25, t * 3.25), vec2(-t * 3, t), t);
// f += line(uv1, vec2(t * 0.25, -t * 3.25), vec2(-t * 3, -t), t);
// }
// }
// return vec4(f);
// }
// SRC 4 : bacteria
subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{ {
// start // start
@@ -244,19 +112,123 @@ subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
// controls // controls
float zoom = 2 + magic(f1, b1, seed + 10) * 20; float z = 10 + magic(f1, b1, 123) * 20;
float details = 5 * magic(f2, b2, seed + 20); float h = magic(f2, b2, seed + 20) * 0.8 + 0.1;
float delta = magic(f3, b3, seed + 30); float v = magic_reverse(f3, b3, seed + 30) * 0.8 + 0.1;
// logic // logic
uv1 *= zoom; uv1 *= z;
uv1 += iBeats;
vec4 data = voronoi(uv1, 1, seed + 40, iBeats * 0.25); float s0 = rand(floor(mod(uv1, 1000))) * 1000;
float s1 = rand(floor(mod(uv1 + vec2(0, 1), 1000))) * 1000;
float s2 = rand(floor(mod(uv1 - vec2(1, 0), 1000))) * 1000;
float f = ease(data.x) + ease(data.y); bool up = rand(s1 + 1) < h;
bool left = rand(s2 + 2) < v;
bool down = rand(s0 + 1) < h;
bool right = rand(s0 + 2) < v;
bool up_down = up && down;
bool left_right = left && right;
f = saw(f * (1 + data.x * details) - delta * 2.0); uv1 = mod(uv1, 1.0) - 0.5;
const float t = 0.1;
float f = 0;
int c = 0;
if (up) {
f += stripe(uv1.x, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.y);
c += 1;
}
if (down) {
f += stripe(uv1.x, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.y);
c += 1;
}
if (left) {
f += stripe(uv1.y, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.x);
c += 1;
}
if (right) {
f += stripe(uv1.y, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.x);
c += 1;
}
if (c == 1) {
f += istep(t, length(uv1));
}
f = min(f, 1);
if ((up_down ^^ left_right) && c == 2) {
if (up_down) {
uv1.xy = uv1.yx;
}
if (rand(s0 + 3) < 0.5) {
uv1.x = -uv1.x;
}
float k = rand(s0 + 4) * 60;
f -= rect(uv1, vec2(0), vec2(t * 3, t));
f = max(0, f);
if (k < 10) { // resistor
f += line(uv1, vec2(-t * 3.25, -t * 0.5), vec2(-t * 2.5, t * 2), t * 0.75);
f += line(uv1, vec2(-t * 2.5, t * 2), vec2(-t * 1.5, -t * 2), t * 0.75);
f += line(uv1, vec2(-t * 1.5, -t * 2), vec2(-t * 0.5, t * 2), t * 0.75);
f += line(uv1, vec2(-t * 0.5, t * 2), vec2(t * 0.5, -t * 2), t * 0.75);
f += line(uv1, vec2(t * 0.5, -t * 2), vec2(t * 1.5, t * 2), t * 0.75);
f += line(uv1, vec2(t * 1.5, t * 2), vec2(t * 2.5, -t * 2), t * 0.75);
f += line(uv1, vec2(t * 2.5, -t * 2), vec2(t * 3.25, t * 0.5), t * 0.75);
} else if (k < 20) { // capacitor
f += rect(uv1, vec2(-t * 2, 0), vec2(t, t * 0.5));
f += rect(uv1, vec2(t * 2, 0), vec2(t, t * 0.5));
f += rect(uv1, vec2(t, 0), vec2(t * 0.5, t * 3.5));
f += rect(uv1, vec2(-t, 0), vec2(t * 0.5, t * 3.5));
} else if (k < 30) { // diode
f += line(uv1, vec2(-t * 2, t * 2.5), vec2(t * 2, 0), t);
f += line(uv1, vec2(-t * 2, -t * 2.5), vec2(t * 2, 0), t);
f += rect(uv1, vec2(t * 2.5, 0), vec2(t * 0.5, t * 3));
f += rect(uv1, vec2(-t * 2.5, 0), vec2(t * 0.5, t * 3));
} else if (k < 40) { // lamp
f += istep(t * 3.5, length(uv1));
f -= istep(t * 2.5, length(uv1));
f += line(uv1, vec2(-t * 2), vec2(t * 2), t);
f += line(uv1, vec2(-t * 2, t * 2), vec2(t * 2, -t * 2), t);
} else if (k < 50) { // inductor
f += istep(t * 2, length(uv1 - vec2(t * 2.5, 0)));
f += istep(t * 2, length(uv1 - vec2(0, 0)));
f += istep(t * 2, length(uv1 - vec2(-t * 2.5, 0)));
f -= 2 * istep(t, length(uv1 - vec2(t * 2.5, 0)));
f -= 2 * istep(t, length(uv1 - vec2(0, 0)));
f -= 2 * istep(t, length(uv1 - vec2(-t * 2.5, 0)));
f *= step(-t * 0.5, uv1.y);
} else if (k < 60) { // switch
f += istep(t, length(uv1 - vec2(t * 2.5, 0)));
f += istep(t, length(uv1 + vec2(t * 2.5, 0)));
f += line(uv1, vec2(t * 2, 0), vec2(-t * 2.5, t * (k < 55 ? 3 : 1)), t);
}
} else if (c == 3) {
if (left_right) {
uv1.xy = uv1.yx;
if (up) {
uv1.x = -uv1.x;
}
} else if (right) {
uv1.x = -uv1.x;
}
float k = rand(s0 + 4) * 20;
if (k < 10) {
f -= rect(uv1, vec2(0), vec2(t * 3));
f = max(0, f);
f += rect(uv1, vec2(-t * 3, 0), vec2(t * 0.5, t * 3));
f += line(uv1, vec2(t * 0.25, t * 3.25), vec2(-t * 3, t), t);
f += line(uv1, vec2(t * 0.25, -t * 3.25), vec2(-t * 3, -t), t);
}
}
return vec4(f); return vec4(f);
} }
@@ -282,7 +254,7 @@ subroutine ( src_stage_sub ) vec4 src_5(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
vec2 uv2 = uv1; vec2 uv2 = uv1;
uv2 *= zoom * 20 + 3; uv2 *= zoom * 20 + 3;
uv2.x += iBeats; uv2.x += iBeats;
vec4 data = voronoi(uv2, voronoi_distort, seed + 50, iBeats); vec4 data = voronoi(uv2, voronoi_distort);
float f = data.x / (data.x + data.y); float f = data.x / (data.x + data.y);
f = sin(f * PI * (details * 20)) * 0.5 + 1; f = sin(f * PI * (details * 20)) * 0.5 + 1;
int nf = int(noise_factor * 6); int nf = int(noise_factor * 6);
@@ -298,7 +270,7 @@ subroutine ( src_stage_sub ) vec4 src_6(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
return src_2(vUV, seed, b1, f1, b2, f2, b3, f3); return src_2(vUV, seed, b1, f1, b2, f2, b3, f3);
} }
return src_thru(vUV, iTex3, seed, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex5, seed, b1, f1, b2, f2, b3, f3);
} }
#include inc_cp437.glsl #include inc_cp437.glsl
@@ -462,7 +434,7 @@ subroutine ( src_stage_sub ) vec4 src_11(vec2 vUV, int seed, vec3 b1, vec2 f1, v
return src_3(vUV, seed, b1, f1, b2, f2, b3, f3); return src_3(vUV, seed, b1, f1, b2, f2, b3, f3);
} }
return src_thru(vUV, iTex4, seed, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex6, seed, b1, f1, b2, f2, b3, f3);
} }
// SRC 12 : Scales // SRC 12 : Scales
+7 -23
View File
@@ -3,27 +3,11 @@
const int YUYV_FOURCC = 1448695129; const int YUYV_FOURCC = 1448695129;
// https://en.wikipedia.org/wiki/Y%E2%80%B2UV const mat3x3 yuyv_to_rgb = {{1,1,1},{0,-0.39465,2.03211},{1.13983,-0.5806,0}};
const mat3x3 yuyv_to_rgb_bt709 = {
{
1,
1,
1
},
{
0,
-0.21482,
2.12798
},
{
1.28033,
-0.38059,
0
}
};
vec4 yuyvTex(sampler2D tex, vec2 vUV, int base_width) { vec4 yuyvTex(sampler2D tex, vec2 vUV, int base_width) {
float w = base_width - 1; float w = base_width - 1;
int x = int(vUV.x * w); int x = int(vUV.x * w);
int xU = x - x % 2; int xU = x - x % 2;
@@ -33,12 +17,12 @@ vec4 yuyvTex(sampler2D tex, vec2 vUV, int base_width) {
vec4 tV = texture(tex, vec2(xV / w, 1 - vUV.y)); vec4 tV = texture(tex, vec2(xV / w, 1 - vUV.y));
vec3 yuv = vec3( vec3 yuv = vec3(
x % 2 == 0 ? tU.x : tV.x, x % 2 == 0 ? tU.x : tV.x,
tU.y - 0.5, tU.y - 0.5,
tV.y - 0.5 tV.y - 0.5
); );
return vec4(yuyv_to_rgb_bt709 * yuv, 1.0); return vec4(yuyv_to_rgb * yuv, 1.0);
} }
#endif #endif
Binary file not shown.
+5 -39
View File
@@ -1,11 +1,11 @@
/** /**
* Loader generated by glad 2.0.8 on Wed May 13 21:51:29 2026 * Loader generated by glad 2.0.8 on Sun Sep 21 11:51:45 2025
* *
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0 * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
* *
* Generator: C/C++ * Generator: C/C++
* Specification: egl * Specification: egl
* Extensions: 11 * Extensions: 10
* *
* APIs: * APIs:
* - egl=1.5 * - egl=1.5
@@ -19,10 +19,10 @@
* - ON_DEMAND = False * - ON_DEMAND = False
* *
* Commandline: * Commandline:
* --api='egl=1.5' --extensions='EGL_EXT_image_dma_buf_import,EGL_EXT_image_dma_buf_import_modifiers,EGL_KHR_debug,EGL_KHR_gl_texture_2D_image,EGL_KHR_image,EGL_KHR_image_base,EGL_KHR_platform_android,EGL_KHR_platform_gbm,EGL_KHR_platform_wayland,EGL_KHR_platform_x11,EGL_MESA_drm_image' c --header-only --loader * --api='egl=1.5' --extensions='EGL_EXT_image_dma_buf_import,EGL_EXT_image_dma_buf_import_modifiers,EGL_KHR_gl_texture_2D_image,EGL_KHR_image,EGL_KHR_image_base,EGL_KHR_platform_android,EGL_KHR_platform_gbm,EGL_KHR_platform_wayland,EGL_KHR_platform_x11,EGL_MESA_drm_image' c --header-only --loader
* *
* Online: * Online:
* http://glad.sh/#api=egl%3D1.5&extensions=EGL_EXT_image_dma_buf_import%2CEGL_EXT_image_dma_buf_import_modifiers%2CEGL_KHR_debug%2CEGL_KHR_gl_texture_2D_image%2CEGL_KHR_image%2CEGL_KHR_image_base%2CEGL_KHR_platform_android%2CEGL_KHR_platform_gbm%2CEGL_KHR_platform_wayland%2CEGL_KHR_platform_x11%2CEGL_MESA_drm_image&generator=c&options=HEADER_ONLY%2CLOADER * http://glad.sh/#api=egl%3D1.5&extensions=EGL_EXT_image_dma_buf_import%2CEGL_EXT_image_dma_buf_import_modifiers%2CEGL_KHR_gl_texture_2D_image%2CEGL_KHR_image%2CEGL_KHR_image_base%2CEGL_KHR_platform_android%2CEGL_KHR_platform_gbm%2CEGL_KHR_platform_wayland%2CEGL_KHR_platform_x11%2CEGL_MESA_drm_image&generator=c&options=HEADER_ONLY%2CLOADER
* *
*/ */
@@ -201,11 +201,6 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2
#define EGL_CORE_NATIVE_ENGINE 0x305B #define EGL_CORE_NATIVE_ENGINE 0x305B
#define EGL_DEBUG_CALLBACK_KHR 0x33B8
#define EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9
#define EGL_DEBUG_MSG_ERROR_KHR 0x33BA
#define EGL_DEBUG_MSG_INFO_KHR 0x33BC
#define EGL_DEBUG_MSG_WARN_KHR 0x33BB
#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) #define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0)
#define EGL_DEPTH_SIZE 0x3025 #define EGL_DEPTH_SIZE 0x3025
#define EGL_DISPLAY_SCALING 10000 #define EGL_DISPLAY_SCALING 10000
@@ -300,13 +295,6 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0) #define EGL_NO_SURFACE EGL_CAST(EGLSurface,0)
#define EGL_NO_SYNC EGL_CAST(EGLSync,0) #define EGL_NO_SYNC EGL_CAST(EGLSync,0)
#define EGL_NO_TEXTURE 0x305C #define EGL_NO_TEXTURE 0x305C
#define EGL_OBJECT_CONTEXT_KHR 0x33B2
#define EGL_OBJECT_DISPLAY_KHR 0x33B1
#define EGL_OBJECT_IMAGE_KHR 0x33B4
#define EGL_OBJECT_STREAM_KHR 0x33B6
#define EGL_OBJECT_SURFACE_KHR 0x33B3
#define EGL_OBJECT_SYNC_KHR 0x33B5
#define EGL_OBJECT_THREAD_KHR 0x33B0
#define EGL_OPENGL_API 0x30A2 #define EGL_OPENGL_API 0x30A2
#define EGL_OPENGL_BIT 0x0008 #define EGL_OPENGL_BIT 0x0008
#define EGL_OPENGL_ES2_BIT 0x0004 #define EGL_OPENGL_ES2_BIT 0x0004
@@ -946,8 +934,6 @@ GLAD_API_CALL int GLAD_EGL_VERSION_1_5;
GLAD_API_CALL int GLAD_EGL_EXT_image_dma_buf_import; GLAD_API_CALL int GLAD_EGL_EXT_image_dma_buf_import;
#define EGL_EXT_image_dma_buf_import_modifiers 1 #define EGL_EXT_image_dma_buf_import_modifiers 1
GLAD_API_CALL int GLAD_EGL_EXT_image_dma_buf_import_modifiers; GLAD_API_CALL int GLAD_EGL_EXT_image_dma_buf_import_modifiers;
#define EGL_KHR_debug 1
GLAD_API_CALL int GLAD_EGL_KHR_debug;
#define EGL_KHR_gl_texture_2D_image 1 #define EGL_KHR_gl_texture_2D_image 1
GLAD_API_CALL int GLAD_EGL_KHR_gl_texture_2D_image; GLAD_API_CALL int GLAD_EGL_KHR_gl_texture_2D_image;
#define EGL_KHR_image 1 #define EGL_KHR_image 1
@@ -982,7 +968,6 @@ typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC)(EGLDisp
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPLATFORMWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, void * native_window, const EGLAttrib * attrib_list); typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPLATFORMWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, void * native_window, const EGLAttrib * attrib_list);
typedef EGLSync (GLAD_API_PTR *PFNEGLCREATESYNCPROC)(EGLDisplay dpy, EGLenum type, const EGLAttrib * attrib_list); typedef EGLSync (GLAD_API_PTR *PFNEGLCREATESYNCPROC)(EGLDisplay dpy, EGLenum type, const EGLAttrib * attrib_list);
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint * attrib_list); typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint * attrib_list);
typedef EGLint (GLAD_API_PTR *PFNEGLDEBUGMESSAGECONTROLKHRPROC)(EGLDEBUGPROCKHR callback, const EGLAttrib * attrib_list);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx); typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYIMAGEPROC)(EGLDisplay dpy, EGLImage image); typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYIMAGEPROC)(EGLDisplay dpy, EGLImage image);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYIMAGEKHRPROC)(EGLDisplay dpy, EGLImageKHR image); typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYIMAGEKHRPROC)(EGLDisplay dpy, EGLImageKHR image);
@@ -1000,11 +985,9 @@ typedef EGLDisplay (GLAD_API_PTR *PFNEGLGETPLATFORMDISPLAYPROC)(EGLenum platform
typedef __eglMustCastToProperFunctionPointerType (GLAD_API_PTR *PFNEGLGETPROCADDRESSPROC)(const char * procname); typedef __eglMustCastToProperFunctionPointerType (GLAD_API_PTR *PFNEGLGETPROCADDRESSPROC)(const char * procname);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLGETSYNCATTRIBPROC)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib * value); typedef EGLBoolean (GLAD_API_PTR *PFNEGLGETSYNCATTRIBPROC)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib * value);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint * major, EGLint * minor); typedef EGLBoolean (GLAD_API_PTR *PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint * major, EGLint * minor);
typedef EGLint (GLAD_API_PTR *PFNEGLLABELOBJECTKHRPROC)(EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); typedef EGLBoolean (GLAD_API_PTR *PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
typedef EGLenum (GLAD_API_PTR *PFNEGLQUERYAPIPROC)(void); typedef EGLenum (GLAD_API_PTR *PFNEGLQUERYAPIPROC)(void);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint * value); typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint * value);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYDEBUGKHRPROC)(EGLint attribute, EGLAttrib * value);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYDMABUFFORMATSEXTPROC)(EGLDisplay dpy, EGLint max_formats, EGLint * formats, EGLint * num_formats); typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYDMABUFFORMATSEXTPROC)(EGLDisplay dpy, EGLint max_formats, EGLint * formats, EGLint * num_formats);
typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYDMABUFMODIFIERSEXTPROC)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR * modifiers, EGLBoolean * external_only, EGLint * num_modifiers); typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYDMABUFMODIFIERSEXTPROC)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR * modifiers, EGLBoolean * external_only, EGLint * num_modifiers);
typedef const char * (GLAD_API_PTR *PFNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name); typedef const char * (GLAD_API_PTR *PFNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name);
@@ -1052,8 +1035,6 @@ GLAD_API_CALL PFNEGLCREATESYNCPROC glad_eglCreateSync;
#define eglCreateSync glad_eglCreateSync #define eglCreateSync glad_eglCreateSync
GLAD_API_CALL PFNEGLCREATEWINDOWSURFACEPROC glad_eglCreateWindowSurface; GLAD_API_CALL PFNEGLCREATEWINDOWSURFACEPROC glad_eglCreateWindowSurface;
#define eglCreateWindowSurface glad_eglCreateWindowSurface #define eglCreateWindowSurface glad_eglCreateWindowSurface
GLAD_API_CALL PFNEGLDEBUGMESSAGECONTROLKHRPROC glad_eglDebugMessageControlKHR;
#define eglDebugMessageControlKHR glad_eglDebugMessageControlKHR
GLAD_API_CALL PFNEGLDESTROYCONTEXTPROC glad_eglDestroyContext; GLAD_API_CALL PFNEGLDESTROYCONTEXTPROC glad_eglDestroyContext;
#define eglDestroyContext glad_eglDestroyContext #define eglDestroyContext glad_eglDestroyContext
GLAD_API_CALL PFNEGLDESTROYIMAGEPROC glad_eglDestroyImage; GLAD_API_CALL PFNEGLDESTROYIMAGEPROC glad_eglDestroyImage;
@@ -1088,16 +1069,12 @@ GLAD_API_CALL PFNEGLGETSYNCATTRIBPROC glad_eglGetSyncAttrib;
#define eglGetSyncAttrib glad_eglGetSyncAttrib #define eglGetSyncAttrib glad_eglGetSyncAttrib
GLAD_API_CALL PFNEGLINITIALIZEPROC glad_eglInitialize; GLAD_API_CALL PFNEGLINITIALIZEPROC glad_eglInitialize;
#define eglInitialize glad_eglInitialize #define eglInitialize glad_eglInitialize
GLAD_API_CALL PFNEGLLABELOBJECTKHRPROC glad_eglLabelObjectKHR;
#define eglLabelObjectKHR glad_eglLabelObjectKHR
GLAD_API_CALL PFNEGLMAKECURRENTPROC glad_eglMakeCurrent; GLAD_API_CALL PFNEGLMAKECURRENTPROC glad_eglMakeCurrent;
#define eglMakeCurrent glad_eglMakeCurrent #define eglMakeCurrent glad_eglMakeCurrent
GLAD_API_CALL PFNEGLQUERYAPIPROC glad_eglQueryAPI; GLAD_API_CALL PFNEGLQUERYAPIPROC glad_eglQueryAPI;
#define eglQueryAPI glad_eglQueryAPI #define eglQueryAPI glad_eglQueryAPI
GLAD_API_CALL PFNEGLQUERYCONTEXTPROC glad_eglQueryContext; GLAD_API_CALL PFNEGLQUERYCONTEXTPROC glad_eglQueryContext;
#define eglQueryContext glad_eglQueryContext #define eglQueryContext glad_eglQueryContext
GLAD_API_CALL PFNEGLQUERYDEBUGKHRPROC glad_eglQueryDebugKHR;
#define eglQueryDebugKHR glad_eglQueryDebugKHR
GLAD_API_CALL PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT; GLAD_API_CALL PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT;
#define eglQueryDmaBufFormatsEXT glad_eglQueryDmaBufFormatsEXT #define eglQueryDmaBufFormatsEXT glad_eglQueryDmaBufFormatsEXT
GLAD_API_CALL PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT; GLAD_API_CALL PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT;
@@ -1180,7 +1157,6 @@ int GLAD_EGL_VERSION_1_4 = 0;
int GLAD_EGL_VERSION_1_5 = 0; int GLAD_EGL_VERSION_1_5 = 0;
int GLAD_EGL_EXT_image_dma_buf_import = 0; int GLAD_EGL_EXT_image_dma_buf_import = 0;
int GLAD_EGL_EXT_image_dma_buf_import_modifiers = 0; int GLAD_EGL_EXT_image_dma_buf_import_modifiers = 0;
int GLAD_EGL_KHR_debug = 0;
int GLAD_EGL_KHR_gl_texture_2D_image = 0; int GLAD_EGL_KHR_gl_texture_2D_image = 0;
int GLAD_EGL_KHR_image = 0; int GLAD_EGL_KHR_image = 0;
int GLAD_EGL_KHR_image_base = 0; int GLAD_EGL_KHR_image_base = 0;
@@ -1208,7 +1184,6 @@ PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC glad_eglCreatePlatformPixmapSurface = NULL
PFNEGLCREATEPLATFORMWINDOWSURFACEPROC glad_eglCreatePlatformWindowSurface = NULL; PFNEGLCREATEPLATFORMWINDOWSURFACEPROC glad_eglCreatePlatformWindowSurface = NULL;
PFNEGLCREATESYNCPROC glad_eglCreateSync = NULL; PFNEGLCREATESYNCPROC glad_eglCreateSync = NULL;
PFNEGLCREATEWINDOWSURFACEPROC glad_eglCreateWindowSurface = NULL; PFNEGLCREATEWINDOWSURFACEPROC glad_eglCreateWindowSurface = NULL;
PFNEGLDEBUGMESSAGECONTROLKHRPROC glad_eglDebugMessageControlKHR = NULL;
PFNEGLDESTROYCONTEXTPROC glad_eglDestroyContext = NULL; PFNEGLDESTROYCONTEXTPROC glad_eglDestroyContext = NULL;
PFNEGLDESTROYIMAGEPROC glad_eglDestroyImage = NULL; PFNEGLDESTROYIMAGEPROC glad_eglDestroyImage = NULL;
PFNEGLDESTROYIMAGEKHRPROC glad_eglDestroyImageKHR = NULL; PFNEGLDESTROYIMAGEKHRPROC glad_eglDestroyImageKHR = NULL;
@@ -1226,11 +1201,9 @@ PFNEGLGETPLATFORMDISPLAYPROC glad_eglGetPlatformDisplay = NULL;
PFNEGLGETPROCADDRESSPROC glad_eglGetProcAddress = NULL; PFNEGLGETPROCADDRESSPROC glad_eglGetProcAddress = NULL;
PFNEGLGETSYNCATTRIBPROC glad_eglGetSyncAttrib = NULL; PFNEGLGETSYNCATTRIBPROC glad_eglGetSyncAttrib = NULL;
PFNEGLINITIALIZEPROC glad_eglInitialize = NULL; PFNEGLINITIALIZEPROC glad_eglInitialize = NULL;
PFNEGLLABELOBJECTKHRPROC glad_eglLabelObjectKHR = NULL;
PFNEGLMAKECURRENTPROC glad_eglMakeCurrent = NULL; PFNEGLMAKECURRENTPROC glad_eglMakeCurrent = NULL;
PFNEGLQUERYAPIPROC glad_eglQueryAPI = NULL; PFNEGLQUERYAPIPROC glad_eglQueryAPI = NULL;
PFNEGLQUERYCONTEXTPROC glad_eglQueryContext = NULL; PFNEGLQUERYCONTEXTPROC glad_eglQueryContext = NULL;
PFNEGLQUERYDEBUGKHRPROC glad_eglQueryDebugKHR = NULL;
PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT = NULL; PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT = NULL;
PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT = NULL; PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT = NULL;
PFNEGLQUERYSTRINGPROC glad_eglQueryString = NULL; PFNEGLQUERYSTRINGPROC glad_eglQueryString = NULL;
@@ -1311,12 +1284,6 @@ static void glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers( GLADuserptrloa
glad_eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC) load(userptr, "eglQueryDmaBufFormatsEXT"); glad_eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC) load(userptr, "eglQueryDmaBufFormatsEXT");
glad_eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC) load(userptr, "eglQueryDmaBufModifiersEXT"); glad_eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC) load(userptr, "eglQueryDmaBufModifiersEXT");
} }
static void glad_egl_load_EGL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
if(!GLAD_EGL_KHR_debug) return;
glad_eglDebugMessageControlKHR = (PFNEGLDEBUGMESSAGECONTROLKHRPROC) load(userptr, "eglDebugMessageControlKHR");
glad_eglLabelObjectKHR = (PFNEGLLABELOBJECTKHRPROC) load(userptr, "eglLabelObjectKHR");
glad_eglQueryDebugKHR = (PFNEGLQUERYDEBUGKHRPROC) load(userptr, "eglQueryDebugKHR");
}
static void glad_egl_load_EGL_KHR_image( GLADuserptrloadfunc load, void* userptr) { static void glad_egl_load_EGL_KHR_image( GLADuserptrloadfunc load, void* userptr) {
if(!GLAD_EGL_KHR_image) return; if(!GLAD_EGL_KHR_image) return;
glad_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) load(userptr, "eglCreateImageKHR"); glad_eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) load(userptr, "eglCreateImageKHR");
@@ -1371,7 +1338,6 @@ static int glad_egl_find_extensions_egl(EGLDisplay display) {
GLAD_EGL_EXT_image_dma_buf_import = glad_egl_has_extension(extensions, "EGL_EXT_image_dma_buf_import"); GLAD_EGL_EXT_image_dma_buf_import = glad_egl_has_extension(extensions, "EGL_EXT_image_dma_buf_import");
GLAD_EGL_EXT_image_dma_buf_import_modifiers = glad_egl_has_extension(extensions, "EGL_EXT_image_dma_buf_import_modifiers"); GLAD_EGL_EXT_image_dma_buf_import_modifiers = glad_egl_has_extension(extensions, "EGL_EXT_image_dma_buf_import_modifiers");
GLAD_EGL_KHR_debug = glad_egl_has_extension(extensions, "EGL_KHR_debug");
GLAD_EGL_KHR_gl_texture_2D_image = glad_egl_has_extension(extensions, "EGL_KHR_gl_texture_2D_image"); GLAD_EGL_KHR_gl_texture_2D_image = glad_egl_has_extension(extensions, "EGL_KHR_gl_texture_2D_image");
GLAD_EGL_KHR_image = glad_egl_has_extension(extensions, "EGL_KHR_image"); GLAD_EGL_KHR_image = glad_egl_has_extension(extensions, "EGL_KHR_image");
GLAD_EGL_KHR_image_base = glad_egl_has_extension(extensions, "EGL_KHR_image_base"); GLAD_EGL_KHR_image_base = glad_egl_has_extension(extensions, "EGL_KHR_image_base");
@@ -1443,7 +1409,6 @@ int gladLoadEGLUserPtr(EGLDisplay display, GLADuserptrloadfunc load, void* userp
if (!glad_egl_find_extensions_egl(display)) return 0; if (!glad_egl_find_extensions_egl(display)) return 0;
glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers(load, userptr); glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers(load, userptr);
glad_egl_load_EGL_KHR_debug(load, userptr);
glad_egl_load_EGL_KHR_image(load, userptr); glad_egl_load_EGL_KHR_image(load, userptr);
glad_egl_load_EGL_KHR_image_base(load, userptr); glad_egl_load_EGL_KHR_image_base(load, userptr);
glad_egl_load_EGL_MESA_drm_image(load, userptr); glad_egl_load_EGL_MESA_drm_image(load, userptr);
@@ -1607,3 +1572,4 @@ void gladLoaderUnloadEGL(void) {
#endif #endif
#endif /* GLAD_EGL_IMPLEMENTATION */ #endif /* GLAD_EGL_IMPLEMENTATION */
+6 -29
View File
@@ -1,11 +1,11 @@
/** /**
* Loader generated by glad 2.0.8 on Wed May 13 21:57:23 2026 * Loader generated by glad 2.0.8 on Sun Sep 21 13:34:57 2025
* *
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0 * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
* *
* Generator: C/C++ * Generator: C/C++
* Specification: gl * Specification: gl
* Extensions: 4 * Extensions: 3
* *
* APIs: * APIs:
* - gl:compatibility=4.6 * - gl:compatibility=4.6
@@ -19,10 +19,10 @@
* - ON_DEMAND = False * - ON_DEMAND = False
* *
* Commandline: * Commandline:
* --api='gl:compatibility=4.6' --extensions='GL_ARB_direct_state_access,GL_EXT_EGL_image_storage,GL_EXT_direct_state_access,GL_KHR_debug' c --header-only --loader * --api='gl:compatibility=4.6' --extensions='GL_ARB_direct_state_access,GL_EXT_EGL_image_storage,GL_EXT_direct_state_access' c --header-only --loader
* *
* Online: * Online:
* http://glad.sh/#api=gl%3Acompatibility%3D4.6&extensions=GL_ARB_direct_state_access%2CGL_EXT_EGL_image_storage%2CGL_EXT_direct_state_access%2CGL_KHR_debug&generator=c&options=HEADER_ONLY%2CLOADER * http://glad.sh/#api=gl%3Acompatibility%3D4.6&extensions=GL_ARB_direct_state_access%2CGL_EXT_EGL_image_storage%2CGL_EXT_direct_state_access&generator=c&options=HEADER_ONLY%2CLOADER
* *
*/ */
@@ -2409,8 +2409,6 @@ GLAD_API_CALL int GLAD_GL_ARB_direct_state_access;
GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage; GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage;
#define GL_EXT_direct_state_access 1 #define GL_EXT_direct_state_access 1
GLAD_API_CALL int GLAD_GL_EXT_direct_state_access; GLAD_API_CALL int GLAD_GL_EXT_direct_state_access;
#define GL_KHR_debug 1
GLAD_API_CALL int GLAD_GL_KHR_debug;
typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value); typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value);
@@ -6398,7 +6396,6 @@ int GLAD_GL_VERSION_4_6 = 0;
int GLAD_GL_ARB_direct_state_access = 0; int GLAD_GL_ARB_direct_state_access = 0;
int GLAD_GL_EXT_EGL_image_storage = 0; int GLAD_GL_EXT_EGL_image_storage = 0;
int GLAD_GL_EXT_direct_state_access = 0; int GLAD_GL_EXT_direct_state_access = 0;
int GLAD_GL_KHR_debug = 0;
@@ -9181,20 +9178,6 @@ static void glad_gl_load_GL_EXT_direct_state_access( GLADuserptrloadfunc load, v
glad_glVertexArrayVertexBindingDivisorEXT = (PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) load(userptr, "glVertexArrayVertexBindingDivisorEXT"); glad_glVertexArrayVertexBindingDivisorEXT = (PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) load(userptr, "glVertexArrayVertexBindingDivisorEXT");
glad_glVertexArrayVertexOffsetEXT = (PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) load(userptr, "glVertexArrayVertexOffsetEXT"); glad_glVertexArrayVertexOffsetEXT = (PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) load(userptr, "glVertexArrayVertexOffsetEXT");
} }
static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
if(!GLAD_GL_KHR_debug) return;
glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load(userptr, "glDebugMessageCallback");
glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load(userptr, "glDebugMessageControl");
glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load(userptr, "glDebugMessageInsert");
glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load(userptr, "glGetDebugMessageLog");
glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load(userptr, "glGetObjectLabel");
glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load(userptr, "glGetObjectPtrLabel");
glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv");
glad_glObjectLabel = (PFNGLOBJECTLABELPROC) load(userptr, "glObjectLabel");
glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load(userptr, "glObjectPtrLabel");
glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load(userptr, "glPopDebugGroup");
glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load(userptr, "glPushDebugGroup");
}
@@ -9293,7 +9276,6 @@ static int glad_gl_find_extensions_gl(void) {
GLAD_GL_ARB_direct_state_access = glad_gl_has_extension(exts, exts_i, "GL_ARB_direct_state_access"); GLAD_GL_ARB_direct_state_access = glad_gl_has_extension(exts, exts_i, "GL_ARB_direct_state_access");
GLAD_GL_EXT_EGL_image_storage = glad_gl_has_extension(exts, exts_i, "GL_EXT_EGL_image_storage"); GLAD_GL_EXT_EGL_image_storage = glad_gl_has_extension(exts, exts_i, "GL_EXT_EGL_image_storage");
GLAD_GL_EXT_direct_state_access = glad_gl_has_extension(exts, exts_i, "GL_EXT_direct_state_access"); GLAD_GL_EXT_direct_state_access = glad_gl_has_extension(exts, exts_i, "GL_EXT_direct_state_access");
GLAD_GL_KHR_debug = glad_gl_has_extension(exts, exts_i, "GL_KHR_debug");
glad_gl_free_extensions(exts_i); glad_gl_free_extensions(exts_i);
@@ -9378,7 +9360,6 @@ int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
glad_gl_load_GL_ARB_direct_state_access(load, userptr); glad_gl_load_GL_ARB_direct_state_access(load, userptr);
glad_gl_load_GL_EXT_EGL_image_storage(load, userptr); glad_gl_load_GL_EXT_EGL_image_storage(load, userptr);
glad_gl_load_GL_EXT_direct_state_access(load, userptr); glad_gl_load_GL_EXT_direct_state_access(load, userptr);
glad_gl_load_GL_KHR_debug(load, userptr);
@@ -9501,9 +9482,7 @@ static void* glad_gl_dlopen_handle(void) {
"libGL-1.so", "libGL-1.so",
#endif #endif
"libGL.so.1", "libGL.so.1",
"libGL.so", "libGL.so"
"libEGL.so.1",
"libEGL.so"
}; };
#endif #endif
@@ -9526,9 +9505,6 @@ static struct _glad_gl_userptr glad_gl_build_userptr(void *handle) {
#else #else
userptr.gl_get_proc_address_ptr = userptr.gl_get_proc_address_ptr =
(GLADglprocaddrfunc) glad_dlsym_handle(handle, "glXGetProcAddressARB"); (GLADglprocaddrfunc) glad_dlsym_handle(handle, "glXGetProcAddressARB");
if (!userptr.gl_get_proc_address_ptr)
userptr.gl_get_proc_address_ptr =
(GLADglprocaddrfunc) glad_dlsym_handle(handle, "eglGetProcAddress");
#endif #endif
return userptr; return userptr;
@@ -9571,3 +9547,4 @@ void gladLoaderUnloadGL(void) {
#endif #endif
#endif /* GLAD_GL_IMPLEMENTATION */ #endif /* GLAD_GL_IMPLEMENTATION */
+70 -78
View File
@@ -6,7 +6,7 @@
# (shaders, video devices, textures, midi inputs, etc.) # (shaders, video devices, textures, midi inputs, etc.)
# Every number based constant will be "one-based" (1,2,3,etc.) # Every number based constant will be "one-based" (1,2,3,etc.)
# To read more, go to # To read more, go to
# https://git.klemek.fr/klemek/forge-steel # https://github.com/klemek/forge-steel
# ================ # ================
@@ -44,8 +44,8 @@ UNIFORM_RESOLUTION=iResolution
# --- uniform vec3 --- # --- uniform vec3 ---
# Midi group X layer Y (beware of group size) # Midi group X layer Y (beware of group size)
# Injected as "iGroupX_Y[Z]" # Injected as "iMidiX_Y[Z]"
UNIFORM_GROUP_PREFIX=iGroup UNIFORM_MIDI_PREFIX=iMidi
# --- uniform sampler2D --- # --- uniform sampler2D ---
@@ -79,17 +79,9 @@ FRAG_OUTPUT=2
FRAG_MONITOR=2 FRAG_MONITOR=2
# ========== # ========
# I/O Inputs # MIDI I/O
# ========== # ========
# Each code either maps to a midi event or a key code
# 0 - 999 -> midi event
# Keyboard modifiers are encoded like this:
# 1000 -> keyboard event
# 10000 -> shift
# 100000 -> control
# 1000000 -> alt
# This means 111082 is control+alt+R
# The recognized ALSA name of the midi device # The recognized ALSA name of the midi device
@@ -122,8 +114,8 @@ FADER_16=23
# Midi code for tap tempo # Midi code for tap tempo
TAP_TEMPO=46 TAP_TEMPO=46
# === GROUP INPUT STATES # === MIDI INPUT STATES
# Inputs will control FORGE's state as follows # Midi inputs will control FORGE's state as follows
# X groups of Y layers sized Z # X groups of Y layers sized Z
# You can manipulate only 1 layer at a time # You can manipulate only 1 layer at a time
# Every layer of every groups will be send as uniforms # Every layer of every groups will be send as uniforms
@@ -131,68 +123,68 @@ TAP_TEMPO=46
# with the same codes for nice display # with the same codes for nice display
# Total number of groups # Total number of groups
GROUP_COUNT=1 MIDI_COUNT=1
# Size of group 1 # Size of group 1
GROUP_1_COUNT=20 MIDI_1_COUNT=20
# Every code of active layer manipulation of group 1 # Every code of active layer manipulation of group 1
GROUP_1_1_X=32 MIDI_1_1_X=32
GROUP_1_1_Y=48 MIDI_1_1_Y=48
GROUP_1_1_Z=64 MIDI_1_1_Z=64
GROUP_1_2_X=0 MIDI_1_2_X=0
GROUP_1_2_Y=16 MIDI_1_2_Y=16
GROUP_1_2_Z= MIDI_1_2_Z=
GROUP_1_3_X=33 MIDI_1_3_X=33
GROUP_1_3_Y=49 MIDI_1_3_Y=49
GROUP_1_3_Z=65 MIDI_1_3_Z=65
GROUP_1_4_X=1 MIDI_1_4_X=1
GROUP_1_4_Y=17 MIDI_1_4_Y=17
GROUP_1_4_Z= MIDI_1_4_Z=
GROUP_1_5_X=34 MIDI_1_5_X=34
GROUP_1_5_Y=50 MIDI_1_5_Y=50
GROUP_1_5_Z=66 MIDI_1_5_Z=66
GROUP_1_6_X=2 MIDI_1_6_X=2
GROUP_1_6_Y=18 MIDI_1_6_Y=18
GROUP_1_6_Z= MIDI_1_6_Z=
GROUP_1_7_X=35 MIDI_1_7_X=35
GROUP_1_7_Y=51 MIDI_1_7_Y=51
GROUP_1_7_Z=67 MIDI_1_7_Z=67
GROUP_1_8_X=3 MIDI_1_8_X=3
GROUP_1_8_Y=19 MIDI_1_8_Y=19
GROUP_1_8_Z= MIDI_1_8_Z=
GROUP_1_9_X=36 MIDI_1_9_X=36
GROUP_1_9_Y=52 MIDI_1_9_Y=52
GROUP_1_9_Z=68 MIDI_1_9_Z=68
GROUP_1_10_X=4 MIDI_1_10_X=4
GROUP_1_10_Y=20 MIDI_1_10_Y=20
GROUP_1_10_Z= MIDI_1_10_Z=
GROUP_1_11_X=37 MIDI_1_11_X=37
GROUP_1_11_Y=53 MIDI_1_11_Y=53
GROUP_1_11_Z=69 MIDI_1_11_Z=69
GROUP_1_12_X=5 MIDI_1_12_X=5
GROUP_1_12_Y=21 MIDI_1_12_Y=21
GROUP_1_12_Z= MIDI_1_12_Z=
GROUP_1_13_X=38 MIDI_1_13_X=38
GROUP_1_13_Y=54 MIDI_1_13_Y=54
GROUP_1_13_Z=70 MIDI_1_13_Z=70
GROUP_1_14_X=6 MIDI_1_14_X=6
GROUP_1_14_Y=22 MIDI_1_14_Y=22
GROUP_1_14_Z= MIDI_1_14_Z=
GROUP_1_15_X=39 MIDI_1_15_X=39
GROUP_1_15_Y=55 MIDI_1_15_Y=55
GROUP_1_15_Z=71 MIDI_1_15_Z=71
GROUP_1_16_X=7 MIDI_1_16_X=7
GROUP_1_16_Y=23 MIDI_1_16_Y=23
GROUP_1_16_Z= MIDI_1_16_Z=
GROUP_1_17_X=58 MIDI_1_17_X=58
GROUP_1_17_Y=59 MIDI_1_17_Y=59
GROUP_1_17_Z= MIDI_1_17_Z=
GROUP_1_18_X=60 MIDI_1_18_X=60
GROUP_1_18_Y=61 MIDI_1_18_Y=61
GROUP_1_18_Z=62 MIDI_1_18_Z=62
GROUP_1_19_X=43 MIDI_1_19_X=43
GROUP_1_19_Y=44 MIDI_1_19_Y=44
GROUP_1_19_Z=42 MIDI_1_19_Z=42
GROUP_1_20_X=41 MIDI_1_20_X=41
GROUP_1_20_Y=45 MIDI_1_20_Y=45
GROUP_1_20_Z= MIDI_1_20_Z=
+28 -28
View File
@@ -12,31 +12,31 @@ uniform int iFPS; // output window frames per seconds
uniform int iDemo; // 0/1 if demo mode uniform int iDemo; // 0/1 if demo mode
uniform int iSeed1; // a random seed assigned at start uniform int iSeed1; // a random seed assigned at start
uniform vec2 iResolution; // output window resolution in pixels uniform vec2 iResolution; // output window resolution in pixels
uniform vec3 iGroup1_1[20]; // all midi inputs defined uniform vec3 iMidi1_1[20]; // all midi inputs defined
uniform sampler2D iTex0; // available texture (this code output, so feedback) uniform sampler2D iTex0; // available texture (this code output, so feedback)
void main() { void main() {
// all available buttons and faders // all available buttons and faders
vec3 b1 = iGroup1_1[0]; vec3 b1 = iMidi1_1[0];
vec2 f1 = iGroup1_1[1].xy; vec2 f1 = iMidi1_1[1].xy;
vec3 b2 = iGroup1_1[2]; vec3 b2 = iMidi1_1[2];
vec2 f2 = iGroup1_1[3].xy; vec2 f2 = iMidi1_1[3].xy;
vec3 b3 = iGroup1_1[4]; vec3 b3 = iMidi1_1[4];
vec2 f3 = iGroup1_1[5].xy; vec2 f3 = iMidi1_1[5].xy;
vec3 b4 = iGroup1_1[6]; vec3 b4 = iMidi1_1[6];
vec2 f4 = iGroup1_1[7].xy; vec2 f4 = iMidi1_1[7].xy;
vec3 b5 = iGroup1_1[8]; vec3 b5 = iMidi1_1[8];
vec2 f5 = iGroup1_1[9].xy; vec2 f5 = iMidi1_1[9].xy;
vec3 b6 = iGroup1_1[10]; vec3 b6 = iMidi1_1[10];
vec2 f6 = iGroup1_1[11].xy; vec2 f6 = iMidi1_1[11].xy;
vec3 b7 = iGroup1_1[12]; vec3 b7 = iMidi1_1[12];
vec2 f7 = iGroup1_1[13].xy; vec2 f7 = iMidi1_1[13].xy;
vec3 b8 = iGroup1_1[14]; vec3 b8 = iMidi1_1[14];
vec2 f8 = iGroup1_1[15].xy; vec2 f8 = iMidi1_1[15].xy;
vec3 b9 = iGroup1_1[16]; vec3 b9 = iMidi1_1[16];
vec3 b10 = iGroup1_1[17]; vec3 b10 = iMidi1_1[17];
vec3 b11 = iGroup1_1[18]; vec3 b11 = iMidi1_1[18];
vec3 b12 = iGroup1_1[19]; vec3 b12 = iMidi1_1[19];
// center UV and scale it to ratio // center UV and scale it to ratio
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
@@ -47,17 +47,17 @@ void main() {
float circle_dist = 0.1 + 0.9 * f1.x; float circle_dist = 0.1 + 0.9 * f1.x;
float circle_size = 0.1 + 0.9 * f2.x; float circle_size = 0.1 + 0.9 * f2.x;
vec2 circle_pos = circle_dist * vec2( vec2 circle_pos = circle_dist * vec2(
sin(iBeats * 2 * PI), sin(iBeats * 2 * PI),
cos(iBeats * 2 * PI) cos(iBeats * 2 * PI)
); );
float circle = 1 - step(circle_size, length(uv1 - circle_pos)); float circle = 1 - step(circle_size, length(uv1 - circle_pos));
// fader 3, 4 and 5 controls the color // fader 3, 4 and 5 controls the color
vec3 color = vec3( vec3 color = vec3(
f3.x, f3.x,
f4.x, f4.x,
f5.x f5.x
); );
vec3 out_color = mix(color, 1 - color, circle); vec3 out_color = mix(color, 1 - color, circle);
// fader 8 controls the feedback value // fader 8 controls the feedback value
+34 -61
View File
@@ -32,14 +32,11 @@ static void print_help(int status_code) {
#ifdef VIDEO_IN #ifdef VIDEO_IN
"[-vi=FILE] " "[-vi=FILE] "
"[-vs=SIZE] " "[-vs=SIZE] "
"[-vb=COUNT] "
"[-vr / -nvr] " "[-vr / -nvr] "
"[-vf=FOURCC] "
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
"[-is=SIZE] " "[-is=SIZE] "
"[-ls / -nls] " "[-ls / -nls] "
"[-ss / -nss] " "[-ss / -nss] "
"[-mr / -nmr] "
"[-tm] " "[-tm] "
"[-tf] " "[-tf] "
"\n\n" "\n\n"
@@ -65,21 +62,16 @@ static void print_help(int status_code) {
#ifdef VIDEO_IN #ifdef VIDEO_IN
" -vi, --video-in path to video capture device (multiple " " -vi, --video-in path to video capture device (multiple "
"allowed)\n" "allowed)\n"
" -vb, --video-buffers number of video buffers to use (default: "
"1)\n"
" -vs, --video-size video capture desired height (default: " " -vs, --video-size video capture desired height (default: "
"internal texture height)\n" "internal texture height)\n"
" -vr, --video-reconnect auto-reconnect video (default)\n" " -vr, --video-reconnect auto-reconnect video (default)\n"
" -nvr, --no-video-reconnect do not auto-reconnect video\n" " -nvr, --no-video-reconnect do not auto-reconnect video\n"
" -vf, --video-fourcc video codec fourcc (default: YUYV)\n"
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
" -is, --internal-size internal texture height (default: 720)\n" " -is, --internal-size internal texture height (default: 720)\n"
" -ls, --load-state load saved state (default)\n" " -ls, --load-state load saved state (default)\n"
" -nls, --no-load-state do not load saved state\n" " -nls, --no-load-state do not load saved state\n"
" -ss, --save-state save state (default)\n" " -ss, --save-state save state (default)\n"
" -nss, --no-save-state do not save state\n" " -nss, --no-save-state do not save state\n"
" -mr, --midi-reconnect auto-reconnect midi (default)\n"
" -nmr, --no-midi-reconnect do not auto-reconnect midi\n"
" -tm, --trace-midi print midi code and values\n" " -tm, --trace-midi print midi code and values\n"
" -tf, --trace-fps print fps status of subsystems\n"); " -tf, --trace-fps print fps status of subsystems\n");
exit(status_code); exit(status_code);
@@ -116,7 +108,7 @@ static unsigned int parse_uint(const char *arg, const char *value) {
tmp_value = (unsigned long long)atoll(value); tmp_value = (unsigned long long)atoll(value);
if (tmp_value > UINT_MAX) { if (tmp_value >= UINT_MAX) {
invalid_value(arg, value); invalid_value(arg, value);
} }
@@ -139,17 +131,12 @@ void args_parse(Parameters *params, int argc, char **argv) {
params->demo = false; params->demo = false;
params->auto_random = false; params->auto_random = false;
params->auto_random_cycle = 4; params->auto_random_cycle = 4;
#ifdef VIDEO_IN
params->video_in.length = 0; params->video_in.length = 0;
params->video_buffers = 1;
params->video_size = 0; params->video_size = 0;
params->video_reconnect = true; params->video_reconnect = true;
strlcpy(params->video_fourcc, "YUYV", 5);
#endif /* VIDEO_IN */
params->internal_size = 720; params->internal_size = 720;
params->load_state = true; params->load_state = true;
params->save_state = true; params->save_state = true;
params->midi_reconnect = true;
params->trace_midi = false; params->trace_midi = false;
params->trace_fps = false; params->trace_fps = false;
@@ -162,14 +149,8 @@ void args_parse(Parameters *params, int argc, char **argv) {
puts(PACKAGE " " VERSION); puts(PACKAGE " " VERSION);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if (is_arg(arg, "-p") || is_arg(arg, "--project")) { } else if (is_arg(arg, "-p") || is_arg(arg, "--project")) {
if (strlen(value) == 0) {
invalid_value(arg, value);
}
strlcpy(params->project_path, value, STR_LEN); strlcpy(params->project_path, value, STR_LEN);
} else if (is_arg(arg, "-c") || is_arg(arg, "--config")) { } else if (is_arg(arg, "-c") || is_arg(arg, "--config")) {
if (strlen(value) == 0) {
invalid_value(arg, value);
}
strlcpy(params->config_file, value, STR_LEN); strlcpy(params->config_file, value, STR_LEN);
} else if (is_arg(arg, "-hr") || is_arg(arg, "--hot-reload")) { } else if (is_arg(arg, "-hr") || is_arg(arg, "--hot-reload")) {
params->hot_reload = true; params->hot_reload = true;
@@ -199,6 +180,38 @@ void args_parse(Parameters *params, int argc, char **argv) {
if (params->auto_random_cycle == 0) { if (params->auto_random_cycle == 0) {
invalid_value(arg, value); invalid_value(arg, value);
} }
} else if (is_arg(arg, "-vi") || is_arg(arg, "--video-in")) {
#ifdef VIDEO_IN
if (params->video_in.length == MAX_VIDEO) {
log_error("maximum video input reached");
exit(EXIT_FAILURE);
}
strlcpy(params->video_in.values[params->video_in.length++], value,
STR_LEN);
#else
invalid_arg(arg);
#endif /* VIDEO_IN */
} else if (is_arg(arg, "-vs") || is_arg(arg, "--video-size")) {
#ifdef VIDEO_IN
params->video_size = parse_uint(arg, value);
if (params->video_size == 0) {
invalid_value(arg, value);
}
#else
invalid_arg(arg);
#endif /* VIDEO_IN */
} else if (is_arg(arg, "-vr") || is_arg(arg, "--video-reconnect")) {
#ifdef VIDEO_IN
params->video_reconnect = true;
#else
invalid_arg(arg);
#endif /* VIDEO_IN */
} else if (is_arg(arg, "-nvr") || is_arg(arg, "--no-video-reconnect")) {
#ifdef VIDEO_IN
params->video_reconnect = false;
#else
invalid_arg(arg);
#endif /* VIDEO_IN */
} else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) { } else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) {
params->internal_size = parse_uint(arg, value); params->internal_size = parse_uint(arg, value);
if (params->internal_size == 0) { if (params->internal_size == 0) {
@@ -212,51 +225,12 @@ void args_parse(Parameters *params, int argc, char **argv) {
params->save_state = true; params->save_state = true;
} else if (is_arg(arg, "-nss") || is_arg(arg, "--no-save-state")) { } else if (is_arg(arg, "-nss") || is_arg(arg, "--no-save-state")) {
params->save_state = false; params->save_state = false;
} else if (is_arg(arg, "-mr") || is_arg(arg, "--midi-reconnect")) {
params->midi_reconnect = true;
} else if (is_arg(arg, "-nmr") || is_arg(arg, "--no-midi-reconnect")) {
params->midi_reconnect = false;
} else if (is_arg(arg, "-tm") || is_arg(arg, "--trace-midi")) { } else if (is_arg(arg, "-tm") || is_arg(arg, "--trace-midi")) {
params->trace_midi = true; params->trace_midi = true;
} else if (is_arg(arg, "-tf") || is_arg(arg, "--trace-fps")) { } else if (is_arg(arg, "-tf") || is_arg(arg, "--trace-fps")) {
params->trace_fps = true; params->trace_fps = true;
} else { } else {
#ifdef VIDEO_IN
if (is_arg(arg, "-vi") || is_arg(arg, "--video-in")) {
if (params->video_in.length == MAX_VIDEO) {
log_error("maximum video input reached");
exit(EXIT_FAILURE);
}
if (strlen(value) == 0) {
invalid_value(arg, value);
}
strlcpy(params->video_in.values[params->video_in.length++], value,
STR_LEN);
} else if (is_arg(arg, "-vb") || is_arg(arg, "--video-buffers")) {
params->video_buffers = parse_uint(arg, value);
if (params->video_buffers == 0) {
invalid_value(arg, value);
}
} else if (is_arg(arg, "-vs") || is_arg(arg, "--video-size")) {
params->video_size = parse_uint(arg, value);
if (params->video_size == 0) {
invalid_value(arg, value);
}
} else if (is_arg(arg, "-vr") || is_arg(arg, "--video-reconnect")) {
params->video_reconnect = true;
} else if (is_arg(arg, "-nvr") || is_arg(arg, "--no-video-reconnect")) {
params->video_reconnect = false;
} else if (is_arg(arg, "-vf") || is_arg(arg, "--video-fourcc")) {
if (strlen(value) == 0) {
invalid_value(arg, value);
}
strlcpy(params->video_fourcc, value, 5);
} else {
invalid_arg(arg);
}
#else
invalid_arg(arg); invalid_arg(arg);
#endif /* VIDEO_IN */
} }
} }
@@ -265,9 +239,8 @@ void args_parse(Parameters *params, int argc, char **argv) {
log_error("monitor screen cannot be the same as output screen"); log_error("monitor screen cannot be the same as output screen");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef VIDEO_IN
if (params->video_size == 0) { if (params->video_size == 0) {
params->video_size = params->internal_size; params->video_size = params->internal_size;
} }
#endif /* VIDEO_IN */
} }
-14
View File
@@ -12,21 +12,7 @@ unsigned int arr_uint_index_of(UintArray array, unsigned int value) {
return ARRAY_NOT_FOUND; return ARRAY_NOT_FOUND;
} }
bool arr_string_match(StringArray array, const char *needle) {
for (unsigned int i = 0; i < array.length; i++) {
if (strncmp(array.values[i], needle, strlen(array.values[i])) == 0) {
return true;
}
}
return false;
}
unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index) { unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index) {
if (offsets.length == 0) {
return 0;
}
for (unsigned int i = offsets.length - 1; i > 0; i--) { for (unsigned int i = offsets.length - 1; i > 0; i--) {
if (*index >= offsets.values[i]) { if (*index >= offsets.values[i]) {
*index -= offsets.values[i]; *index -= offsets.values[i];
-2
View File
@@ -7,6 +7,4 @@ unsigned int arr_uint_index_of(UintArray array, unsigned int value);
unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index); unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index);
bool arr_string_match(StringArray array, const char *needle);
#endif /* ARR_H */ #endif /* ARR_H */
+3 -9
View File
@@ -68,7 +68,8 @@ void config_file_read(ConfigFile *config, const char *path) {
char *line; char *line;
char *rest; char *rest;
config->map = NULL; config->map = hashmap_new(sizeof(ConfigFileItem), 0, 0, 0, item_hash,
item_compare, NULL, NULL);
file_read(&file, path); file_read(&file, path);
@@ -77,9 +78,6 @@ void config_file_read(ConfigFile *config, const char *path) {
return; return;
} }
config->map = hashmap_new(sizeof(ConfigFileItem), 0, 0, 0, item_hash,
item_compare, NULL, NULL);
config->error = false; config->error = false;
line = strtok_r(file.content, "\n", &rest); line = strtok_r(file.content, "\n", &rest);
@@ -140,8 +138,4 @@ unsigned int config_file_get_int(const ConfigFile *config, const char *key,
return (unsigned int)atoi(item->value); return (unsigned int)atoi(item->value);
} }
void config_file_free(const ConfigFile *config) { void config_file_free(const ConfigFile *config) { hashmap_free(config->map); }
if (config->map != NULL) {
hashmap_free(config->map);
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
#ifndef CONSTANTS_H #ifndef CONSTANTS_H
#define CONSTANTS_H #define CONSTANTS_H
static const char *vertex_shader_text = static char *vertex_shader_text =
"#version 460\n" "#version 460\n"
"const mat4 mvp = " "const mat4 mvp = "
"{{2.,0.,0.,0.},{0.,2.,0.,0.},{0.,0.,2.,0.},{-1.,-1.,1.,1.}};\n" "{{2.,0.,0.,0.},{0.,2.,0.,0.},{0.,0.,2.,0.},{-1.,-1.,1.,1.}};\n"
+3 -17
View File
@@ -26,7 +26,6 @@ bool file_should_update(const File *file) {
bool file_update(File *file) { bool file_update(File *file) {
long length; long length;
size_t read_length;
FILE *file_pointer; FILE *file_pointer;
// free remaining data // free remaining data
@@ -48,12 +47,6 @@ bool file_update(File *file) {
// read file length // read file length
fseek(file_pointer, 0, SEEK_END); fseek(file_pointer, 0, SEEK_END);
length = ftell(file_pointer); length = ftell(file_pointer);
if (length == -1L) {
file->error = true;
fclose(file_pointer);
log_error("Cannot get file length for '%s'", file->path);
return false;
}
// init buffer // init buffer
fseek(file_pointer, 0, SEEK_SET); fseek(file_pointer, 0, SEEK_SET);
file->content = malloc(length + 1); file->content = malloc(length + 1);
@@ -64,13 +57,7 @@ bool file_update(File *file) {
return false; return false;
} }
// read file // read file
read_length = fread(file->content, sizeof(char), length, file_pointer); fread(file->content, sizeof(char), length, file_pointer);
if (read_length != (unsigned)length) {
file->error = true;
fclose(file_pointer);
log_error("Cannot read complete file '%s'", file->path);
return false;
}
// close file // close file
fclose(file_pointer); fclose(file_pointer);
// append null byte // append null byte
@@ -130,9 +117,8 @@ void file_write(const char *path, const StringArray *lines) {
fclose(file_pointer); fclose(file_pointer);
} }
void file_free(File *file) { void file_free(const File *file) {
if (!file->error && file->content != NULL) { if (!file->error) {
free(file->content); free(file->content);
file->content = NULL;
} }
} }
+1 -1
View File
@@ -13,6 +13,6 @@ void file_write(const char *path, const StringArray *lines);
void file_dump(const char *path, const char *content); void file_dump(const char *path, const char *content);
void file_free(File *file); void file_free(const File *file);
#endif /* FILE_H */ #endif /* FILE_H */
+105 -180
View File
@@ -1,6 +1,5 @@
#include <log.h> #include <log.h>
#include <math.h> #include <math.h>
#include <pthread.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -15,6 +14,7 @@
#include "midi.h" #include "midi.h"
#include "project.h" #include "project.h"
#include "shaders.h" #include "shaders.h"
#include "shared.h"
#include "state.h" #include "state.h"
#include "tempo.h" #include "tempo.h"
#include "timer.h" #include "timer.h"
@@ -22,18 +22,15 @@
#include "window.h" #include "window.h"
static Parameters init_params; static Parameters init_params;
static Context context; static SharedContext *context;
static ShaderProgram program; static ShaderProgram program;
static Window *window_output; static Window *window_output;
static Window *window_monitor; static Window *window_monitor;
static Timer timer; static Timer timer;
static MidiDevice midi; static MidiDevice midi;
static bool trace_midi;
static Project project; static Project project;
#ifdef VIDEO_IN
static VideoCaptureArray video_captures;
#endif /* VIDEO_IN */
static void compute_fps() { static void compute_fps() {
double fps; double fps;
char title[STR_LEN]; char title[STR_LEN];
@@ -55,118 +52,103 @@ static void compute_fps() {
window_update_title(window_monitor, title); window_update_title(window_monitor, title);
} }
context.fps = (unsigned int)round(fps); context->fps = (unsigned int)round(fps);
} }
} }
static void init_context() { static void init_context() {
context.stop = false; context = shared_init_context("/" PACKAGE "_context");
state_init(&context, project.state_config, init_params.demo, context->stop = false;
state_init(context, &project.state_config, init_params.demo,
init_params.auto_random, init_params.auto_random_cycle, init_params.auto_random, init_params.auto_random_cycle,
init_params.base_tempo, init_params.load_state); init_params.base_tempo, init_params.load_state);
#ifdef VIDEO_IN memset(context->input_resolutions, 0, sizeof(context->input_resolutions));
memset(context.input_resolutions, 0, sizeof(context.input_resolutions));
memset(context.input_formats, 0, sizeof(context.input_formats));
memset(context.input_fps, 0, sizeof(context.input_fps));
memset(context.input_index, 0, sizeof(context.input_index));
#endif /* VIDEO_IN */
} }
static void free_context() { shared_close_context(context); }
static void reload_shader(unsigned int i) { static void reload_shader(unsigned int i) {
shaders_update(&program, &project.fragment_shaders[i][0], i, &project); shaders_update(&program, &project.fragment_shaders[i][0], i, &project);
} }
#ifdef VIDEO_IN #ifdef VIDEO_IN
static void init_inputs() { static void init_inputs() {
video_captures.length = init_params.video_in.length; context->inputs.length = init_params.video_in.length;
for (unsigned int i = 0; i < init_params.video_in.length; i++) { for (unsigned int i = 0; i < init_params.video_in.length; i++) {
video_init(&video_captures.values[i], init_params.video_in.values[i], video_init(&context->inputs.values[i], init_params.video_in.values[i],
init_params.video_size, init_params.video_buffers, init_params.video_size);
init_params.video_fourcc, true);
if (!video_captures.values[i].error) { if (!context->inputs.values[i].error) {
context.input_resolutions[i][0] = video_captures.values[i].width; context->input_resolutions[i][0] = context->inputs.values[i].width;
context.input_resolutions[i][1] = video_captures.values[i].height; context->input_resolutions[i][1] = context->inputs.values[i].height;
context.input_formats[i] = video_captures.values[i].pixelformat; context->inputs.values[i].needs_reload = false;
video_captures.values[i].needs_reload = false; context->inputs.values[i].disconnected = false;
video_captures.values[i].disconnected = false;
} }
} }
} }
static void start_video_background_read(VideoCapture *video_capture, static bool reconnect_video_captures() {
Context *context, int input_index, for (unsigned int i = 0; i < init_params.video_in.length; i++) {
bool trace_fps) { if (context->inputs.values[i].disconnected) {
pthread_t thread; video_init(&context->inputs.values[i], init_params.video_in.values[i],
VideoBackgroundReadArgs *process_args = init_params.video_size);
(VideoBackgroundReadArgs *)malloc(sizeof(VideoBackgroundReadArgs));
process_args->capture = video_capture;
process_args->context = context;
process_args->input_index = input_index;
process_args->trace_fps = trace_fps;
if (pthread_create(&thread, NULL, video_background_read,
(void *)process_args) == 0) {
pthread_detach(thread);
} else {
log_error("background video acquisition failed to start");
free(process_args);
}
}
static void * if (!context->inputs.values[i].error) {
background_reconnect_video_captures(__attribute__((unused)) void *args) { context->input_resolutions[i][0] = context->inputs.values[i].width;
log_info("background video capture reconnect started"); context->input_resolutions[i][1] = context->inputs.values[i].height;
while (!context.stop) {
sleep(1);
for (unsigned int i = 0; i < init_params.video_in.length; i++) {
if (video_captures.values[i].disconnected) {
video_free(&video_captures.values[i]);
video_init(&video_captures.values[i], init_params.video_in.values[i],
init_params.video_size, init_params.video_buffers,
init_params.video_fourcc, false);
if (!video_captures.values[i].error) { if (!video_background_read(&context->inputs.values[i], context, i,
context.input_resolutions[i][0] = video_captures.values[i].width; init_params.trace_fps)) {
context.input_resolutions[i][1] = video_captures.values[i].height; return false;
context.input_formats[i] = video_captures.values[i].pixelformat;
video_captures.values[i].needs_reload = true;
video_captures.values[i].disconnected = false;
start_video_background_read(&video_captures.values[i], &context, i,
init_params.trace_fps);
} }
context->inputs.values[i].needs_reload = true;
context->inputs.values[i].disconnected = false;
} }
} }
} }
pthread_exit(NULL); return true;
} }
static void start_video_captures() { static bool start_video_captures() {
pthread_t thread; pid_t pid;
for (unsigned int i = 0; i < video_captures.length; i++) { for (unsigned int i = 0; i < context->inputs.length; i++) {
if (!video_captures.values[i].error) { if (!context->inputs.values[i].error &&
start_video_background_read(&video_captures.values[i], &context, i, !video_background_read(&context->inputs.values[i], context, i,
init_params.trace_fps); init_params.trace_fps)) {
return false;
} }
} }
if (init_params.video_reconnect) { if (!init_params.video_reconnect) {
if (pthread_create(&thread, NULL, background_reconnect_video_captures, return true;
NULL) == 0) { }
pthread_detach(thread); pid = fork();
} else { if (pid < 0) {
log_info("background video capture reconnect failed to start"); log_error("Could not create subprocess");
return false;
}
if (pid == 0) {
return true;
}
log_info("background reconnect acquisition started (pid: %d)", pid);
while (!context->stop) {
sleep(1);
if (!reconnect_video_captures()) {
return false;
} }
} }
exit(EXIT_SUCCESS);
} }
static void free_video_captures() { static void free_video_captures() {
for (unsigned int i = 0; i < video_captures.length; i++) { for (unsigned int i = 0; i < context->inputs.length; i++) {
shaders_free_input(&program, i); shaders_free_input(&program, i);
video_free(&video_captures.values[i]); video_free(&context->inputs.values[i]);
} }
} }
@@ -175,7 +157,7 @@ static void free_video_captures() {
static void error_callback(int error, const char *description) { static void error_callback(int error, const char *description) {
log_error("[GLFW] %d: %s", error, description); log_error("[GLFW] %d: %s", error, description);
window_terminate(); window_terminate();
context.stop = true; context->stop = true;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -191,78 +173,13 @@ static void key_callback(Window *window, int key,
log_info("[ESC] Closing..."); log_info("[ESC] Closing...");
window_close(window); window_close(window);
} else if (event > 0) { } else if (event > 0) {
state_key_event(&context, project.state_config, event, midi); state_key_event(context, &project.state_config, event, &midi);
} }
} }
static void midi_callback(unsigned char code, unsigned char value) { static void midi_callback(unsigned char code, unsigned char value) {
state_midi_event(&context, project.state_config, midi, code, value, state_midi_event(context, &project.state_config, &midi, code, value,
init_params.trace_midi); trace_midi);
}
static void start_state_background_write() {
pthread_t thread;
StateBackgroundWriteArgs *process_args =
(StateBackgroundWriteArgs *)malloc(sizeof(StateBackgroundWriteArgs));
process_args->context = &context;
process_args->state_config = project.state_config;
process_args->midi = &midi;
if (pthread_create(&thread, NULL, state_background_write, process_args) ==
0) {
pthread_detach(thread);
} else {
log_error("background writing failed to start");
free(process_args);
}
}
static void start_midi_background_listen() {
pthread_t thread;
MidiBackgroundListenArgs *process_args =
(MidiBackgroundListenArgs *)malloc(sizeof(MidiBackgroundListenArgs));
process_args->device = &midi;
process_args->context = &context;
process_args->event_callback = midi_callback;
if (pthread_create(&thread, NULL, midi_background_listen, process_args) ==
0) {
pthread_detach(thread);
} else {
log_error("background midi acquisition failed to start");
free(process_args);
}
}
static void *background_reconnect_midi(__attribute__((unused)) void *args) {
log_info("background midi reconnect started");
while (!context.stop) {
sleep(1);
if (!midi.connected) {
midi_open(&midi, config_file_get_str(&project.config, "MIDI_HW", "hw"),
false);
if (midi.connected) {
start_midi_background_listen();
}
}
}
pthread_exit(NULL);
}
static void init_midi() {
pthread_t thread;
midi_open(&midi, config_file_get_str(&project.config, "MIDI_HW", "hw"), true);
if (midi.connected) {
start_midi_background_listen();
}
if (init_params.midi_reconnect) {
if (pthread_create(&thread, NULL, background_reconnect_midi, NULL) == 0) {
pthread_detach(thread);
} else {
log_error("background midi reconnect failed to start");
}
}
} }
static bool init(const Parameters *params) { static bool init(const Parameters *params) {
@@ -279,25 +196,38 @@ static bool init(const Parameters *params) {
#ifdef VIDEO_IN #ifdef VIDEO_IN
init_inputs(); init_inputs();
start_video_captures(); if (!start_video_captures()) {
return false;
}
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
init_midi(); midi_open(&midi, config_file_get_str(&project.config, "MIDI_HW", "hw"));
start_state_background_write(); if (midi.error) {
context->demo = true;
} else {
trace_midi = params->trace_midi;
if (!midi_background_listen(&midi, context, midi_callback)) {
return false;
}
}
if (!state_background_write(context, &project.state_config, &midi)) {
return false;
}
window_startup(error_callback); window_startup(error_callback);
context.tex_resolution[0] = params->internal_size; context->tex_resolution[1] = params->internal_size;
context.tex_resolution[1] = params->internal_size;
if (params->output) { if (params->output) {
window_output = window_init(PACKAGE " " VERSION, params->output_screen, window_output = window_init(PACKAGE " " VERSION, params->output_screen,
params->windowed, NULL, key_callback); params->windowed, NULL, key_callback);
window_use(window_output, &context); window_use(window_output, context);
shaders_init(&program, &project, &context, false); shaders_init(&program, &project, context, false);
} else { } else {
window_output = NULL; window_output = NULL;
} }
@@ -307,24 +237,19 @@ static bool init(const Parameters *params) {
window_init(PACKAGE " " VERSION " (monitor)", params->monitor_screen, window_init(PACKAGE " " VERSION " (monitor)", params->monitor_screen,
params->windowed, window_output, key_callback); params->windowed, window_output, key_callback);
window_use(window_monitor, &context); window_use(window_monitor, context);
shaders_init(&program, &project, &context, window_output != NULL); shaders_init(&program, &project, context, window_output != NULL);
} else { } else {
window_monitor = NULL; window_monitor = NULL;
} }
#ifdef VIDEO_IN #ifdef VIDEO_IN
if (params->output && params->monitor) { shaders_link_inputs(&program, &project, &context->inputs);
window_use(window_output, &context);
}
shaders_link_inputs(&program, &project, &video_captures,
init_params.video_buffers);
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
if (program.error) { if (program.error) {
context.stop = true; context->stop = true;
window_terminate(); window_terminate();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -348,10 +273,10 @@ static bool loop() {
#ifdef VIDEO_IN #ifdef VIDEO_IN
if (init_params.video_reconnect) { if (init_params.video_reconnect) {
for (unsigned int i = 0; i < video_captures.length; i++) { for (unsigned int i = 0; i < context->inputs.length; i++) {
if (video_captures.values[i].needs_reload) { if (context->inputs.values[i].needs_reload) {
shaders_relink_input(&program, &project, &video_captures, i); shaders_relink_input(&program, &project, &context->inputs, i);
video_captures.values[i].needs_reload = false; context->inputs.values[i].needs_reload = false;
} }
} }
} }
@@ -359,21 +284,21 @@ static bool loop() {
compute_fps(); compute_fps();
context.time = window_get_time(); context->time = window_get_time();
context.tempo_total = (float)tempo_total(&context.tempo); context->tempo_total = (float)tempo_total(&context->tempo);
if (window_output != NULL) { if (window_output != NULL) {
window_use(window_output, &context); window_use(window_output, context);
shaders_compute(&program, &context, false, false); shaders_compute(&program, context, false, false);
window_refresh(window_output); window_refresh(window_output);
} }
if (window_monitor != NULL) { if (window_monitor != NULL) {
window_use(window_monitor, &context); window_use(window_monitor, context);
shaders_compute(&program, &context, true, window_output != NULL); shaders_compute(&program, context, true, window_output != NULL);
window_refresh(window_monitor); window_refresh(window_monitor);
} }
@@ -384,31 +309,31 @@ static bool loop() {
} }
static void shutdown() { static void shutdown() {
context.stop = true; context->stop = true;
if (init_params.save_state) { if (init_params.save_state) {
state_save(&context, project.state_config); state_save(context, &project.state_config);
} }
shaders_free(&program);
if (window_output != NULL) { if (window_output != NULL) {
window_use(window_output, &context); window_use(window_output, context);
shaders_free_window(&program, false); shaders_free_window(&program, false);
} }
if (window_monitor != NULL) { if (window_monitor != NULL) {
window_use(window_monitor, &context); window_use(window_monitor, context);
shaders_free_window(&program, init_params.output); shaders_free_window(&program, init_params.output);
} }
shaders_free(&program);
#ifdef VIDEO_IN #ifdef VIDEO_IN
free_video_captures(); free_video_captures();
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
midi_close(&midi); free_context();
project_free(&project); project_free(&project);
+29 -60
View File
@@ -1,40 +1,26 @@
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <log.h> #include <log.h>
#include <pthread.h> #include <stdlib.h>
#include "types.h" #include "types.h"
#include "config.h" #include "config.h"
void snd_no_log(__attribute__((unused)) int prio, void midi_open(MidiDevice *device, const char *name) {
__attribute__((unused)) int interface,
__attribute__((unused)) const char *file,
__attribute__((unused)) int line,
__attribute__((unused)) const char *function,
__attribute__((unused)) int errcode,
__attribute__((unused)) const char *fmt,
__attribute__((unused)) va_list arg) {}
void midi_open(MidiDevice *device, const char *name, bool log_error) {
strlcpy(device->name, name, STR_LEN); strlcpy(device->name, name, STR_LEN);
device->connected = false;
device->input = NULL; device->input = NULL;
device->output = NULL; device->output = NULL;
device->connected = snd_rawmidi_open(&device->input, &device->output, name, snd_rawmidi_open(&device->input, &device->output, name, SND_RAWMIDI_NONBLOCK);
SND_RAWMIDI_SYNC) == 0 &&
device->input != NULL && device->output != NULL; device->error = device->input == NULL || device->output == NULL;
if (log_error) {
if (device->connected) { log_info("(%s) MIDI open", name);
log_info("(%s) MIDI open", name);
} else {
log_warn("(%s) MIDI open failed", name);
}
}
} }
void midi_write(MidiDevice device, unsigned char code, unsigned char value) { void midi_write(const MidiDevice *device, unsigned char code,
if (!device.connected) { unsigned char value) {
if (device->error) {
return; return;
} }
@@ -44,52 +30,35 @@ void midi_write(MidiDevice device, unsigned char code, unsigned char value) {
buffer[1] = code; buffer[1] = code;
buffer[2] = value; buffer[2] = value;
snd_rawmidi_write(device.output, buffer, 3); snd_rawmidi_write(device->output, buffer, 3);
} }
void midi_close(MidiDevice *device) { bool midi_background_listen(const MidiDevice *device,
if (device->connected) { const SharedContext *context,
snd_rawmidi_close(device->input); void (*event_callback)(unsigned char code,
snd_rawmidi_close(device->output); unsigned char value)) {
device->connected = false; pid_t pid;
}
}
void *midi_background_listen(void *args) {
MidiBackgroundListenArgs *process_args = (MidiBackgroundListenArgs *)args;
MidiDevice *device = process_args->device;
Context *context = process_args->context;
int bytes_read; int bytes_read;
snd_rawmidi_info_t *info;
unsigned char buffer[3]; unsigned char buffer[3];
log_info("(%s) background acquisition started", device->name); pid = fork();
if (pid < 0) {
snd_rawmidi_info_malloc(&info); log_error("Could not create subprocess");
return false;
if (info == NULL) {
log_error("(%s) failed to allocate MIDI info", device->name);
free(process_args);
pthread_exit(NULL);
} }
if (pid == 0) {
return true;
}
log_info("(%s) background acquisition started (pid: %d)", device->name, pid);
while (!context->stop && snd_rawmidi_info(device->output, info) == 0) { while (!context->stop) {
bytes_read = snd_rawmidi_read(device->input, buffer, 3); bytes_read = snd_rawmidi_read(device->input, buffer, 3);
if (bytes_read == 3) { if (bytes_read == 3) {
process_args->event_callback(buffer[1], buffer[2]); event_callback(buffer[1], buffer[2]);
} }
} }
snd_rawmidi_info_free(info); log_info("(%s) background acquisition stopped by main thread (pid: %d)",
device->name, pid);
if (context->stop) { exit(EXIT_SUCCESS);
log_info("(%s) background acquisition stopped by main thread",
device->name);
} else {
log_info("(%s) background acquisition stopped after error", device->name);
midi_close(device);
}
free(process_args);
pthread_exit(NULL);
} }
+7 -4
View File
@@ -3,9 +3,12 @@
#ifndef MIDI_H #ifndef MIDI_H
#define MIDI_H #define MIDI_H
void midi_open(MidiDevice *device, const char *name, bool log_error); void midi_open(MidiDevice *device, const char *name);
void midi_write(MidiDevice device, unsigned char code, unsigned char value); void midi_write(const MidiDevice *device, unsigned char code,
void *midi_background_listen(void *args); unsigned char value);
void midi_close(MidiDevice *device); bool midi_background_listen(const MidiDevice *device,
const SharedContext *context,
void (*event_callback)(unsigned char code,
unsigned char value));
#endif /* MIDI_H */ #endif /* MIDI_H */
+1 -10
View File
@@ -48,8 +48,6 @@ static bool parse_fragment_shader_file(Project *project, unsigned int i) {
include_end - project->fragment_shaders[i][0].content, include_end - project->fragment_shaders[i][0].content,
tmp_file.content); tmp_file.content);
free(project->fragment_shaders[i][0].content);
project->fragment_shaders[i][0].content = new_content; project->fragment_shaders[i][0].content = new_content;
file_free(&tmp_file); file_free(&tmp_file);
@@ -104,12 +102,6 @@ void project_init(Project *project, const char *project_path,
project->sub_counts.length = project->frag_count; project->sub_counts.length = project->frag_count;
for (unsigned int i = 0; i < project->frag_count; i++) {
for (unsigned int j = 0; j < MAX_SUB_FILE + 1; j++) {
project->fragment_shaders[i][j].content = NULL;
}
}
for (unsigned int i = 0; i < project->frag_count; i++) { for (unsigned int i = 0; i < project->frag_count; i++) {
project->sub_counts.values[i] = 0; project->sub_counts.values[i] = 0;
if (!read_fragment_shader_file(project, frag_prefix, i)) { if (!read_fragment_shader_file(project, frag_prefix, i)) {
@@ -142,10 +134,9 @@ void project_reload(Project *project, void (*reload_callback)(unsigned int)) {
} }
} }
void project_free(Project *project) { void project_free(const Project *project) {
for (unsigned int i = 0; i < project->frag_count; i++) { for (unsigned int i = 0; i < project->frag_count; i++) {
file_free(&project->fragment_shaders[i][0]); file_free(&project->fragment_shaders[i][0]);
// other sub files contents are freed at parse_fragment_shader_file
} }
config_file_free(&project->config); config_file_free(&project->config);
+1 -1
View File
@@ -8,6 +8,6 @@ void project_init(Project *project, const char *project_path,
void project_reload(Project *project, void (*reload_callback)(unsigned int)); void project_reload(Project *project, void (*reload_callback)(unsigned int));
void project_free(Project *project); void project_free(const Project *project);
#endif /* PROJECT_H */ #endif /* PROJECT_H */
+3 -3
View File
@@ -4,7 +4,7 @@ static unsigned long long mcg_state = 0xcafef00dd15ea5e5u; // Must be odd
static unsigned long long const multiplier = 6364136223846793005u; static unsigned long long const multiplier = 6364136223846793005u;
// https://en.wikipedia.org/wiki/Permuted_congruential_generator // https://en.wikipedia.org/wiki/Permuted_congruential_generator
static unsigned long fast_rand(void) { static unsigned long rand(void) {
unsigned long long x = mcg_state; unsigned long long x = mcg_state;
unsigned count = (unsigned)(x >> 61); unsigned count = (unsigned)(x >> 61);
@@ -15,9 +15,9 @@ static unsigned long fast_rand(void) {
void rand_set_seed(unsigned long long seed) { void rand_set_seed(unsigned long long seed) {
mcg_state = 2 * seed + 1; mcg_state = 2 * seed + 1;
(void)fast_rand(); (void)rand();
} }
unsigned int rand_uint(const unsigned int max) { unsigned int rand_uint(const unsigned int max) {
return max == 0 ? 0 : (unsigned int)(fast_rand() % max); return max == 0 ? 0 : (unsigned int)(rand() % max);
} }
+103 -191
View File
@@ -24,9 +24,9 @@
#include <GLFW/glfw3native.h> #include <GLFW/glfw3native.h>
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
static const GLint UNUSED_UNIFORM = -1; static const GLuint unused_uniform = (GLuint)-1;
static bool check_glerror_ro(const char *context) { bool check_glerror_ro(const char *context) {
unsigned int code; unsigned int code;
code = glGetError(); code = glGetError();
@@ -39,7 +39,7 @@ static bool check_glerror_ro(const char *context) {
return false; return false;
} }
static bool check_glerror(ShaderProgram *program, const char *context) { bool check_glerror(ShaderProgram *program, const char *context) {
if (check_glerror_ro(context)) { if (check_glerror_ro(context)) {
program->error = true; program->error = true;
return true; return true;
@@ -47,26 +47,13 @@ static bool check_glerror(ShaderProgram *program, const char *context) {
return false; return false;
} }
#ifdef GL_DEBUG bool check_eglerror_ro(const char *context) {
static void gl_debug_callback(GLenum source, GLenum type, GLuint id,
GLenum severity,
__attribute__((unused)) GLsizei length,
const GLchar *message,
__attribute__((unused)) const void *userParam) {
log_debug("GL Debug: source=%x, type=%x, id=%d, severity=%x, message=%s",
source, type, id, severity, message ? message : "(null)");
}
#endif /* GL_DEBUG */
static bool check_eglerror_ro(const char *context) {
#ifdef VIDEO_IN #ifdef VIDEO_IN
unsigned int code; unsigned int code;
code = eglGetError(); code = eglGetError();
if (code != EGL_SUCCESS) { if (code > 0 && code != EGL_SUCCESS) {
log_warn("EGL Error: %04x (%s)", code, context); log_warn("EGL Error: %04x (%s)", code, context);
return true; return true;
} }
@@ -74,7 +61,7 @@ static bool check_eglerror_ro(const char *context) {
return false; return false;
} }
static bool check_eglerror(ShaderProgram *program, const char *context) { bool check_eglerror(ShaderProgram *program, const char *context) {
if (check_eglerror_ro(context)) { if (check_eglerror_ro(context)) {
program->error = true; program->error = true;
return true; return true;
@@ -82,29 +69,9 @@ static bool check_eglerror(ShaderProgram *program, const char *context) {
return false; return false;
} }
#ifdef VIDEO_IN
#ifdef EGL_DEBUG
static void egl_debug_callback(EGLenum error, const char *command,
EGLint messageType, EGLLabelKHR threadLabel,
EGLLabelKHR objectLabel, const char *message) {
log_debug("EGL Debug: error=%04x, command=%s, type=%d, "
"thread=%p, object=%p, message=%s",
error, command ? command : "(null)", messageType, threadLabel,
objectLabel, message ? message : "(null)");
}
#endif /* EGL_DEBUG */
#endif /* VIDEO_IN */
static bool init_gl(ShaderProgram *program) { static bool init_gl(ShaderProgram *program) {
gladLoadGL(glfwGetProcAddress); gladLoadGL(glfwGetProcAddress);
#ifdef GL_DEBUG
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(gl_debug_callback, NULL);
#endif /* GL_DEBUG */
#ifdef VIDEO_IN #ifdef VIDEO_IN
program->egl_display = glfwGetEGLDisplay(); program->egl_display = glfwGetEGLDisplay();
if (program->egl_display == EGL_NO_DISPLAY) { if (program->egl_display == EGL_NO_DISPLAY) {
@@ -114,27 +81,14 @@ static bool init_gl(ShaderProgram *program) {
} }
gladLoadEGL(program->egl_display, glfwGetProcAddress); gladLoadEGL(program->egl_display, glfwGetProcAddress);
#ifdef EGL_DEBUG
{
PFNEGLDEBUGMESSAGECONTROLKHRPROC debug_ctrl =
(PFNEGLDEBUGMESSAGECONTROLKHRPROC)glfwGetProcAddress(
"eglDebugMessageControlKHR");
if (debug_ctrl != NULL) {
const EGLAttrib attrib_list[] = {EGL_NONE};
debug_ctrl(egl_debug_callback, attrib_list);
}
}
#endif /* EGL_DEBUG */
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
return !check_glerror(program, "init_gl") && return !check_glerror(program, "init_gl") &&
!check_eglerror(program, "init_gl"); !check_eglerror(program, "init_gl");
} }
static bool init_textures(ShaderProgram *program, const Context *context) { static bool init_textures(ShaderProgram *program,
const SharedContext *context) {
glGenTextures(program->tex_count, program->textures); glGenTextures(program->tex_count, program->textures);
if (check_glerror(program, "init_textures/glGenTextures")) { if (check_glerror(program, "init_textures/glGenTextures")) {
return false; return false;
@@ -191,20 +145,18 @@ static void rebind_textures(const ShaderProgram *program) {
#ifdef VIDEO_IN #ifdef VIDEO_IN
static bool link_input_to_texture(ShaderProgram *program, VideoCapture *input, static bool link_input_to_texture(ShaderProgram *program, VideoCapture *input,
unsigned int input_index, unsigned int input_index,
unsigned int sub_index, bool reload) { unsigned int texture_index, bool swap,
unsigned int texture_index = bool reload) {
program->tex_count + input_index * program->sub_video_count + sub_index;
if (reload) { if (reload) {
glDeleteTextures(1, program->textures + texture_index); glDeleteTextures(1, program->textures + texture_index);
if (check_glerror(program, "link_input_to_texture/glDeleteTextures")) { if (check_glerror(program, "link_input_to_texture/glDeleteTextures")) {
return false; return false;
} }
}
glGenTextures(1, program->textures + texture_index); glGenTextures(1, program->textures + texture_index);
if (check_glerror(program, "link_input_to_texture/glGenTextures")) { if (check_glerror(program, "link_input_to_texture/glGenTextures")) {
return false; return false;
}
} }
EGLImageKHR dma_image; EGLImageKHR dma_image;
@@ -219,7 +171,7 @@ static bool link_input_to_texture(ShaderProgram *program, VideoCapture *input,
EGL_LINUX_DRM_FOURCC_EXT, EGL_LINUX_DRM_FOURCC_EXT,
input->pixelformat, input->pixelformat,
EGL_DMA_BUF_PLANE0_FD_EXT, EGL_DMA_BUF_PLANE0_FD_EXT,
input->exp_fd[sub_index], swap ? input->exp_fd_swap : input->exp_fd,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGL_DMA_BUF_PLANE0_OFFSET_EXT,
0, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, EGL_DMA_BUF_PLANE0_PITCH_EXT,
@@ -232,8 +184,11 @@ static bool link_input_to_texture(ShaderProgram *program, VideoCapture *input,
return false; return false;
} }
program->dma_images[input_index * program->sub_video_count + sub_index] = if (swap) {
dma_image; program->dma_images_swap[input_index] = dma_image;
} else {
program->dma_images[input_index] = dma_image;
}
glActiveTexture(GL_TEXTURE0 + texture_index); glActiveTexture(GL_TEXTURE0 + texture_index);
if (check_glerror(program, "link_input_to_texture/glActiveTexture")) { if (check_glerror(program, "link_input_to_texture/glActiveTexture")) {
@@ -245,6 +200,12 @@ static bool link_input_to_texture(ShaderProgram *program, VideoCapture *input,
return false; return false;
} }
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, input->width, input->height, 0, GL_RGB,
GL_UNSIGNED_BYTE, 0);
if (check_glerror(program, "link_input_to_texture/glTexImage2D")) {
return false;
}
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_EGL_image_storage.txt // https://registry.khronos.org/OpenGL/extensions/EXT/EXT_EGL_image_storage.txt
glEGLImageTargetTexStorageEXT(GL_TEXTURE_2D, dma_image, NULL); glEGLImageTargetTexStorageEXT(GL_TEXTURE_2D, dma_image, NULL);
if (check_eglerror(program, if (check_eglerror(program,
@@ -252,35 +213,33 @@ static bool link_input_to_texture(ShaderProgram *program, VideoCapture *input,
return false; return false;
} }
log_info("Texture %d linked to %s[%d]", texture_index, input->name, log_info("Texture %d linked to %s", texture_index, input->name);
sub_index);
return true; return true;
} }
static bool init_input(ShaderProgram *program, const ConfigFile *config, static bool init_input(ShaderProgram *program, const ConfigFile *config,
VideoCaptureArray *inputs, unsigned int input_index, VideoCaptureArray *inputs, unsigned int i, bool reload) {
bool reload) {
unsigned int tex_i; unsigned int tex_i;
unsigned int sub_index;
char name[STR_LEN]; char name[STR_LEN];
if (input_index < inputs->length && input_index < program->in_count && if (i < inputs->length && !inputs->values[i].error) {
!inputs->values[input_index].error) { snprintf(name, STR_LEN, "IN_%d_OUT", i + 1);
snprintf(name, STR_LEN, "IN_%d_OUT", input_index + 1);
tex_i = config_file_get_int(config, name, 0); tex_i = config_file_get_int(config, name, 0);
for (sub_index = 0; sub_index < inputs->values[input_index].buf_count; if (!link_input_to_texture(program, &inputs->values[i], i, tex_i, false,
sub_index++) { reload)) {
if (!link_input_to_texture(program, &inputs->values[input_index], return false;
input_index, sub_index, reload)) { }
if (inputs->values[i].with_swap) {
snprintf(name, STR_LEN, "IN_%d_SWAP_OUT", i + 1);
tex_i = config_file_get_int(config, name, 0);
if (!link_input_to_texture(program, &inputs->values[i], i, tex_i, true,
reload)) {
return false; return false;
} }
} }
program->input_tex_map[input_index] = tex_i;
program->tex_map[tex_i] =
program->tex_count + input_index * program->sub_video_count;
} else { } else {
log_warn("Cannot link input %d", input_index + 1); log_warn("Cannot link input %d", i + 1);
} }
return true; return true;
} }
@@ -405,7 +364,7 @@ static bool compile_shader(GLuint shader_id, const char *name,
glGetShaderiv(shader_id, GL_COMPILE_STATUS, &status_params); glGetShaderiv(shader_id, GL_COMPILE_STATUS, &status_params);
check_glerror_ro("compile_shader/glGetShaderiv"); check_glerror_ro("compile_shader/glGetShaderiv");
glGetShaderInfoLog(shader_id, STR_LEN, NULL, (GLchar *)log); glGetShaderInfoLog(shader_id, 1024, NULL, (GLchar *)&log);
check_glerror_ro("compile_shader/glGetShaderInfoLog"); check_glerror_ro("compile_shader/glGetShaderInfoLog");
if (status_params == GL_FALSE) { if (status_params == GL_FALSE) {
@@ -456,8 +415,6 @@ static bool init_single_program(ShaderProgram *program, unsigned int i,
unsigned int index2; unsigned int index2;
char name[STR_LEN]; char name[STR_LEN];
const char *prefix; const char *prefix;
GLint link_status;
char link_log[STR_LEN];
program->programs[i] = glCreateProgram(); program->programs[i] = glCreateProgram();
if (check_glerror(program, "init_single_program/glCreateProgram")) { if (check_glerror(program, "init_single_program/glCreateProgram")) {
@@ -475,19 +432,6 @@ static bool init_single_program(ShaderProgram *program, unsigned int i,
return false; return false;
} }
glGetProgramiv(program->programs[i], GL_LINK_STATUS, &link_status);
if (check_glerror(program, "init_single_program/glGetProgramiv")) {
return false;
}
if (link_status != GL_TRUE) {
glGetProgramInfoLog(program->programs[i], STR_LEN, NULL, link_log);
if (check_glerror(program, "init_single_program/glGetProgramInfoLog")) {
return false;
}
log_error("Program %d link error: %s", i + 1, link_log);
return false;
}
// create uniforms pointers // create uniforms pointers
program->itime_locations[i] = glGetUniformLocation( program->itime_locations[i] = glGetUniformLocation(
program->programs[i], program->programs[i],
@@ -545,6 +489,13 @@ static bool init_single_program(ShaderProgram *program, unsigned int i,
glGetUniformLocation(program->programs[i], name); glGetUniformLocation(program->programs[i], name);
} }
prefix = config_file_get_str(config, "UNIFORM_IN_SWAP_PREFIX", "iInputSwap");
for (unsigned int j = 0; j < program->in_count; j++) {
snprintf(name, STR_LEN, "%s%d", prefix, j + 1);
program->iinswap_locations[i * program->in_count + j] =
glGetUniformLocation(program->programs[i], name);
}
prefix = config_file_get_str(config, "UNIFORM_SEED_PREFIX", "iSeed"); prefix = config_file_get_str(config, "UNIFORM_SEED_PREFIX", "iSeed");
for (unsigned int j = 0; j < program->frag_count; j++) { for (unsigned int j = 0; j < program->frag_count; j++) {
snprintf(name, STR_LEN, "%s%d", prefix, j + 1); snprintf(name, STR_LEN, "%s%d", prefix, j + 1);
@@ -568,24 +519,23 @@ static bool init_single_program(ShaderProgram *program, unsigned int i,
if (program->midi_lengths.length == 0) { if (program->midi_lengths.length == 0) {
index1 = 0; index1 = 0;
for (unsigned int j = 0; j < state_config->group_active_counts.length; for (unsigned int j = 0; j < state_config->midi_active_counts.length; j++) {
j++) { for (unsigned int k = 0; k < state_config->midi_active_counts.values[j];
for (unsigned int k = 0; k < state_config->group_active_counts.values[j];
k++) { k++) {
program->midi_lengths.values[index1++] = program->midi_lengths.values[index1++] =
state_config->group_counts.values[j]; state_config->midi_counts.values[j];
} }
} }
program->midi_lengths.length = index1; program->midi_lengths.length = index1;
} }
prefix = config_file_get_str(config, "UNIFORM_GROUP_PREFIX", "iGroup"); prefix = config_file_get_str(config, "UNIFORM_MIDI_PREFIX", "iMidi");
index2 = 0; index2 = 0;
for (unsigned int j = 0; j < state_config->group_active_counts.length; j++) { for (unsigned int j = 0; j < state_config->midi_active_counts.length; j++) {
for (unsigned int k = 0; k < state_config->group_active_counts.values[j]; for (unsigned int k = 0; k < state_config->midi_active_counts.values[j];
k++) { k++) {
snprintf(name, STR_LEN, "%s%d_%d", prefix, j + 1, k + 1); snprintf(name, STR_LEN, "%s%d_%d", prefix, j + 1, k + 1);
program->igroup_locations[i * program->midi_lengths.length + index2++] = program->imidi_locations[i * program->midi_lengths.length + index2++] =
glGetUniformLocation(program->programs[i], name); glGetUniformLocation(program->programs[i], name);
} }
} }
@@ -642,7 +592,8 @@ static bool init_programs(ShaderProgram *program, const ConfigFile *config,
return true; return true;
} }
static void update_viewport(ShaderProgram *program, const Context *context) { static void update_viewport(ShaderProgram *program,
const SharedContext *context) {
// viewport changed // viewport changed
if (context->resolution[0] != program->last_resolution[0] || if (context->resolution[0] != program->last_resolution[0] ||
context->resolution[1] != program->last_resolution[1]) { context->resolution[1] != program->last_resolution[1]) {
@@ -653,40 +604,41 @@ static void update_viewport(ShaderProgram *program, const Context *context) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, context->tex_resolution[0], glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, context->tex_resolution[0],
context->tex_resolution[1], 0, GL_RGB, GL_UNSIGNED_BYTE, 0); context->tex_resolution[1], 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
check_glerror_ro("update_viewport/glTexImage2D"); check_glerror_ro(
"update_viewport/glTexImage2D"); // TODO dont remap input textures
} }
program->last_resolution[0] = context->resolution[0]; program->last_resolution[0] = context->resolution[0];
program->last_resolution[1] = context->resolution[1]; program->last_resolution[1] = context->resolution[1];
} }
} }
static void write_uniform_1f(GLint location, float value) { static void write_uniform_1f(GLuint location, float value) {
if (location != UNUSED_UNIFORM) { if (location != unused_uniform) {
glUniform1f(location, value); glUniform1f(location, value);
} }
} }
static void write_uniform_1i(GLint location, unsigned int value) { static void write_uniform_1i(GLuint location, unsigned int value) {
if (location != UNUSED_UNIFORM) { if (location != unused_uniform) {
glUniform1i(location, (const GLint)value); glUniform1i(location, (const GLint)value);
} }
} }
static void write_uniform_2f(GLint location, const vec2 *value) { static void write_uniform_2f(GLuint location, const vec2 *value) {
if (location != UNUSED_UNIFORM) { if (location != unused_uniform) {
glUniform2fv(location, 1, (const GLfloat *)value); glUniform2fv(location, 1, (const GLfloat *)value);
} }
} }
static void write_uniform_multi_3f(GLint location, unsigned int count, static void write_uniform_multi_3f(GLuint location, unsigned int count,
const vec3 *value) { const vec3 *value) {
if (location != UNUSED_UNIFORM) { if (location != unused_uniform) {
glUniform3fv(location, count, (const GLfloat *)value); glUniform3fv(location, count, (const GLfloat *)value);
} }
} }
static void use_program(const ShaderProgram *program, int i, bool output, static void use_program(const ShaderProgram *program, int i, bool output,
const Context *context) { const SharedContext *context) {
unsigned int k; unsigned int k;
unsigned int offset; unsigned int offset;
unsigned int subcount; unsigned int subcount;
@@ -729,19 +681,17 @@ static void use_program(const ShaderProgram *program, int i, bool output,
context->active[j] + 1); context->active[j] + 1);
} }
#ifdef VIDEO_IN
for (unsigned int j = 0; j < program->in_count; j++) { for (unsigned int j = 0; j < program->in_count; j++) {
write_uniform_2f(program->iinres_locations[i * program->in_count + j], write_uniform_2f(program->iinres_locations[i * program->in_count + j],
&context->input_resolutions[j]); &context->input_resolutions[j]);
write_uniform_1i(program->iinfmt_locations[i * program->in_count + j], write_uniform_1i(program->iinfmt_locations[i * program->in_count + j],
context->input_formats[j]); context->inputs.values[j].pixelformat);
write_uniform_1i(program->iinfps_locations[i * program->in_count + j], write_uniform_1i(program->iinfps_locations[i * program->in_count + j],
context->input_fps[j]); context->inputs.values[j].fps);
write_uniform_1i(program->iinswap_locations[i * program->in_count + j],
context->inputs.values[j].swap ? 1 : 0);
} }
#endif /* VIDEO_IN */
// set seeds uniforms // set seeds uniforms
for (unsigned int j = 0; j < program->frag_count; j++) { for (unsigned int j = 0; j < program->frag_count; j++) {
write_uniform_1i(program->iseed_locations[i * program->frag_count + j], write_uniform_1i(program->iseed_locations[i * program->frag_count + j],
@@ -756,7 +706,7 @@ static void use_program(const ShaderProgram *program, int i, bool output,
offset = 0; offset = 0;
for (unsigned int j = 0; j < program->midi_lengths.length; j++) { for (unsigned int j = 0; j < program->midi_lengths.length; j++) {
write_uniform_multi_3f( write_uniform_multi_3f(
program->igroup_locations[i * program->midi_lengths.length + j], program->imidi_locations[i * program->midi_lengths.length + j],
program->midi_lengths.values[j], context->values + offset); program->midi_lengths.values[j], context->values + offset);
offset += program->midi_lengths.values[j]; offset += program->midi_lengths.values[j];
} }
@@ -768,7 +718,7 @@ static void use_program(const ShaderProgram *program, int i, bool output,
if (program->sub_locations[i * program->sub_variant_count * if (program->sub_locations[i * program->sub_variant_count *
program->sub_type_count + program->sub_type_count +
j * program->sub_variant_count + k] != j * program->sub_variant_count + k] !=
UNUSED_UNIFORM) { unused_uniform) {
subroutines[subcount++] = subroutines[subcount++] =
program->sub_locations[i * program->sub_variant_count * program->sub_locations[i * program->sub_variant_count *
program->sub_type_count + program->sub_type_count +
@@ -783,7 +733,7 @@ static void use_program(const ShaderProgram *program, int i, bool output,
// set GL_TEXTURE(X) to uniform sampler2D texX // set GL_TEXTURE(X) to uniform sampler2D texX
for (unsigned int j = 0; j < program->tex_count; j++) { for (unsigned int j = 0; j < program->tex_count; j++) {
write_uniform_1i(program->textures_locations[i * program->tex_count + j], write_uniform_1i(program->textures_locations[i * program->tex_count + j],
program->tex_map[j]); j);
} }
// draw output // draw output
@@ -791,17 +741,12 @@ static void use_program(const ShaderProgram *program, int i, bool output,
} }
void shaders_init(ShaderProgram *program, const Project *project, void shaders_init(ShaderProgram *program, const Project *project,
const Context *context, bool rebind) { const SharedContext *context, bool rebind) {
unsigned int i;
if (!rebind) { if (!rebind) {
program->error = false; program->error = false;
program->last_resolution[0] = context->resolution[0]; program->last_resolution[0] = context->resolution[0];
program->last_resolution[1] = context->resolution[1]; program->last_resolution[1] = context->resolution[1];
program->tex_count = config_file_get_int(&project->config, "TEX_COUNT", 9); program->tex_count = config_file_get_int(&project->config, "TEX_COUNT", 9);
memset(program->tex_map, 0, sizeof(program->tex_map));
for (i = 0; i < program->tex_count; i++) {
program->tex_map[i] = i;
}
program->frag_count = project->frag_count; program->frag_count = project->frag_count;
program->frag_output_index = program->frag_output_index =
config_file_get_int(&project->config, "FRAG_OUTPUT", 1) - 1; config_file_get_int(&project->config, "FRAG_OUTPUT", 1) - 1;
@@ -811,12 +756,12 @@ void shaders_init(ShaderProgram *program, const Project *project,
config_file_get_int(&project->config, "SUB_TYPE_COUNT", 0); config_file_get_int(&project->config, "SUB_TYPE_COUNT", 0);
program->in_count = config_file_get_int(&project->config, "IN_COUNT", 0); program->in_count = config_file_get_int(&project->config, "IN_COUNT", 0);
program->sub_variant_count = project->state_config.state_max; program->sub_variant_count = project->state_config.state_max;
program->active_count = project->state_config.group_active_counts.length; program->active_count = project->state_config.midi_active_counts.length;
program->midi_lengths.length = 0; program->midi_lengths.length = 0;
#ifdef VIDEO_IN #ifdef VIDEO_IN
memset(program->dma_images, 0, sizeof(program->dma_images)); memset(program->dma_images, 0, sizeof(program->dma_images));
memset(program->input_tex_map, 0, sizeof(program->input_tex_map)); memset(program->dma_images_swap, 0, sizeof(program->dma_images_swap));
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
if (!init_gl(program)) { if (!init_gl(program)) {
@@ -849,54 +794,22 @@ void shaders_init(ShaderProgram *program, const Project *project,
} }
} }
#ifdef VIDEO_IN
void shaders_relink_input(ShaderProgram *program, const Project *project, void shaders_relink_input(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs, unsigned int input_index) { VideoCaptureArray *inputs, unsigned int i) {
shaders_free_input(program, input_index); #ifdef VIDEO_IN
init_input(program, &project->config, inputs, input_index, true); // shaders_free_input(program, i);
init_input(program, &project->config, inputs, i, true);
#endif /* VIDEO_IN */
} }
void shaders_link_inputs(ShaderProgram *program, const Project *project, void shaders_link_inputs(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs, unsigned int buffer_count) { VideoCaptureArray *inputs) {
unsigned int i; #ifdef VIDEO_IN
program->sub_video_count = buffer_count; for (unsigned int i = 0; i < program->in_count; i++) {
for (i = 0; i < program->in_count; i++) {
init_input(program, &project->config, inputs, i, false); init_input(program, &project->config, inputs, i, false);
} }
}
void shaders_free_input(ShaderProgram *program, unsigned int input_index) {
unsigned int sub_index;
for (sub_index = 0; sub_index < program->sub_video_count; sub_index++) {
if (program->dma_images[input_index * program->sub_video_count +
sub_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(
program->egl_display,
program
->dma_images[input_index * program->sub_video_count + sub_index]);
program->dma_images[input_index * program->sub_video_count + sub_index] =
EGL_NO_IMAGE_KHR;
}
}
check_eglerror_ro("shaders_free_input/eglDestroyImageKHR");
}
static void update_inputs_tex_map(ShaderProgram *program,
const Context *context) {
unsigned int i;
unsigned int tex_i;
for (i = 0; i < program->in_count; i++) {
if (context->input_formats[i] != 0) {
tex_i = program->input_tex_map[i];
program->tex_map[tex_i] = program->tex_count +
i * program->sub_video_count +
context->input_index[i];
}
}
}
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
}
void shaders_update(ShaderProgram *program, const File *fragment_shader, void shaders_update(ShaderProgram *program, const File *fragment_shader,
unsigned int i, const Project *project) { unsigned int i, const Project *project) {
@@ -908,12 +821,8 @@ void shaders_update(ShaderProgram *program, const File *fragment_shader,
} }
} }
void shaders_compute(ShaderProgram *program, const Context *context, void shaders_compute(ShaderProgram *program, const SharedContext *context,
bool monitor, bool output_only) { bool monitor, bool output_only) {
#ifdef VIDEO_IN
update_inputs_tex_map(program, context);
#endif /* VIDEO_IN */
if (!output_only) { if (!output_only) {
glBindVertexArray(program->vertex_array[0]); glBindVertexArray(program->vertex_array[0]);
@@ -944,24 +853,12 @@ void shaders_free(const ShaderProgram *program) {
} }
check_glerror_ro("shaders_free/glDeleteProgram"); check_glerror_ro("shaders_free/glDeleteProgram");
glDeleteShader(program->vertex_shader);
for (unsigned int i = 0; i < program->frag_count; i++) {
glDeleteShader(program->fragment_shaders[i]);
}
check_glerror_ro("shaders_free/glDeleteShader");
glDeleteFramebuffers(program->frag_count, program->frame_buffers); glDeleteFramebuffers(program->frag_count, program->frame_buffers);
check_glerror_ro("shaders_free/glDeleteFramebuffers"); check_glerror_ro("shaders_free/glDeleteFramebuffers");
glDeleteTextures(program->tex_count, program->textures); glDeleteTextures(program->tex_count, program->textures);
check_glerror_ro("shaders_free/glDeleteTextures"); check_glerror_ro("shaders_free/glDeleteTextures");
#ifdef VIDEO_IN
glDeleteTextures(program->in_count * program->sub_video_count,
program->textures + program->tex_count);
check_glerror_ro("shaders_free/glDeleteTextures");
#endif
glDeleteBuffers(1, &program->vertex_buffer); glDeleteBuffers(1, &program->vertex_buffer);
check_glerror_ro("shaders_free/glDeleteBuffers"); check_glerror_ro("shaders_free/glDeleteBuffers");
} }
@@ -970,3 +867,18 @@ void shaders_free_window(const ShaderProgram *program, bool secondary) {
glDeleteVertexArrays(1, &program->vertex_array[secondary ? 1 : 0]); glDeleteVertexArrays(1, &program->vertex_array[secondary ? 1 : 0]);
check_glerror_ro("shaders_free_window/glDeleteVertexArrays"); check_glerror_ro("shaders_free_window/glDeleteVertexArrays");
} }
void shaders_free_input(ShaderProgram *program, unsigned int input_index) {
#ifdef VIDEO_IN
if (program->dma_images[input_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(program->egl_display, program->dma_images[input_index]);
program->dma_images[input_index] = EGL_NO_IMAGE_KHR;
}
if (program->dma_images_swap[input_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(program->egl_display,
program->dma_images_swap[input_index]);
program->dma_images_swap[input_index] = EGL_NO_IMAGE_KHR;
}
check_eglerror_ro("shaders_free_input/eglDestroyImageKHR");
#endif /* VIDEO_IN */
}
+5 -9
View File
@@ -4,28 +4,24 @@
#define SHADERS_H #define SHADERS_H
void shaders_init(ShaderProgram *program, const Project *project, void shaders_init(ShaderProgram *program, const Project *project,
const Context *context, bool rebind); const SharedContext *context, bool rebind);
#ifdef VIDEO_IN
void shaders_relink_input(ShaderProgram *program, const Project *project, void shaders_relink_input(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs, unsigned int i); VideoCaptureArray *inputs, unsigned int i);
void shaders_link_inputs(ShaderProgram *program, const Project *project, void shaders_link_inputs(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs, unsigned int buffer_count); VideoCaptureArray *inputs);
void shaders_free_input(ShaderProgram *program, unsigned int input_index);
#endif /* VIDEO_IN */
void shaders_update(ShaderProgram *program, const File *fragment_shader, void shaders_update(ShaderProgram *program, const File *fragment_shader,
unsigned int i, const Project *project); unsigned int i, const Project *project);
void shaders_compute(ShaderProgram *program, const Context *context, void shaders_compute(ShaderProgram *program, const SharedContext *context,
bool monitor, bool output_only); bool monitor, bool output_only);
void shaders_free(const ShaderProgram *program); void shaders_free(const ShaderProgram *program);
void shaders_free_window(const ShaderProgram *program, bool secondary); void shaders_free_window(const ShaderProgram *program, bool secondary);
void shaders_free_input(ShaderProgram *program, unsigned int input_index);
#endif /* SHADERS_H */ #endif /* SHADERS_H */
+35
View File
@@ -0,0 +1,35 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "types.h"
#include "shared.h"
static void *open_shared(const char *key, size_t size, int *fd) {
*fd = shm_open(key, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
ftruncate(*fd, size);
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
}
static void close_shared(void *shared, size_t size, int fd) {
munmap(shared, size);
close(fd);
}
SharedContext *shared_init_context(const char *key) {
int shared_fd;
SharedContext *shared;
shared = open_shared(key, sizeof(SharedContext), &shared_fd);
shared->fd = shared_fd;
return shared;
}
void shared_close_context(SharedContext *shared) {
close_shared(shared, sizeof(SharedContext), shared->fd);
}
+9
View File
@@ -0,0 +1,9 @@
#include "types.h"
#ifndef SHARED_H
#define SHARED_H
SharedContext *shared_init_context(const char *key);
void shared_close_context(SharedContext *shared);
#endif /* SHARED_H */
+272 -418
View File
File diff suppressed because it is too large Load Diff
+10 -8
View File
@@ -5,19 +5,21 @@
void state_parse_config(StateConfig *state_config, const ConfigFile *config); void state_parse_config(StateConfig *state_config, const ConfigFile *config);
void state_midi_event(Context *context, StateConfig state_config, void state_midi_event(SharedContext *context, const StateConfig *state_config,
MidiDevice midi, unsigned char code, const MidiDevice *midi, unsigned char code,
unsigned char value, bool trace_midi); unsigned char value, bool trace_midi);
void state_key_event(Context *context, StateConfig state_config, void state_key_event(SharedContext *context, const StateConfig *state_config,
unsigned int code, MidiDevice midi); unsigned int code, const MidiDevice *midi);
void *state_background_write(void *args); bool state_background_write(SharedContext *context,
const StateConfig *state_config,
const MidiDevice *midi);
void state_init(Context *context, StateConfig state_config, bool demo, void state_init(SharedContext *context, const StateConfig *state_config,
bool auto_random, unsigned int auto_random_cycles, bool demo, bool auto_random, unsigned int auto_random_cycles,
unsigned int base_tempo, bool load_state); unsigned int base_tempo, bool load_state);
void state_save(const Context *context, StateConfig state_config); void state_save(const SharedContext *context, const StateConfig *state_config);
#endif /* STATE_H */ #endif /* STATE_H */
+1 -9
View File
@@ -15,7 +15,7 @@ unsigned int string_trim(char *str) {
start = 0; start = 0;
end = strnlen(str, STR_LEN) - 1; end = strnlen(str, STR_LEN) - 1;
if (end <= 0) { if (end == 0) {
return 0; return 0;
} }
@@ -62,19 +62,11 @@ char *string_replace_at(const char *src, unsigned int from, unsigned int to,
unsigned long rpl_len; unsigned long rpl_len;
char *dst; char *dst;
if (to < from) {
return "";
}
src_len = strnlen(src, STR_LEN * STR_LEN); src_len = strnlen(src, STR_LEN * STR_LEN);
rpl_len = strnlen(rpl, STR_LEN * STR_LEN); rpl_len = strnlen(rpl, STR_LEN * STR_LEN);
dst = malloc(src_len - (to - from) + rpl_len + 1); dst = malloc(src_len - (to - from) + rpl_len + 1);
if (dst == NULL) {
return "";
}
strlcpy(dst, src, from + 1); strlcpy(dst, src, from + 1);
strlcpy(dst + from, rpl, rpl_len + 1); strlcpy(dst + from, rpl, rpl_len + 1);
strlcpy(dst + from + rpl_len, src + to, src_len - to + 1); strlcpy(dst + from + rpl_len, src + to, src_len - to + 1);
+11 -11
View File
@@ -1,18 +1,18 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <time.h> #include <sys/time.h>
#include "types.h" #include "types.h"
#include "config.h" #include "config.h"
#include "tempo.h" #include "tempo.h"
static long now_ms() { static long now() {
struct timespec ts; struct timeval now;
if (clock_gettime(CLOCK_REALTIME, &ts) != 0) {
return 0; gettimeofday(&now, NULL);
}
return 1000 * ts.tv_sec + ts.tv_nsec / 1e6; return now.tv_sec * 1000 + now.tv_usec / 1000;
} }
static void reset_tap_chain(Tempo *tempo, long t) { static void reset_tap_chain(Tempo *tempo, long t) {
@@ -93,7 +93,7 @@ static void add_tap_to_chain(Tempo *tempo, long t) {
void tempo_init(Tempo *tempo, float value) { void tempo_init(Tempo *tempo, float value) {
long t; long t;
t = now_ms(); t = now();
reset_tap_chain(tempo, t); reset_tap_chain(tempo, t);
@@ -105,7 +105,7 @@ void tempo_set(Tempo *tempo, float value) {
long t; long t;
long progress; long progress;
t = now_ms(); t = now();
progress = (t - tempo->last_reset) % tempo->beat_length; progress = (t - tempo->last_reset) % tempo->beat_length;
@@ -118,7 +118,7 @@ void tempo_set(Tempo *tempo, float value) {
void tempo_tap(Tempo *tempo) { void tempo_tap(Tempo *tempo) {
long t; long t;
t = now_ms(); t = now();
if (!is_chain_active(*tempo, t)) { if (!is_chain_active(*tempo, t)) {
reset_tap_chain(tempo, t); reset_tap_chain(tempo, t);
@@ -130,7 +130,7 @@ void tempo_tap(Tempo *tempo) {
double tempo_total(const Tempo *tempo) { double tempo_total(const Tempo *tempo) {
long t; long t;
t = now_ms(); t = now();
return (double)(t - tempo->last_reset) / (double)tempo->beat_length; return (double)(t - tempo->last_reset) / (double)tempo->beat_length;
} }
+8 -11
View File
@@ -1,6 +1,4 @@
#include <bits/time.h> #include <sys/time.h>
#include <limits.h>
#include <time.h>
#include "types.h" #include "types.h"
@@ -9,25 +7,24 @@
void timer_init(Timer *timer, const unsigned int target) { void timer_init(Timer *timer, const unsigned int target) {
timer->counter = 0; timer->counter = 0;
timer->target = target; timer->target = target;
clock_gettime(CLOCK_REALTIME, &timer->start);
gettimeofday(&timer->start, NULL);
} }
bool timer_inc(Timer *timer) { bool timer_inc(Timer *timer) {
timer->counter += 1; timer->counter += 1;
return timer->counter == UINT_MAX || timer->counter >= timer->target; return timer->counter >= timer->target;
} }
double timer_reset(Timer *timer) { double timer_reset(Timer *timer) {
struct timespec stop; struct timeval stop;
double secs; double secs;
double per_secs; double per_secs;
if (clock_gettime(CLOCK_REALTIME, &stop) != 0) { gettimeofday(&stop, NULL);
return 0.0;
}
secs = (double)(stop.tv_sec - timer->start.tv_sec) + secs = (double)(stop.tv_usec - timer->start.tv_usec) / 1000000 +
(double)(stop.tv_nsec - timer->start.tv_nsec) / 1e9; (double)(stop.tv_sec - timer->start.tv_sec);
per_secs = (double)timer->counter / secs; per_secs = (double)timer->counter / secs;
timer->start = stop; timer->start = stop;
+82 -111
View File
@@ -45,17 +45,12 @@ typedef struct Parameters {
bool demo; bool demo;
bool auto_random; bool auto_random;
unsigned int auto_random_cycle; unsigned int auto_random_cycle;
#ifdef VIDEO_IN
StringArray video_in; StringArray video_in;
unsigned int video_buffers;
unsigned int video_size; unsigned int video_size;
bool video_reconnect;
char video_fourcc[5];
#endif /* VIDEO_IN */
unsigned int internal_size; unsigned int internal_size;
bool video_reconnect;
bool load_state; bool load_state;
bool save_state; bool save_state;
bool midi_reconnect;
bool trace_midi; bool trace_midi;
bool trace_fps; bool trace_fps;
} Parameters; } Parameters;
@@ -89,7 +84,6 @@ typedef struct ShaderProgram {
GLuint vertex_array[2]; GLuint vertex_array[2];
unsigned int tex_count; unsigned int tex_count;
unsigned int tex_map[ARRAY_SIZE];
GLuint textures[ARRAY_SIZE]; GLuint textures[ARRAY_SIZE];
unsigned int frag_count; unsigned int frag_count;
@@ -101,46 +95,74 @@ typedef struct ShaderProgram {
GLuint frame_buffers[ARRAY_SIZE]; GLuint frame_buffers[ARRAY_SIZE];
GLuint fragment_shaders[ARRAY_SIZE]; GLuint fragment_shaders[ARRAY_SIZE];
GLint itime_locations[ARRAY_SIZE]; GLuint itime_locations[ARRAY_SIZE];
GLint itempo_locations[ARRAY_SIZE]; GLuint itempo_locations[ARRAY_SIZE];
GLint ibeats_locations[ARRAY_SIZE]; GLuint ibeats_locations[ARRAY_SIZE];
GLint ifps_locations[ARRAY_SIZE]; GLuint ifps_locations[ARRAY_SIZE];
GLint ires_locations[ARRAY_SIZE]; GLuint ires_locations[ARRAY_SIZE];
GLint itexres_locations[ARRAY_SIZE]; GLuint itexres_locations[ARRAY_SIZE];
GLint iinres_locations[ARRAY_SIZE]; GLuint iinres_locations[ARRAY_SIZE];
GLint iinfmt_locations[ARRAY_SIZE]; GLuint iinfmt_locations[ARRAY_SIZE];
GLint iinfps_locations[ARRAY_SIZE]; GLuint iinfps_locations[ARRAY_SIZE];
GLint idemo_locations[ARRAY_SIZE]; GLuint iinswap_locations[ARRAY_SIZE];
GLint iautorand_locations[ARRAY_SIZE]; GLuint idemo_locations[ARRAY_SIZE];
GLint iautorandcycle_locations[ARRAY_SIZE]; GLuint iautorand_locations[ARRAY_SIZE];
GLint iseed_locations[ARRAY_SIZE]; GLuint iautorandcycle_locations[ARRAY_SIZE];
GLint istate_locations[ARRAY_SIZE]; GLuint iseed_locations[ARRAY_SIZE];
GLint ipage_locations[ARRAY_SIZE]; GLuint istate_locations[ARRAY_SIZE];
GLint iselected_locations[ARRAY_SIZE]; GLuint ipage_locations[ARRAY_SIZE];
GLint iactive_locations[ARRAY_SIZE]; GLuint iselected_locations[ARRAY_SIZE];
GLuint iactive_locations[ARRAY_SIZE];
UintArray midi_lengths; UintArray midi_lengths;
GLint igroup_locations[ARRAY_SIZE]; GLuint imidi_locations[ARRAY_SIZE];
GLint vpos_locations[ARRAY_SIZE]; GLuint vpos_locations[ARRAY_SIZE];
GLint textures_locations[ARRAY_SIZE]; GLuint textures_locations[ARRAY_SIZE];
unsigned int sub_type_count; unsigned int sub_type_count;
unsigned int sub_variant_count; unsigned int sub_variant_count;
GLint sub_locations[ARRAY_SIZE]; GLuint sub_locations[ARRAY_SIZE];
unsigned int active_count; unsigned int active_count;
unsigned int in_count; unsigned int in_count;
#ifdef VIDEO_IN #ifdef VIDEO_IN
unsigned int sub_video_count;
unsigned int input_tex_map[MAX_VIDEO];
EGLDisplay egl_display; EGLDisplay egl_display;
EGLImageKHR dma_images[MAX_VIDEO]; EGLImageKHR dma_images[MAX_VIDEO];
EGLImageKHR dma_images_swap[MAX_VIDEO];
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
} ShaderProgram; } ShaderProgram;
// video.c
typedef struct VideoCapture {
char name[STR_LEN];
bool error;
bool disconnected;
bool needs_reload;
bool with_swap;
bool swap;
unsigned int fps;
int fd;
int exp_fd;
int exp_fd_swap;
unsigned int width;
unsigned int height;
unsigned int pixelformat;
unsigned int bytesperline;
#ifdef VIDEO_IN
struct v4l2_buffer buf;
struct v4l2_buffer buf_swap;
#endif /* VIDEO_IN */
} VideoCapture;
typedef struct VideoCaptureArray {
VideoCapture values[MAX_VIDEO];
unsigned int length;
} VideoCaptureArray;
// window.c // window.c
typedef GLFWwindow Window; typedef GLFWwindow Window;
@@ -160,16 +182,11 @@ typedef struct Tempo {
// context.c // context.c
typedef struct Context { typedef struct SharedContext {
int fd; int fd;
vec2 resolution; vec2 resolution;
vec2 tex_resolution; vec2 tex_resolution;
#ifdef VIDEO_IN
vec2 input_resolutions[MAX_VIDEO]; vec2 input_resolutions[MAX_VIDEO];
unsigned int input_formats[MAX_VIDEO];
unsigned int input_fps[MAX_VIDEO];
unsigned int input_index[MAX_VIDEO];
#endif /* VIDEO_IN */
double time; double time;
Tempo tempo; Tempo tempo;
double tempo_total; double tempo_total;
@@ -183,57 +200,9 @@ typedef struct Context {
unsigned int auto_random_cycle; unsigned int auto_random_cycle;
unsigned int seeds[MAX_FRAG]; unsigned int seeds[MAX_FRAG];
unsigned int fps; unsigned int fps;
_Atomic bool stop; VideoCaptureArray inputs;
} Context; bool stop;
} SharedContext;
// video.c
#ifdef VIDEO_IN
typedef struct VideoCapture {
char name[STR_LEN];
_Atomic bool error;
_Atomic bool disconnected;
_Atomic bool needs_reload;
unsigned int buf_count;
unsigned int buf_index;
int fd;
int exp_fd[ARRAY_SIZE];
unsigned int width;
unsigned int height;
unsigned int pixelformat;
unsigned int bytesperline;
struct v4l2_buffer buf[ARRAY_SIZE];
} VideoCapture;
typedef struct VideoCaptureArray {
VideoCapture values[MAX_VIDEO];
unsigned int length;
} VideoCaptureArray;
typedef struct VideoBackgroundReadArgs {
VideoCapture *capture;
Context *context;
int input_index;
bool trace_fps;
} VideoBackgroundReadArgs;
#endif /* VIDEO_IN */
// midi.c
typedef struct MidiDevice {
_Atomic bool connected;
char name[STR_LEN];
snd_rawmidi_t *input;
snd_rawmidi_t *output;
} MidiDevice;
typedef struct MidiBackgroundListenArgs {
MidiDevice *device;
Context *context;
void (*event_callback)(unsigned char code, unsigned char value);
} MidiBackgroundListenArgs;
// state.c // state.c
@@ -243,15 +212,14 @@ typedef struct StateConfig {
UintArray select_page_codes; UintArray select_page_codes;
UintArray select_item_codes; UintArray select_item_codes;
UintArray select_frag_codes; UintArray select_frag_codes;
UintArray group_active_counts; UintArray midi_active_counts;
UintArray group_active_offsets; UintArray midi_active_offsets;
UintArray group_active_codes; UintArray midi_active_codes;
UintArray group_counts; UintArray midi_counts;
UintArray group_offsets; UintArray midi_offsets;
UintArray codes; UintArray midi_codes;
UintArray fader_codes; UintArray fader_codes;
UintArray values_offsets; UintArray values_offsets;
UintArray random_ignored;
unsigned int value_count; unsigned int value_count;
@@ -259,29 +227,23 @@ typedef struct StateConfig {
char save_file_prefix[STR_LEN]; char save_file_prefix[STR_LEN];
unsigned int key_randomize; unsigned int hotkey_randomize;
unsigned int key_reset; unsigned int hotkey_reset;
unsigned int key_demo; unsigned int hotkey_demo;
unsigned int key_autorand; unsigned int hotkey_autorand;
unsigned int key_autorand_up; unsigned int hotkey_autorand_up;
unsigned int key_autorand_down; unsigned int hotkey_autorand_down;
unsigned int key_tempo_up; unsigned int hotkey_tempo_up;
unsigned int key_tempo_down; unsigned int hotkey_tempo_down;
UintArray key_load; UintArray hotkey_load;
UintArray key_save; UintArray hotkey_save;
} StateConfig; } StateConfig;
typedef struct StateBackgroundWriteArgs {
Context *context;
StateConfig state_config;
MidiDevice *midi;
} StateBackgroundWriteArgs;
// timer.c // timer.c
typedef struct Timer { typedef struct Timer {
struct timespec start; struct timeval start;
unsigned int counter; unsigned int counter;
unsigned int target; unsigned int target;
} Timer; } Timer;
@@ -298,6 +260,15 @@ typedef struct ConfigFileItem {
char value[STR_LEN]; char value[STR_LEN];
} ConfigFileItem; } ConfigFileItem;
// midi.c
typedef struct MidiDevice {
bool error;
char name[STR_LEN];
snd_rawmidi_t *input;
snd_rawmidi_t *output;
} MidiDevice;
// project.c // project.c
typedef struct Project { typedef struct Project {
+78 -125
View File
@@ -4,8 +4,8 @@
#include <fcntl.h> #include <fcntl.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <log.h> #include <log.h>
#include <pthread.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <unistd.h> #include <unistd.h>
@@ -16,6 +16,7 @@
#include "timer.h" #include "timer.h"
#include "video.h" #include "video.h"
static const unsigned int pixel_format = V4L2_PIX_FMT_YUYV;
static const enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; static const enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
static void ioctl_error(VideoCapture *video_capture, const char *operation, static void ioctl_error(VideoCapture *video_capture, const char *operation,
@@ -69,31 +70,14 @@ static void ioctl_error(VideoCapture *video_capture, const char *operation,
video_capture->error = true; video_capture->error = true;
} }
static void fourcc_to_string(unsigned int fourcc, char *str) { static void open_device(VideoCapture *video_capture, const char *name) {
str[0] = (char)(fourcc & 0xFF);
str[1] = (char)((fourcc >> 8) & 0xFF);
str[2] = (char)((fourcc >> 16) & 0xFF);
str[3] = (char)((fourcc >> 24) & 0xFF);
str[4] = '\0';
}
static int string_to_fourcc(const char *str) {
return (unsigned int)str[0] | ((unsigned int)str[1] << 8) |
((unsigned int)str[2] << 16) | ((unsigned int)str[3] << 24);
}
static void open_device(VideoCapture *video_capture, const char *name,
bool log_error) {
strlcpy(video_capture->name, name, STR_LEN); strlcpy(video_capture->name, name, STR_LEN);
video_capture->error = false; video_capture->error = false;
video_capture->fd = -1; video_capture->fd = -1;
video_capture->buf_count = 0;
video_capture->fd = open(name, O_RDWR | O_NONBLOCK); video_capture->fd = open(name, O_RDWR | O_NONBLOCK);
if (video_capture->fd == -1) { if (video_capture->fd == -1) {
if (log_error) { log_warn("(%s) Cannot open device", name);
log_warn("(%s) Cannot open device", name);
}
video_capture->error = true; video_capture->error = true;
} }
} }
@@ -124,8 +108,7 @@ static bool check_caps(VideoCapture *video_capture) {
} }
static bool get_available_sizes(VideoCapture *video_capture, static bool get_available_sizes(VideoCapture *video_capture,
unsigned int preferred_height, unsigned int preferred_height) {
unsigned int pixel_format) {
struct v4l2_frmsizeenum fmt_enum; struct v4l2_frmsizeenum fmt_enum;
unsigned int index; unsigned int index;
bool found = false; bool found = false;
@@ -178,9 +161,8 @@ static bool get_available_sizes(VideoCapture *video_capture,
return true; return true;
} }
static bool set_format(VideoCapture *video_capture, unsigned int pixel_format) { static bool set_format(VideoCapture *video_capture) {
struct v4l2_format fmt; struct v4l2_format fmt;
char fourcc[STR_LEN];
memset(&fmt, 0, sizeof(fmt)); memset(&fmt, 0, sizeof(fmt));
@@ -201,24 +183,23 @@ static bool set_format(VideoCapture *video_capture, unsigned int pixel_format) {
video_capture->pixelformat = fmt.fmt.pix.pixelformat; video_capture->pixelformat = fmt.fmt.pix.pixelformat;
video_capture->bytesperline = fmt.fmt.pix.bytesperline; video_capture->bytesperline = fmt.fmt.pix.bytesperline;
fourcc_to_string(fmt.fmt.pix.pixelformat, fourcc); log_info("(%s) Format fourcc: %c%c%c%c", video_capture->name,
fmt.fmt.pix.pixelformat, fmt.fmt.pix.pixelformat >> 8,
log_info("(%s) Format fourcc: %s", video_capture->name, fourcc); fmt.fmt.pix.pixelformat >> 16, fmt.fmt.pix.pixelformat >> 24);
log_info("(%s) Resolution: %dx%d", video_capture->name, fmt.fmt.pix.width, log_info("(%s) Resolution: %dx%d", video_capture->name, fmt.fmt.pix.width,
fmt.fmt.pix.height); fmt.fmt.pix.height);
return true; return true;
} }
static bool request_buffers(VideoCapture *video_capture, static bool request_buffers(VideoCapture *video_capture) {
unsigned int buffer_count) {
struct v4l2_requestbuffers reqbuf; struct v4l2_requestbuffers reqbuf;
memset(&reqbuf, 0, sizeof(reqbuf)); memset(&reqbuf, 0, sizeof(reqbuf));
reqbuf.type = buf_type; reqbuf.type = buf_type;
reqbuf.memory = V4L2_MEMORY_MMAP; reqbuf.memory = V4L2_MEMORY_MMAP;
reqbuf.count = buffer_count; reqbuf.count = 2;
if (ioctl(video_capture->fd, VIDIOC_REQBUFS, &reqbuf) == -1) { if (ioctl(video_capture->fd, VIDIOC_REQBUFS, &reqbuf) == -1) {
ioctl_error(video_capture, "VIDIOC_REQBUFS", ioctl_error(video_capture, "VIDIOC_REQBUFS",
@@ -228,10 +209,7 @@ static bool request_buffers(VideoCapture *video_capture,
log_info("(%s) V4L2 Buffer Count: %d", video_capture->name, reqbuf.count); log_info("(%s) V4L2 Buffer Count: %d", video_capture->name, reqbuf.count);
video_capture->buf_count = reqbuf.count; video_capture->with_swap = reqbuf.count > 1;
for (unsigned int i = 0; i < reqbuf.count; i++) {
video_capture->exp_fd[i] = -1;
}
return true; return true;
} }
@@ -261,15 +239,16 @@ static bool export_buffer(VideoCapture *video_capture, int *fd,
} }
static bool export_buffers(VideoCapture *video_capture) { static bool export_buffers(VideoCapture *video_capture) {
unsigned int i; bool result;
for (i = 0; i < video_capture->buf_count; i++) { result = export_buffer(video_capture, &video_capture->exp_fd, 0);
if (!export_buffer(video_capture, &video_capture->exp_fd[i], i)) {
return false; if (result && video_capture->with_swap) {
} result =
result && export_buffer(video_capture, &video_capture->exp_fd_swap, 1);
} }
return true; return result;
} }
static bool open_stream(VideoCapture *video_capture) { static bool open_stream(VideoCapture *video_capture) {
@@ -283,7 +262,7 @@ static bool open_stream(VideoCapture *video_capture) {
return true; return true;
} }
static bool create_image_buffer(VideoCapture *video_capture, static void create_image_buffer(const VideoCapture *video_capture,
struct v4l2_buffer *buf, unsigned int index) { struct v4l2_buffer *buf, unsigned int index) {
memset(buf, 0, sizeof(*buf)); memset(buf, 0, sizeof(*buf));
@@ -291,24 +270,15 @@ static bool create_image_buffer(VideoCapture *video_capture,
buf->memory = V4L2_MEMORY_MMAP; buf->memory = V4L2_MEMORY_MMAP;
buf->index = index; buf->index = index;
if (ioctl(video_capture->fd, VIDIOC_QBUF, buf) == -1) { ioctl(video_capture->fd, VIDIOC_QBUF, buf);
ioctl_error(video_capture, "VIDIOC_QBUF", "Could not enqueue buffer");
return false;
}
return true;
} }
static bool create_image_buffers(VideoCapture *video_capture) { static void create_image_buffers(VideoCapture *video_capture) {
unsigned int i; create_image_buffer(video_capture, &video_capture->buf, 0);
for (i = 0; i < video_capture->buf_count; i++) { if (video_capture->with_swap) {
if (!create_image_buffer(video_capture, &video_capture->buf[i], i)) { create_image_buffer(video_capture, &video_capture->buf_swap, 1);
return false;
}
} }
return true;
} }
static void close_stream(const VideoCapture *video_capture) { static void close_stream(const VideoCapture *video_capture) {
@@ -316,136 +286,119 @@ static void close_stream(const VideoCapture *video_capture) {
} }
static unsigned int read_video(VideoCapture *video_capture) { static unsigned int read_video(VideoCapture *video_capture) {
unsigned int result;
struct v4l2_capability cap; struct v4l2_capability cap;
if (ioctl(video_capture->fd, VIDIOC_DQBUF, result = 0;
&video_capture->buf[video_capture->buf_index]) != -1) {
if (ioctl(video_capture->fd, VIDIOC_QBUF,
&video_capture->buf[video_capture->buf_index]) == -1) {
video_capture->error = true;
return false;
} else {
video_capture->buf_index =
(video_capture->buf_index + 1) % video_capture->buf_count;
return true;
}
}
if (ioctl(video_capture->fd, VIDIOC_QUERYCAP, &cap) == -1) { if ((video_capture->swap || !video_capture->with_swap) &&
ioctl(video_capture->fd, VIDIOC_DQBUF, &video_capture->buf) != -1) {
ioctl(video_capture->fd, VIDIOC_QBUF, &video_capture->buf);
result = 1;
} else if (!video_capture->swap && video_capture->with_swap &&
ioctl(video_capture->fd, VIDIOC_DQBUF, &video_capture->buf_swap) !=
-1) {
ioctl(video_capture->fd, VIDIOC_QBUF, &video_capture->buf_swap);
result = 2;
} else if (ioctl(video_capture->fd, VIDIOC_QUERYCAP, &cap) == -1) {
video_capture->error = true; video_capture->error = true;
} }
return false; return result;
} }
void video_init(VideoCapture *video_capture, const char *name, void video_init(VideoCapture *video_capture, const char *name,
unsigned int preferred_height, unsigned int buffer_count, unsigned int preferred_height) {
const char *video_fourcc, bool log_error) { open_device(video_capture, name);
open_device(video_capture, name, log_error);
if (video_capture->error) { if (video_capture->error) {
return; return;
} }
if (!check_caps(video_capture)) { if (!check_caps(video_capture)) {
video_capture->error = true;
video_free(video_capture);
return; return;
} }
if (!get_available_sizes(video_capture, preferred_height, if (!get_available_sizes(video_capture, preferred_height)) {
string_to_fourcc(video_fourcc))) {
video_capture->error = true;
video_free(video_capture);
return; return;
} }
if (!set_format(video_capture, string_to_fourcc(video_fourcc))) { if (!set_format(video_capture)) {
video_capture->error = true;
video_free(video_capture);
return; return;
} }
if (!request_buffers(video_capture, buffer_count)) { if (!request_buffers(video_capture)) {
video_capture->error = true;
video_free(video_capture);
return; return;
} }
if (!export_buffers(video_capture)) { if (!export_buffers(video_capture)) {
video_capture->error = true;
video_free(video_capture);
return; return;
} }
if (!open_stream(video_capture)) { if (!open_stream(video_capture)) {
video_capture->error = true;
video_free(video_capture);
return; return;
} }
if (!create_image_buffers(video_capture)) { create_image_buffers(video_capture);
video_capture->error = true;
video_free(video_capture);
return;
}
} }
void *video_background_read(void *args) { bool video_background_read(VideoCapture *video_capture, SharedContext *context,
VideoBackgroundReadArgs *process_args = (VideoBackgroundReadArgs *)args; int input_index, bool trace_fps) {
VideoCapture *video_capture = process_args->capture; pid_t pid;
Context *context = process_args->context;
int input_index = process_args->input_index;
bool trace_fps = process_args->trace_fps;
Timer timer; Timer timer;
double fps; double fps;
bool result; unsigned int video_result;
log_info("(%s) background acquisition started", video_capture->name); pid = fork();
if (pid < 0) {
log_error("Could not create subprocess");
return false;
}
if (pid == 0) {
return true;
}
log_info("(%s) background acquisition started (pid: %d)", video_capture->name,
pid);
timer_init(&timer, 30); timer_init(&timer, 30);
while (!context->stop && !video_capture->error) { while (!context->stop && !video_capture->error) {
result = read_video(video_capture); video_result = read_video(video_capture);
if (video_result > 0 && timer_inc(&timer)) {
if (result && timer_inc(&timer)) {
fps = timer_reset(&timer); fps = timer_reset(&timer);
context->input_fps[input_index] = (unsigned int)round(fps); context->inputs.values[input_index].fps = (unsigned int)round(fps);
if (trace_fps) { if (trace_fps) {
log_trace("(%s) %.2ffps", video_capture->name, fps); log_trace("(%s) %.2ffps", video_capture->name, fps);
} }
} }
if (video_result > 0) {
if (result) { video_capture->swap = video_result == 2;
context->input_index[input_index] = video_capture->buf_index;
} }
} }
if (context->stop) { if (context->stop) {
log_info("(%s) background acquisition stopped by main thread", log_info("(%s) background acquisition stopped by main thread (pid: %d)",
video_capture->name); video_capture->name, pid);
} else { } else {
log_info("(%s) background acquisition stopped after error", log_info("(%s) background acquisition stopped after error (pid: %d)",
video_capture->name); video_capture->name, pid);
video_capture->disconnected = true; video_capture->disconnected = true;
context->input_formats[input_index] = 0; video_capture->pixelformat = 0;
context->input_resolutions[input_index][0] = 0; video_free(video_capture);
context->input_resolutions[input_index][1] = 0;
} }
free(process_args); exit(context->stop ? EXIT_SUCCESS : EXIT_FAILURE);
pthread_exit(NULL);
} }
void video_free(const VideoCapture *video_capture) { void video_free(const VideoCapture *video_capture) {
unsigned int i; close_stream(video_capture);
if (video_capture->exp_fd != -1) {
for (i = 0; i < video_capture->buf_count; i++) { close(video_capture->exp_fd);
if (video_capture->exp_fd[i] != -1) { }
close(video_capture->exp_fd[i]); if (video_capture->exp_fd_swap != -1) {
} close(video_capture->exp_fd);
} }
if (video_capture->fd != -1) { if (video_capture->fd != -1) {
close_stream(video_capture);
close(video_capture->fd); close(video_capture->fd);
} }
} }
+3 -7
View File
@@ -3,16 +3,12 @@
#ifndef VIDEO_H #ifndef VIDEO_H
#define VIDEO_H #define VIDEO_H
#ifdef VIDEO_IN
void video_init(VideoCapture *video_capture, const char *name, void video_init(VideoCapture *video_capture, const char *name,
unsigned int preferred_height, unsigned int buffer_count, unsigned int preferred_height);
const char *video_fourcc, bool log_error);
void *video_background_read(void *args); bool video_background_read(VideoCapture *video_capture, SharedContext *context,
int input_index, bool trace_fps);
void video_free(const VideoCapture *video_capture); void video_free(const VideoCapture *video_capture);
#endif /* VIDEO_IN */
#endif /* VIDEO_H */ #endif /* VIDEO_H */
+8 -12
View File
@@ -59,9 +59,6 @@ create_window(GLFWmonitor *monitor, const char *title, Window *shared_context,
// Context related hints // Context related hints
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
#ifdef GL_DEBUG
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
#endif
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// create fullscreen window in selected monitor // create fullscreen window in selected monitor
@@ -123,7 +120,7 @@ void window_events() { glfwPollEvents(); }
double window_get_time() { return glfwGetTime(); } double window_get_time() { return glfwGetTime(); }
void window_use(Window *window, Context *context) { void window_use(Window *window, SharedContext *context) {
int width; int width;
int height; int height;
@@ -131,10 +128,9 @@ void window_use(Window *window, Context *context) {
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
context->resolution[0] = width; context->resolution[0] = width;
context->resolution[1] = height; context->resolution[1] = height;
if (height > 0) { context->tex_resolution[0] =
context->tex_resolution[0] = (int)(context->tex_resolution[1] * context->resolution[0] /
(int)(context->tex_resolution[1] * width / height); context->resolution[1]);
}
} }
void window_close(Window *window) { void window_close(Window *window) {
@@ -158,15 +154,15 @@ unsigned int window_read_key(int key, int action, int mods) {
key == GLFW_KEY_RIGHT_ALT) { key == GLFW_KEY_RIGHT_ALT) {
return 0; return 0;
} }
result = 1000 + key; result = key;
if ((mods & GLFW_MOD_SHIFT) > 0) { if ((mods & GLFW_MOD_SHIFT) > 0) {
result += 10000; result += 1000;
} }
if ((mods & GLFW_MOD_CONTROL) > 0) { if ((mods & GLFW_MOD_CONTROL) > 0) {
result += 100000; result += 10000;
} }
if ((mods & GLFW_MOD_ALT) > 0) { if ((mods & GLFW_MOD_ALT) > 0) {
result += 1000000; result += 100000;
} }
return result; return result;
} }
+1 -1
View File
@@ -15,7 +15,7 @@ void window_update_title(Window *window, const char *title);
double window_get_time(); double window_get_time();
void window_use(Window *window, Context *context); void window_use(Window *window, SharedContext *context);
void window_refresh(Window *window); void window_refresh(Window *window);