Cleaned up assembly loading. Added a note to handle error logging in the future

This commit is contained in:
Peter Slattery 2020-02-05 12:29:48 -08:00
parent 75bb2ae86d
commit 305afc65cd
2 changed files with 37 additions and 26 deletions

View File

@ -61,6 +61,9 @@ ConstructAssemblyFromDefinition (assembly_definition Definition,
return Assembly; return Assembly;
} }
// NOTE(Peter): These are here so that if we load 2+ sculptures, they don't all
// end up on top of one another. Purely aesthetic. Can remove once we implement
// scene editing tools
static v4 TempAssemblyOffsets[] = { v4{0, 0, 0, 0}, v4{250, 0, 75, 0}, v4{-250, 0, 75, 0} }; static v4 TempAssemblyOffsets[] = { v4{0, 0, 0, 0}, v4{250, 0, 75, 0}, v4{-250, 0, 75, 0} };
s32 TempAssemblyOffsetsCount = 3; s32 TempAssemblyOffsetsCount = 3;
@ -68,34 +71,32 @@ internal void
LoadAssembly (app_state* State, context Context, char* Path) LoadAssembly (app_state* State, context Context, char* Path)
{ {
platform_memory_result TestAssemblyFile = Context.PlatformReadEntireFile(Path); platform_memory_result TestAssemblyFile = Context.PlatformReadEntireFile(Path);
if (TestAssemblyFile.Error != PlatformMemory_NoError) if (TestAssemblyFile.Error == PlatformMemory_NoError)
{ {
return;
}
assembly_definition AssemblyDefinition = ParseAssemblyFile(TestAssemblyFile.Base, TestAssemblyFile.Size, &State->Transient); assembly_definition AssemblyDefinition = ParseAssemblyFile(TestAssemblyFile.Base, TestAssemblyFile.Size, &State->Transient);
Context.PlatformFree(TestAssemblyFile.Base, TestAssemblyFile.Size);
string PathString = MakeStringLiteral(Path); string PathString = MakeStringLiteral(Path);
s32 IndexOfLastSlash = FastLastIndexOfCharInCharArray(PathString.Memory, PathString.Length, '\\'); s32 IndexOfLastSlash = FastLastIndexOfCharInCharArray(PathString.Memory, PathString.Length, '\\');
string FileName = Substring(PathString, IndexOfLastSlash + 1); string FileName = Substring(PathString, IndexOfLastSlash + 1);
r32 Scale = 100;
memory_arena AssemblyArena = {}; memory_arena AssemblyArena = {};
AssemblyArena.Alloc = (gs_memory_alloc*)Context.PlatformAlloc; AssemblyArena.Alloc = (gs_memory_alloc*)Context.PlatformAlloc;
AssemblyArena.Realloc = (gs_memory_realloc*)Context.PlatformRealloc; AssemblyArena.Realloc = (gs_memory_realloc*)Context.PlatformRealloc;
v4 Offset = TempAssemblyOffsets[State->ActiveAssemblyIndecies.Used % TempAssemblyOffsetsCount]; v4 Offset = TempAssemblyOffsets[State->ActiveAssemblyIndecies.Used % TempAssemblyOffsetsCount];
assembly NewAssembly = ConstructAssemblyFromDefinition(AssemblyDefinition, r32 Scale = 100;
FileName, assembly NewAssembly = ConstructAssemblyFromDefinition(AssemblyDefinition, FileName, Offset, Scale, AssemblyArena);
Offset,
Scale,
AssemblyArena);
gs_list_handle NewAssemblyHandle = State->AssemblyList.PushElementOnList(NewAssembly); gs_list_handle NewAssemblyHandle = State->AssemblyList.PushElementOnList(NewAssembly);
State->ActiveAssemblyIndecies.PushElementOnList(NewAssemblyHandle);
State->ActiveAssemblyIndecies.PushElementOnList(NewAssemblyHandle);
State->TotalLEDsCount += NewAssembly.LEDCount; State->TotalLEDsCount += NewAssembly.LEDCount;
Context.PlatformFree(TestAssemblyFile.Base, TestAssemblyFile.Size);
}
else
{
// TODO(Peter): :ErrorLogging
}
} }
internal void internal void

View File

@ -24,6 +24,15 @@ x Hot Code Reloading
x File Loading x File Loading
x Gracefully handle File Not found x Gracefully handle File Not found
- Internal Log File
- NOTE: This should not be a part of the debug system
- Save output log to a file continuously
- Have a window where we can view the log within the app
- Create a bar that displays the most recent error message
- :ErrorLogging
- Make sure it works without building in Debug Mode
- Buckets & Lists - Buckets & Lists
- Allow them to use memory arenas - Allow them to use memory arenas
- Zero is initialization - Zero is initialization
@ -40,6 +49,7 @@ x File Loading
- icon system - icon system
- Sculptures - Sculptures
- store scale in the assembly definition file
- cache led vertex buffers - cache led vertex buffers
- custom sculpture update functions (for motion) - custom sculpture update functions (for motion)
- placing sculptures - placing sculptures