summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drm_fb.c69
-rw-r--r--src/mem_fb.c79
-rw-r--r--src/modules/blinds/blinds.c29
-rw-r--r--src/modules/checkers/checkers.c31
-rw-r--r--src/modules/compose/compose.c2
-rw-r--r--src/modules/drizzle/drizzle.c33
-rw-r--r--src/modules/flui2d/flui2d.c27
-rw-r--r--src/modules/mixer/mixer.c31
-rw-r--r--src/modules/moire/moire.c29
-rw-r--r--src/modules/montage/montage.c2
-rw-r--r--src/modules/pixbounce/pixbounce.c24
-rw-r--r--src/modules/plato/plato.c27
-rw-r--r--src/modules/rkt/rkt.c27
-rw-r--r--src/modules/roto/roto.c29
-rw-r--r--src/modules/rtv/rtv.c2
-rw-r--r--src/modules/shapes/shapes.c33
-rw-r--r--src/modules/sparkler/sparkler.c29
-rw-r--r--src/modules/stars/stars.c26
-rw-r--r--src/modules/strobe/strobe.c31
-rw-r--r--src/modules/submit/submit.c29
-rw-r--r--src/modules/swarm/swarm.c27
-rw-r--r--src/modules/voronoi/voronoi.c33
-rw-r--r--src/sdl_fb.c176
-rw-r--r--src/til.c31
-rw-r--r--src/til_setup.c3
-rw-r--r--src/til_setup.h3
26 files changed, 465 insertions, 397 deletions
diff --git a/src/drm_fb.c b/src/drm_fb.c
index d10891b..0b6e053 100644
--- a/src/drm_fb.c
+++ b/src/drm_fb.c
@@ -296,38 +296,6 @@ static void drm_fb_setup_free(til_setup_t *setup)
}
-/* setup is called repeatedly as settings is constructed, until 0 is returned. */
-/* a negative value is returned on error */
-/* positive value indicates another setting is needed, described in next_setting */
-static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup)
-{
- drm_fb_setup_t *setup = til_setup_new(settings, sizeof(*setup), drm_fb_setup_free);
- til_setting_desc_generator_t generators[] = {
- {
- .key = "dev",
- .value_ptr = &setup->dev,
- .func = dev_desc_generator
- }, {
- .key = "connector",
- .value_ptr = &setup->connector,
- .func = connector_desc_generator
- }, {
- .key = "mode",
- .value_ptr = &setup->mode,
- .func = mode_desc_generator
- },
- };
-
- if (!drmAvailable())
- return -ENOSYS;
-
- if (!setup)
- return -ENOMEM;
-
- return til_settings_apply_desc_generators(settings, generators, nelems(generators), &setup->til_setup, res_setting, res_desc, res_setup);
-}
-
-
/* lookup a mode string in the given connector returning its respective modeinfo */
static drmModeModeInfo * lookup_mode(drmModeConnector *connector, const char *mode)
{
@@ -563,6 +531,9 @@ static int drm_fb_page_flip(til_fb_t *fb, void *context, void *page)
}
+static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
til_fb_ops_t drm_fb_ops = {
.setup = drm_fb_setup,
.init = drm_fb_init,
@@ -573,3 +544,37 @@ til_fb_ops_t drm_fb_ops = {
.page_free = drm_fb_page_free,
.page_flip = drm_fb_page_flip
};
+
+
+/* setup is called repeatedly as settings is constructed, until 0 is returned. */
+/* a negative value is returned on error */
+/* positive value indicates another setting is needed, described in next_setting */
+static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup)
+{
+ drm_fb_setup_t *setup = til_setup_new(settings, sizeof(*setup), drm_fb_setup_free, &drm_fb_ops);
+ til_setting_desc_generator_t generators[] = {
+ {
+ .key = "dev",
+ .value_ptr = &setup->dev,
+ .func = dev_desc_generator
+ }, {
+ .key = "connector",
+ .value_ptr = &setup->connector,
+ .func = connector_desc_generator
+ }, {
+ .key = "mode",
+ .value_ptr = &setup->mode,
+ .func = mode_desc_generator
+ },
+ };
+
+ if (!drmAvailable())
+ return -ENOSYS;
+
+ if (!setup)
+ return -ENOMEM;
+
+ return til_settings_apply_desc_generators(settings, generators, nelems(generators), &setup->til_setup, res_setting, res_desc, res_setup);
+}
+
+
diff --git a/src/mem_fb.c b/src/mem_fb.c
index ee736c7..bd25265 100644
--- a/src/mem_fb.c
+++ b/src/mem_fb.c
@@ -26,43 +26,6 @@ typedef struct mem_fb_t {
} mem_fb_t;
-static int mem_fb_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 *size;
- int r;
-
- r = til_settings_get_and_describe_value(settings,
- &(til_setting_spec_t){
- .name = "Virtual window size",
- .key = "size",
- .regex = "[1-9][0-9]*[xX][1-9][0-9]*",
- .preferred = "640x480",
- .values = NULL,
- .annotations = NULL
- },
- &size,
- res_setting,
- res_desc);
- if (r)
- return r;
-
- if (res_setup) {
- mem_fb_setup_t *setup;
-
- setup = til_setup_new(settings, sizeof(*setup), NULL);
- if (!setup)
- return -ENOMEM;
-
- /* TODO FIXME: parse errors */
- sscanf(size, "%ux%u", &setup->width, &setup->height);
-
- *res_setup = &setup->til_setup;
- }
-
- return 0;
-}
-
-
static int mem_fb_init(const char *title, const til_setup_t *setup, void **res_context)
{
mem_fb_t *c;
@@ -163,6 +126,9 @@ static int mem_fb_page_flip(til_fb_t *fb, void *context, void *page)
}
+static int mem_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
til_fb_ops_t mem_fb_ops = {
.setup = mem_fb_setup,
.init = mem_fb_init,
@@ -173,3 +139,42 @@ til_fb_ops_t mem_fb_ops = {
.page_free = mem_fb_page_free,
.page_flip = mem_fb_page_flip
};
+
+
+static int mem_fb_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 *size;
+ int r;
+
+ r = til_settings_get_and_describe_value(settings,
+ &(til_setting_spec_t){
+ .name = "Virtual window size",
+ .key = "size",
+ .regex = "[1-9][0-9]*[xX][1-9][0-9]*",
+ .preferred = "640x480",
+ .values = NULL,
+ .annotations = NULL
+ },
+ &size,
+ res_setting,
+ res_desc);
+ if (r)
+ return r;
+
+ if (res_setup) {
+ mem_fb_setup_t *setup;
+
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &mem_fb_ops);
+ if (!setup)
+ return -ENOMEM;
+
+ /* TODO FIXME: parse errors */
+ sscanf(size, "%ux%u", &setup->width, &setup->height);
+
+ *res_setup = &setup->til_setup;
+ }
+
+ return 0;
+}
+
+
diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c
index 8ffd596..68a387c 100644
--- a/src/modules/blinds/blinds.c
+++ b/src/modules/blinds/blinds.c
@@ -171,6 +171,21 @@ static void blinds_render_fragment(til_module_context_t *context, til_stream_t *
}
+static int blinds_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t blinds_module = {
+ .create_context = blinds_create_context,
+ .prepare_frame = blinds_prepare_frame,
+ .render_fragment = blinds_render_fragment,
+ .setup = blinds_setup,
+ .name = "blinds",
+ .description = "Retro 80s-inspired window blinds (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int blinds_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 *orientation;
@@ -225,7 +240,7 @@ static int blinds_setup(const til_settings_t *settings, til_setting_t **res_sett
if (res_setup) {
blinds_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &blinds_module);
if (!setup)
return -ENOMEM;
@@ -246,15 +261,3 @@ static int blinds_setup(const til_settings_t *settings, til_setting_t **res_sett
return 0;
}
-
-
-til_module_t blinds_module = {
- .create_context = blinds_create_context,
- .prepare_frame = blinds_prepare_frame,
- .render_fragment = blinds_render_fragment,
- .setup = blinds_setup,
- .name = "blinds",
- .description = "Retro 80s-inspired window blinds (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c
index d6530eb..a33a922 100644
--- a/src/modules/checkers/checkers.c
+++ b/src/modules/checkers/checkers.c
@@ -486,6 +486,22 @@ static int checkers_value_to_pos(const char **options, const char *value, unsign
}
+static int checkers_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t checkers_module = {
+ .create_context = checkers_create_context,
+ .destroy_context = checkers_destroy_context,
+ .prepare_frame = checkers_prepare_frame,
+ .render_fragment = checkers_render_fragment,
+ .setup = checkers_setup,
+ .name = "checkers",
+ .description = "Checker-patterned overlay (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int checkers_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 *size;
@@ -749,7 +765,7 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se
if (res_setup) {
checkers_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), checkers_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup), checkers_setup_free, &checkers_module);
if (!setup)
return -ENOMEM;
@@ -825,16 +841,3 @@ static int checkers_setup(const til_settings_t *settings, til_setting_t **res_se
return 0;
}
-
-
-til_module_t checkers_module = {
- .create_context = checkers_create_context,
- .destroy_context = checkers_destroy_context,
- .prepare_frame = checkers_prepare_frame,
- .render_fragment = checkers_render_fragment,
- .setup = checkers_setup,
- .name = "checkers",
- .description = "Checker-patterned overlay (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index 5a10113..5420cc3 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -409,7 +409,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set
til_setting_t *layer_setting;
compose_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup) + n_layers * sizeof(*setup->layers), compose_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup) + n_layers * sizeof(*setup->layers), compose_setup_free, &compose_module);
if (!setup)
return -ENOMEM;
diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c
index d85d904..9ca58f7 100644
--- a/src/modules/drizzle/drizzle.c
+++ b/src/modules/drizzle/drizzle.c
@@ -350,6 +350,23 @@ static void drizzle_finish_frame(til_module_context_t *context, til_stream_t *st
}
+static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t drizzle_module = {
+ .create_context = drizzle_create_context,
+ .destroy_context = drizzle_destroy_context,
+ .prepare_frame = drizzle_prepare_frame,
+ .render_fragment = drizzle_render_fragment,
+ .finish_frame = drizzle_finish_frame,
+ .name = "drizzle",
+ .description = "Classic 2D rain effect (threaded (poorly))",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .setup = drizzle_setup,
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int drizzle_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 *viscosity;
@@ -402,7 +419,7 @@ static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_set
drizzle_setup_t *setup;
int i;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &drizzle_module);
if (!setup)
return -ENOMEM;
@@ -424,17 +441,3 @@ static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_set
return 0;
}
-
-
-til_module_t drizzle_module = {
- .create_context = drizzle_create_context,
- .destroy_context = drizzle_destroy_context,
- .prepare_frame = drizzle_prepare_frame,
- .render_fragment = drizzle_render_fragment,
- .finish_frame = drizzle_finish_frame,
- .name = "drizzle",
- .description = "Classic 2D rain effect (threaded (poorly))",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .setup = drizzle_setup,
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c
index 147bb32..bfa36fb 100644
--- a/src/modules/flui2d/flui2d.c
+++ b/src/modules/flui2d/flui2d.c
@@ -398,6 +398,20 @@ static void flui2d_render_fragment(til_module_context_t *context, til_stream_t *
}
+static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t flui2d_module = {
+ .create_context = flui2d_create_context,
+ .prepare_frame = flui2d_prepare_frame,
+ .render_fragment = flui2d_render_fragment,
+ .setup = flui2d_setup,
+ .name = "flui2d",
+ .description = "Fluid dynamics simulation in 2D (threaded (poorly))",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+};
+
+
/* Settings hooks for configurable variables */
static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup)
{
@@ -523,7 +537,7 @@ static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_sett
if (res_setup) {
flui2d_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &flui2d_module);
if (!setup)
return -ENOMEM;
@@ -554,14 +568,3 @@ static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_sett
return 0;
}
-
-
-til_module_t flui2d_module = {
- .create_context = flui2d_create_context,
- .prepare_frame = flui2d_prepare_frame,
- .render_fragment = flui2d_render_fragment,
- .setup = flui2d_setup,
- .name = "flui2d",
- .description = "Fluid dynamics simulation in 2D (threaded (poorly))",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
-};
diff --git a/src/modules/mixer/mixer.c b/src/modules/mixer/mixer.c
index b9e4bfd..b3559c1 100644
--- a/src/modules/mixer/mixer.c
+++ b/src/modules/mixer/mixer.c
@@ -299,6 +299,22 @@ static void mixer_setup_free(til_setup_t *setup)
}
+static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t mixer_module = {
+ .create_context = mixer_create_context,
+ .destroy_context = mixer_destroy_context,
+ .prepare_frame = mixer_prepare_frame,
+ .render_fragment = mixer_render_fragment,
+ .finish_frame = mixer_finish_frame,
+ .name = "mixer",
+ .description = "Module blender",
+ .setup = mixer_setup,
+ .flags = TIL_MODULE_EXPERIMENTAL,
+};
+
+
static int mixer_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 *style_values[] = {
@@ -387,7 +403,7 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti
if (res_setup) {
mixer_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), mixer_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup), mixer_setup_free, &mixer_module);
if (!setup)
return -ENOMEM;
@@ -427,16 +443,3 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti
return 0;
}
-
-
-til_module_t mixer_module = {
- .create_context = mixer_create_context,
- .destroy_context = mixer_destroy_context,
- .prepare_frame = mixer_prepare_frame,
- .render_fragment = mixer_render_fragment,
- .finish_frame = mixer_finish_frame,
- .name = "mixer",
- .description = "Module blender",
- .setup = mixer_setup,
- .flags = TIL_MODULE_EXPERIMENTAL,
-};
diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c
index 853b106..9924a10 100644
--- a/src/modules/moire/moire.c
+++ b/src/modules/moire/moire.c
@@ -113,6 +113,21 @@ static void moire_render_fragment(til_module_context_t *context, til_stream_t *s
}
+static int moire_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t moire_module = {
+ .create_context = moire_create_context,
+ .prepare_frame = moire_prepare_frame,
+ .render_fragment = moire_render_fragment,
+ .setup = moire_setup,
+ .name = "moire",
+ .description = "2D Moire interference patterns (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int moire_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 *centers;
@@ -143,7 +158,7 @@ static int moire_setup(const til_settings_t *settings, til_setting_t **res_setti
if (res_setup) {
moire_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &moire_module);
if (!setup)
return -ENOMEM;
@@ -154,15 +169,3 @@ static int moire_setup(const til_settings_t *settings, til_setting_t **res_setti
return 0;
}
-
-
-til_module_t moire_module = {
- .create_context = moire_create_context,
- .prepare_frame = moire_prepare_frame,
- .render_fragment = moire_render_fragment,
- .setup = moire_setup,
- .name = "moire",
- .description = "2D Moire interference patterns (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 8efeec1..9864520 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -307,7 +307,7 @@ static int montage_setup(const til_settings_t *settings, til_setting_t **res_set
til_setting_t *tile_setting;
montage_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup) + n_tiles * sizeof(*setup->tiles), montage_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup) + n_tiles * sizeof(*setup->tiles), montage_setup_free, &montage_module);
if (!setup)
return -ENOMEM;
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index fcc3c5b..7dfceaf 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -315,6 +315,18 @@ static void pixbounce_render_fragment(til_module_context_t *context, til_stream_
ctxt->y = ctxt->y+ctxt->y_dir;
}
+int pixbounce_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+til_module_t pixbounce_module = {
+ .create_context = pixbounce_create_context,
+ .render_fragment = pixbounce_render_fragment,
+ .setup = pixbounce_setup,
+ .name = "pixbounce",
+ .description = "Pixmap bounce",
+ .author = "Philip J Freeman <elektron@halo.nu>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
int pixbounce_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 *pixmap_size;
@@ -374,7 +386,7 @@ int pixbounce_setup(const til_settings_t *settings, til_setting_t **res_setting,
if (res_setup) {
pixbounce_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &pixbounce_module);
if (!setup)
return -ENOMEM;
@@ -405,13 +417,3 @@ int pixbounce_setup(const til_settings_t *settings, til_setting_t **res_setting,
return 0;
}
-
-til_module_t pixbounce_module = {
- .create_context = pixbounce_create_context,
- .render_fragment = pixbounce_render_fragment,
- .setup = pixbounce_setup,
- .name = "pixbounce",
- .description = "Pixmap bounce",
- .author = "Philip J Freeman <elektron@halo.nu>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index a20137e..89661c3 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -691,6 +691,20 @@ static void plato_render_fragment(til_module_context_t *context, til_stream_t *s
}
+static int plato_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t plato_module = {
+ .create_context = plato_create_context,
+ .render_fragment = plato_render_fragment,
+ .setup = plato_setup,
+ .name = "plato",
+ .description = "Platonic solids rendered in 3D",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int plato_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 *orbit_rate;
@@ -744,7 +758,7 @@ static int plato_setup(const til_settings_t *settings, til_setting_t **res_setti
if (res_setup) {
plato_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &plato_module);
if (!setup)
return -ENOMEM;
@@ -756,14 +770,3 @@ static int plato_setup(const til_settings_t *settings, til_setting_t **res_setti
return 0;
}
-
-
-til_module_t plato_module = {
- .create_context = plato_create_context,
- .render_fragment = plato_render_fragment,
- .setup = plato_setup,
- .name = "plato",
- .description = "Platonic solids rendered in 3D",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c
index f5f73e7..45073ef 100644
--- a/src/modules/rkt/rkt.c
+++ b/src/modules/rkt/rkt.c
@@ -397,6 +397,20 @@ int rkt_scene_module_setup(const til_settings_t *settings, til_setting_t **res_s
}
+static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t rkt_module = {
+ .create_context = rkt_create_context,
+ .destroy_context = rkt_destroy_context,
+ .render_fragment = rkt_render_fragment,
+ .name = "rkt",
+ .description = "GNU Rocket module sequencer",
+ .setup = rkt_setup,
+ .flags = TIL_MODULE_HERMETIC, /* this needs refinement esp. if rkt gets split into a player and editor */
+};
+
+
static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup)
{
const til_settings_t *scenes_settings;
@@ -596,7 +610,7 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting
rkt_setup_t *setup;
unsigned ibpm, irpb;
- setup = til_setup_new(settings, sizeof(*setup) + n_scenes * sizeof(*setup->scenes), rkt_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup) + n_scenes * sizeof(*setup->scenes), rkt_setup_free, &rkt_module);
if (!setup)
return -ENOMEM;
@@ -683,14 +697,3 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting
return 0;
}
-
-
-til_module_t rkt_module = {
- .create_context = rkt_create_context,
- .destroy_context = rkt_destroy_context,
- .render_fragment = rkt_render_fragment,
- .name = "rkt",
- .description = "GNU Rocket module sequencer",
- .setup = rkt_setup,
- .flags = TIL_MODULE_HERMETIC, /* this needs refinement esp. if rkt gets split into a player and editor */
-};
diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c
index 8c9dd99..d60629c 100644
--- a/src/modules/roto/roto.c
+++ b/src/modules/roto/roto.c
@@ -419,6 +419,21 @@ static void roto_setup_free(til_setup_t *setup)
}
+static int roto_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t roto_module = {
+ .create_context = roto_create_context,
+ .destroy_context = roto_destroy_context,
+ .prepare_frame = roto_prepare_frame,
+ .render_fragment = roto_render_fragment,
+ .setup = roto_setup,
+ .name = "roto",
+ .description = "Anti-aliased tiled texture rotation (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+};
+
+
static int roto_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 *fill_module, *fill_module_name;
@@ -497,7 +512,7 @@ static int roto_setup(const til_settings_t *settings, til_setting_t **res_settin
if (res_setup) {
roto_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), roto_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup), roto_setup_free, &roto_module);
if (!setup)
return -ENOMEM;
@@ -520,15 +535,3 @@ static int roto_setup(const til_settings_t *settings, til_setting_t **res_settin
return 0;
}
-
-
-til_module_t roto_module = {
- .create_context = roto_create_context,
- .destroy_context = roto_destroy_context,
- .prepare_frame = roto_prepare_frame,
- .render_fragment = roto_render_fragment,
- .setup = roto_setup,
- .name = "roto",
- .description = "Anti-aliased tiled texture rotation (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
-};
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 445be0f..a9e8678 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -520,7 +520,7 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting
rtv_setup_t *setup;
/* FIXME: rtv_setup_t.snow_module needs freeing, so we need a bespoke free_func */
- setup = til_setup_new(settings, sizeof(*setup) + sizeof(setup->channels[0]), NULL);
+ setup = til_setup_new(settings, sizeof(*setup) + sizeof(setup->channels[0]), NULL, &rtv_module);
if (!setup)
return -ENOMEM;
diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c
index 56ad35a..e96d806 100644
--- a/src/modules/shapes/shapes.c
+++ b/src/modules/shapes/shapes.c
@@ -476,6 +476,23 @@ static void shapes_finish_frame(til_module_context_t *context, til_stream_t *str
}
+static int shapes_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t shapes_module = {
+ .create_context = shapes_create_context,
+ .destroy_context = shapes_destroy_context,
+ .prepare_frame = shapes_prepare_frame,
+ .render_fragment = shapes_render_fragment,
+ .finish_frame = shapes_finish_frame,
+ .setup = shapes_setup,
+ .name = "shapes",
+ .description = "Procedural 2D shapes (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int shapes_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 *type;
@@ -684,7 +701,7 @@ static int shapes_setup(const til_settings_t *settings, til_setting_t **res_sett
shapes_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &shapes_module);
if (!setup)
return -ENOMEM;
@@ -717,17 +734,3 @@ static int shapes_setup(const til_settings_t *settings, til_setting_t **res_sett
return 0;
}
-
-
-til_module_t shapes_module = {
- .create_context = shapes_create_context,
- .destroy_context = shapes_destroy_context,
- .prepare_frame = shapes_prepare_frame,
- .render_fragment = shapes_render_fragment,
- .finish_frame = shapes_finish_frame,
- .setup = shapes_setup,
- .name = "shapes",
- .description = "Procedural 2D shapes (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index 8cd1bf9..1e7e171 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -99,6 +99,21 @@ static void sparkler_render_fragment(til_module_context_t *context, til_stream_t
}
+static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t sparkler_module = {
+ .create_context = sparkler_create_context,
+ .destroy_context = sparkler_destroy_context,
+ .prepare_frame = sparkler_prepare_frame,
+ .render_fragment = sparkler_render_fragment,
+ .setup = sparkler_setup,
+ .name = "sparkler",
+ .description = "Particle system with spatial interactions (threaded (poorly))",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+};
+
+
/* Settings hooks for configurable variables */
static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup)
{
@@ -184,7 +199,7 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
if (res_setup) {
sparkler_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &sparkler_module);
if (!setup)
return -ENOMEM;
@@ -206,15 +221,3 @@ static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_se
return 0;
}
-
-
-til_module_t sparkler_module = {
- .create_context = sparkler_create_context,
- .destroy_context = sparkler_destroy_context,
- .prepare_frame = sparkler_prepare_frame,
- .render_fragment = sparkler_render_fragment,
- .setup = sparkler_setup,
- .name = "sparkler",
- .description = "Particle system with spatial interactions (threaded (poorly))",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
-};
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 4e0b4fd..fff6792 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -248,6 +248,19 @@ static void stars_render_fragment(til_module_context_t *context, til_stream_t *s
}
}
+int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+til_module_t stars_module = {
+ .create_context = stars_create_context,
+ .destroy_context = stars_destroy_context,
+ .render_fragment = stars_render_fragment,
+ .setup = stars_setup,
+ .name = "stars",
+ .description = "Basic starfield",
+ .author = "Philip J Freeman <elektron@halo.nu>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
int stars_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 *rot_adj;
@@ -280,7 +293,7 @@ int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, con
if (res_setup) {
stars_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &stars_module);
if (!setup)
return -ENOMEM;
@@ -291,14 +304,3 @@ int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, con
return 0;
}
-
-til_module_t stars_module = {
- .create_context = stars_create_context,
- .destroy_context = stars_destroy_context,
- .render_fragment = stars_render_fragment,
- .setup = stars_setup,
- .name = "stars",
- .description = "Basic starfield",
- .author = "Philip J Freeman <elektron@halo.nu>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c
index 1ed0b8b..3b90c2d 100644
--- a/src/modules/strobe/strobe.c
+++ b/src/modules/strobe/strobe.c
@@ -89,6 +89,22 @@ static void strobe_finish_frame(til_module_context_t *context, til_stream_t *str
}
+static int strobe_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t strobe_module = {
+ .create_context = strobe_create_context,
+ .prepare_frame = strobe_prepare_frame,
+ .render_fragment = strobe_render_fragment,
+ .finish_frame = strobe_finish_frame,
+ .setup = strobe_setup,
+ .name = "strobe",
+ .description = "Strobe light (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int strobe_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 *period;
@@ -123,7 +139,7 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett
if (res_setup) {
strobe_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &strobe_module);
if (!setup)
return -ENOMEM;
@@ -134,16 +150,3 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett
return 0;
}
-
-
-til_module_t strobe_module = {
- .create_context = strobe_create_context,
- .prepare_frame = strobe_prepare_frame,
- .render_fragment = strobe_render_fragment,
- .finish_frame = strobe_finish_frame,
- .setup = strobe_setup,
- .name = "strobe",
- .description = "Strobe light (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c
index a3f7b25..4952d2d 100644
--- a/src/modules/submit/submit.c
+++ b/src/modules/submit/submit.c
@@ -324,6 +324,21 @@ static void submit_render_fragment(til_module_context_t *context, til_stream_t *
}
+static int submit_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t submit_module = {
+ .create_context = submit_create_context,
+ .destroy_context = submit_destroy_context,
+ .prepare_frame = submit_prepare_frame,
+ .render_fragment = submit_render_fragment,
+ .name = "submit",
+ .description = "Cellular automata conquest game sim (threaded (poorly))",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .setup = submit_setup,
+};
+
+
static int submit_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 *values[] = {
@@ -352,7 +367,7 @@ static int submit_setup(const til_settings_t *settings, til_setting_t **res_sett
if (res_setup) {
submit_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &submit_module);
if (!setup)
return -ENOMEM;
@@ -364,15 +379,3 @@ static int submit_setup(const til_settings_t *settings, til_setting_t **res_sett
return 0;
}
-
-
-til_module_t submit_module = {
- .create_context = submit_create_context,
- .destroy_context = submit_destroy_context,
- .prepare_frame = submit_prepare_frame,
- .render_fragment = submit_render_fragment,
- .name = "submit",
- .description = "Cellular automata conquest game sim (threaded (poorly))",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .setup = submit_setup,
-};
diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c
index 97a04d0..9407168 100644
--- a/src/modules/swarm/swarm.c
+++ b/src/modules/swarm/swarm.c
@@ -414,6 +414,20 @@ static void swarm_render_fragment(til_module_context_t *context, til_stream_t *s
}
+static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t swarm_module = {
+ .create_context = swarm_create_context,
+ .render_fragment = swarm_render_fragment,
+ .setup = swarm_setup,
+ .name = "swarm",
+ .description = "\"Boids\"-inspired particle swarm in 3D",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int swarm_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 *styles[] = {
@@ -441,7 +455,7 @@ static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setti
if (res_setup) {
swarm_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &swarm_module);
if (!setup)
return -ENOMEM;
@@ -455,14 +469,3 @@ static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setti
return 0;
}
-
-
-til_module_t swarm_module = {
- .create_context = swarm_create_context,
- .render_fragment = swarm_render_fragment,
- .setup = swarm_setup,
- .name = "swarm",
- .description = "\"Boids\"-inspired particle swarm in 3D",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c
index b2eff94..e4621ab 100644
--- a/src/modules/voronoi/voronoi.c
+++ b/src/modules/voronoi/voronoi.c
@@ -349,6 +349,23 @@ static void voronoi_finish_frame(til_module_context_t *context, til_stream_t *st
}
+static int voronoi_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+til_module_t voronoi_module = {
+ .create_context = voronoi_create_context,
+ .destroy_context = voronoi_destroy_context,
+ .prepare_frame = voronoi_prepare_frame,
+ .render_fragment = voronoi_render_fragment,
+ .finish_frame = voronoi_finish_frame,
+ .setup = voronoi_setup,
+ .name = "voronoi",
+ .description = "Voronoi diagram (threaded)",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+ .flags = TIL_MODULE_OVERLAYABLE,
+};
+
+
static int voronoi_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 *n_cells;
@@ -403,7 +420,7 @@ static int voronoi_setup(const til_settings_t *settings, til_setting_t **res_set
if (res_setup) {
voronoi_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &voronoi_module);
if (!setup)
return -ENOMEM;
@@ -416,17 +433,3 @@ static int voronoi_setup(const til_settings_t *settings, til_setting_t **res_set
}
return 0;
}
-
-
-til_module_t voronoi_module = {
- .create_context = voronoi_create_context,
- .destroy_context = voronoi_destroy_context,
- .prepare_frame = voronoi_prepare_frame,
- .render_fragment = voronoi_render_fragment,
- .finish_frame = voronoi_finish_frame,
- .setup = voronoi_setup,
- .name = "voronoi",
- .description = "Voronoi diagram (threaded)",
- .author = "Vito Caputo <vcaputo@pengaru.com>",
- .flags = TIL_MODULE_OVERLAYABLE,
-};
diff --git a/src/sdl_fb.c b/src/sdl_fb.c
index 6221a83..16609f8 100644
--- a/src/sdl_fb.c
+++ b/src/sdl_fb.c
@@ -36,92 +36,6 @@ typedef struct sdl_fb_t {
} sdl_fb_t;
-static int sdl_fb_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 *fullscreen_values[] = {
- "off",
- "on",
- NULL
- };
- const char *fullscreen;
- const char *size;
- int r;
-
- r = til_settings_get_and_describe_value(settings,
- &(til_setting_spec_t){
- .name = "SDL fullscreen mode",
- .key = "fullscreen",
- .regex = NULL,
- .preferred = fullscreen_values[0],
- .values = fullscreen_values,
- .annotations = NULL
- },
- &fullscreen,
- res_setting,
- res_desc);
- if (r)
- return r;
-
- if (!strcasecmp(fullscreen, "off")) {
- r = til_settings_get_and_describe_value(settings,
- &(til_setting_spec_t){
- .name = "SDL window size",
- .key = "size",
- .regex = "[1-9][0-9]*[xX][1-9][0-9]*",
- .preferred = "640x480",
- .values = NULL,
- .annotations = NULL
- },
- &size,
- res_setting,
- res_desc);
- if (r)
- return r;
- } else if ((size = til_settings_get_value_by_key(settings, "size", res_setting)) && !(*res_setting)->desc) {
- /* if fullscreen=on AND size=WxH is specified, we'll do a more legacy style SDL fullscreen
- * where it tries to change the video mode. But if size is unspecified, it'll be a desktop
- * style fullscreen where it just uses a fullscreen window in the existing video mode, and
- * we won't forcibly require a size= be specified.
- */
- /* FIXME TODO: this is all copy-n-pasta grossness that wouldn't need to exist if
- * til_settings_get_and_describe_value() just supported optional settings we only
- * describe when they're already present. It just needs something like an optional flag,
- * to be added in a future commit which will remove this hack.
- */
- r = til_setting_desc_new( settings,
- &(til_setting_spec_t){
- .name = "SDL window size",
- .key = "size",
- .regex = "[1-9][0-9]*[xX][1-9][0-9]*",
- .preferred = "640x480",
- .values = NULL,
- .annotations = NULL
- }, res_desc);
- if (r < 0)
- return r;
-
- return 1;
- }
-
- if (res_setup) {
- sdl_fb_setup_t *setup;
-
- setup = til_setup_new(settings, sizeof(*setup), NULL);
- if (!setup)
- return -ENOMEM;
-
- if (!strcasecmp(fullscreen, "on"))
- setup->fullscreen = 1;
-
- if (size)
- sscanf(size, "%u%*[xX]%u", &setup->width, &setup->height);
-
- *res_setup = &setup->til_setup;
- }
-
- return 0;
-}
-
static int sdl_err_to_errno(int err)
{
switch (err) {
@@ -343,6 +257,9 @@ static int sdl_fb_page_flip(til_fb_t *fb, void *context, void *page)
}
+static int sdl_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
til_fb_ops_t sdl_fb_ops = {
.setup = sdl_fb_setup,
.init = sdl_fb_init,
@@ -353,3 +270,90 @@ til_fb_ops_t sdl_fb_ops = {
.page_free = sdl_fb_page_free,
.page_flip = sdl_fb_page_flip
};
+
+
+static int sdl_fb_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 *fullscreen_values[] = {
+ "off",
+ "on",
+ NULL
+ };
+ const char *fullscreen;
+ const char *size;
+ int r;
+
+ r = til_settings_get_and_describe_value(settings,
+ &(til_setting_spec_t){
+ .name = "SDL fullscreen mode",
+ .key = "fullscreen",
+ .regex = NULL,
+ .preferred = fullscreen_values[0],
+ .values = fullscreen_values,
+ .annotations = NULL
+ },
+ &fullscreen,
+ res_setting,
+ res_desc);
+ if (r)
+ return r;
+
+ if (!strcasecmp(fullscreen, "off")) {
+ r = til_settings_get_and_describe_value(settings,
+ &(til_setting_spec_t){
+ .name = "SDL window size",
+ .key = "size",
+ .regex = "[1-9][0-9]*[xX][1-9][0-9]*",
+ .preferred = "640x480",
+ .values = NULL,
+ .annotations = NULL
+ },
+ &size,
+ res_setting,
+ res_desc);
+ if (r)
+ return r;
+ } else if ((size = til_settings_get_value_by_key(settings, "size", res_setting)) && !(*res_setting)->desc) {
+ /* if fullscreen=on AND size=WxH is specified, we'll do a more legacy style SDL fullscreen
+ * where it tries to change the video mode. But if size is unspecified, it'll be a desktop
+ * style fullscreen where it just uses a fullscreen window in the existing video mode, and
+ * we won't forcibly require a size= be specified.
+ */
+ /* FIXME TODO: this is all copy-n-pasta grossness that wouldn't need to exist if
+ * til_settings_get_and_describe_value() just supported optional settings we only
+ * describe when they're already present. It just needs something like an optional flag,
+ * to be added in a future commit which will remove this hack.
+ */
+ r = til_setting_desc_new( settings,
+ &(til_setting_spec_t){
+ .name = "SDL window size",
+ .key = "size",
+ .regex = "[1-9][0-9]*[xX][1-9][0-9]*",
+ .preferred = "640x480",
+ .values = NULL,
+ .annotations = NULL
+ }, res_desc);
+ if (r < 0)
+ return r;
+
+ return 1;
+ }
+
+ if (res_setup) {
+ sdl_fb_setup_t *setup;
+
+ setup = til_setup_new(settings, sizeof(*setup), NULL, &sdl_fb_ops);
+ if (!setup)
+ return -ENOMEM;
+
+ if (!strcasecmp(fullscreen, "on"))
+ setup->fullscreen = 1;
+
+ if (size)
+ sscanf(size, "%u%*[xX]%u", &setup->width, &setup->height);
+
+ *res_setup = &setup->til_setup;
+ }
+
+ return 0;
+}
diff --git a/src/til.c b/src/til.c
index 4629dd7..3154733 100644
--- a/src/til.c
+++ b/src/til.c
@@ -250,6 +250,20 @@ static void _ref_setup_free(til_setup_t *setup)
}
+static int _ref_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
+
+
+static til_module_t _ref_module = {
+ .create_context = _ref_create_context,
+ .destroy_context = _ref_destroy_context,
+ .render_fragment = _ref_render_fragment,
+ .setup = _ref_setup,
+ .name = "ref",
+ .description = "built-in context referencer",
+ .author = "built-in",
+};
+
+
static int _ref_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 *path;
@@ -271,7 +285,7 @@ static int _ref_setup(const til_settings_t *settings, til_setting_t **res_settin
if (res_setup) {
_ref_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), _ref_setup_free);
+ setup = til_setup_new(settings, sizeof(*setup), _ref_setup_free, &_ref_module);
if (!setup)
return -ENOMEM;
@@ -289,17 +303,6 @@ static int _ref_setup(const til_settings_t *settings, til_setting_t **res_settin
}
-static til_module_t _ref_module = {
- .create_context = _ref_create_context,
- .destroy_context = _ref_destroy_context,
- .render_fragment = _ref_render_fragment,
- .setup = _ref_setup,
- .name = "ref",
- .description = "built-in context referencer",
- .author = "built-in",
-};
-
-
const til_module_t * til_lookup_module(const char *name)
{
static const til_module_t *builtins[] = {
@@ -658,7 +661,7 @@ int til_module_setup_randomize(const til_module_t *module, til_settings_t *setti
if (!module->setup) {
til_setup_t *setup;
- setup = til_setup_new(settings, sizeof(*setup), NULL);
+ setup = til_setup_new(settings, sizeof(*setup), NULL, module);
if (!setup)
r = -ENOMEM;
else
@@ -762,7 +765,7 @@ int til_module_setup_finalize(const til_module_t *module, const til_settings_t *
if (!module->setup) {
til_setup_t *setup;
- setup = til_setup_new(module_settings, sizeof(*setup), NULL);
+ setup = til_setup_new(module_settings, sizeof(*setup), NULL, module);
if (!setup)
return -ENOMEM;
diff --git a/src/til_setup.c b/src/til_setup.c
index bd57073..ce95366 100644
--- a/src/til_setup.c
+++ b/src/til_setup.c
@@ -22,7 +22,7 @@
* as the callers are generally using it in place of calloc(), and assign it to a
* container struct of some other type but having an embedded til_setup_t.
*/
-void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup))
+void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup), const void *creator)
{
char *path_buf = NULL;
size_t path_len;
@@ -53,6 +53,7 @@ void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_fu
setup->path_hash = til_jenkins((uint8_t *)path_buf, path_len + 1 /* include the \0 */);
setup->refcount = 1;
setup->free = free_func;
+ setup->creator = creator;
return setup;
}
diff --git a/src/til_setup.h b/src/til_setup.h
index 06ed4ea..905dd6e 100644
--- a/src/til_setup.h
+++ b/src/til_setup.h
@@ -11,9 +11,10 @@ struct til_setup_t {
uint32_t path_hash;
unsigned refcount;
void (*free)(til_setup_t *setup);
+ const void *creator;
};
-void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup));
+void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup), const void *creator);
void * til_setup_ref(til_setup_t *setup);
void * til_setup_free(til_setup_t *setup);
© All Rights Reserved