diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-01-15 22:45:41 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-01-21 13:34:12 -0800 |
commit | a583ead0f41e6bcec76b32a95985667fdbe2192a (patch) | |
tree | def19fbf8a01a6a820e0b5eac175f9e70ed65048 | |
parent | 6d6619cc5f4f04710dd7dfccce713385924b3b06 (diff) |
modules/rocket: preliminary rocket module
This just stubs out a rocket meta module that renders with
another module.
Future commits will integrate GNU Rocket here.
When recursive settings formally lands you'll be able to nest as
much settings content as necessary for the underlying module
used, as part of the rocket settings. That should enable
describing stuff like complex compose scenarios for rocket to
sequence.
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/modules/Makefile.am | 2 | ||||
-rw-r--r-- | src/modules/rocket/Makefile.am | 3 | ||||
-rw-r--r-- | src/modules/rocket/rocket.c | 138 | ||||
-rw-r--r-- | src/til.c | 2 |
6 files changed, 146 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index c796695..8ebd846 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,7 @@ AC_CONFIG_FILES([ src/modules/plasma/Makefile src/modules/plato/Makefile src/modules/ray/Makefile + src/modules/rocket/Makefile src/modules/roto/Makefile src/modules/rtv/Makefile src/modules/shapes/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index f5b2116..e3264d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = libs modules noinst_LTLIBRARIES = libtil.la libtil_la_SOURCES = til_args.c til_args.h til_fb.c til_fb.h til_jenkins.c til_jenkins.h til_knobs.h til.c til.h til_module_context.c til_module_context.h til_settings.h til_settings.c til_setup.c til_setup.h til_stream.c til_stream.h til_tap.h til_threads.c til_threads.h til_util.c til_util.h libtil_la_CPPFLAGS = -I@top_srcdir@/src -libtil_la_LIBADD = modules/blinds/libblinds.la modules/checkers/libcheckers.la modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/moire/libmoire.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/roto/libroto.la modules/rtv/librtv.la modules/shapes/libshapes.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/strobe/libstrobe.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la modules/voronoi/libvoronoi.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/rocket/librocket.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la +libtil_la_LIBADD = modules/blinds/libblinds.la modules/checkers/libcheckers.la modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/moire/libmoire.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/rocket/librocket.la modules/roto/libroto.la modules/rtv/librtv.la modules/shapes/libshapes.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/strobe/libstrobe.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la modules/voronoi/libvoronoi.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/rocket/librocket.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la bin_PROGRAMS = rototiller rototiller_SOURCES = fps.c fps.h main.c mem_fb.c setup.h setup.c til.h til_fb.c til_fb.h til_knobs.h til_settings.c til_settings.h til_threads.c til_threads.h til_util.c til_util.h diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am index f88879e..1ce37de 100644 --- a/src/modules/Makefile.am +++ b/src/modules/Makefile.am @@ -1 +1 @@ -SUBDIRS = blinds checkers compose drizzle flui2d julia meta2d moire montage pixbounce plasma plato ray roto rtv shapes snow sparkler spiro stars strobe submit swab swarm voronoi +SUBDIRS = blinds checkers compose drizzle flui2d julia meta2d moire montage pixbounce plasma plato ray rocket roto rtv shapes snow sparkler spiro stars strobe submit swab swarm voronoi diff --git a/src/modules/rocket/Makefile.am b/src/modules/rocket/Makefile.am new file mode 100644 index 0000000..96da9aa --- /dev/null +++ b/src/modules/rocket/Makefile.am @@ -0,0 +1,3 @@ +noinst_LTLIBRARIES = librocket.la +librocket_la_SOURCES = rocket.c +librocket_la_CPPFLAGS = -I@top_srcdir@/src -I@top_srcdir@/src/libs -I@top_srcdir@/src/libs/rocket/rocket/lib diff --git a/src/modules/rocket/rocket.c b/src/modules/rocket/rocket.c new file mode 100644 index 0000000..1ad2c51 --- /dev/null +++ b/src/modules/rocket/rocket.c @@ -0,0 +1,138 @@ +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "til.h" +#include "til_fb.h" +#include "til_module_context.h" +#include "til_settings.h" +#include "til_util.h" + +#include "txt/txt.h" + +/* Copyright (C) 2023 - Vito Caputo <vcaputo@pengaru.com> */ + +/* This implements a rudimentary sequencing module varying + * "tapped" variables of other modules on a timeline via + * GNU Rocket. + */ + +typedef struct rocket_context_t { + til_module_context_t til_module_context; + + const til_module_t *module; + til_module_context_t *module_ctxt; + char *module_settings; +} rocket_context_t; + +typedef struct rocket_setup_t { + til_setup_t til_setup; + const char *module; +} rocket_setup_t; + +static rocket_setup_t rocket_default_setup = { .module = "rtv" }; + + +static til_module_context_t * rocket_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) +{ + rocket_context_t *ctxt; + const til_module_t *module; + + if (!setup) + setup = &rocket_default_setup.til_setup; + + module = til_lookup_module(((rocket_setup_t *)setup)->module); + if (!module) + return NULL; + + ctxt = til_module_context_new(stream, sizeof(rocket_context_t), seed, ticks, n_cpus, path); + if (!ctxt) + return NULL; + + ctxt->module = module; + + { + til_setup_t *module_setup = NULL; + + (void) til_module_randomize_setup(ctxt->module, rand_r(&seed), &module_setup, NULL); + + (void) til_module_create_context(ctxt->module, stream, rand_r(&seed), ticks, 0, path, module_setup, &ctxt->module_ctxt); + til_setup_free(module_setup); + } + + return &ctxt->til_module_context; +} + + +static void rocket_destroy_context(til_module_context_t *context) +{ + rocket_context_t *ctxt = (rocket_context_t *)context; + + til_module_context_free(ctxt->module_ctxt); + free(context); +} + + +static void rocket_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) +{ + rocket_context_t *ctxt = (rocket_context_t *)context; + + til_module_render(ctxt->module_ctxt, stream, ticks, fragment_ptr); +} + + +static int rocket_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) +{ + const char *module; + int r; + + r = til_settings_get_and_describe_value(settings, + &(til_setting_desc_t){ + .name = "Module to sequence", + .key = "module", + .preferred = "rtv", + .annotations = NULL, + }, + &module, + res_setting, + res_desc); + if (r) + return r; + + /* turn layers colon-separated list into a null-terminated array of strings */ + if (res_setup) { + const til_module_t *til_module; + rocket_setup_t *setup; + + if (!strcmp(module, "rocket")) + return -EINVAL; + + til_module = til_lookup_module(module); + if (!til_module) + return -ENOENT; + + if (til_module->flags & (TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL)) + return -EINVAL; + + setup = til_setup_new(sizeof(*setup), (void(*)(til_setup_t *))free); + if (!setup) + return -ENOMEM; + + setup->module = til_module->name; + + *res_setup = &setup->til_setup; + } + + return 0; +} + + +til_module_t rocket_module = { + .create_context = rocket_create_context, + .destroy_context = rocket_destroy_context, + .render_fragment = rocket_render_fragment, + .name = "rocket", + .description = "GNU Rocket module sequencer", + .setup = rocket_setup, + .flags = TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL, +}; @@ -37,6 +37,7 @@ extern til_module_t pixbounce_module; extern til_module_t plasma_module; extern til_module_t plato_module; extern til_module_t ray_module; +extern til_module_t rocket_module; extern til_module_t roto_module; extern til_module_t rtv_module; extern til_module_t shapes_module; @@ -64,6 +65,7 @@ static const til_module_t *modules[] = { &plasma_module, &plato_module, &ray_module, + &rocket_module, &roto_module, &rtv_module, &shapes_module, |