added documentation to all files

This commit is contained in:
Peter Slattery 2020-01-01 18:41:43 -08:00
parent 2ab7ff1194
commit 0164fea691
48 changed files with 960 additions and 336 deletions

View File

@ -1,9 +1,16 @@
//
// File: foldhaus_animation.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
// TODO
// [] - animation blending
// [] - delete a layer
// [] - will need a way to create an empty layer
// [] - get a list of all animation procs
#ifndef FOLDHAUS_ANIMATION
#define ANIMATION_PROC(name) void name(assembly* Assembly, r32 Time)
typedef ANIMATION_PROC(animation_proc);
@ -33,3 +40,6 @@ struct animation_system
r32 AnimationStart;
r32 AnimationEnd;
};
#define FOLDHAUS_ANIMATION
#endif // FOLDHAUS_ANIMATION

View File

@ -1 +1,10 @@
//
// File: artnet.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
/* For future artnet implementation */
#ifndef ARTNET_H
#define ARTNET_H
#endif // ARTNET_H

View File

@ -1,3 +1,10 @@
//
// File: assembly_parser.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef ASSEMBLY_PARSER_CPP
internal assembly_token
ParseToken (tokenizer* Tokenizer)
@ -222,3 +229,6 @@ ParseAssemblyFile (u8* FileBase, s32 FileSize, memory_arena* Arena)
return AssemblyDefinition;
}
#define ASSEMBLY_PARSER_CPP
#endif // ASSEMBLY_PARSER_CPP

View File

@ -1,3 +1,10 @@
//
// File: assembly_parser.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef ASSEMBLY_PARSER_H
#define LED_STRIP_COUNT_IDENTIFIER "led_strip_count"
#define LED_STRIP_IDENTIFIER "led_strip"
@ -59,3 +66,6 @@ struct assembly_definition
s32 TotalLEDCount;
led_strip_definition* LEDStrips;
};
#define ASSEMBLY_PARSER_H
#endif // ASSEMBLY_PARSER_H

View File

@ -1,3 +1,10 @@
//
// File: DMX_H
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef DMX_H
struct dmx_buffer
{
s32 Universe;
@ -45,3 +52,6 @@ DMXBufferListAppend (dmx_buffer_list* AppendTo, dmx_buffer_list* Append)
return Result;
}
#define DMX_H
#endif // DMX_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_app.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_APP_CPP
#include "foldhaus_platform.h"
#include "foldhaus_app.h"
@ -422,3 +429,6 @@ CLEANUP_APPLICATION(CleanupApplication)
app_state* State = (app_state*)Context.MemoryBase;
SACNCleanup(&State->SACN, Context);
}
#define FOLDHAUS_APP_CPP
#endif // FOLDHAUS_APP_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_app.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_APP_H
#include "../meta/gs_meta_lexer.h"
#include "gs_font.h"
@ -231,3 +238,7 @@ typedef PANEL_RENDER_PROC(panel_render_proc);
#include "generated/foldhaus_panels_generated.h"
#include "foldhaus_interface.cpp"
#define FOLDHAUS_APP_H
#endif // FOLDHAUS_APP_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_assembly.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_ASSEMBLY_CPP
internal s32
GetAssemblyMemorySizeFromDefinition(assembly_definition Definition, string Name)
{
@ -115,3 +122,7 @@ UnloadAssembly (u32 AssemblyIndex, app_state* State, context Context)
}
}
}
#define FOLDHAUS_ASSEMBLY_CPP
#endif // FOLDHAUS_ASSEMBLY_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_assembly.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_ASSEMBLY_H
struct led
{
s32 Index;
@ -36,3 +43,7 @@ struct assembly
s32 LEDUniverseMapCount;
leds_in_universe_range* LEDUniverseMap;
};
#define FOLDHAUS_ASSEMBLY_H
#endif // FOLDHAUS_ASSEMBLY_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_command_dispatch.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_COMMAND_DISPATCH_H
#define FOLDHAUS_INPUT_COMMAND_PROC(name) void name(app_state* State, input_entry Event, mouse_state Mouse)
typedef FOLDHAUS_INPUT_COMMAND_PROC(input_command_proc);
@ -194,3 +201,6 @@ RegisterKeyPressCommand (input_command_registry* CommandRegistry,
Command->Mdfr = Mdfr;
Command->Proc = Proc;
}
#define FOLDHAUS_COMMAND_DISPATCH_H
#endif // FOLDHAUS_COMMAND_DISPATCH_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_debug.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_DEBUG_H
#define SCOPE_NAME_LENGTH 256
struct scope_record
{
@ -427,3 +434,7 @@ struct scope_tracker
}
}
};
#define FOLDHAUS_DEBUG_H
#endif // FOLDHAUS_DEBUG_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_debug_visuals.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_DEBUG_VISUALS_H
internal void
DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_config Interface, r32 WindowWidth, r32 WindowHeight, r32 DeltaTime, app_state* State, camera Camera, mouse_state Mouse, memory_arena* Transient)
{
@ -113,3 +120,7 @@ DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_c
TopOfScreenLinePos.y -= NewLineYOffset(*Interface.Font);
}
}
#define FOLDHAUS_DEBUG_VISUALS_H
#endif // FOLDHAUS_DEBUG_VISUALS_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_default_nodes.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_DEFAULT_NODES_H
//////////////////////////////////
//
// Values
@ -135,3 +142,7 @@ NODE_PROC(MultiplyPatterns, multiply_patterns_data)
LED++;
}
}
#define FOLDHAUS_DEFAULT_NODES_H
#endif // FOLDHAUS_DEFAULT_NODES_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_interface.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_INTERFACE_CPP
////////////////////////////////////////
//
// Universe View
@ -603,3 +610,7 @@ DrawAllPanels(panel_layout PanelLayout, render_command_buffer* RenderBuffer, mou
DrawPanelBorder(*Panel, PanelBounds.Min, PanelBounds.Max, BorderColor, Mouse, RenderBuffer);
}
}
#define FOLDHAUS_INTERFACE_CPP
#endif // FOLDHAUS_INTERFACE_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_memory.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_MEMORY_H
#ifndef GS_MEMORY_H
#if 0
@ -267,3 +274,6 @@ PushSize_ (static_memory_arena* Arena, u32 Size)
#define GS_MEMORY_H
#endif // GS_MEMORY_H
#define FOLDHAUS_MEMORY_H
#endif // FOLDHAUS_MEMORY_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_network_ordering.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_NETWORK_ORDERING_H
// Packs a u8 to a known big endian buffer
inline u8*
PackB1(u8* ptr, u8 val)
@ -131,3 +138,7 @@ UpackL8(const u8* ptr)
{
return *((u64*)ptr);
}
#define FOLDHAUS_NETWORK_ORDERING_H
#endif // FOLDHAUS_NETWORK_ORDERING_H

View File

