From 0916bef999b7839bf8ecdbc03ef118d5e29323bb Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Sat, 23 Jan 2021 12:48:14 -0800 Subject: [PATCH] introduced BlumenLumen_CustomUpdate and Init as proxies for an eventual user space system --- src/app/blumen_lumen.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ src/app/foldhaus_app.cpp | 31 ++++++---------------- src/app/foldhaus_app.h | 1 + 3 files changed, 66 insertions(+), 23 deletions(-) create mode 100644 src/app/blumen_lumen.cpp diff --git a/src/app/blumen_lumen.cpp b/src/app/blumen_lumen.cpp new file mode 100644 index 0000000..8a9d23b --- /dev/null +++ b/src/app/blumen_lumen.cpp @@ -0,0 +1,57 @@ +// +// File: blumen_lumen.cpp +// Author: Peter Slattery +// Creation Date: 2021-01-23 +// +#ifndef BLUMEN_LUMEN_CPP + +struct foo_ +{ + u32 Heyo; +}; + +internal gs_data +BlumenLumen_CustomInit(app_state* State, context Context) +{ + // This is memory for any custom data that we want to use + // as a part of a particular sculpture. + // By returning it from here, it will be sent as an argument to + // the sculpture's CustomUpdate function; + gs_data Result = {}; + + Result = PushSizeToData(&State->Permanent, sizeof(foo_)); + foo_* MyFoo = (foo_*)Result.Memory; + MyFoo->Heyo = 5; + + { // Animation PLAYGROUND + + animation Anim = {0}; + Anim.Name = PushStringF(&State->Permanent, 256, "test_anim_one"); + Anim.Layers = AnimLayerArray_Create(State->AnimationSystem.Storage, 8); + Anim.Blocks_ = AnimBlockArray_Create(State->AnimationSystem.Storage, 8); + Anim.PlayableRange.Min = 0; + Anim.PlayableRange.Max = SecondsToFrames(15, State->AnimationSystem); + Animation_AddLayer(&Anim, MakeString("Base Layer"), BlendMode_Overwrite, &State->AnimationSystem); + Animation_AddLayer(&Anim, MakeString("Color Layer"), BlendMode_Multiply, &State->AnimationSystem); + Animation_AddLayer(&Anim, MakeString("Sparkles"), BlendMode_Add, &State->AnimationSystem); + + Animation_AddBlock(&Anim, 0, Anim.PlayableRange.Max, Patterns_IndexToHandle(5), 0); + + AnimationArray_Push(&State->AnimationSystem.Animations, Anim); + + State->AnimationSystem.TimelineShouldAdvance = true; + } // End Animation Playground + + return Result; +} + +internal void +BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) +{ + foo_* MyFoo = (foo_*)UserData.Memory; + Assert(MyFoo->Heyo == 5); +} + + +#define BLUMEN_LUMEN_CPP +#endif // BLUMEN_LUMEN_CPP \ No newline at end of file diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index ade4707..ef95275 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -90,29 +90,12 @@ INITIALIZE_APPLICATION(InitializeApplication) LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog); #endif - { // Animation PLAYGROUND - State->AnimationSystem = {}; - State->AnimationSystem.Storage = &State->Permanent; - State->AnimationSystem.Animations = AnimationArray_Create(State->AnimationSystem.Storage, 32); - - State->AnimationSystem.SecondsPerFrame = 1.f / 24.f; - - animation Anim = {0}; - Anim.Name = PushStringF(&State->Permanent, 256, "test_anim_one"); - Anim.Layers = AnimLayerArray_Create(State->AnimationSystem.Storage, 8); - Anim.Blocks_ = AnimBlockArray_Create(State->AnimationSystem.Storage, 8); - Anim.PlayableRange.Min = 0; - Anim.PlayableRange.Max = SecondsToFrames(15, State->AnimationSystem); - Animation_AddLayer(&Anim, MakeString("Base Layer"), BlendMode_Overwrite, &State->AnimationSystem); - Animation_AddLayer(&Anim, MakeString("Color Layer"), BlendMode_Multiply, &State->AnimationSystem); - Animation_AddLayer(&Anim, MakeString("Sparkles"), BlendMode_Add, &State->AnimationSystem); - - Animation_AddBlock(&Anim, 0, Anim.PlayableRange.Max, Patterns_IndexToHandle(5), 0); - - AnimationArray_Push(&State->AnimationSystem.Animations, Anim); - - State->AnimationSystem.TimelineShouldAdvance = true; - } // End Animation Playground + State->AnimationSystem = {}; + State->AnimationSystem.Storage = &State->Permanent; + State->AnimationSystem.Animations = AnimationArray_Create(State->AnimationSystem.Storage, 32); + State->AnimationSystem.SecondsPerFrame = 1.f / 24.f; + + State->UserData = BlumenLumen_CustomInit(State, Context); } UPDATE_AND_RENDER(UpdateAndRender) @@ -139,6 +122,8 @@ UPDATE_AND_RENDER(UpdateAndRender) State->UserData.Memory); } + BlumenLumen_CustomUpdate(State->UserData, State, Context); + AssemblyDebug_OverrideOutput(State->AssemblyDebugState, State->Assemblies, State->LedSystem); diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index bf99bf6..a6608dc 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -78,6 +78,7 @@ internal void OpenColorPicker(app_state* State, v4* Address); #include "engine/assembly/foldhaus_assembly.cpp" #include "patterns/blumen_patterns.h" +#include "blumen_lumen.cpp" internal void EndCurrentOperationMode(app_state* State)