feat(video): can build without video

This commit is contained in:
2025-11-23 00:45:54 +01:00
parent d9074c366e
commit 01266e7823
10 changed files with 43 additions and 19 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
- name: install libs - name: install libs
run: sudo apt install -y libglfw3-dev libgl-dev libv4l-dev libasound2-dev libbsd-dev run: sudo apt install -y libglfw3-dev libgl-dev libv4l-dev libasound2-dev libbsd-dev
- name: gcc - name: gcc
run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DVIDEO_IN
build-release: build-release:
needs: lint needs: lint
+1
View File
@@ -125,6 +125,7 @@ make -f Makefile.dev release-arch
- [x] Configurable key codes - [x] Configurable key codes
- [x] Monitor improvements - [x] Monitor improvements
- [ ] Ignore some values in auto random - [ ] Ignore some values in auto random
- [x] build without video in
- [ ] Update README monitor/keymap - [ ] Update README monitor/keymap
- [ ] Auto reconnect midi input - [ ] Auto reconnect midi input
- [ ] Auto reconnect video device - [ ] Auto reconnect video device
+1 -1
View File
@@ -1,7 +1,7 @@
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/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_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 -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 -lbsd forge_LDADD = -lm -lGL -lglfw -lasound -lbsd
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 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
+1
View File
@@ -21,6 +21,7 @@ build:
-DGLFW_EXPOSE_NATIVE_EGL \ -DGLFW_EXPOSE_NATIVE_EGL \
-DGLFW_NATIVE_INCLUDE_NONE \ -DGLFW_NATIVE_INCLUDE_NONE \
-DLOG_USE_COLOR \ -DLOG_USE_COLOR \
-DVIDEO_IN \
-o build/$(TARGET) \ -o build/$(TARGET) \
-g -Og -g -Og
+1
View File
@@ -2,3 +2,4 @@
-DGLFW_INCLUDE_NONE -DGLFW_INCLUDE_NONE
-DGLFW_EXPOSE_NATIVE_EGL -DGLFW_EXPOSE_NATIVE_EGL
-DGLFW_NATIVE_INCLUDE_NONE -DGLFW_NATIVE_INCLUDE_NONE
-DVIDEO_IN
+14 -5
View File
@@ -82,6 +82,7 @@ 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
static void init_inputs(const StringArray *video_in, unsigned int video_size) { static void init_inputs(const StringArray *video_in, unsigned int video_size) {
inputs.length = video_in->length; inputs.length = video_in->length;
@@ -97,7 +98,6 @@ static bool start_video_captures(unsigned int video_count, bool trace_fps) {
return false; return false;
} }
} }
return true; return true;
} }
@@ -108,6 +108,7 @@ static void free_video_captures(unsigned int video_count) {
video_free(&inputs.values[i]); video_free(&inputs.values[i]);
} }
} }
#endif /* VIDEO_IN */
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);
@@ -177,13 +178,15 @@ void forge_run(const Parameters *params) {
return; return;
} }
init_inputs(&params->video_in, params->video_size);
init_context(params, project.in_count); init_context(params, project.in_count);
#ifdef VIDEO_IN
init_inputs(&params->video_in, params->video_size);
if (!start_video_captures(params->video_in.length, params->trace_fps)) { if (!start_video_captures(params->video_in.length, params->trace_fps)) {
return; return;
} }
#endif /* VIDEO_IN */
midi_open(&midi, config_file_get_str(&project.config, "MIDI_HW", "hw")); midi_open(&midi, config_file_get_str(&project.config, "MIDI_HW", "hw"));
@@ -211,7 +214,7 @@ void forge_run(const Parameters *params) {
window_use(window_output, context); window_use(window_output, context);
shaders_init(&program, &project, context, &inputs, false); shaders_init(&program, &project, context, false);
} else { } else {
window_output = NULL; window_output = NULL;
} }
@@ -223,11 +226,15 @@ void forge_run(const Parameters *params) {
window_use(window_monitor, context); window_use(window_monitor, context);
shaders_init(&program, &project, context, &inputs, window_output != NULL); shaders_init(&program, &project, context, window_output != NULL);
} else { } else {
window_monitor = NULL; window_monitor = NULL;
} }
#ifdef VIDEO_IN
shaders_link_inputs(&program, &project, &inputs);
#endif /* VIDEO_IN */
if (program.error) { if (program.error) {
context->stop = true; context->stop = true;
window_terminate(); window_terminate();
@@ -263,7 +270,9 @@ void forge_run(const Parameters *params) {
shaders_free_window(&program, params->output); shaders_free_window(&program, params->output);
} }
#ifdef VIDEO_IN
free_video_captures(params->video_in.length); free_video_captures(params->video_in.length);
#endif /* VIDEO_IN */
free_context(); free_context();
+10 -8
View File
@@ -534,8 +534,7 @@ 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 SharedContext *context, VideoCaptureArray *inputs, const SharedContext *context, bool rebind) {
bool rebind) {
if (!rebind) { if (!rebind) {
program->error = false; program->error = false;
program->last_resolution[0] = context->resolution[0]; program->last_resolution[0] = context->resolution[0];
@@ -571,12 +570,6 @@ void shaders_init(ShaderProgram *program, const Project *project,
return; return;
} }
init_input(program, &project->config, inputs);
if (check_glerror(program)) {
return;
}
init_framebuffers(program, &project->config); init_framebuffers(program, &project->config);
if (check_glerror(program)) { if (check_glerror(program)) {
@@ -603,6 +596,15 @@ void shaders_init(ShaderProgram *program, const Project *project,
} }
} }
void shaders_link_inputs(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs) {
init_input(program, &project->config, inputs);
if (check_glerror(program)) {
return;
}
}
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) {
bool result; bool result;
+4 -2
View File
@@ -4,8 +4,10 @@
#define SHADERS_H #define SHADERS_H
void shaders_init(ShaderProgram *program, const Project *project, void shaders_init(ShaderProgram *program, const Project *project,
const SharedContext *context, VideoCaptureArray *inputs, const SharedContext *context, bool rebind);
bool rebind);
void shaders_link_inputs(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs);
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);
+4
View File
@@ -4,7 +4,11 @@
#include <glad/gl.h> #include <glad/gl.h>
#include <hashmap.h> #include <hashmap.h>
#include <linmath.h> #include <linmath.h>
#ifdef VIDEO_IN
#include <linux/videodev2.h> #include <linux/videodev2.h>
#else
struct v4l2_buffer {};
#endif /* VIDEO_IN */
#include <stdbool.h> #include <stdbool.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
+4
View File
@@ -1,3 +1,5 @@
#ifdef VIDEO_IN
#include <bsd/string.h> #include <bsd/string.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
@@ -374,3 +376,5 @@ void video_free(const VideoCapture *video_capture) {
close(video_capture->fd); close(video_capture->fd);
} }
} }
#endif /* VIDEO_IN */