@ -1,6 +1,175 @@
//
// File: foldhaus_node.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_NODE_CPP
internal void
PushNodeOnWorkspace(s32 NodeSpecificationIndex, pattern_node_workspace* Workspace)
ClearNodeWorkspaceStorage(pattern_node_workspace* Workspace)
{
ClearArena(&Workspace->Storage);
Workspace->SparseToSortedNodeMap = 0;
Workspace->SortedNodeHandles = 0;
}
struct adjacency_list
{
// TODO(Peter): Can make these as buffers, not single digits later
gs_list_handle NodeHandle;
adjacency_list* Next;
};
internal u32
SortNodeNeighbors(u32 ContiguousNodeIndex, gs_list_handle NodeHandle, adjacency_list** NeighborsLists, b8* NodesVisited, gs_list_handle* SortedNodeHandles, u32 SortedNodesCount, s32* SparseToContiguousNodeMap)
{
NodesVisited[ContiguousNodeIndex] = true;
adjacency_list* Neighbor = NeighborsLists[ContiguousNodeIndex];
while (Neighbor)
{
u32 ContiguousNeighborNodeIndex = SparseToContiguousNodeMap[Neighbor->NodeHandle.Index];
if (!NodesVisited[ContiguousNeighborNodeIndex])
{
SortedNodesCount = SortNodeNeighbors(ContiguousNeighborNodeIndex, Neighbor->NodeHandle, NeighborsLists, NodesVisited, SortedNodeHandles, SortedNodesCount, SparseToContiguousNodeMap);
}
Neighbor = Neighbor->Next;
}
SortedNodeHandles[SortedNodesCount++] = NodeHandle;
return SortedNodesCount;
}
internal s32*
CreateSparseToContiguousMap (pattern_node_workspace Workspace, memory_arena* Scratch)
{
s32* Result = PushArray(Scratch, s32, Workspace.Nodes.OnePastLastUsed);
s32 ContiguousIndex = 0;
for (u32 SparseNodeIndex = 0; SparseNodeIndex < Workspace.Nodes.OnePastLastUsed; SparseNodeIndex++)
{
gs_list_entry<pattern_node>* Entry = Workspace.Nodes.GetEntryAtIndex(SparseNodeIndex);
if (!EntryIsFree(Entry))
{
Result[SparseNodeIndex] = ContiguousIndex++;
}
}
return Result;
}
internal void
UpdateSortedNodes(pattern_node_workspace* Workspace, memory_arena* Scratch)
{
ClearNodeWorkspaceStorage(Workspace);
u32 NodeCount = Workspace->Nodes.Used;
u32 SparseNodeCount = Workspace->Nodes.OnePastLastUsed;
s32* SparseToContiguousNodeMap = CreateSparseToContiguousMap(*Workspace, &Workspace->Storage);
// NOTE(Peter): We need to sort this later on so I'm just storing list lengths in this format
// to begin with.
// NeighborsListLengths[n].Radix = the number of neighbors for the node
// NeighborsListLengths[n].ID = the sparse array index of the node
gs_radix_entry* NeighborsListLengths = PushArray(Scratch, gs_radix_entry, NodeCount);
adjacency_list** NeighborsLists = PushArray(Scratch, adjacency_list*, NodeCount);
GSZeroArray(NeighborsLists, adjacency_list*, SparseNodeCount);
// Fill Radix
for (u32 n = 0; n < SparseNodeCount; n++)
{
s32 ContiguousIndex = SparseToContiguousNodeMap[n];
if (ContiguousIndex >= 0)
{
NeighborsListLengths[ContiguousIndex].Radix = 0;
NeighborsListLengths[ContiguousIndex].ID = n;
}
}
// Construct Adjaceny List
for (u32 c = 0; c < Workspace->Connections.Used; c++)
{
pattern_node_connection Connection = *Workspace->Connections.GetElementAtIndex(c);
adjacency_list* ListAddition = PushStruct(Scratch, adjacency_list);
ListAddition->NodeHandle = Connection.DownstreamNodeHandle;
s32 ContiguousNodeIndex = SparseToContiguousNodeMap[Connection.UpstreamNodeHandle.Index];
ListAddition->Next = NeighborsLists[ContiguousNodeIndex];
NeighborsLists[ContiguousNodeIndex] = ListAddition;
// Increment the number of neighbors - stored in Radix
NeighborsListLengths[ContiguousNodeIndex].Radix++;
}
// Sort by number of neighbors
RadixSortInPlace(NeighborsListLengths, Workspace->Nodes.Used);
char* OutputCharArray = PushArray(Scratch, char, 1024);
string OutputString = MakeString(OutputCharArray, 0, 1024);
PrintF(&OutputString, "Neighbors Lists: \n");
for (u32 d = 0; d < Workspace->Nodes.Used; d++)
{
PrintF(&OutputString, " %d: Node [ %d ] : neighbors { ", d, NeighborsListLengths[d].ID);
adjacency_list* Neighbors = NeighborsLists[d];
while (Neighbors)
{
PrintF(&OutputString, "%d, ", Neighbors->NodeHandle.Index);
Neighbors = Neighbors->Next;
}
PrintF(&OutputString, " }\n");
}
NullTerminate(&OutputString);
OutputDebugStringA(OutputCharArray);
// This is a contiguous array.
b8* NodesVisited = PushArray(Scratch, b8, NodeCount);
GSZeroArray(NodesVisited, b8, NodeCount);
Workspace->SortedNodeHandles = PushArray(&Workspace->Storage, gs_list_handle, NodeCount);
u32 SortedSparseNodeIndeciesUsed = 0;
for (u32 n = 0; n < Workspace->Nodes.Used; n++)
{
gs_radix_entry SortedNeighborsCount = NeighborsListLengths[n];
u32 NeighborCount = SortedNeighborsCount.Radix;
u32 NodeIndex = SortedNeighborsCount.ID;
gs_list_handle NodeHandle = Workspace->Nodes.GetEntryAtIndex(NodeIndex)->Handle;
u32 ContiguousNodeIndex = SparseToContiguousNodeMap[NodeIndex];
SortedSparseNodeIndeciesUsed = SortNodeNeighbors(ContiguousNodeIndex, NodeHandle, NeighborsLists, NodesVisited, Workspace->SortedNodeHandles, SortedSparseNodeIndeciesUsed, SparseToContiguousNodeMap);
}
Workspace->SparseToSortedNodeMap = SparseToContiguousNodeMap;
for (u32 SortedIndex = 0; SortedIndex < NodeCount; SortedIndex++)
{
gs_list_handle SortedHandle = Workspace->SortedNodeHandles[SortedIndex];
Workspace->SparseToSortedNodeMap[SortedHandle.Index] = SortedIndex;
}
}
internal void
PushNodeOnWorkspace(s32 NodeSpecificationIndex, pattern_node_workspace* Workspace, memory_arena* Scratch)
{
pattern_node* NewNode = Workspace->Nodes.TakeElement();
NewNode->SpecificationIndex = NodeSpecificationIndex;
UpdateSortedNodes(Workspace, Scratch);
}
internal void
PushNodeConnectionOnWorkspace(gs_list_handle UpstreamNodeHandle, u32 UpstreamPortIndex, gs_list_handle DownstreamNodeHandle, u32 DownstreamPortIndex, pattern_node_workspace* Workspace, memory_arena* Scratch)
{
pattern_node_connection Connection = {};
Connection.UpstreamNodeHandle = UpstreamNodeHandle;
Connection.DownstreamNodeHandle = DownstreamNodeHandle;
Connection.UpstreamPortIndex = UpstreamPortIndex;
Connection.DownstreamPortIndex = DownstreamPortIndex;
Workspace->Connections.PushElementOnBucket(Connection);
UpdateSortedNodes(Workspace, Scratch);
}
#define FOLDHAUS_NODE_CPP
#endif // FOLDHAUS_NODE_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_node.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_NODE_H
typedef enum node_type node_type;
#define IsInputMember 1 << 0
@ -75,6 +82,13 @@ struct pattern_node_workspace
{
gs_list<pattern_node> Nodes;
gs_bucket<pattern_node_connection> Connections;
// This is storage for all the structures which follow.
// It is cleared when new nodes are added so that the
// acceleration structures can be recalculated
memory_arena Storage;
s32* SparseToSortedNodeMap;
gs_list_handle* SortedNodeHandles;
};
@ -108,3 +122,6 @@ NODE_PROC(OutputNode, output_node_data)
{
}
#define FOLDHAUS_NODE_H
#endif // FOLDHAUS_NODE_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_node_gui.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_NODE_GUI_H
struct gui_node
{
s32 Handle;
@ -11,3 +18,7 @@ struct gui_node_list
s32 NodesUsed;
gui_node Nodes[GUI_NODES_MAX];
};
#define FOLDHAUS_NODE_GUI_H
#endif // FOLDHAUS_NODE_GUI_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_operation_mode.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_OPERATION_MODE_H
typedef struct operation_mode operation_mode;
#define OPERATION_STATE_DEF(name) struct name
@ -81,3 +88,7 @@ CreateOperationState_ (operation_mode* Mode, operation_mode_system* System, s32
Mode->OpStateMemory = PushSize(&System->Arena, StateSize);
return Mode->OpStateMemory;
}
#define FOLDHAUS_OPERATION_MODE_H
#endif // FOLDHAUS_OPERATION_MODE_H

