summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-10 23:42:32 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-11 22:31:31 -0800
commit01bf40c402f9da50e4282eef722a25c9668efc3c (patch)
treecaf0f1224e44403d262b10c779e6aebd198d5c5e
parentfe4d2000013329ed9882fb900a19a6fe03876c52 (diff)
src/modules/{stars,plato}: stream tapped variables
Now that til_stream_t is implemented, let's wire up the taps. Note that nothing actually creates the stream and puts it in the fragment yet, so stream is still always NULL for these effectively turning this into a NOP.
-rw-r--r--src/modules/plato/plato.c5
-rw-r--r--src/modules/stars/stars.c37
2 files changed, 30 insertions, 12 deletions
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index 1e9f6bd..1dc56a3 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -47,6 +47,7 @@
#include "til.h"
#include "til_fb.h"
#include "til_module_context.h"
+#include "til_stream.h"
#include "til_tap.h"
#define PLATO_DEFAULT_ORBIT_RATE .25
@@ -651,6 +652,10 @@ static void plato_render_fragment(til_module_context_t *context, unsigned ticks,
plato_context_t *ctxt = (plato_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
+ /* since we don't automate the rates ourselves, we don't care about the tap return values */
+ (void) til_stream_tap_context(fragment->stream, context, &ctxt->taps.orbit_rate);
+ (void) til_stream_tap_context(fragment->stream, context, &ctxt->taps.spin_rate);
+
ctxt->r += (float)(ticks - context->ticks) * (*ctxt->orbit_rate * .001f);
ctxt->rr += (float)(ticks - context->ticks) * (*ctxt->spin_rate * .001f);
context->ticks = ticks;
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index e8a2f18..82619d7 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -12,6 +12,7 @@
#include "til_fb.h"
#include "til_module_context.h"
#include "til_settings.h"
+#include "til_stream.h"
#include "til_tap.h"
#include "draw.h"
@@ -222,20 +223,32 @@ static void stars_render_fragment(til_module_context_t *context, unsigned ticks,
ctxt->points = tmp_ptr;
}
- // handle rotation parameters
- if(*ctxt->rot_angle>M_PI_4)
- *ctxt->rot_rate=*ctxt->rot_rate-ctxt->rot_adj;
- else
- *ctxt->rot_rate=*ctxt->rot_rate+ctxt->rot_adj;
- *ctxt->rot_angle=*ctxt->rot_angle+*ctxt->rot_rate;
+ if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.rot_angle))
+ *ctxt->rot_angle+=*ctxt->rot_rate;
+
+ if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.rot_rate)) {
+ // handle rotation parameters
+ if(*ctxt->rot_angle>M_PI_4)
+ *ctxt->rot_rate=*ctxt->rot_rate-ctxt->rot_adj;
+ else
+ *ctxt->rot_rate=*ctxt->rot_rate+ctxt->rot_adj;
+ }
+
+ /* there's no automation of offset_angle */
+ (void) til_stream_tap_context(fragment->stream, context, &ctxt->taps.offset_angle);
// handle offset parameters
- float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle))-
- (*ctxt->offset_y*sinf(*ctxt->offset_angle));
- float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle))+
- (*ctxt->offset_y*cosf(*ctxt->offset_angle));
- *ctxt->offset_x = tmp_x;
- *ctxt->offset_y = tmp_y;
+ if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.offset_x)) {
+ float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle))-
+ (*ctxt->offset_y*sinf(*ctxt->offset_angle));
+ *ctxt->offset_x = tmp_x;
+ }
+
+ if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.offset_y)) {
+ float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle))+
+ (*ctxt->offset_y*cosf(*ctxt->offset_angle));
+ *ctxt->offset_y = tmp_y;
+ }
}
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)
© All Rights Reserved