feat(video): can build without video
This commit is contained in:
+14
-5
@@ -82,6 +82,7 @@ static void reload_shader(unsigned int i) {
|
||||
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) {
|
||||
inputs.length = video_in->length;
|
||||
|
||||
@@ -97,7 +98,6 @@ static bool start_video_captures(unsigned int video_count, bool trace_fps) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ static void free_video_captures(unsigned int video_count) {
|
||||
video_free(&inputs.values[i]);
|
||||
}
|
||||
}
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
static void error_callback(int error, const char *description) {
|
||||
log_error("[GLFW] %d: %s", error, description);
|
||||
@@ -177,13 +178,15 @@ void forge_run(const Parameters *params) {
|
||||
return;
|
||||
}
|
||||
|
||||
init_inputs(¶ms->video_in, params->video_size);
|
||||
|
||||
init_context(params, project.in_count);
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
init_inputs(¶ms->video_in, params->video_size);
|
||||
|
||||
if (!start_video_captures(params->video_in.length, params->trace_fps)) {
|
||||
return;
|
||||
}
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
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);
|
||||
|
||||
shaders_init(&program, &project, context, &inputs, false);
|
||||
shaders_init(&program, &project, context, false);
|
||||
} else {
|
||||
window_output = NULL;
|
||||
}
|
||||
@@ -223,11 +226,15 @@ void forge_run(const Parameters *params) {
|
||||
|
||||
window_use(window_monitor, context);
|
||||
|
||||
shaders_init(&program, &project, context, &inputs, window_output != NULL);
|
||||
shaders_init(&program, &project, context, window_output != NULL);
|
||||
} else {
|
||||
window_monitor = NULL;
|
||||
}
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
shaders_link_inputs(&program, &project, &inputs);
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
if (program.error) {
|
||||
context->stop = true;
|
||||
window_terminate();
|
||||
@@ -263,7 +270,9 @@ void forge_run(const Parameters *params) {
|
||||
shaders_free_window(&program, params->output);
|
||||
}
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
free_video_captures(params->video_in.length);
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
free_context();
|
||||
|
||||
|
||||
+10
-8
@@ -534,8 +534,7 @@ static void use_program(const ShaderProgram *program, int i, bool output,
|
||||
}
|
||||
|
||||
void shaders_init(ShaderProgram *program, const Project *project,
|
||||
const SharedContext *context, VideoCaptureArray *inputs,
|
||||
bool rebind) {
|
||||
const SharedContext *context, bool rebind) {
|
||||
if (!rebind) {
|
||||
program->error = false;
|
||||
program->last_resolution[0] = context->resolution[0];
|
||||
@@ -571,12 +570,6 @@ void shaders_init(ShaderProgram *program, const Project *project,
|
||||
return;
|
||||
}
|
||||
|
||||
init_input(program, &project->config, inputs);
|
||||
|
||||
if (check_glerror(program)) {
|
||||
return;
|
||||
}
|
||||
|
||||
init_framebuffers(program, &project->config);
|
||||
|
||||
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,
|
||||
unsigned int i, const Project *project) {
|
||||
bool result;
|
||||
|
||||
+4
-2
@@ -4,8 +4,10 @@
|
||||
#define SHADERS_H
|
||||
|
||||
void shaders_init(ShaderProgram *program, const Project *project,
|
||||
const SharedContext *context, VideoCaptureArray *inputs,
|
||||
bool rebind);
|
||||
const SharedContext *context, bool rebind);
|
||||
|
||||
void shaders_link_inputs(ShaderProgram *program, const Project *project,
|
||||
VideoCaptureArray *inputs);
|
||||
|
||||
void shaders_update(ShaderProgram *program, const File *fragment_shader,
|
||||
unsigned int i, const Project *project);
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
#include <glad/gl.h>
|
||||
#include <hashmap.h>
|
||||
#include <linmath.h>
|
||||
#ifdef VIDEO_IN
|
||||
#include <linux/videodev2.h>
|
||||
#else
|
||||
struct v4l2_buffer {};
|
||||
#endif /* VIDEO_IN */
|
||||
#include <stdbool.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
+5
-1
@@ -1,3 +1,5 @@
|
||||
#ifdef VIDEO_IN
|
||||
|
||||
#include <bsd/string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -373,4 +375,6 @@ void video_free(const VideoCapture *video_capture) {
|
||||
if (video_capture->fd != -1) {
|
||||
close(video_capture->fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* VIDEO_IN */
|
||||
Reference in New Issue
Block a user