View File

@ -1,14 +1,13 @@
/*
File: foldhaus_panel.cpp
Description: a system for laying out panels on a screen
Author: Peter Slattery
Creation Date: 2019-12-26
Usage:
Include this file in ONE file in your project.
Define SetPanelDefinitionExternal
*/
//
// File: foldhaus_panel.h
// Author: Peter Slattery
// Creation Date: 2019-12-26
//
// Usage:
// Include this file in ONE file in your project.
// Define SetPanelDefinitionExternal
//
#ifndef FOLDHAUS_PANEL_H
typedef struct panel panel;
@ -351,3 +350,7 @@ GetPanelContainingPoint(v2 Point, panel_system* PanelSystem, rect WindowBounds)
}
return Result;
}
#define FOLDHAUS_PANEL_H
#endif // FOLDHAUS_PANEL_H

View File

@ -1,9 +1,18 @@
//
// File: foldhaus_platform.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PLATFORM_H
#include <windows.h>
#include <stdio.h>
#define GS_LANGUAGE_NO_PROFILER_DEFINES
#include <gs_language.h>
#include "gs_platform.h"
#include <gs_radix_sort.h>
#include <gs_list.h>
#include <gs_bucket.h>
@ -151,3 +160,7 @@ struct context
platform_send_to* PlatformSendTo;
platform_close_socket* PlatformCloseSocket;
};
#define FOLDHAUS_PLATFORM_H
#endif // FOLDHAUS_PLATFORM_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_renderer.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_RENDERER_CPP
internal render_command_buffer
AllocateRenderCommandBuffer (u8* Memory, s32 Size, renderer_realloc* Realloc)
{
@ -178,3 +185,6 @@ ClearRenderBuffer (render_command_buffer* Buffer)
{
Buffer->CommandMemoryUsed = 0;
}
#define FOLDHAUS_RENDERER_CPP
#endif // FOLDHAUS_RENDERER_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_renderer.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_RENDERER_H
#define IMMEDIATE_MODE_RENDERING 0
struct camera
@ -24,17 +31,17 @@ GetCameraModelViewMatrix (camera Camera)
r32 Z = Camera.Position.z;
m44 RotationMatrix = M44(
CamRight.x, CamUp.x, CamForward.x, 0,
CamRight.y, CamUp.y, CamForward.y, 0,
CamRight.z, CamUp.z, CamForward.z, 0,
0, 0, 0, 1);
CamRight.x, CamUp.x, CamForward.x, 0,
CamRight.y, CamUp.y, CamForward.y, 0,
CamRight.z, CamUp.z, CamForward.z, 0,
0, 0, 0, 1);
m44 PositionMatrix = M44(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
-X, -Y, -Z, 1
);
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
-X, -Y, -Z, 1
);
m44 ModelViewMatrix = PositionMatrix * RotationMatrix;
@ -654,3 +661,7 @@ PushRenderBoundingBox2D (render_command_buffer* Buffer, v2 Min, v2 Max, r32 Thic
PushQuad2DOnBatch(&Batch, v2{Max.x - Thickness, Min.y}, Max, Color);
PushQuad2DOnBatch(&Batch, Min, v2{Max.x, Min.y + Thickness}, Color);
}
#define FOLDHAUS_RENDERER_H
#endif // FOLDHAUS_RENDERER_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_sacn_view.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_SACN_VIEW_CPP
internal void
DrawSACNUniversePixels (render_command_buffer* RenderBuffer, sacn_universe* ToDraw,
v2 TopLeft, v2 Dimension)
@ -31,3 +38,6 @@ DrawSACNUniversePixels (render_command_buffer* RenderBuffer, sacn_universe* ToDr
++PixelsDrawn;
}
}
#define FOLDHAUS_SACN_VIEW_CPP
#endif // FOLDHAUS_SACN_VIEW_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_search_lister.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_SEARCH_LISTER_CPP
internal b32
NamePassesFilter (string Target, string Filter)
{
@ -42,3 +49,7 @@ GetPrevFilteredItem (search_lister SearchLister)
s32 Result = GSMax(SearchLister.HotItem - 1, 0);
return Result;
}
#define FOLDHAUS_SEARCH_LISTER_CPP
#endif // FOLDHAUS_SEARCH_LISTER_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_search_lister.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_SEARCH_LISTER_H
struct search_lister
{
// TODO(Peter): Giving up trying to just use the source list for now. At the moment
@ -18,3 +25,7 @@ struct search_lister
string Filter;
};
#define FOLDHAUS_SEARCH_LISTER_H
#endif // FOLDHAUS_SEARCH_LISTER_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_text_entry.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_TEXT_ENTRY_CPP
internal void
ResetTextInput (text_entry* Input)
{
@ -226,3 +233,7 @@ InitializeTextInputCommands (input_command_registry* Commands, memory_arena* Per
{ KeyCode_GreaterThan, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Tilde, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_BackQuote, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }
#define FOLDHAUS_TEXT_ENTRY_CPP
#endif // FOLDHAUS_TEXT_ENTRY_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_text_entry.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_TEXT_ENTRY_H
enum text_translation_type
{
TextTranslateTo_String,
@ -24,3 +31,6 @@ struct text_entry
text_entry_destination Destination;
};
#define FOLDHAUS_TEXT_ENTRY_H
#endif // FOLDHAUS_TEXT_ENTRY_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_util_radialumia_file_converter.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_UTIL_RADIALUMIA_FILE_CONVERTER_CPP
#define DEBUG
#define DEBUG_TRACK_SCOPE(name)
@ -365,3 +372,6 @@ int main(int ArgCount, char* Args[])
return 0;
}
#define FOLDHAUS_UTIL_RADIALUMIA_FILE_CONVERTER_CPP
#endif // FOLDHAUS_UTIL_RADIALUMIA_FILE_CONVERTER_CPP

View File

@ -1,3 +1,10 @@
//
// File: gs_array.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_ARRAY_H
struct free_list
{
free_list* Next;
@ -31,12 +38,12 @@ struct array_entry_handle
#define TYPEDEF_ARRAY(element_type) \
struct element_type##_array_entry { \
s32 Generation; \
union \
{ \
element_type Entry; \
free_list Free; \
}; \
s32 Generation; \
union \
{ \
element_type Entry; \
free_list Free; \
}; \
}; \
\
struct element_type##_array \
@ -50,180 +57,183 @@ struct element_type##_array \
\
internal void \
GrowBuffer(element_type##_array* Buffer) \
{ \
s32 NewBucketSize = sizeof(element_type##_array_entry) * Buffer->BucketSize; \
element_type##_array_entry* NewBucket = (element_type##_array_entry*)malloc(NewBucketSize); \
GSZeroMemory((u8*)NewBucket, NewBucketSize); \
\
s32 NewBucketIndex = Buffer->BucketCount++; \
if (!Buffer->Buckets) \
{ \
Buffer->Buckets = (element_type##_array_entry**)malloc(sizeof(element_type##_array_entry*)); \
} \
else \
{ \
Buffer->Buckets = (element_type##_array_entry**)realloc(Buffer->Buckets, sizeof(element_type##_array_entry*) * Buffer->BucketCount); \
} \
Buffer->Buckets[NewBucketIndex] = NewBucket; \
} \
\
internal element_type##_array_entry* \
GetEntryAtIndex (s32 Index, element_type##_array Buffer) \
{ \
bucket_index BucketIndex = GetBucketIndexForIndex(Index, Buffer.BucketSize); \
element_type##_array_entry* Entry = Buffer.Buckets[BucketIndex.Bucket] + BucketIndex.IndexInBucket; \
return Entry; \
} \
\
internal array_entry_handle \
PushElement (element_type Data, element_type##_array* Buffer) \
{ \
array_entry_handle Result = {}; \
\
if (Buffer->FreeList.Next != &Buffer->FreeList) \
{ \
free_list* FreeList = Buffer->FreeList.Next; \
element_type##_array_entry* Entry = GetEntryAtIndex(FreeList->Index, *Buffer); \
Buffer->FreeList.Next = Entry->Free.Next; \
\
Result.Index = Entry->Free.Index; \
Result.Generation = Entry->Generation; \
Entry->Entry = Data; \
\
++Buffer->Used; \
} \
else \
{ \
if (Buffer->Used >= Buffer->BucketSize * Buffer->BucketCount) \
{ \
GrowBuffer(Buffer); \
} \
\
s32 Index = Buffer->Used++; \
s32 BucketIndex = Index / Buffer->BucketSize; \
s32 IndexInBucket = Index % Buffer->BucketSize; \
\
Buffer->Buckets[BucketIndex][IndexInBucket].Entry = Data; \
Result.Index = Index; \
Result.Generation = Buffer->Buckets[BucketIndex][IndexInBucket].Generation; \
} \
\
return Result; \
} \
\
internal element_type* \
GetElementAtIndex (s32 Index, element_type##_array Buffer) \
{ \
Assert(Index < Buffer.Used); \
element_type##_array_entry* Entry = GetEntryAtIndex(Index, Buffer); \
element_type* Result = &Entry->Entry; \
return Result; \
} \
\
internal element_type* \
GetElementWithHandle (array_entry_handle Handle, element_type##_array Buffer) \
{ \
element_type* Result = 0; \
\
element_type##_array_entry* Entry = GetEntryAtIndex(Handle.Index, Buffer); \
\
if (Entry->Generation == Handle.Generation) \
{ \
Result = &Entry->Entry; \
} \
\
return Result; \
} \
\
internal void \
RemoveElementAtIndex (s32 Index, element_type##_array* Buffer) \
{ \
Assert(Index < Buffer->Used); \
\
element_type##_array_entry* Entry = GetEntryAtIndex(Index, *Buffer); \
++Entry->Generation; \
Entry->Free.Index = Index; \
\
Entry->Free.Next = Buffer->FreeList.Next; \
Buffer->FreeList.Next = &Entry->Free; \
\
} \
{ \
s32 NewBucketSize = sizeof(element_type##_array_entry) * Buffer->BucketSize; \
element_type##_array_entry* NewBucket = (element_type##_array_entry*)malloc(NewBucketSize); \
GSZeroMemory((u8*)NewBucket, NewBucketSize); \
\
s32 NewBucketIndex = Buffer->BucketCount++; \
if (!Buffer->Buckets) \
{ \
Buffer->Buckets = (element_type##_array_entry**)malloc(sizeof(element_type##_array_entry*)); \
} \
else \
{ \
Buffer->Buckets = (element_type##_array_entry**)realloc(Buffer->Buckets, sizeof(element_type##_array_entry*) * Buffer->BucketCount); \
} \
Buffer->Buckets[NewBucketIndex] = NewBucket; \
} \
\
internal element_type##_array_entry* \
GetEntryAtIndex (s32 Index, element_type##_array Buffer) \
{ \
bucket_index BucketIndex = GetBucketIndexForIndex(Index, Buffer.BucketSize); \
element_type##_array_entry* Entry = Buffer.Buckets[BucketIndex.Bucket] + BucketIndex.IndexInBucket; \
return Entry; \
} \
\
internal array_entry_handle \
PushElement (element_type Data, element_type##_array* Buffer) \
{ \
array_entry_handle Result = {}; \
\
if (Buffer->FreeList.Next != &Buffer->FreeList) \
{ \
free_list* FreeList = Buffer->FreeList.Next; \
element_type##_array_entry* Entry = GetEntryAtIndex(FreeList->Index, *Buffer); \
Buffer->FreeList.Next = Entry->Free.Next; \
\
Result.Index = Entry->Free.Index; \
Result.Generation = Entry->Generation; \
Entry->Entry = Data; \
\
++Buffer->Used; \
} \
else \
{ \
if (Buffer->Used >= Buffer->BucketSize * Buffer->BucketCount) \
{ \
GrowBuffer(Buffer); \
} \
\
s32 Index = Buffer->Used++; \
s32 BucketIndex = Index / Buffer->BucketSize; \
s32 IndexInBucket = Index % Buffer->BucketSize; \
\
Buffer->Buckets[BucketIndex][IndexInBucket].Entry = Data; \
Result.Index = Index; \
Result.Generation = Buffer->Buckets[BucketIndex][IndexInBucket].Generation; \
} \
\
return Result; \
} \
\
internal element_type* \
GetElementAtIndex (s32 Index, element_type##_array Buffer) \
{ \
Assert(Index < Buffer.Used); \
element_type##_array_entry* Entry = GetEntryAtIndex(Index, Buffer); \
element_type* Result = &Entry->Entry; \
return Result; \
} \
\
internal element_type* \
GetElementWithHandle (array_entry_handle Handle, element_type##_array Buffer) \
{ \
element_type* Result = 0; \
\
element_type##_array_entry* Entry = GetEntryAtIndex(Handle.Index, Buffer); \
\
if (Entry->Generation == Handle.Generation) \
{ \
Result = &Entry->Entry; \
} \
\
return Result; \
} \
\
internal void \
RemoveElementAtIndex (s32 Index, element_type##_array* Buffer) \
{ \
Assert(Index < Buffer->Used); \
\
element_type##_array_entry* Entry = GetEntryAtIndex(Index, *Buffer); \
++Entry->Generation; \
Entry->Free.Index = Index; \
\
Entry->Free.Next = Buffer->FreeList.Next; \
Buffer->FreeList.Next = &Entry->Free; \
\
} \
// END OF CRAZY MACRO
// END OF CRAZY MACRO
#define TYPEDEF_CONTIGUOUS_ARRAY(element_type) \
struct element_type##_contiguous_array \
{ \
element_type** Buckets; \
s32 BucketSize; \
s32 BucketCount; \
s32 Used; \
}; \
\
internal void \
GrowBuffer(element_type##_contiguous_array* Buffer) \
{ \
s32 NewBucketSize = sizeof(element_type) * Buffer->BucketSize; \
element_type* NewBucket = (element_type*)malloc(NewBucketSize); \
GSZeroMemory((u8*)NewBucket, NewBucketSize); \
\
s32 NewBucketIndex = Buffer->BucketCount++; \
if (!Buffer->Buckets) \
{ \
Buffer->Buckets = (element_type**)malloc(sizeof(element_type*)); \
} \
else \
{ \
Buffer->Buckets = (element_type**)realloc(Buffer->Buckets, sizeof(element_type*) * Buffer->BucketCount); \
} \
Buffer->Buckets[NewBucketIndex] = NewBucket; \
} \
\
internal element_type* \
GetElementAtIndex (s32 Index, element_type##_contiguous_array Buffer) \
{ \
element_type* Entry = 0; \
if (Index <= Buffer.Used) \
{ \
bucket_index BucketIndex = GetBucketIndexForIndex(Index, Buffer.BucketSize); \
Entry = Buffer.Buckets[BucketIndex.Bucket] + BucketIndex.IndexInBucket; \
} \
return Entry; \
} \
\
internal s32 \
PushElement (element_type Data, element_type##_contiguous_array* Buffer) \
{ \
s32 Result = -1; \
\
if (Buffer->Used >= Buffer->BucketSize * Buffer->BucketCount) \
{ \
GrowBuffer(Buffer); \
} \
\
s32 Index = Buffer->Used++; \
s32 BucketIndex = Index / Buffer->BucketSize; \
s32 IndexInBucket = Index % Buffer->BucketSize; \
\
Buffer->Buckets[BucketIndex][IndexInBucket] = Data; \
Result = Index; \
return Result; \
} \
\
internal void \
RemoveElementAtIndex (s32 Index, element_type##_contiguous_array* Buffer) \
{ \
Assert(Index < Buffer->Used); \
\
bucket_index IndexToRemove = GetBucketIndexForIndex(Index, Buffer->BucketSize); \
bucket_index LastIndex = GetBucketIndexForIndex(Buffer->Used - 1, Buffer->BucketSize); \
element_type ValueAtLastIndex = Buffer->Buckets[LastIndex.Bucket][LastIndex.IndexInBucket]; \
Buffer->Buckets[IndexToRemove.Bucket][IndexToRemove.IndexInBucket] = ValueAtLastIndex; \
--Buffer->Used; \
} \
struct element_type##_contiguous_array \
{ \
element_type** Buckets; \
s32 BucketSize; \
s32 BucketCount; \
s32 Used; \
}; \
\
internal void \
GrowBuffer(element_type##_contiguous_array* Buffer) \
{ \
s32 NewBucketSize = sizeof(element_type) * Buffer->BucketSize; \
element_type* NewBucket = (element_type*)malloc(NewBucketSize); \
GSZeroMemory((u8*)NewBucket, NewBucketSize); \
\
s32 NewBucketIndex = Buffer->BucketCount++; \
if (!Buffer->Buckets) \
{ \
Buffer->Buckets = (element_type**)malloc(sizeof(element_type*)); \
} \
else \
{ \
Buffer->Buckets = (element_type**)realloc(Buffer->Buckets, sizeof(element_type*) * Buffer->BucketCount); \
} \
Buffer->Buckets[NewBucketIndex] = NewBucket; \
} \
\
internal element_type* \
GetElementAtIndex (s32 Index, element_type##_contiguous_array Buffer) \
{ \
element_type* Entry = 0; \
if (Index <= Buffer.Used) \
{ \
bucket_index BucketIndex = GetBucketIndexForIndex(Index, Buffer.BucketSize); \
Entry = Buffer.Buckets[BucketIndex.Bucket] + BucketIndex.IndexInBucket; \
} \
return Entry; \
} \
\
internal s32 \
PushElement (element_type Data, element_type##_contiguous_array* Buffer) \
{ \
s32 Result = -1; \
\
if (Buffer->Used >= Buffer->BucketSize * Buffer->BucketCount) \
{ \
GrowBuffer(Buffer); \
} \
\
s32 Index = Buffer->Used++; \
s32 BucketIndex = Index / Buffer->BucketSize; \
s32 IndexInBucket = Index % Buffer->BucketSize; \
\
Buffer->Buckets[BucketIndex][IndexInBucket] = Data; \
Result = Index; \
return Result; \
} \
\
internal void \
RemoveElementAtIndex (s32 Index, element_type##_contiguous_array* Buffer) \
{ \
Assert(Index < Buffer->Used); \
\
bucket_index IndexToRemove = GetBucketIndexForIndex(Index, Buffer->BucketSize); \
bucket_index LastIndex = GetBucketIndexForIndex(Buffer->Used - 1, Buffer->BucketSize); \
element_type ValueAtLastIndex = Buffer->Buckets[LastIndex.Bucket][LastIndex.IndexInBucket]; \
Buffer->Buckets[IndexToRemove.Bucket][IndexToRemove.IndexInBucket] = ValueAtLastIndex; \
--Buffer->Used; \
} \
// END OF CRAZY MACRO
// END OF CRAZY MACRO
TYPEDEF_ARRAY(array_entry_handle);
TYPEDEF_CONTIGUOUS_ARRAY(array_entry_handle);
TYPEDEF_ARRAY(array_entry_handle);
TYPEDEF_CONTIGUOUS_ARRAY(array_entry_handle);
#define GS_ARRAY_H
#endif // GS_ARRAY_H

View File

@ -1,3 +1,10 @@
//
// File: gs_font.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_FONT_H
#ifndef GS_FONT_H
struct codepoint_bitmap
@ -119,3 +126,6 @@ NewLineYOffset (bitmap_font Font)
#define GS_FONT_H
#endif
#define GS_FONT_H
#endif // GS_FONT_H

View File

@ -1 +1,11 @@
//
// File: gs_hashtable.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_HASHTABLE_H
//
#define GS_HASHTABLE_H
#endif // GS_HASHTABLE_H

View File

@ -1,3 +1,10 @@
//
// File: gs_input.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_INPUT_H
enum key_state_flags
{
KeyState_WasDown = 1 << 0,
@ -109,3 +116,6 @@ MouseButtonHeldDown (b32 MouseButtonState)
b32 IsDown = KeyIsDown(MouseButtonState);
return (WasDown && IsDown);
}
#define GS_INPUT_H
#endif // GS_INPUT_H

View File

@ -1,3 +1,10 @@
//
// File: gs_platform.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_PLATFORM_H
#ifndef GS_PLATFORM_H
#ifndef GS_LANGUAGE_H
@ -387,3 +394,6 @@ GetSecondsElapsed (s64 Start, s64 End, s64 PerformanceCountFrequency)
#define GS_PLATFORM_H
#endif // GS_PLATFORM_H
#define GS_PLATFORM_H
#endif // GS_PLATFORM_H

View File

@ -1,3 +1,10 @@
//
// File: gs_win32.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_WIN32_CPP
#ifndef GS_WIN32_CPP
struct win32_state
@ -141,18 +148,18 @@ Win32CreateWindow (HINSTANCE HInstance, char* WindowName, s32 Width, s32 Height,
if (RegisterClass(&Result.Class))
{
Result.Handle = CreateWindowEx(
0,
Result.Class.lpszClassName,
WindowName,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
Width,
Height,
0,
0,
HInstance,
0);
0,
Result.Class.lpszClassName,
WindowName,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
Width,
Height,
0,
0,
HInstance,
0);
Result.DeviceContext = GetDC(Result.Handle);
}
@ -281,17 +288,17 @@ HandleWindowEventUnlessWouldUseDefault (HWND WindowHandle, UINT Msg, WPARAM wPar
LRESULT CALLBACK
Win32HandleWindowsEvents (
HWND WindowHandle,
UINT Msg,
WPARAM wParam,
LPARAM lParam
)
HWND WindowHandle,
UINT Msg,
WPARAM wParam,
LPARAM lParam
)
{
handle_window_event_result EventResult = HandleWindowEventUnlessWouldUseDefault(
WindowHandle,
Msg,
wParam,
lParam);
WindowHandle,
Msg,
wParam,
lParam);
if (!EventResult.Handled)
{
@ -409,8 +416,8 @@ Win32GetKeyCode (int Win32VirtualKey, bool NumpadValid, bool TranslateToChar)
internal handle_window_msg_result
HandleWindowsMessage (
HWND WindowHandle,
MSG Message)
HWND WindowHandle,
MSG Message)
{
handle_window_msg_result Result = {};
Result.NeedsUpdate = 0;
@ -616,7 +623,7 @@ PLATFORM_REALLOC(Win32Realloc)
u8* NewMemory = Win32BasicAlloc(NewSize);
if (Base)
{
GSMemCopy(Base, NewMemory, OldSize);
GSMemCopy(Base, NewMemory, OldSize);
Win32Free(Base, OldSize);
}
return NewMemory;
@ -629,13 +636,13 @@ PLATFORM_READ_ENTIRE_FILE(Win32ReadEntireFile)
Result.Error = PLATFORM_MEMORY_NO_ERROR;
HANDLE FileHandle = CreateFileA (
Path,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
Path,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (FileHandle != INVALID_HANDLE_VALUE)
{
@ -671,13 +678,13 @@ PLATFORM_WRITE_ENTIRE_FILE(Win32WriteEntireFile)
{
b32 Result = false;
HANDLE FileHandle = CreateFileA (
Path,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
Path,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (FileHandle != INVALID_HANDLE_VALUE)
{
@ -1016,3 +1023,6 @@ BindTexture (s32 TextureHandle)
#define GS_WIN32_CPP
#endif // GS_WIN32_CPP
#define GS_WIN32_CPP
#endif // GS_WIN32_CPP

View File

@ -1,3 +1,10 @@
//
// File: gs_win32.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef GS_WIN32_H
#ifndef GS_WIN32_H
struct platform_font_info
@ -11,3 +18,7 @@ struct platform_font_info
#define GS_WIN32_H
#endif // GS_WIN32_H
#define GS_WIN32_H
#endif // GS_WIN32_H

View File

@ -1,3 +1,10 @@
//
// File: interface.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef INTERFACE_H
enum string_alignment
{
Align_Left,
@ -613,3 +620,6 @@ EvaluateSearchLister (render_command_buffer* RenderBuffer, v2 TopLeft, v2 Dimens
return Result;
}
#define INTERFACE_H
#endif // INTERFACE_H

View File

@ -1,3 +1,9 @@
//
// File: foldhaus_node_interface.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLHAUS_NODE_INTERFACE_CPP
////////////////////////////////////////
//
@ -89,8 +95,8 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
for (s32 i = 0; i < OpState->SearchLister.SourceListCount; i++)
{
OpState->SearchLister.SourceList[i] = MakeString(
NodeSpecifications[i].Name,
NodeSpecifications[i].NameLength);
NodeSpecifications[i].Name,
NodeSpecifications[i].NameLength);
}
}
OpState->SearchLister.Filter = MakeString(PushArray(&State->Modes.Arena, char, 64), 0, 64);
@ -217,8 +223,8 @@ internal void
BeginDraggingNodePort(app_state* State, node_interaction Interaction)
{
operation_mode* DragNodePortMode = ActivateOperationModeWithCommands(
&State->Modes,
DragNodePortInputCommands);
&State->Modes,
DragNodePortInputCommands);
DragNodePortMode->Render = RenderDraggingNodePort;
drag_node_port_operation_state* OpState = CreateOperationState(DragNodePortMode,
@ -276,8 +282,8 @@ internal void
BeginDraggingNode(app_state* State, node_interaction Interaction)
{
operation_mode* DragNodeMode = ActivateOperationModeWithCommands(
&State->Modes,
DragNodeInputCommands);
&State->Modes,
DragNodeInputCommands);
DragNodeMode->Render = RenderDraggingNode;
drag_node_operation_state* OpState = CreateOperationState(DragNodeMode,
@ -496,3 +502,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeView)
OpState->SelectedNodeHandle = 0;
}
#define FOLHAUS_NODE_INTERFACE_CPP
#endif // FOLHAUS_NODE_INTERFACE_CPP

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_panel_animation_timeline.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PANEL_ANIMATION_TIMELINE_H
// TODO
// [x] - Moving animation blocks
// [x] - dragging beginning and end of time blocks
@ -479,3 +486,6 @@ PANEL_RENDER_PROC(AnimationTimeline_Render)
State->AnimationSystem.Time = 0;
}
}
#define FOLDHAUS_PANEL_ANIMATION_TIMELINE_H
#endif // FOLDHAUS_PANEL_ANIMATION_TIMELINE_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_panel_dmx_view.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PANEL_DMX_VIEW_H
PANEL_INIT_PROC(DMXView_Init)
{
@ -75,3 +82,7 @@ PANEL_RENDER_PROC(DMXView_Render)
}
#endif
}
#define FOLDHAUS_PANEL_DMX_VIEW_H
#endif // FOLDHAUS_PANEL_DMX_VIEW_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_panel_hierarchy.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PANEL_HIERARCHY_H
PANEL_INIT_PROC(HierarchyView_Init)
{
@ -76,3 +83,7 @@ PANEL_RENDER_PROC(HierarchyView_Render)
List.ListElementsCount++;
}
}
#define FOLDHAUS_PANEL_HIERARCHY_H
#endif // FOLDHAUS_PANEL_HIERARCHY_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_panel_node_graph.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PANEL_NODE_GRAPH_H
struct visual_node
{
node_specification Spec;
@ -127,14 +134,10 @@ FOLDHAUS_INPUT_COMMAND_PROC(EndConnectNodesOperation)
visual_port UpstreamPort = (OpState->IsInput & IsInputMember) ? VisualPort : OpState->VisualPort;
visual_port DownstreamPort = (OpState->IsInput & IsInputMember) ? OpState->VisualPort : VisualPort;
// Make Connection
pattern_node_connection Connection = {};
Connection.UpstreamNodeHandle = UpstreamPort.SparseNodeHandle;
Connection.DownstreamNodeHandle = DownstreamPort.SparseNodeHandle;
Connection.UpstreamPortIndex = UpstreamPort.PortIndex;
Connection.DownstreamPortIndex = DownstreamPort.PortIndex;
PushNodeConnectionOnWorkspace(UpstreamPort.SparseNodeHandle, UpstreamPort.PortIndex,
DownstreamPort.SparseNodeHandle, DownstreamPort.PortIndex,
&State->NodeWorkspace, &State->Transient);
State->NodeWorkspace.Connections.PushElementOnBucket(Connection);
GraphState->LayoutIsDirty = true;
}
}
@ -242,7 +245,7 @@ DrawNodePorts(node_specification Spec, b32 InputMask, v2 Position, r32 LineHeigh
}
internal void
DrawNode (v2 Position, node_specification NodeSpecification, r32 NodeWidth, r32 LineHeight, interface_config Interface, render_command_buffer* RenderBuffer, mouse_state Mouse)
DrawNode (v2 Position, node_specification NodeSpecification, gs_list_handle NodeHandle, r32 NodeWidth, r32 LineHeight, interface_config Interface, render_command_buffer* RenderBuffer, mouse_state Mouse, memory_arena* Scratch)
{
u32 InputMembers = 0;
u32 OutputMembers = 0;
@ -269,8 +272,11 @@ DrawNode (v2 Position, node_specification NodeSpecification, r32 NodeWidth, r32
v2 TextOffset = v2{Interface.Margin.x, 0};
PushRenderQuad2D(RenderBuffer, LinePosition, LinePosition + v2{NodeWidth, LineHeight}, v4{1.f, .24f, .39f, 1.f});
string NodeName = MakeString(NodeSpecification.Name, NodeSpecification.NameLength);
DrawString(RenderBuffer, NodeName, Interface.Font, LinePosition + TextOffset, WhiteV4);
string NodePrintName = MakeString(PushArray(Scratch, char, 256), 0, 256);
PrintF(&NodePrintName, "%S [%d]", NodeName, NodeHandle.Index);
DrawString(RenderBuffer, NodePrintName, Interface.Font, LinePosition + TextOffset, WhiteV4);
LinePosition.y -= LineHeight;
DrawNodePorts(NodeSpecification, IsInputMember, LinePosition, LineHeight, Align_Left, TextOffset, Interface, RenderBuffer, Mouse);
@ -299,57 +305,18 @@ GetVisualPortIndexForNode(gs_list_handle SparseNodeHandle, u32 PortIndex, node_l
}
internal node_layout
ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance, r32 LineHeight, memory_arena* Storage)
ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance, r32 LineHeight, memory_arena* Storage, app_state* State)
{
node_layout Result = {};
Result.SparseToContiguousNodeMapCount = Workspace.Nodes.OnePastLastUsed;
Result.SparseToContiguousNodeMap = PushArray(Storage, s32, Result.SparseToContiguousNodeMapCount);
u32 DestinationIndex = 0;
Result.VisualPortsCount = 0;
for (u32 i = 0; i < Result.SparseToContiguousNodeMapCount; i++)
for (u32 n = 0; n < Workspace.Nodes.Used; n++)
{
gs_list_entry<pattern_node>* Entry = Workspace.Nodes.GetEntryAtIndex(i);
if (!EntryIsFree(Entry))
{
Result.SparseToContiguousNodeMap[i] = DestinationIndex++;
gs_list_handle NodeHandle = Workspace.SortedNodeHandles[n];
pattern_node Node = *Workspace.Nodes.GetElementWithHandle(NodeHandle);
pattern_node Node = Entry->Value;
node_specification Spec = NodeSpecifications[Node.SpecificationIndex];
Result.VisualPortsCount += Spec.MemberListLength;
}
else
{
Result.SparseToContiguousNodeMap[i] = -1;
}
}
// Figure out how to arrange nodes
Result.LayerCount = 1;
Result.VisualNodeLayers = PushArray(Storage, u32, Workspace.Nodes.Used);
GSZeroMemory((u8*)Result.VisualNodeLayers, sizeof(u32) * Workspace.Nodes.Used);
for (u32 c = 0; c < Workspace.Connections.Used; c++)
{
pattern_node_connection Connection = *Workspace.Connections.GetElementAtIndex(c);
u32 UpstreamNodeLayerIndex = Result.SparseToContiguousNodeMap[Connection.UpstreamNodeHandle.Index];
u32 DownstreamNodeLayerIndex = Result.SparseToContiguousNodeMap[Connection.DownstreamNodeHandle.Index];
u32 UpstreamNodeInitialLayer = Result.VisualNodeLayers[UpstreamNodeLayerIndex];
u32 DownstreamNodeLayer = Result.VisualNodeLayers[DownstreamNodeLayerIndex];
Result.VisualNodeLayers[UpstreamNodeLayerIndex] = GSMax(UpstreamNodeInitialLayer, DownstreamNodeLayer + 1);
Result.LayerCount = GSMax(Result.VisualNodeLayers[UpstreamNodeLayerIndex] + 1, Result.LayerCount);
}
// Place Layer Columns
Result.LayerPositions = PushArray(Storage, v2, Result.LayerCount);
for (u32 l = 0; l < Result.LayerCount; l++)
{
u32 FromRight = Result.LayerCount - l;
Result.LayerPositions[l] = v2{ (NodeWidth + LayerDistance) * FromRight, 0 };
u32 SpecIndex = Node.SpecificationIndex;
node_specification Spec = NodeSpecifications[SpecIndex];
Result.VisualPortsCount += Spec.MemberListLength;
}
// Place nodes and connections
@ -359,20 +326,17 @@ ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance,
u32 VisualPortsUsed = 0;
Result.VisualPorts = PushArray(Storage, visual_port, Result.VisualPortsCount);
for (u32 n = 0; n < Result.SparseToContiguousNodeMapCount; n++)
for (u32 n = 0; n < Workspace.Nodes.Used; n++)
{
u32 NodeIndex = Result.SparseToContiguousNodeMap[n];
gs_list_entry<pattern_node>* NodeEntry = Workspace.Nodes.GetEntryAtIndex(NodeIndex);
pattern_node Node = NodeEntry->Value;
gs_list_handle NodeHandle = Workspace.SortedNodeHandles[n];
pattern_node Node = *Workspace.Nodes.GetElementWithHandle(NodeHandle);
u32 SpecIndex = Node.SpecificationIndex;
node_specification Spec = NodeSpecifications[SpecIndex];
u32 NodeLayer = Result.VisualNodeLayers[n];
visual_node* VisualNode = Result.VisualNodes + n;
VisualNode->Spec = Spec;
VisualNode->Position = Result.LayerPositions[NodeLayer];
Result.LayerPositions[NodeLayer].y -= 200;
VisualNode->Position = v2{(1.5f * NodeWidth) * n, 0};
// NOTE(Peter): These start at 2 to account for the offset past the node title
s32 InputsCount = 2;
@ -397,12 +361,14 @@ ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance,
PortBounds.Max = PortBounds.Min + v2{8, 8};
visual_port* VisualPort = Result.VisualPorts + VisualPortsUsed++;
VisualPort->SparseNodeHandle = NodeEntry->Handle;
VisualPort->SparseNodeHandle = NodeHandle;
VisualPort->PortIndex = p;
VisualPort->PortBounds = PortBounds;
}
}
Result.VisualConnectionsCount = 0;
Result.VisualConnectionsCount = Workspace.Connections.Used;
Result.VisualConnections = PushArray(Storage, visual_connection, Result.VisualConnectionsCount);
for (u32 c = 0; c < Workspace.Connections.Used; c++)
@ -450,7 +416,7 @@ PANEL_RENDER_PROC(NodeGraph_Render)
ClearArena(&GraphState->LayoutMemory);
GraphState->Layout = {};
GraphState->Layout = ArrangeNodes(State->NodeWorkspace, NodeWidth, LayerDistance, LineHeight, &GraphState->LayoutMemory);
GraphState->Layout = ArrangeNodes(State->NodeWorkspace, NodeWidth, LayerDistance, LineHeight, &GraphState->LayoutMemory, State);
GraphState->LayoutIsDirty = false;
}
@ -463,6 +429,10 @@ PANEL_RENDER_PROC(NodeGraph_Render)
v2 Start = GraphState->ViewOffset + Connection.UpstreamPosition;
v2 End = GraphState->ViewOffset + Connection.DownstreamPosition;
PushRenderLine2D(RenderBuffer, Start, End, 1.5f, WhiteV4);
v2 TempDim = v2{6, 6};
PushRenderQuad2D(RenderBuffer, Start - TempDim, Start + TempDim, PinkV4);
PushRenderQuad2D(RenderBuffer, End - TempDim, End + TempDim, YellowV4);
}
if (GraphState->Layout.ConnectionIsInProgress)
@ -476,7 +446,8 @@ PANEL_RENDER_PROC(NodeGraph_Render)
for (u32 i = 0; i < GraphState->Layout.VisualNodesCount; i++)
{
visual_node VisualNode = GraphState->Layout.VisualNodes[i];
DrawNode(VisualNode.Position + GraphState->ViewOffset, VisualNode.Spec, NodeWidth, LineHeight, State->Interface, RenderBuffer, Mouse);
gs_list_handle NodeHandle = State->NodeWorkspace.SortedNodeHandles[i];
DrawNode(VisualNode.Position + GraphState->ViewOffset, VisualNode.Spec, NodeHandle, NodeWidth, LineHeight, State->Interface, RenderBuffer, Mouse, &State->Transient);
}
for (u32 p = 0; p < GraphState->Layout.VisualPortsCount; p++)
@ -529,7 +500,7 @@ PANEL_RENDER_PROC(NodeGraph_Render)
if (MouseButtonTransitionedDown(Mouse.LeftButtonState)
&& PointIsInRect(Mouse.DownPos, ElementBounds))
{
PushNodeOnWorkspace(i, &State->NodeWorkspace);
PushNodeOnWorkspace(i, &State->NodeWorkspace, &State->Transient);
GraphState->LayoutIsDirty = true;
MouseHandled = true;
}
@ -540,3 +511,7 @@ PANEL_RENDER_PROC(NodeGraph_Render)
BeginPanNodeGraph(State, {}, Mouse);
}
}
#define FOLDHAUS_PANEL_NODE_GRAPH_H
#endif // FOLDHAUS_PANEL_NODE_GRAPH_H

View File

@ -1,3 +1,10 @@
//
// File: foldhaus_panel_profiler.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PANEL_PROFILER_H
PANEL_INIT_PROC(ProfilerView_Init)
{
@ -197,3 +204,7 @@ PANEL_RENDER_PROC(ProfilerView_Render)
VisibleFrame, Memory);
}
}
#define FOLDHAUS_PANEL_PROFILER_H
#endif // FOLDHAUS_PANEL_PROFILER_H

View File

@ -1,3 +1,9 @@
//
// File: foldhaus_panel_sculpture_view.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef FOLDHAUS_PANEL_SCULPTURE_VIEW_H
// 3D Mouse View
@ -166,3 +172,6 @@ PANEL_RENDER_PROC(SculptureView_Render)
Context.GeneralWorkQueue->DoQueueWorkUntilDone(Context.GeneralWorkQueue, 0);
Context.GeneralWorkQueue->ResetWorkQueue(Context.GeneralWorkQueue);
}
#define FOLDHAUS_PANEL_SCULPTURE_VIEW_H
#endif // FOLDHAUS_PANEL_SCULPTURE_VIEW_H

View File

@ -1,3 +1,10 @@
//
// File: sacn.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef SACN_H
#define NETWORKINTID_INVALID -1
#define DEFAULT_STREAMING_ACN_PORT 5568
@ -336,3 +343,7 @@ SACNGetUniverseSendAddress(s32 Universe)
u_long V4Address = (u_long)UpackB4(MulticastAddressBuffer);
return V4Address;
}
#define SACN_H
#endif // SACN_H

View File

@ -1,3 +1,10 @@
//
// File: test_patterns.h
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef TEST_PATTERNS_H
NODE_STRUCT(solid_color_data)
{
@ -112,3 +119,6 @@ NODE_PROC(RevolvingDiscs, revolving_discs_data)
LED++;
}
}
#define TEST_PATTERNS_H
#endif // TEST_PATTERNS_H

View File

@ -1,3 +1,10 @@
//
// File: win32_foldhaus.cpp
// Author: Peter Slattery
// Creation Date: 2020-01-01
//
#ifndef WIN32_FOLDHAUS_CPP
#include <Winsock2.h>
#include <ws2tcpip.h>
#include <intrin.h>
@ -710,3 +717,6 @@ WinMain (
return 0;
}
#define WIN32_FOLDHAUS_CPP
#endif // WIN32_FOLDHAUS_CPP