From 834aab26717595bc0498a3ee0527a2bb1f5b27fc Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Mon, 11 Nov 2019 20:34:56 -0800 Subject: [PATCH] Did a bunch of stuff with nodes --- meta/foldhaus_meta.cpp | 7 +- src/foldhaus_app.cpp | 6 +- src/foldhaus_debug_visuals.h | 10 +- src/foldhaus_interface.cpp | 36 ++- src/foldhaus_memory.h | 14 +- src/foldhaus_node.cpp | 318 ++++++++++----------- src/foldhaus_node.h | 33 ++- src/foldhaus_node_gui.h | 13 + src/foldhaus_operation_mode.h | 15 +- src/foldhaus_platform.h | 7 +- src/foldhaus_sacn.h | 24 +- src/generated/foldhaus_nodes_generated.cpp | 13 +- src/gs_platform.h | 2 +- src/gs_win32.cpp | 14 +- src/win32_foldhaus.cpp | 32 ++- todo.txt | 10 +- 16 files changed, 289 insertions(+), 265 deletions(-) create mode 100644 src/foldhaus_node_gui.h diff --git a/meta/foldhaus_meta.cpp b/meta/foldhaus_meta.cpp index deb9152..160f9f7 100644 --- a/meta/foldhaus_meta.cpp +++ b/meta/foldhaus_meta.cpp @@ -571,7 +571,7 @@ int main(int ArgCount, char** ArgV) InitMemoryArena(&SourceFileArena, 0, 0, StdAlloc); code_block_builder NodeTypeBlock = InitCodeBlockBuilder(); - CodeBlockPrint(&NodeTypeBlock, MakeStringLiteral("enum node_type\n{\nNodeType_OutputNode,\n")); + CodeBlockPrint(&NodeTypeBlock, MakeStringLiteral("enum node_type\n{\n")); code_block_builder NodeMembersBlock = InitCodeBlockBuilder(); @@ -580,7 +580,10 @@ int main(int ArgCount, char** ArgV) code_block_builder CallNodeProcBlock = InitCodeBlockBuilder(); CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("internal void CallNodeProc(node_header* Node, u8* Data, led* LEDs, s32 LEDsCount, r32 DeltaTime)\n{\n")); - CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("switch (Node->Type)\n{\n")); + CodeBlockPrint(&CallNodeProcBlock, + MakeStringLiteral("node_specification Spec = NodeSpecifications[Node->Type];\n")); + CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("switch (Spec.Type)\n{\n")); + // Build Search Paths Array s32 SearchPathsCount = 1; //ArgCount - 1; diff --git a/src/foldhaus_app.cpp b/src/foldhaus_app.cpp index 7733949..df1af3d 100644 --- a/src/foldhaus_app.cpp +++ b/src/foldhaus_app.cpp @@ -345,6 +345,8 @@ RELOAD_STATIC_DATA(ReloadStaticData) app_state* State = (app_state*)Context.MemoryBase; GlobalDebugServices = DebugServices; + GSAlloc = Alloc; + GSFree = Free; if (State->DefaultInputCommandRegistry.Size > 0) { @@ -461,7 +463,7 @@ INITIALIZE_APPLICATION(InitializeApplication) GlobalDebugServices->Interface.RenderSculpture = true; - State->NodeList = AllocateNodeList(State->Permanent, 512); //Kilobytes(64)); + State->NodeList = AllocateNodeList(State->Permanent, 128); State->OutputNode = PushOutputNodeOnList(State->NodeList, v2{500, 250}, State->Permanent); { State->NodeRenderSettings.PortColors[MemberType_r32] = RedV4; @@ -469,7 +471,7 @@ INITIALIZE_APPLICATION(InitializeApplication) State->NodeRenderSettings.PortColors[MemberType_v4] = BlueV4; State->NodeRenderSettings.Font = State->Font; } - ReloadStaticData(Context, GlobalDebugServices); + ReloadStaticData(Context, GlobalDebugServices, Alloc, Free); { // MODES PLAYGROUND State->Modes.ActiveModesCount = 0; diff --git a/src/foldhaus_debug_visuals.h b/src/foldhaus_debug_visuals.h index 14e43e4..e9e313a 100644 --- a/src/foldhaus_debug_visuals.h +++ b/src/foldhaus_debug_visuals.h @@ -211,17 +211,9 @@ DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_c r32 FramesPerSecond = 1.0f / DeltaTime; - string ModeName = MakeStringLiteral("Base Mode"); - if (State->Modes.ActiveModesCount > 0 && - State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Name.Length > 0) - { - ModeName = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Name; - } - - PrintF(&DebugString, "Framerate: %.*f s %d fps | Current Mode: %.*s Modes: %d Memory Used: %d / %d | Commands: %d", + PrintF(&DebugString, "Framerate: %.*f s %d fps | Modes: %d Memory Used: %d / %d | Commands: %d", 5, DeltaTime, (u32)FramesPerSecond, - ModeName.Length, ModeName.Memory, State->Modes.ActiveModesCount, State->Modes.Arena.CurrentRegion->Used, State->Modes.Arena.CurrentRegion->Size, diff --git a/src/foldhaus_interface.cpp b/src/foldhaus_interface.cpp index a6ec563..21e2a86 100644 --- a/src/foldhaus_interface.cpp +++ b/src/foldhaus_interface.cpp @@ -113,7 +113,7 @@ input_command UniverseViewCommands [] = { FOLDHAUS_INPUT_COMMAND_PROC(OpenUniverseView) { - operation_mode* UniverseViewMode = ActivateOperationModeWithCommands(&State->Modes, "Universe View", UniverseViewCommands); + operation_mode* UniverseViewMode = ActivateOperationModeWithCommands(&State->Modes, UniverseViewCommands); UniverseViewMode->Render = RenderUniverseView; // State Setup @@ -183,7 +183,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(SelectAndCloseNodeLister) if (FilteredNodeIndex >= 0) { s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex]; - PushNodeOnListFromSpecification(State->NodeList, NodeSpecifications[NodeIndex], + PushNodeOnListFromSpecification(State->NodeList, (node_type)NodeIndex, Mouse.Pos, State->Permanent); } CloseNodeLister(State, Event, Mouse); @@ -200,7 +200,7 @@ input_command UniverseViewCommads [] = { FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister) { - operation_mode* AddNodeOperation = ActivateOperationModeWithCommands(&State->Modes, "Node Lister", UniverseViewCommads); + operation_mode* AddNodeOperation = ActivateOperationModeWithCommands(&State->Modes, UniverseViewCommads); AddNodeOperation->Render = RenderNodeLister; @@ -246,6 +246,11 @@ CloseColorPicker(app_state* State) DeactivateCurrentOperationMode(&State->Modes); } +FOLDHAUS_INPUT_COMMAND_PROC(CloseColorPickerCommand) +{ + CloseColorPicker(State); +} + OPERATION_RENDER_PROC(RenderColorPicker) { color_picker_operation_state* OpState = (color_picker_operation_state*)Operation.OpStateMemory; @@ -260,16 +265,20 @@ OPERATION_RENDER_PROC(RenderColorPicker) } } +input_command ColorPickerCommands [] = { + { KeyCode_Esc, KeyCode_Invalid, Command_Began, CloseColorPickerCommand }, +}; + internal void OpenColorPicker(app_state* State, node_connection* Connection) { - operation_mode* ColorPickerMode = ActivateOperationMode(&State->Modes, "Color Picker"); + operation_mode* ColorPickerMode = ActivateOperationModeWithCommands(&State->Modes, ColorPickerCommands); ColorPickerMode->Render = RenderColorPicker; color_picker_operation_state* OpState = CreateOperationState(ColorPickerMode, &State->Modes, color_picker_operation_state); - OpState->ValueAddr = &Connection->V4Value; + OpState->ValueAddr = Connection->V4ValuePtr; } @@ -294,10 +303,9 @@ internal void BeginNodeFieldTextEdit(app_state* State, node_connection* Connection) { operation_mode* NodeFieldTextEditMode = ActivateOperationModeWithCommands(&State->Modes, - "Node Field Text Edit", NodeFieldTextEditCommands); - SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value); + SetTextInputDestinationToFloat(&State->ActiveTextEntry, Connection->R32ValuePtr); } //////////////////////////////////////// @@ -335,7 +343,6 @@ BeginDraggingNodePort(app_state* State, node_interaction Interaction) { operation_mode* DragNodePortMode = ActivateOperationModeWithCommands( &State->Modes, - "Drag Node Port", DragNodePortInputCommands); DragNodePortMode->Render = RenderDraggingNodePort; @@ -395,7 +402,6 @@ BeginDraggingNode(app_state* State, node_interaction Interaction) { operation_mode* DragNodeMode = ActivateOperationModeWithCommands( &State->Modes, - "Drag Node", DragNodeInputCommands); DragNodeMode->Render = RenderDraggingNode; @@ -503,7 +509,8 @@ OPERATION_RENDER_PROC(RenderNodeView) // TODO(Peter): This is just for debug purposes. We can remove and go back to just having // Node->Name in DrawString - PrintF(&NodeHeaderBuffer, "%.*s: %d", Node->Name.Length, Node->Name.Memory, Node->Handle); + string NodeName = GetNodeName(*Node); + PrintF(&NodeHeaderBuffer, "%.*s: %d", NodeName.Length, NodeName.Memory, Node->Handle); DrawString(RenderBuffer, NodeHeaderBuffer, State->NodeRenderSettings.Font, v2{NodeBounds.Min.x + 5, NodeBounds.Max.y - (State->NodeRenderSettings.Font->PixelHeight + NODE_HEADER_HEIGHT + 5)}, WhiteV4); @@ -527,7 +534,7 @@ OPERATION_RENDER_PROC(RenderNodeView) // if (Node->Type != NodeType_OutputNode && DrawFields) { - node_specification Spec = NodeSpecifications[Node->Type - 1]; + node_specification Spec = NodeSpecifications[Node->Type]; node_struct_member Member = Spec.MemberList[Connection]; DrawString(RenderBuffer, MakeString(Member.Name), State->NodeRenderSettings.Font, @@ -558,7 +565,7 @@ OPERATION_RENDER_PROC(RenderNodeView) if (DrawFields) { - node_specification Spec = NodeSpecifications[Node->Type - 1]; + node_specification Spec = NodeSpecifications[Node->Type]; node_struct_member Member = Spec.MemberList[Connection]; DrawString(RenderBuffer, MakeString(Member.Name), State->NodeRenderSettings.Font, @@ -605,12 +612,13 @@ input_command NodeViewCommands [] = { FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeView) { - operation_mode* NodeViewMode = ActivateOperationModeWithCommands(&State->Modes, "Node View", NodeViewCommands); + operation_mode* NodeViewMode = ActivateOperationModeWithCommands(&State->Modes, NodeViewCommands); NodeViewMode->Render = RenderNodeView; node_view_operation_state* OpState = CreateOperationState(NodeViewMode, &State->Modes, node_view_operation_state); + OpState->SelectedNodeHandle = 0; } @@ -649,7 +657,7 @@ input_command MouseRotateViewCommands [] = { FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate) { - operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, "Rotate 3D View", MouseRotateViewCommands); + operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands); RotateViewMode->Render = Update3DViewMouseRotate; mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode, diff --git a/src/foldhaus_memory.h b/src/foldhaus_memory.h index 7dec4fb..61464af 100644 --- a/src/foldhaus_memory.h +++ b/src/foldhaus_memory.h @@ -122,11 +122,10 @@ PushSize_ (memory_arena* Arena, u32 Size) s32 RegionPagesNeeded = IntegerDivideRoundUp(SizeNeeded, MEMORY_REGION_PAGE_SIZE); s32 SizeToAllocate = RegionPagesNeeded * MEMORY_REGION_PAGE_SIZE; - platform_memory_result AllocResult = Arena->PlatformAlloc(SizeToAllocate); - Assert(AllocResult.Error == PLATFORM_MEMORY_NO_ERROR); - Assert(AllocResult.Size >= SizeNeeded); + u8* AllocResult = Arena->PlatformAlloc(SizeToAllocate); + Assert(AllocResult); - memory_region* NewRegion = BootstrapRegionOntoMemory(AllocResult.Base, AllocResult.Size); + memory_region* NewRegion = BootstrapRegionOntoMemory(AllocResult, SizeToAllocate); NewRegion->PreviousRegion = Arena->CurrentRegion; Arena->CurrentRegion = NewRegion; PushOntoRegion = Arena->CurrentRegion; @@ -177,11 +176,10 @@ AllocateNonGrowableArenaWithSpace(platform_alloc* PlatformAlloc, s32 SizeNeeded) memory_arena Result = {}; s32 AllocateSize = SizeNeeded + sizeof(memory_region); - platform_memory_result Memory = PlatformAlloc(AllocateSize); - Assert(Memory.Error == PLATFORM_MEMORY_NO_ERROR); - Assert(Memory.Size == AllocateSize); + u8* Memory = PlatformAlloc(AllocateSize); + Assert(Memory); - InitMemoryArena(&Result, Memory.Base, Memory.Size, 0); + InitMemoryArena(&Result, Memory, AllocateSize, 0); return Result; } diff --git a/src/foldhaus_node.cpp b/src/foldhaus_node.cpp index d219fa7..3768e2e 100644 --- a/src/foldhaus_node.cpp +++ b/src/foldhaus_node.cpp @@ -1,23 +1,12 @@ -inline s32 -GetNodeMemorySize(s32 ConnectionsCount) -{ - s32 Result = sizeof(node_header) + (sizeof(node_connection) * ConnectionsCount); - return Result; -} - -inline s32 -GetNodeMemorySize (node_header Node) -{ - return GetNodeMemorySize(Node.ConnectionsCount); -} - internal node_list_iterator GetNodeListIterator(node_list List) { node_list_iterator Result = {}; Result.List = List; Result.CurrentBuffer = List.First; - Result.At = (node_header*)Result.CurrentBuffer->Memory; + Result.At = Result.CurrentBuffer->Headers; + Result.TotalIndexAt = 0; + Result.BufferIndexAt = 0; return Result; } @@ -26,90 +15,106 @@ internal b32 NodeIteratorIsValid(node_list_iterator Iter) { b32 Result = (Iter.At != 0); - Result &= (((u8*)Iter.At - Iter.CurrentBuffer->Memory) < Iter.CurrentBuffer->Used); + Result &= Iter.TotalIndexAt < Iter.List.TotalUsed && Iter.TotalIndexAt >= 0; + Result &= Iter.BufferIndexAt < Iter.CurrentBuffer->Used && Iter.BufferIndexAt >= 0; return Result; } internal void Next (node_list_iterator* Iter) { - if (Iter->At->Handle == 0) + if (Iter->BufferIndexAt < Iter->CurrentBuffer->Used) { - node_free_list_member* FreeNode = (node_free_list_member*)Iter->At; - s32 SkipAmount = FreeNode->Size; - Iter->At = (node_header*)((u8*)Iter->At + SkipAmount); + Iter->At++; + Iter->TotalIndexAt++; + Iter->BufferIndexAt++; + if (Iter->At->Handle == 0) { Next(Iter); } + } + else if (Iter->CurrentBuffer->Next) + { + Iter->CurrentBuffer = Iter->CurrentBuffer->Next; + Iter->At = Iter->CurrentBuffer->Headers; + Iter->TotalIndexAt++; + Iter->BufferIndexAt = 0; + if (Iter->At->Handle == 0) { Next(Iter); } } else { - s32 SkipAmount = GetNodeMemorySize(*Iter->At); - if (((u8*)Iter->At - Iter->CurrentBuffer->Memory) + SkipAmount < Iter->CurrentBuffer->Used) - { - Iter->At = (node_header*)((u8*)Iter->At + SkipAmount); - if (Iter->At->Handle == 0) { Next(Iter); } - } - else if (Iter->CurrentBuffer->Next) - { - Iter->CurrentBuffer = Iter->CurrentBuffer->Next; - Iter->At = (node_header*)Iter->CurrentBuffer->Memory; - if (Iter->At->Handle == 0) { Next(Iter); } - } - else - { - Iter->At = 0; - } + Iter->At = 0; + Iter->TotalIndexAt = -1; + Iter->BufferIndexAt = -1; } } internal node_list_buffer* -AllocateNodeListBuffer (memory_arena* Storage, s32 Size) +AllocateNodeListBuffer (memory_arena* Storage, s32 Count) { node_list_buffer* Result = PushStruct(Storage, node_list_buffer);; - Result->Memory = PushSize(Storage, Size); - Result->Max = Size; + Result->Headers = PushArray(Storage, node_header, Count); + Result->Max = Count; Result->Used = 0; Result->Next = 0; return Result; } internal node_list* -AllocateNodeList (memory_arena* Storage, s32 InitialSize) +AllocateNodeList (memory_arena* Storage, s32 InitialCount) { node_list* Result = PushStruct(Storage, node_list); - Result->First = AllocateNodeListBuffer(Storage, InitialSize); + Result->First = AllocateNodeListBuffer(Storage, InitialCount); Result->Head = Result->First; - Result->TotalMax = InitialSize; + Result->TotalMax = InitialCount; Result->TotalUsed = 0; Result->HandleAccumulator = 0; return Result; } +global_variable char* OutputName = "Output"; + +internal string +GetNodeName (node_header Node) +{ + string Result = {}; + + node_specification Spec = NodeSpecifications[Node.Type]; + Result = MakeString(Spec.Name, Spec.NameLength); + + return Result; +} + internal node_header* PushNodeOnList (node_list* List, s32 ConnectionsCount, v2 Min, v2 Dim, memory_arena* Storage) { node_header* Result = 0; - s32 NodeMemorySize = GetNodeMemorySize(ConnectionsCount); - - if (List->TotalUsed + NodeMemorySize >= List->TotalMax) + if ((List->TotalUsed + 1) >= List->TotalMax) { node_list_buffer* Buf = AllocateNodeListBuffer(Storage, List->Head->Max); List->Head->Next = Buf; List->Head = Buf; List->TotalMax += Buf->Max; } - Assert(List->TotalUsed + NodeMemorySize <= List->TotalMax); + Assert(List->TotalUsed + 1 <= List->TotalMax); - Result = (node_header*)(List->Head->Memory + List->Head->Used); + Result = List->Head->Headers + List->Head->Used; Result->Handle = ++List->HandleAccumulator; + // :ConnectionsToStretchyBuffer + Assert(List->ConnectionsUsed + ConnectionsCount < NODE_LIST_CONNECTIONS_MAX); Result->ConnectionsCount = ConnectionsCount; - Result->Connections = (node_connection*)(Result + 1); + Result->Connections = (node_connection*)(List->Connections + List->ConnectionsUsed); + List->ConnectionsUsed += ConnectionsCount; + + for (s32 c = 0; c < Result->ConnectionsCount; c++) + { + Result->Connections[c].NodeHandle = Result->Handle; + } Result->Min = Min; Result->Dim = Dim; - List->Head->Used += NodeMemorySize; - List->TotalUsed += NodeMemorySize; + List->Head->Used++; + List->TotalUsed++; return Result; } @@ -121,38 +126,42 @@ FreeNodeOnList (node_list* List, node_header* Node) } internal void -InitializeNodeConnection (node_connection* Connection, struct_member_type Type, b32 DirectionMask) +InitializeNodeConnection (node_connection* Connection, node_struct_member Member, node_header* Node) { - Connection->Type = Type; + Connection->Type = Member.Type; Connection->UpstreamNodeHandle = 0; Connection->UpstreamNodePortIndex = -1; Connection->DownstreamNodeHandle = 0; Connection->DownstreamNodePortIndex = -1; - Connection->DirectionMask = DirectionMask; - switch (Type) + Connection->DirectionMask = Member.IsInput; + + Connection->Ptr = Node->PersistentData + Member.Offset; + + switch (Member.Type) { case MemberType_s32: { - Connection->S32Value = 0; + *Connection->S32ValuePtr = 0; }break; case MemberType_r32: { - Connection->R32Value = 0; + *Connection->R32ValuePtr = 0; }break; case MemberType_v4: { - Connection->V4Value = v4{0, 0, 0, 1}; + *Connection->V4ValuePtr = v4{0, 0, 0, 1}; }break; case MemberType_NODE_COLOR_BUFFER: { - Connection->LEDsValue = {}; + *Connection->LEDsValuePtr = {}; }break; InvalidDefaultCase; } + } inline r32 @@ -162,51 +171,38 @@ CalculateNodeHeight (s32 Members) return Result; } -internal void -PushNodeOnListFromSpecification (node_list* List, node_specification Spec, v2 Min, memory_arena* Storage) +internal node_header* +PushNodeOnListFromSpecification (node_list* List, node_type Type, v2 Min, memory_arena* Storage) { + node_header* Node = 0; + + node_specification Spec = NodeSpecifications[Type]; + // :NodesDontNeedToKnowTheirBounds r32 NodeHeight = CalculateNodeHeight (Spec.MemberListLength); - node_header* Node = PushNodeOnList(List, - Spec.MemberListLength, - Min, - v2{150, NodeHeight}, - Storage); - Node->Type = Spec.Type; - - // TODO(Peter): This doesn't work with code reloading, probably just want to store the spec index - // we'll get there - // :HotCodeReloading - Node->Name = MakeString(Spec.Name, Spec.NameLength); + Node = PushNodeOnList(List, + Spec.MemberListLength, + Min, + v2{150, NodeHeight}, + Storage); + Node->Type = Type; + Node->PersistentData = PushArray(Storage, u8, Spec.DataStructSize); node_struct_member* MemberList = Spec.MemberList; for (s32 MemberIdx = 0; MemberIdx < Spec.MemberListLength; MemberIdx++) { node_struct_member Member = MemberList[MemberIdx]; - InitializeNodeConnection(Node->Connections + MemberIdx, Member.Type, Member.IsInput); + InitializeNodeConnection(Node->Connections + MemberIdx, Member, Node); } - Node->PersistentData = PushArray(Storage, u8, Spec.DataStructSize); + return Node; } -global_variable char* OutputName = "Output"; - internal node_header* PushOutputNodeOnList (node_list* List, v2 Min, memory_arena* Storage) { - node_header* Node = PushNodeOnList(List, - 1, - Min, - DEFAULT_NODE_DIMENSION, - Storage); - Node->Type = NodeType_OutputNode; - - // :HotCodeReloading - Node->Name = MakeString(OutputName); - - InitializeNodeConnection(Node->Connections, MemberType_NODE_COLOR_BUFFER, IsInputMember); - - return Node; + node_header* Result = PushNodeOnListFromSpecification(List, NodeType_OutputNode, Min, Storage); + return Result; } internal node_header* @@ -804,12 +800,12 @@ UpdateDraggingNodeValue (v2 MousePos, v2 LastFrameMousePos, node_interaction Int { case MemberType_s32: { - Connection->S32Value += (s32)(MouseDelta.y * .05f); + *Connection->S32ValuePtr += (s32)(MouseDelta.y * .05f); }break; case MemberType_r32: { - Connection->R32Value += (MouseDelta.y * .05f); + *Connection->R32ValuePtr += (MouseDelta.y * .05f); }break; case MemberType_v4: @@ -846,26 +842,29 @@ UpdateNodesConnectedUpstream (node_header* Node, node_list* NodeList, { UpdateNodeCalculation(UpstreamNode, NodeList, Permanent, Transient, LEDs, ColorsInit, LEDCount, DeltaTime); } + + node_connection UpstreamConnection = UpstreamNode->Connections[Connection->UpstreamNodePortIndex]; + switch (Connection->Type) { case MemberType_s32: { - Connection->S32Value = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].S32Value; + *Connection->S32ValuePtr = *UpstreamConnection.S32ValuePtr; }break; case MemberType_r32: { - Connection->R32Value = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].R32Value; + *Connection->R32ValuePtr = *UpstreamConnection.R32ValuePtr; }break; case MemberType_v4: { - Connection->V4Value = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].V4Value; + *Connection->V4ValuePtr = *UpstreamConnection.V4ValuePtr; }break; case MemberType_NODE_COLOR_BUFFER: { - Connection->LEDsValue = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].LEDsValue; + *Connection->LEDsValuePtr = *UpstreamConnection.LEDsValuePtr; }break; InvalidDefaultCase; @@ -882,10 +881,11 @@ UpdateNodeCalculation (node_header* Node, node_list* NodeList, { DEBUG_TRACK_FUNCTION; Assert(Node->PersistentData != 0); + Assert(Node->Type != NodeType_OutputNode); // NOTE(Peter): Have to subtract one here so that we account for the // NodeType_OutputNode entry in the enum - node_specification Spec = NodeSpecifications[Node->Type - 1]; + node_specification Spec = NodeSpecifications[Node->Type]; node_struct_member* MemberList = Spec.MemberList; // NOTE(Peter): We do this at the beginning in case there is a node connected to this one @@ -907,40 +907,15 @@ UpdateNodeCalculation (node_header* Node, node_list* NodeList, // needs the leds to request that as its own member/parameter. if (Connection.Type == MemberType_NODE_COLOR_BUFFER) { - node_led_color_connection* ColorConnection = (node_led_color_connection*)(Node->PersistentData + MemberList[ConnectionIdx].Offset); - - ColorConnection->LEDs = LEDs; - ColorConnection->LEDCount = LEDCount; - ColorConnection->Colors = Connection.LEDsValue.Colors; - + node_led_color_connection* ColorConnection = Connection.LEDsValuePtr; if (!ColorConnection->Colors) { sacn_pixel* ColorsCopy = PushArray(Transient, sacn_pixel, LEDCount); GSMemSet((u8*)ColorsCopy, 0, sizeof(sacn_pixel) * LEDCount); + ColorConnection->Colors = ColorsCopy; - } - } - else if (ConnectionIsInput(Connection)) - { - Assert(Connection.Type != MemberType_NODE_COLOR_BUFFER); - switch (Connection.Type) - { - case MemberType_s32: - { - GSMemCopy(&Connection.S32Value, (Node->PersistentData + MemberList[ConnectionIdx].Offset), sizeof(s32)); - }break; - - case MemberType_r32: - { - GSMemCopy(&Connection.R32Value, (Node->PersistentData + MemberList[ConnectionIdx].Offset), sizeof(r32)); - }break; - - case MemberType_v4: - { - GSMemCopy(&Connection.V4Value, (Node->PersistentData + MemberList[ConnectionIdx].Offset), sizeof(v4)); - }break; - - InvalidDefaultCase; + ColorConnection->LEDs = LEDs; + ColorConnection->LEDCount = LEDCount; } } } @@ -949,41 +924,8 @@ UpdateNodeCalculation (node_header* Node, node_list* NodeList, for (s32 ConnectionIdx = 0; ConnectionIdx < Node->ConnectionsCount; ConnectionIdx++) { - node_connection* Connection = 0; - if (ConnectionIsOutput(Node, ConnectionIdx)) - { - Connection = Node->Connections + ConnectionIdx; - } - else - { - continue; - } - - switch (Connection->Type) - { - case MemberType_s32: - { - GSMemCopy((Node->PersistentData + MemberList[ConnectionIdx].Offset), &Connection->S32Value, sizeof(s32)); - }break; - - case MemberType_r32: - { - GSMemCopy((Node->PersistentData + MemberList[ConnectionIdx].Offset), &Connection->R32Value, sizeof(r32)); - }break; - - case MemberType_v4: - { - GSMemCopy((Node->PersistentData + MemberList[ConnectionIdx].Offset), &Connection->V4Value, sizeof(v4)); - }break; - - case MemberType_NODE_COLOR_BUFFER: - { - node_led_color_connection* Value = (node_led_color_connection*)(Node->PersistentData + MemberList[ConnectionIdx].Offset); - Connection->LEDsValue.Colors = Value->Colors; - }break; - - InvalidDefaultCase; - } + if (!ConnectionIsOutput(Node, ConnectionIdx)) { continue; } + node_connection* Connection = Node->Connections + ConnectionIdx; } } @@ -993,13 +935,14 @@ UpdateOutputNodeCalculations (node_header* OutputNode, node_list* NodeList, led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime) { Assert(OutputNode->Type == NodeType_OutputNode); + UpdateNodesConnectedUpstream(OutputNode, NodeList, Permanent, Transient, LEDs, Colors, LEDCount, DeltaTime); node_connection ColorsConnection = OutputNode->Connections[0]; - if (ColorsConnection.LEDsValue.Colors) + if (ColorsConnection.LEDsValuePtr->Colors) { sacn_pixel* DestPixel = Colors; - sacn_pixel* SourcePixel = ColorsConnection.LEDsValue.Colors; + sacn_pixel* SourcePixel = ColorsConnection.LEDsValuePtr->Colors; for (s32 i = 0; i < LEDCount; i++) { *DestPixel++ = *SourcePixel++; @@ -1007,6 +950,53 @@ UpdateOutputNodeCalculations (node_header* OutputNode, node_list* NodeList, } } +#if 0 +// Trying to put updating nodes in terms of connections, rather than nodes. +internal void +UpdateAllNodesFloodFill (node_list* NodeList, memory_arena* Permanent, memory_arena* Transient, led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime) +{ + s32 NodesUpdated = 0; + + s32 DEBUGIterations = 0; + while(NodesUpdated < NodeList->TotalUsed) + { + node_list_iterator NodeIter = GetNodeListIterator(*NodeList); + while (NodeIteratorIsValid(NodeIter)) + { + node_header* Node = NodeIter.At; + + s32 ConnectionsReady = 0; + // Check if all upstream connections have been updated + // TODO(Peter): we should move the HasBeenUpdated field into the connections + // and have connections push their updates upstream + for (s32 c = 0; c < Node->ConnectionsCount; c++) + { + node_connection* Connection = Node->Connections + c; + if (ConnectionIsInput(*Connection) && + ConnectionHasUpstreamConnection(*Connection)) + { + node_header* UpstreamNode = GetNodeWithHandle(NodeList, Connection->UpstreamNodeHandle); + if (UpstreamNode->UpdatedThisFrame) + { + ConnectionsReady += 1; + } + else + { + break; + } + } + } + + if (ConnectionsReady == Node->ConnectionsCount) + { + + } + } + DEBUGIterations++; + } +} +#endif + internal void UpdateAllNodeCalculations (node_list* NodeList, memory_arena* Permanent, memory_arena* Transient, led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime) { @@ -1034,7 +1024,7 @@ ClearTransientNodeColorBuffers (node_list* NodeList) node_connection* Connection = Node->Connections + ConnectionIdx; if (Connection->Type == MemberType_NODE_COLOR_BUFFER) { - Connection->LEDsValue.Colors = 0; + Connection->LEDsValuePtr->Colors = 0; } } Next(&NodeIter); @@ -1053,19 +1043,19 @@ DrawValueDisplay (render_command_buffer* RenderBuffer, rect Bounds, node_connect { case MemberType_s32: { - PrintF(&String, "%.*d", 4, Value.S32Value); + PrintF(&String, "%.*d", 4, *Value.S32ValuePtr); DrawString(RenderBuffer, String, Font, Bounds.Min + v2{2, 2}, WhiteV4); }break; case MemberType_r32: { - PrintF(&String, "%.*f", 4, Value.R32Value); + PrintF(&String, "%.*f", 4, *Value.R32ValuePtr); DrawString(RenderBuffer, String, Font, Bounds.Min + v2{2, 2}, WhiteV4); }break; case MemberType_v4: { - PushRenderQuad2D(RenderBuffer, Bounds.Min + v2{2, 2}, Bounds.Max - v2{2, 2}, Value.V4Value); + PushRenderQuad2D(RenderBuffer, Bounds.Min + v2{2, 2}, Bounds.Max - v2{2, 2}, *Value.V4ValuePtr); }break; case MemberType_NODE_COLOR_BUFFER: diff --git a/src/foldhaus_node.h b/src/foldhaus_node.h index a4dc8c8..60b7726 100644 --- a/src/foldhaus_node.h +++ b/src/foldhaus_node.h @@ -64,10 +64,11 @@ struct node_connection union { - s32 S32Value; - r32 R32Value; - v4 V4Value; - node_led_color_connection LEDsValue; + u8* Ptr; + s32* S32ValuePtr; + r32* R32ValuePtr; + v4* V4ValuePtr; + node_led_color_connection* LEDsValuePtr; }; }; @@ -77,19 +78,19 @@ struct node_connection struct node_header { s32 Handle; // NOTE(Peter): stores a non-zero handle. must come first to match node_free_list_member - string Name; + node_type Type; v2 Min, Dim; s32 ConnectionsCount; node_connection* Connections; - node_type Type; b32 UpdatedThisFrame; u8* PersistentData; }; +// TODO(Peter): @Remove Confirm we don't need it first struct node_free_list_member { s32 Handle; // NOTE(Peter): this will always be zero, and must come first to match node_header @@ -100,7 +101,7 @@ struct node_free_list_member struct node_list_buffer { - u8* Memory; + node_header* Headers; s32 Max; s32 Used; @@ -117,6 +118,8 @@ struct node_list s32 HandleAccumulator; + // TODO(Peter): Replace this with some sort of stretchy bufferf + // :ConnectionsToStretchyBuffer s32 ConnectionsUsed; node_connection Connections[NODE_LIST_CONNECTIONS_MAX]; }; @@ -126,6 +129,8 @@ struct node_list_iterator node_list List; node_list_buffer* CurrentBuffer; node_header* At; + s32 BufferIndexAt; + s32 TotalIndexAt; }; enum node_interaction_flag @@ -206,3 +211,17 @@ void proc_name(input_type* Data, r32 DeltaTime) #define NODE_IN(type, name) type name #define NODE_OUT(type, name) type name + +/////////////////////////////////////////////// +// OUTPUT NODE +/////////////////////////////////////////////// + +NODE_STRUCT(output_node_data) +{ + NODE_COLOR_BUFFER_IN(Result); +}; + +NODE_PROC(OutputNode, output_node_data) +{ + +} diff --git a/src/foldhaus_node_gui.h b/src/foldhaus_node_gui.h new file mode 100644 index 0000000..a70cf74 --- /dev/null +++ b/src/foldhaus_node_gui.h @@ -0,0 +1,13 @@ +struct gui_node +{ + s32 Handle; + node_type Type; + v2 Min, Dim; +}; + +#define GUI_NODES_MAX 256 +struct gui_node_list +{ + s32 NodesUsed; + gui_node Nodes[GUI_NODES_MAX]; +}; diff --git a/src/foldhaus_operation_mode.h b/src/foldhaus_operation_mode.h index 8bf7ae6..ef7d043 100644 --- a/src/foldhaus_operation_mode.h +++ b/src/foldhaus_operation_mode.h @@ -8,8 +8,6 @@ struct operation_mode input_command_registry Commands; operation_render_proc* Render; u8* OpStateMemory; - - string Name; }; #define OPERATION_MODES_MAX 32 @@ -25,7 +23,7 @@ struct operation_mode_system }; internal operation_mode* -ActivateOperationMode (operation_mode_system* System, char* ModeName) +ActivateOperationMode (operation_mode_system* System) { Assert(System->ActiveModesCount < OPERATION_MODES_MAX); s32 ModeIndex = System->ActiveModesCount++; @@ -33,21 +31,18 @@ ActivateOperationMode (operation_mode_system* System, char* ModeName) System->ModeMemorySnapshots[ModeIndex] = TakeSnapshotOfArena(System->Arena); operation_mode NewMode = {}; - s32 NameLength = CharArrayLength(ModeName); - NewMode.Name = MakeString(PushArray(&System->Arena, char, NameLength), 0, NameLength); - CopyCharArrayToString(ModeName, &NewMode.Name); System->ActiveModes[ModeIndex] = NewMode; return &System->ActiveModes[ModeIndex]; } -#define ActivateOperationModeWithCommands(sys, name, cmds) \ -ActivateOperationModeWithCommands_(sys, name, cmds, (s32)(sizeof(cmds) / sizeof(cmds[0]))); +#define ActivateOperationModeWithCommands(sys, cmds) \ +ActivateOperationModeWithCommands_(sys, cmds, (s32)(sizeof(cmds) / sizeof(cmds[0]))); internal operation_mode* -ActivateOperationModeWithCommands_(operation_mode_system* System, char* ModeName, input_command* Commands, s32 CommandsCount) +ActivateOperationModeWithCommands_(operation_mode_system* System, input_command* Commands, s32 CommandsCount) { - operation_mode* NewMode = ActivateOperationMode(System, ModeName); + operation_mode* NewMode = ActivateOperationMode(System); InitializeInputCommandRegistry(&NewMode->Commands, CommandsCount, &System->Arena); for (s32 i = 0; i < CommandsCount; i++) diff --git a/src/foldhaus_platform.h b/src/foldhaus_platform.h index c71f92e..f927a2a 100644 --- a/src/foldhaus_platform.h +++ b/src/foldhaus_platform.h @@ -7,6 +7,9 @@ global_variable debug_services* GlobalDebugServices; +global_variable platform_alloc* GSAlloc; +global_variable platform_free* GSFree; + #include "gs_vector_matrix.h" #include "gs_input.h" @@ -19,13 +22,13 @@ typedef struct context context; // Application Functions -#define INITIALIZE_APPLICATION(name) void name(context Context) +#define INITIALIZE_APPLICATION(name) void name(context Context, platform_alloc* Alloc, platform_free* Free) typedef INITIALIZE_APPLICATION(initialize_application); #define UPDATE_AND_RENDER(name) void name(context Context, input_queue InputQueue, mouse_state Mouse, render_command_buffer* RenderBuffer) typedef UPDATE_AND_RENDER(update_and_render); -#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices) +#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices, platform_alloc* Alloc, platform_free* Free) typedef RELOAD_STATIC_DATA(reload_static_data); #define CLEANUP_APPLICATION(name) void name(context Context) diff --git a/src/foldhaus_sacn.h b/src/foldhaus_sacn.h index 689ccb3..8d90d72 100644 --- a/src/foldhaus_sacn.h +++ b/src/foldhaus_sacn.h @@ -90,6 +90,13 @@ struct sacn_universe platform_network_address_handle SendAddress; }; +struct sacn_pixel +{ + u8 R; + u8 G; + u8 B; +}; + struct sacn_send_buffer { u8* Memory; @@ -132,13 +139,6 @@ internal cid StringToCID_ (const char* String); // Utility -struct sacn_pixel -{ - u8 R; - u8 G; - u8 B; -}; - internal sacn_pixel PackFloatsToSACNPixel (r32 R, r32 G, r32 B) { @@ -246,6 +246,7 @@ struct sacn_add_universes_result sacn_send_buffer* NewSendBuffer; sacn_universe_buffer* NewUniverseBuffer; }; + internal sacn_add_universes_result SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, context Context) { @@ -270,7 +271,8 @@ SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, conte } } - // Push On New Send and Universe Buffers + // Reallocate and Copy over the send buffer + s32 SendBufferSize = CalculateSendBufferSize(UniversesToAdd); u8* SendBufferMemory = PushArray(&SACN->Memory, u8, SendBufferSize); sacn_send_buffer* SendBufferHeader = (sacn_send_buffer*)SendBufferMemory; @@ -334,12 +336,6 @@ SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, conte HostToNetU16(DEFAULT_STREAMING_ACN_PORT), HostToNetU32(V4Address)); -#if 0 // Old Net Code - UniverseBufferHeader->Universes[Index].SendAddress.sin_family = AF_INET; - UniverseBufferHeader->Universes[Index].SendAddress.sin_port = HostToNetU16(DEFAULT_STREAMING_ACN_PORT); - UniverseBufferHeader->Universes[Index].SendAddress.sin_addr.s_addr = HostToNetU32(V4Address); -#endif - s32 SlotCount = 512; InitStreamHeader(UniverseBufferHeader->Universes[Index].StartPositionInSendBuffer, UniverseBufferHeader->Universes[Index].SizeInSendBuffer, diff --git a/src/generated/foldhaus_nodes_generated.cpp b/src/generated/foldhaus_nodes_generated.cpp index 2945e79..5e06e73 100644 --- a/src/generated/foldhaus_nodes_generated.cpp +++ b/src/generated/foldhaus_nodes_generated.cpp @@ -1,12 +1,12 @@ enum node_type { -NodeType_OutputNode, NodeType_FloatValue, NodeType_VectorValue, NodeType_MultiplyNodeProc, NodeType_AddNodeProc, NodeType_SinWave, NodeType_MultiplyPatterns, +NodeType_OutputNode, NodeType_SwdColorProc, NodeType_SolidColorProc, NodeType_VerticalColorFadeProc, @@ -52,6 +52,10 @@ node_struct_member MemberList_multiply_patterns_data[] = { { MemberType_NODE_COLOR_BUFFER, "ResultLEDs", (u64)&((multiply_patterns_data*)0)->ResultLEDs, IsOutputMember}, }; +node_struct_member MemberList_output_node_data[] = { +{ MemberType_NODE_COLOR_BUFFER, "ResultLEDs", (u64)&((output_node_data*)0)->ResultLEDs, IsInputMember }, +}; + node_struct_member MemberList_swd_color_data[] = { { MemberType_v4, "Color", (u64)&((swd_color_data*)0)->Color, IsInputMember }, { MemberType_v4, "ColorB", (u64)&((swd_color_data*)0)->ColorB, IsInputMember }, @@ -88,16 +92,18 @@ node_specification NodeSpecifications[] = { { NodeType_AddNodeProc, "AddNodeProc", 11, MemberList_add_data, 48, 3, false}, { NodeType_SinWave, "SinWave", 7, MemberList_sin_wave_data, 20, 4, false}, { NodeType_MultiplyPatterns, "MultiplyPatterns", 16, MemberList_multiply_patterns_data, 60, 3, false}, +{ NodeType_OutputNode, "OutputNode", 10, MemberList_output_node_data, 20, 1, false}, { NodeType_SwdColorProc, "SwdColorProc", 12, MemberList_swd_color_data, 52, 3, false}, { NodeType_SolidColorProc, "SolidColorProc", 14, MemberList_solid_color_data, 36, 2, false}, { NodeType_VerticalColorFadeProc, "VerticalColorFadeProc", 21, MemberList_vertical_color_fade_data, 44, 4, false}, { NodeType_RevolvingDiscs, "RevolvingDiscs", 14, MemberList_revolving_discs_data, 60, 8, false}, }; -s32 NodeSpecificationsCount = 10; +s32 NodeSpecificationsCount = 11; internal void CallNodeProc(node_header* Node, u8* Data, led* LEDs, s32 LEDsCount, r32 DeltaTime) { -switch (Node->Type) +node_specification Spec = NodeSpecifications[Node->Type]; +switch (Spec.Type) { case NodeType_FloatValue: { FloatValue((float_value_data*)Data, DeltaTime); } break; case NodeType_VectorValue: { VectorValue((vector_data*)Data, DeltaTime); } break; @@ -105,6 +111,7 @@ case NodeType_MultiplyNodeProc: { MultiplyNodeProc((multiply_data*)Data, DeltaTi case NodeType_AddNodeProc: { AddNodeProc((add_data*)Data, DeltaTime); } break; case NodeType_SinWave: { SinWave((sin_wave_data*)Data, DeltaTime); } break; case NodeType_MultiplyPatterns: { MultiplyPatterns((multiply_patterns_data*)Data, DeltaTime); } break; +case NodeType_OutputNode: { OutputNode((output_node_data*)Data, DeltaTime); } break; case NodeType_SwdColorProc: { SwdColorProc((swd_color_data*)Data, DeltaTime); } break; case NodeType_SolidColorProc: { SolidColorProc((solid_color_data*)Data, DeltaTime); } break; case NodeType_VerticalColorFadeProc: { VerticalColorFadeProc((vertical_color_fade_data*)Data, DeltaTime); } break; diff --git a/src/gs_platform.h b/src/gs_platform.h index 2e525b6..332d349 100644 --- a/src/gs_platform.h +++ b/src/gs_platform.h @@ -69,7 +69,7 @@ struct system_path s32 IndexOfLastSlash; }; -#define PLATFORM_ALLOC(name) platform_memory_result name(s32 Size) +#define PLATFORM_ALLOC(name) u8* name(s32 Size) typedef PLATFORM_ALLOC(platform_alloc); #define PLATFORM_FREE(name) b32 name(u8* Base, s32 Size) diff --git a/src/gs_win32.cpp b/src/gs_win32.cpp index 7028457..9b1277e 100644 --- a/src/gs_win32.cpp +++ b/src/gs_win32.cpp @@ -595,19 +595,7 @@ Win32BasicAlloc (s32 Size) PLATFORM_ALLOC(Win32Alloc) { - platform_memory_result Result = {}; - Result.Error = PLATFORM_MEMORY_NO_ERROR; - - Result.Base = Win32BasicAlloc(Size); - if (Result.Base) - { - Result.Size = Size; - } - else - { - Result.Error = 1; - } - + u8* Result = Win32BasicAlloc(Size); return Result; } diff --git a/src/win32_foldhaus.cpp b/src/win32_foldhaus.cpp index 422dd55..3877ac5 100644 --- a/src/win32_foldhaus.cpp +++ b/src/win32_foldhaus.cpp @@ -136,10 +136,10 @@ PLATFORM_GET_SOCKET_HANDLE(Win32GetSocketHandle) { s32 NewDictionaryMax = Win32SocketHandleMax + SOCKET_DICTIONARY_GROW_SIZE; s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(win32_socket); - platform_memory_result DictionaryMemory = Win32Alloc(NewDictionaryDataSize); - Assert(DictionaryMemory.Size > 0); + u8* DictionaryMemory = Win32Alloc(NewDictionaryDataSize); + Assert(DictionaryMemory); - win32_socket* NewValues = (win32_socket*)(DictionaryMemory.Base); + win32_socket* NewValues = (win32_socket*)(DictionaryMemory); if (SocketValues) { GSMemCopy(SocketValues, NewValues, sizeof(win32_socket) * NewDictionaryMax); @@ -169,10 +169,10 @@ PLATFORM_GET_SEND_ADDRESS_HANDLE(Win32GetSendAddress) { s32 NewDictionaryMax = Win32NetworkAddressHandleMax + NETWORK_ADDRESS_DICTIONARY_GROW_SIZE; s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(sockaddr_in); - platform_memory_result DictionaryMemory = Win32Alloc(NewDictionaryDataSize); - Assert(DictionaryMemory.Size > 0); + u8* DictionaryMemory = Win32Alloc(NewDictionaryDataSize); + Assert(DictionaryMemory); - sockaddr_in* NewValues = (sockaddr_in*)(DictionaryMemory.Base); + sockaddr_in* NewValues = (sockaddr_in*)(DictionaryMemory); if (NetworkAddressValues) { GSMemCopy(NetworkAddressValues, NewValues, sizeof(win32_socket) * NewDictionaryMax); @@ -556,7 +556,7 @@ INT NCmdShow input_queue InputQueue; { s32 InputQueueMemorySize = sizeof(input_entry) * 32; - u8* InputQueueMemory = Win32Alloc(InputQueueMemorySize).Base; + u8* InputQueueMemory = Win32Alloc(InputQueueMemorySize); InputQueue = InitializeInputQueue(InputQueueMemory, InputQueueMemorySize); Mouse = {0, 0}; @@ -589,10 +589,11 @@ INT NCmdShow WorkerThreads[i].Handle = CreateThread(0, 0, &WorkerThreadProc, (void*)&WorkerThreads[i], 0, 0); } - platform_memory_result InitialMemory = Win32Alloc(Megabytes(64)); + s32 InitialMemorySize = Megabytes(64); + u8* InitialMemory = Win32Alloc(InitialMemorySize); context Context = {}; - Context.MemorySize = InitialMemory.Size; - Context.MemoryBase = InitialMemory.Base; + Context.MemorySize = InitialMemorySize; + Context.MemoryBase = InitialMemory; Context.WindowWidth = MainWindow.Width; Context.WindowHeight = MainWindow.Height; @@ -615,7 +616,7 @@ INT NCmdShow if (HotLoadDLL(&DLLRefresh)) { SetApplicationLinks(&Context, DLLRefresh, &WorkQueue); - Context.ReloadStaticData(Context, GlobalDebugServices); + Context.ReloadStaticData(Context, GlobalDebugServices, Win32BasicAlloc, Win32Free); } else { @@ -625,10 +626,11 @@ INT NCmdShow WSADATA WSAData; WSAStartup(MAKEWORD(2, 2), &WSAData); - platform_memory_result RenderMemory = Win32Alloc(Megabytes(12)); - render_command_buffer RenderBuffer = AllocateRenderCommandBuffer(RenderMemory.Base, RenderMemory.Size, Win32Realloc); + s32 RenderMemorySize = Megabytes(12); + u8* RenderMemory = Win32Alloc(RenderMemorySize); + render_command_buffer RenderBuffer = AllocateRenderCommandBuffer(RenderMemory, RenderMemorySize, Win32Realloc); - Context.InitializeApplication(Context); + Context.InitializeApplication(Context, Win32BasicAlloc, Win32Free); Running = true; Context.WindowIsVisible = true; @@ -644,7 +646,7 @@ INT NCmdShow if (HotLoadDLL(&DLLRefresh)) { SetApplicationLinks(&Context, DLLRefresh, &WorkQueue); - Context.ReloadStaticData(Context, GlobalDebugServices); + Context.ReloadStaticData(Context, GlobalDebugServices, Win32BasicAlloc, Win32Free); } { // Mouse Position diff --git a/todo.txt b/todo.txt index f454fc1..fc45d31 100644 --- a/todo.txt +++ b/todo.txt @@ -7,11 +7,19 @@ BUGS - Typing a period into a float value doesn't register. Problem here is that we arent' translating key presses into characters at the win32 layer. Need to do that. Switch To Nodes +x output should generate a node_specification +x go back to calling SpecificationIndex Type +- BUG: Connect a solid color node to output then try and pick a color. I think temporary node buffers are +- overwriting other data when they get evaluated. Bigger solution is to create a system of working +- led buffers that get assigned to nodes as needed. +- gonna need to remove output node from the node lister - delete nodes - - Simplify node storage - x don't pull node names into the struct, just reference the specification -- - separate storage of node headers from connections +- x separate storage of node headers from connections - - investigate if node connections can be operated on separately from the node headers +- - UpdatedThisFrame can probably go into each connection +- x connections shouldn't store their own values, they should just point into permanent storage - - Allow insertion/deletion within connection table - - Allow inerstion/deletion within header table - - maintain free list of connections and headers