From 0b0aa3b06fac0bcdeb31d5e2211d1ba149531692 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Thu, 6 Oct 2022 14:30:48 -0400 Subject: GL renderer preparation --- createcalls.cpp | 141 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 67 deletions(-) (limited to 'createcalls.cpp') diff --git a/createcalls.cpp b/createcalls.cpp index 3bd13f8..2c2df61 100644 --- a/createcalls.cpp +++ b/createcalls.cpp @@ -1,29 +1,92 @@ +static void +PostMsg(project_state *State, char *msg) +{ + State->MsgTime = 120; + State->Msg = msg; +} -static bool32 +static uint16 Source_Generate(project_data *File, project_state *State, memory *Memory, void *TempString) { Assert(File->Source_Count < MAX_SOURCES); bool32 IsVideo = 0; - if (AV_IsFileSupported((char *)Path, &IsVideo)) { - block_source *Source = - uint16 = String_AddToFile(Memory, (char *)TempString); + if (AV_IsFileSupported((char *)TempString, &IsVideo)) { + uint16 Index = Memory_Block_AllocateNew(Memory, F_Strings); + block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Index); + History_Entry_Commit(Memory, "Add source"); + History_Action_Block_Swap(Memory, F_Sources, Source); + + Source->Occupied = 1; + Source->Block_String_Index = String_AddToFile(Memory, (char *)TempString); if (IsVideo) Source->SourceType = source_type_video; else Source->SourceType = source_type_image; - History_Entry_Commit(Memory, action_entry_default, "Add source"); - History_Action_Change(Memory, &Source->Path, &Source->Path, &Path, action_type_change_ptr); - uint32 i = File->NumberOfSources + 1; - History_Action_Change(Memory, &File->NumberOfSources, &File->NumberOfSources, &i, action_type_change_u16); + + History_Action_Swap(Memory, F_File, sizeof(File->Source_Count), &File->Source_Count); + File->Source_Count++; History_Entry_End(Memory); - return 1; + return Index; } else { - void *Address = Memory_Rewind(Memory, STRING_SIZE, F_Strings); PostMsg(State, "File not supported..."); } - return 0; + return -1; +} + +static property_channel +Property_InitFloat(char *Name, real32 Val, real32 ScrubVal, real32 MinVal = PROPERTY_REAL_MIN, real32 MaxVal = PROPERTY_REAL_MAX) { property_channel Property = {}; + Property.Name = Name; + Property.CurrentValue = Val; + Property.MinVal = MinVal; + Property.MaxVal = MaxVal; + Property.ScrubVal = ScrubVal; + return Property; +} + + +block_layer * Layer_Init(project_data *File, memory *Memory) +{ + block_layer *Layer = (block_layer *)Memory_Block_AllocateAddress(Memory, F_Layers); + History_Action_Block_Swap(Memory, F_Layers, Layer); + + *Layer = {}; + Layer->Occupied = 1; + + Layer->Block_String_Index = Memory_Block_AllocateNew(Memory, F_Strings); + block_string *String = (block_string *)Memory_Block_AddressAtIndex(Memory, F_Strings, Layer->Block_String_Index); + sprintf(String->Char, "Layer %i", File->Layer_Count + 1); // CSbros... + + Layer->x = Property_InitFloat("X Position", 0.0f, 1.0f); + Layer->y = Property_InitFloat("Y Position", 0.0f, 1.0f); + Layer->ax = Property_InitFloat("Anchor X", 0.5f, 0.005f); + Layer->ay = Property_InitFloat("Anchor Y", 0.5f, 0.005f); + Layer->scale = Property_InitFloat("Scale", 1.0f, 0.005f); + Layer->rotation = Property_InitFloat("Rotation", 0.0f, 1.0f); + Layer->opacity = Property_InitFloat("Opacity", 1.0f, 0.005f, 0.0f, 1.0f); + Layer->time = Property_InitFloat("Frame Number", 0.0f, 1.0f, 0, 100000); + + History_Action_Swap(Memory, F_File, sizeof(File->Layer_Count), &File->Layer_Count); + File->Layer_Count++; + + return Layer; +} + + +static void +Layer_CreateFromSource(project_data *File, project_state *State, memory *Memory, uint16 SourceIndex, int32 Frame_End) +{ + if (File->Layer_Count + 1 > MAX_LAYERS) { + Assert(0); + } + History_Entry_Commit(Memory,"Add layer from source"); + block_layer *Layer = Layer_Init(File, Memory); + Layer->Block_Source_Index = SourceIndex; + Layer->Frame_End = Frame_End; + History_Entry_End(Memory); + + State->UpdateFrame = true; } #if 0 @@ -36,25 +99,6 @@ IncrementFrame(project_data *File, int16 Amount) { } } -static void -PostMsg(project_state *State, char *msg) -{ - State->MsgTime = 120; - State->Msg = msg; -} - -static property_channel -InitFloatProperty(char *Name, real32 Val, real32 ScrubVal, real32 MinVal = PROPERTY_REAL_MIN, real32 MaxVal = PROPERTY_REAL_MAX) { - property_channel Property = {}; - Property.Name = Name; - Property.CurrentValue.f = Val; - Property.MinVal.f = MinVal; - Property.MaxVal.f = MaxVal; - Property.ScrubVal.f = ScrubVal; - Property.VarType = type_real; - return Property; -} - static void CreateKeyframeBlock(property_channel *Property, memory *Memory) { @@ -72,43 +116,6 @@ void * Layer_AllocateBitmap(memory *Memory, uint16 Width, uint16 Height, uint16 return Address; } -project_layer * Layer_Init(project_data *File, memory *Memory) -{ - int16 Index = File->NumberOfLayers; - int16 NextIndex = File->NumberOfLayers + 1; - - // NOTE(fox): We don't have to record any values that get set here aside - // from this index in the Action tree since all we need to do to "delete" - // the layer is to unset this. The layer that gets made here is always at - // the top of the index. - History_Entry_Commit(Memory, action_entry_layerinit, "Create layer"); - History_Action_Change(Memory, &File->NumberOfLayers, &Index, &NextIndex, action_type_change_u16); - - File->Layer[Index] = (project_layer *)AllocateMemory(Memory, sizeof(project_layer), F_Layers); - - project_layer *Layer = File->Layer[Index]; - *Layer = {}; - Layer->BitmapInfo.CurrentFrame = -1; - - History_Entry_SetPointer(Memory, &Layer->BitmapInfo.AVInfo); - - History_Entry_End(Memory); - - Layer->Name = (char *)AllocateMemory(Memory, STRING_SIZE, F_Strings); - sprintf(Layer->Name, "Layer %i", NextIndex); // CSbros... - Layer->x = InitFloatProperty("X Position", 0.0f, 1.0f); - Layer->y = InitFloatProperty("Y Position", 0.0f, 1.0f); - Layer->ax = InitFloatProperty("Anchor X", 0.5f, 0.005f); - Layer->ay = InitFloatProperty("Anchor Y", 0.5f, 0.005f); - Layer->scale = InitFloatProperty("Scale", 1.0f, 0.005f); - Layer->rotation = InitFloatProperty("Rotation", 0.0f, 1.0f); - Layer->opacity = InitFloatProperty("Opacity", 1.0f, 0.005f, 0.0f, 1.0f); - Layer->time = InitFloatProperty("Frame Number", 0.0f, 1.0f, 0, 100000); - Layer->EndFrame = File->NumberOfFrames; - - return Layer; -} - static cached_bitmap * Cache_CheckBitmap(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, int32 TimelineFrame) { -- cgit v1.2.3