introduced BlumenLumen_CustomUpdate and Init as proxies for an eventual user space system

This commit is contained in:
Peter Slattery 2021-01-23 12:48:14 -08:00
parent 2769640adf
commit 0916bef999
3 changed files with 66 additions and 23 deletions

57
src/app/blumen_lumen.cpp Normal file
View File

@ -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

View File

@ -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);

View File

@ -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)