diff --git a/src/app/animation/foldhaus_animation.h b/src/app/animation/foldhaus_animation.h index a63e3d1..0c22ee7 100644 --- a/src/app/animation/foldhaus_animation.h +++ b/src/app/animation/foldhaus_animation.h @@ -135,7 +135,7 @@ RemoveAnimationBlock(gs_list_handle AnimationBlockHandle, animation_system* Anim internal u32 AddLayer (string Name, animation_system* AnimationSystem, blend_mode BlendMode = BlendMode_Overwrite) { - // TODO(Peter): If this assert fires its time to make the layer buffer system + // NOTE(Peter): If this assert fires its time to make the layer buffer system // resizable. Assert(AnimationSystem->LayersCount < AnimationSystem->LayersMax); diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index 99b0246..c3b9cb1 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -500,6 +500,8 @@ UPDATE_AND_RENDER(UpdateAndRender) } #endif + + PushRenderOrthographic(RenderBuffer, 0, 0, gs_Width(State->WindowBounds), gs_Height(State->WindowBounds)); PushRenderClearScreen(RenderBuffer); diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index 4241d77..6d65e46 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -221,8 +221,7 @@ typedef PANEL_INIT_PROC(panel_init_proc); #define PANEL_CLEANUP_PROC(name) void name(panel* Panel, app_state* State) typedef PANEL_CLEANUP_PROC(panel_cleanup_proc); -// TODO(Peter): Should be able to take the mouse out of this -#define PANEL_RENDER_PROC(name) void name(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +#define PANEL_RENDER_PROC(name) void name(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) typedef PANEL_RENDER_PROC(panel_render_proc); // NOTE(Peter): This is used by the meta system to generate panel type info diff --git a/src/app/foldhaus_assembly.cpp b/src/app/foldhaus_assembly.cpp index 0ba40b2..896d326 100644 --- a/src/app/foldhaus_assembly.cpp +++ b/src/app/foldhaus_assembly.cpp @@ -114,9 +114,9 @@ internal void LoadAssembly (assembly_array* Assemblies, led_system* LedSystem, memory_arena* Scratch, context Context, string Path, event_log* GlobalLog) { platform_memory_result AssemblyFile = ReadEntireFile(Context, Path); - if (AssemblyFile.Error == PlatformMemory_NoError && AssemblyFile.Size > 0) + if (AssemblyFile.Error == PlatformMemory_NoError && AssemblyFile.Data.Size > 0) { - string AssemblyFileText = MakeString((char*)AssemblyFile.Base); + string AssemblyFileText = MakeString((char*)AssemblyFile.Data.Base); Assert(Assemblies->Count < Assemblies->CountMax); assembly* NewAssembly = &Assemblies->Values[Assemblies->Count++]; @@ -129,7 +129,7 @@ LoadAssembly (assembly_array* Assemblies, led_system* LedSystem, memory_arena* S { v4 Offset = TempAssemblyOffsets[Assemblies->Count % TempAssemblyOffsetsCount]; ConstructAssemblyFromDefinition(NewAssembly, FileName, Offset, LedSystem); - PlatformFree(Context.PlatformMemory, AssemblyFile.Base, AssemblyFile.Size); + PlatformFree(Context.PlatformMemory, AssemblyFile.Data.Base, AssemblyFile.Data.Size); } else { diff --git a/src/app/foldhaus_interface.cpp b/src/app/foldhaus_interface.cpp index b8c762e..f9345cb 100644 --- a/src/app/foldhaus_interface.cpp +++ b/src/app/foldhaus_interface.cpp @@ -454,7 +454,7 @@ RenderPanel(panel* Panel, rect PanelBounds, rect WindowBounds, render_command_bu }; panel_definition Definition = GlobalPanelDefs[Panel->PanelDefinitionIndex]; - Definition.Render(*Panel, PanelViewBounds, RenderBuffer, State, Context, Mouse); + Definition.Render(*Panel, PanelViewBounds, RenderBuffer, State, Context); PushRenderOrthographic(RenderBuffer, WindowBounds.Min.x, WindowBounds.Min.y, WindowBounds.Max.x, WindowBounds.Max.y); DrawPanelFooter(Panel, RenderBuffer, FooterBounds, Mouse, State); diff --git a/src/app/foldhaus_platform.h b/src/app/foldhaus_platform.h index 93dfa64..f8f801c 100644 --- a/src/app/foldhaus_platform.h +++ b/src/app/foldhaus_platform.h @@ -63,12 +63,15 @@ enum platform_memory_error PlatformMemory_UnknownError, // You should implement handling this when you see it }; -// TODO(Peter): Change this to just be data -// - Base, and Size -struct platform_memory_result +struct data { u8* Base; - s32 Size; + u64 Size; +}; + +struct platform_memory_result +{ + data Data; platform_memory_error Error; }; @@ -132,15 +135,6 @@ typedef PLATFORM_SEND_TO(platform_send_to); #define PLATFORM_CLOSE_SOCKET(name) void name(platform_socket_handle SocketHandle) typedef PLATFORM_CLOSE_SOCKET(platform_close_socket); -// File IO - -// TODO(Peter): -struct directory_listing -{ - string Path; - directory_listing* Next; -}; - // Font struct platform_font_info { @@ -285,7 +279,6 @@ ReadEntireFile(context Context, string Path) internal b32 WriteEntireFile(platform_file_handler FileHandler, string Path, u8* Contents, u32 Size) { - // TODO(Peter): Overload to take a data struct instead of Contents And Size b32 Result = FileHandler.WriteEntireFile(Path, Contents, Size); return Result; } diff --git a/src/app/foldhaus_renderer.h b/src/app/foldhaus_renderer.h index b29130f..a0f384b 100644 --- a/src/app/foldhaus_renderer.h +++ b/src/app/foldhaus_renderer.h @@ -20,7 +20,7 @@ inline m44 GetCameraModelViewMatrix (camera Camera) { // Forward - v4 CamForward = V4(Normalize(Camera.Position - Camera.LookAt), 0); + v4 CamForward = V4(Normalize(Camera.Position - Camera.LookAt), 0); // Right v4 CamRight = Normalize(Cross(v4{0, 1, 0, 0}, CamForward)); // Up @@ -64,7 +64,7 @@ GetCameraPerspectiveProjectionMatrix(camera Camera) r32 E = ((2 * Camera.Near) / (Right - Left)); r32 F = ((2 * Camera.Near) / (Top - Bottom)); - m44 PerspectiveProjectionMatrix = + m44 PerspectiveProjectionMatrix = { E, 0, A, 0, 0, F, B, 0, @@ -254,7 +254,7 @@ ResizeBufferIfNecessary(render_command_buffer* Buffer, s32 DataSize) s32 SpaceNeeded = DataSize - SpaceAvailable; // This is known to be positive at this point s32 AdditionSize = GSMax(SpaceNeeded, COMMAND_BUFFER_MIN_GROW_SIZE); s32 NewSize = Buffer->CommandMemorySize + AdditionSize; - Buffer->CommandMemory = Buffer->Realloc(Buffer->CommandMemory, + Buffer->CommandMemory = Buffer->Realloc(Buffer->CommandMemory, Buffer->CommandMemorySize, NewSize); Buffer->CommandMemorySize = NewSize; @@ -297,10 +297,10 @@ internal s32 ThreadSafeIncrementQuadConstructorCount (render_quad_batch_constructor* Constructor) { s32 Result = InterlockedIncrement((long*)&Constructor->Count); - // NOTE(Peter): Have to decrement the value by one. + // NOTE(Peter): Have to decrement the value by one. // Interlocked Increment acts as (++Constructor->Count), not (Constructor->Count++) which // is what we wanted; - // This was causing the first triangle to be garbage data. + // This was causing the first triangle to be garbage data. Result -= 1; return Result; } @@ -322,8 +322,8 @@ ThreadSafeReserveRangeInQuadConstructor(render_quad_batch_constructor* Construct inline void SetTri3DInBatch (render_quad_batch_constructor* Constructor, s32 TriIndex, - v4 P0, v4 P1, v4 P2, - v2 UV0, v2 UV1, v2 UV2, + v4 P0, v4 P1, v4 P2, + v2 UV0, v2 UV1, v2 UV2, v4 C0, v4 C1, v4 C2) { // Vertecies @@ -342,10 +342,11 @@ SetTri3DInBatch (render_quad_batch_constructor* Constructor, s32 TriIndex, Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 2)] = C2; } + inline void -PushTri3DOnBatch (render_quad_batch_constructor* Constructor, - v4 P0, v4 P1, v4 P2, - v2 UV0, v2 UV1, v2 UV2, +PushTri3DOnBatch (render_quad_batch_constructor* Constructor, + v4 P0, v4 P1, v4 P2, + v2 UV0, v2 UV1, v2 UV2, v4 C0, v4 C1, v4 C2) { DEBUG_TRACK_FUNCTION; @@ -362,9 +363,9 @@ PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, v4 P0, v4 P1, v4 } internal void -PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, - v4 P0, v4 P1, v4 P2, v4 P3, - v2 UV0, v2 UV1, v2 UV2, v2 UV3, +PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, + v4 P0, v4 P1, v4 P2, v4 P3, + v2 UV0, v2 UV1, v2 UV2, v2 UV3, v4 C0, v4 C1, v4 C2, v4 C3) { Assert(Constructor->Count < Constructor->Max); @@ -379,8 +380,8 @@ PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, v4 P0, v4 P1, v4 } internal void -PushQuad2DOnBatch (render_quad_batch_constructor* Constructor, - v2 P0, v2 P1, v2 P2, v2 P3, +PushQuad2DOnBatch (render_quad_batch_constructor* Constructor, + v2 P0, v2 P1, v2 P2, v2 P3, v2 UV0, v2 UV1, v2 UV2, v2 UV3, v4 C0, v4 C1, v4 C2, v4 C3) { @@ -610,7 +611,7 @@ PushRenderCameraFacingQuad (render_command_buffer* Buffer, v4 Center, v2 Dimensi } internal render_quad_batch_constructor -PushRenderTexture2DBatch(render_command_buffer* Buffer, s32 QuadCount, +PushRenderTexture2DBatch(render_command_buffer* Buffer, s32 QuadCount, render_texture Texture) { s32 DataSize = BATCH_2D_SIZE(QuadCount); @@ -628,15 +629,15 @@ PushRenderTexture2DBatch(render_command_buffer* Buffer, s32 QuadCount, } internal render_quad_batch_constructor -PushRenderTexture2DBatch (render_command_buffer* Buffer, s32 QuadCount, +PushRenderTexture2DBatch (render_command_buffer* Buffer, s32 QuadCount, u8* TextureMemory, s32 TextureHandle, s32 TextureWidth, s32 TextureHeight, s32 TextureBytesPerPixel, s32 TextureStride) { render_texture Texture = render_texture{ - TextureMemory, - TextureHandle, - TextureWidth, - TextureHeight, + TextureMemory, + TextureHandle, + TextureWidth, + TextureHeight, TextureBytesPerPixel, TextureStride}; return PushRenderTexture2DBatch(Buffer, QuadCount, Texture); diff --git a/src/app/generated/gs_meta_generated_typeinfo.h b/src/app/generated/gs_meta_generated_typeinfo.h index 9395469..fd1d779 100644 --- a/src/app/generated/gs_meta_generated_typeinfo.h +++ b/src/app/generated/gs_meta_generated_typeinfo.h @@ -59,6 +59,10 @@ static gsm_struct_member_type_info StructMembers_v4[] = { { "g", 1, (u64)&((v4*)0)->g, {}, 0}, { "b", 1, (u64)&((v4*)0)->b, {}, 0}, { "a", 1, (u64)&((v4*)0)->a, {}, 0}, +{ "xy", 2, (u64)&((v4*)0)->xy, {}, 0}, +{ "yz", 2, (u64)&((v4*)0)->yz, {}, 0}, +{ "xyz", 3, (u64)&((v4*)0)->xyz, {}, 0}, +{ "z", 1, (u64)&((v4*)0)->z, {}, 0}, { "E", 1, (u64)&((v4*)0)->E, {}, 0}, }; static gsm_struct_member_type_info StructMembers_pixel[] = { @@ -107,7 +111,7 @@ static gsm_struct_member_type_info StructMembers_multiply_patterns_data[] = { static gsm_struct_type_info StructTypes[] = { { gsm_StructType_solid_color_data, "solid_color_data", 16, 36, 0, 0, StructMembers_solid_color_data, 2 }, -{ gsm_StructType_v4, "v4", 2, 16, 0, 0, StructMembers_v4, 3 }, +{ gsm_StructType_v4, "v4", 2, 16, 0, 0, StructMembers_v4, 5 }, { gsm_StructType_float, "float", 5, 4, 0, 0, 0, 0 }, { gsm_StructType_color_buffer, "color_buffer", 12, 20, 0, 0, StructMembers_color_buffer, 3 }, { gsm_StructType_pixel, "pixel", 5, 3, 0, 0, StructMembers_pixel, 2 }, diff --git a/src/app/panels/foldhaus_panel_animation_timeline.h b/src/app/panels/foldhaus_panel_animation_timeline.h index 1f243fa..0f5e9b6 100644 --- a/src/app/panels/foldhaus_panel_animation_timeline.h +++ b/src/app/panels/foldhaus_panel_animation_timeline.h @@ -572,7 +572,7 @@ DrawAnimationClipsList(rect PanelBounds, ui_interface* Interface, u32 SelectedAn GSMetaTag(panel_render); GSMetaTag(panel_type_animation_timeline); internal void -AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { animation_timeline_state* TimelineState = (animation_timeline_state*)Panel.PanelStateMemory; gs_list_handle SelectedBlockHandle = State->SelectedAnimationBlockHandle; diff --git a/src/app/panels/foldhaus_panel_dmx_view.h b/src/app/panels/foldhaus_panel_dmx_view.h index b4b5ea4..8d5acce 100644 --- a/src/app/panels/foldhaus_panel_dmx_view.h +++ b/src/app/panels/foldhaus_panel_dmx_view.h @@ -37,7 +37,7 @@ DMXView_Cleanup(panel* Panel, app_state* State) // This won't actually function // :NoLongerFunctionalSACNCodeButThatsOk internal void -DrawSACNUniversePixels (render_command_buffer* RenderBuffer, sacn_universe* ToDraw, +DrawSACNUniversePixels (render_command_buffer* RenderBuffer, sacn_universe* ToDraw, v2 TopLeft, v2 Dimension) { Assert(ToDraw); @@ -69,12 +69,12 @@ DrawSACNUniversePixels (render_command_buffer* RenderBuffer, sacn_universe* ToDr ++PixelsDrawn; } } -#endif +#endif GSMetaTag(panel_render); GSMetaTag(panel_type_dmx_view); internal void -DMXView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +DMXView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { #if 0 // :NoLongerFunctionalSACNCodeButThatsOk @@ -121,7 +121,7 @@ DMXView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffe { v2 TitleDisplayStart = UniverseDisplayTopLeft + v2{0, 12}; PrintF(&TitleBarString, "Universe %d", Universe->Universe); - DrawString(RenderBuffer, TitleBarString, State->Interface.Font, + DrawString(RenderBuffer, TitleBarString, State->Interface.Font, TitleDisplayStart, WhiteV4); } diff --git a/src/app/panels/foldhaus_panel_file_view.h b/src/app/panels/foldhaus_panel_file_view.h index 658435b..bfcd34e 100644 --- a/src/app/panels/foldhaus_panel_file_view.h +++ b/src/app/panels/foldhaus_panel_file_view.h @@ -36,7 +36,7 @@ FileView_Cleanup(panel* Panel, app_state* State) GSMetaTag(panel_render); GSMetaTag(panel_type_file_view); internal void -FileView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +FileView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { rect HeaderBounds = {0}; HeaderBounds.Min = {PanelBounds.Min.x, PanelBounds.Max.y - 32}; diff --git a/src/app/panels/foldhaus_panel_hierarchy.h b/src/app/panels/foldhaus_panel_hierarchy.h index 7b56c47..043caa0 100644 --- a/src/app/panels/foldhaus_panel_hierarchy.h +++ b/src/app/panels/foldhaus_panel_hierarchy.h @@ -27,7 +27,7 @@ HierarchyView_Cleanup(panel* Panel, app_state* State) GSMetaTag(panel_render); GSMetaTag(panel_type_hierarchy); internal void -HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { ui_layout Layout = ui_CreateLayout(State->Interface, PanelBounds); string TempString = PushString(&State->Transient, 256); diff --git a/src/app/panels/foldhaus_panel_node_graph.h b/src/app/panels/foldhaus_panel_node_graph.h index 3bc27c4..80aa175 100644 --- a/src/app/panels/foldhaus_panel_node_graph.h +++ b/src/app/panels/foldhaus_panel_node_graph.h @@ -420,7 +420,7 @@ ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance, GSMetaTag(panel_render); GSMetaTag(panel_type_node_graph); internal void -NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { node_graph_state* GraphState = (node_graph_state*)Panel.PanelStateMemory; b32 MouseHandled = false; @@ -477,7 +477,7 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf { visual_node VisualNode = GraphState->Layout.VisualNodes[i]; gs_list_handle NodeHandle = State->NodeWorkspace.SortedNodeHandles[i]; - DrawNode(VisualNode.Position + GraphState->ViewOffset, VisualNode.Spec, NodeHandle, NodeWidth, LineHeight, State->Interface.Style, RenderBuffer, Mouse, &State->Transient); + DrawNode(VisualNode.Position + GraphState->ViewOffset, VisualNode.Spec, NodeHandle, NodeWidth, LineHeight, State->Interface.Style, RenderBuffer, Context.Mouse, &State->Transient); } for (u32 p = 0; p < GraphState->Layout.VisualPortsCount; p++) @@ -487,12 +487,12 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf VisualPort.PortBounds.Max += GraphState->ViewOffset; v4 PortColor = WhiteV4; - if (PointIsInRange(Mouse.Pos, VisualPort.PortBounds.Min, VisualPort.PortBounds.Max)) + if (PointIsInRange(Context.Mouse.Pos, VisualPort.PortBounds.Min, VisualPort.PortBounds.Max)) { PortColor = PinkV4; - if (MouseButtonTransitionedDown(Mouse.LeftButtonState)) + if (MouseButtonTransitionedDown(Context.Mouse.LeftButtonState)) { - BeginConnectNodesOperation(VisualPort, p, Mouse, State); + BeginConnectNodesOperation(VisualPort, p, Context.Mouse, State); MouseHandled = true; } } @@ -519,15 +519,15 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf List.ElementLabelIndent = v2{10, 4}; string TitleString = MakeStringLiteral("Available Nodes"); - DrawListElement(TitleString, &List, Mouse, RenderBuffer, State->Interface.Style); + DrawListElement(TitleString, &List, Context.Mouse, RenderBuffer, State->Interface.Style); for (u32 i = 0; i < NodeType_Count; i++) { node_specification_ Spec = NodeSpecifications[i]; - rect ElementBounds = DrawListElement(Spec.Identifier, &List, Mouse, RenderBuffer, State->Interface.Style); + rect ElementBounds = DrawListElement(Spec.Identifier, &List, Context.Mouse, RenderBuffer, State->Interface.Style); - if (MouseButtonTransitionedDown(Mouse.LeftButtonState) - && gs_PointIsInRect(Mouse.DownPos, ElementBounds)) + if (MouseButtonTransitionedDown(Context.Mouse.LeftButtonState) + && gs_PointIsInRect(Context.Mouse.DownPos, ElementBounds)) { PushNodeOnWorkspace(i, &State->NodeWorkspace, &State->Transient); GraphState->LayoutIsDirty = true; @@ -535,9 +535,9 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf } } - if (!MouseHandled && MouseButtonTransitionedDown(Mouse.LeftButtonState)) + if (!MouseHandled && MouseButtonTransitionedDown(Context.Mouse.LeftButtonState)) { - BeginPanNodeGraph(State, {}, Mouse); + BeginPanNodeGraph(State, {}, Context.Mouse); } } diff --git a/src/app/panels/foldhaus_panel_profiler.h b/src/app/panels/foldhaus_panel_profiler.h index a6eadfd..75c010a 100644 --- a/src/app/panels/foldhaus_panel_profiler.h +++ b/src/app/panels/foldhaus_panel_profiler.h @@ -133,7 +133,7 @@ RenderProfiler_ListVisualization(ui_interface* Interface, ui_layout Layout, debu GSMetaTag(panel_render); GSMetaTag(panel_type_profiler); internal void -ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { memory_arena* Memory = &State->Transient; string String = InitializeEmptyString(PushArray(Memory, char, 256), 256); @@ -149,9 +149,9 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render r32 SingleFrameWidth = (r32)((s32)SingleFrameStep - 2); ui_OutlineRect(&State->Interface, FrameListBounds, 2, WhiteV4); - if (gs_PointIsInRect(Mouse.Pos, FrameListBounds) && MouseButtonHeldDown(Mouse.LeftButtonState)) + if (gs_PointIsInRect(Context.Mouse.Pos, FrameListBounds) && MouseButtonHeldDown(Context.Mouse.LeftButtonState)) { - v2 LocalMouse = gs_TransformPointIntoRectSpace(Mouse.Pos, FrameListBounds); + v2 LocalMouse = gs_TransformPointIntoRectSpace(Context.Mouse.Pos, FrameListBounds); s32 ClosestFrameIndex = (LocalMouse.x / SingleFrameStep); if (ClosestFrameIndex >= 0 && ClosestFrameIndex < DEBUG_FRAME_COUNT) { diff --git a/src/app/panels/foldhaus_panel_sculpture_view.h b/src/app/panels/foldhaus_panel_sculpture_view.h index 7ff61ee..c605a0f 100644 --- a/src/app/panels/foldhaus_panel_sculpture_view.h +++ b/src/app/panels/foldhaus_panel_sculpture_view.h @@ -71,6 +71,7 @@ SculptureView_Cleanup(panel* Panel, app_state* State) struct draw_leds_job_data { + v4 CameraPosition; v4* Positions; pixel* Colors; s32 StartIndex; @@ -107,18 +108,19 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData) v2 UV2 = v2{1, 1}; v2 UV3 = v2{0, 1}; - for (s32 LedIndex = 0; LedIndex < LEDCount; LedIndex++) { pixel PixelColor = Data->Colors[LedIndex]; v4 Color = v4{PixelColor.R / 255.f, PixelColor.G / 255.f, PixelColor.B / 255.f, 1.0f}; - v4 V4Position = Data->Positions[Data->StartIndex + LedIndex]; - V4Position.w = 0; - v4 P0 = P0_In + V4Position; - v4 P1 = P1_In + V4Position; - v4 P2 = P2_In + V4Position; - v4 P3 = P3_In + V4Position; + v4 Position = Data->Positions[Data->StartIndex + LedIndex]; + m44 FaceCameraMatrix = GetLookAtMatrix(Position, Data->CameraPosition); + v4 PositionOffset = V4(Position.xyz, 0); // Ensure PositionOffset is a vector, not a point + + v4 P0 = (FaceCameraMatrix * P0_In) + PositionOffset; + v4 P1 = (FaceCameraMatrix * P1_In) + PositionOffset; + v4 P2 = (FaceCameraMatrix * P2_In) + PositionOffset; + v4 P3 = (FaceCameraMatrix * P3_In) + PositionOffset; SetTri3DInBatch(Data->Batch, BatchReservedRange.Start + TrisUsed++, P0, P1, P2, UV0, UV1, UV2, Color, Color, Color); @@ -130,7 +132,7 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData) GSMetaTag(panel_render); GSMetaTag(panel_type_sculpture_view); internal void -SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) +SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { DEBUG_TRACK_SCOPE(RenderSculpture); @@ -145,9 +147,7 @@ SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende PushRenderPerspective(RenderBuffer, PanelBounds.Min.x, PanelBounds.Min.y, PanelWidth, PanelHeight, State->Camera); - // TODO(Peter): Pretty sure this isn't working right now m44 FaceCameraMatrix = GetLookAtMatrix(v4{0, 0, 0, 1}, V4(State->Camera.Position, 1)); - FaceCameraMatrix = FaceCameraMatrix; u32 MaxLEDsPerJob = 2048; render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->LedSystem.LedsCountTotal); @@ -166,13 +166,19 @@ SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende JobData->StartIndex = Job * MaxLEDsPerJob; JobData->OnePastLastIndex = GSMin(JobData->StartIndex + MaxLEDsPerJob, LedBuffer->LedCount); JobData->Batch = &RenderLEDsBatch; - JobData->FaceCameraMatrix; + //JobData->FaceCameraMatrix = FaceCameraMatrix; JobData->ModelViewMatrix = ModelViewMatrix; JobData->LEDHalfWidth = LEDHalfWidth; + JobData->CameraPosition = V4(State->Camera.Position, 1); + Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, DrawLEDsInBufferRangeJob, JobData, "Sculpture Draw LEDS"); } } + + + + Context.GeneralWorkQueue->DoQueueWorkUntilDone(Context.GeneralWorkQueue, 0); } diff --git a/src/app/win32_foldhaus_fileio.h b/src/app/win32_foldhaus_fileio.h index 2240dbc..46a109a 100644 --- a/src/app/win32_foldhaus_fileio.h +++ b/src/app/win32_foldhaus_fileio.h @@ -19,30 +19,33 @@ PLATFORM_READ_ENTIRE_FILE(Win32ReadEntireFile) if (FileHandle != INVALID_HANDLE_VALUE) { DWORD FileSize = GetFileSize(FileHandle, NULL); - Result.Base = (u8*)VirtualAlloc(NULL, FileSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); - if (Result.Base) + Result.Data.Base = (u8*)VirtualAlloc(NULL, FileSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + if (Result.Data.Base) { - Result.Size = FileSize; + Result.Data.Size = FileSize; s32 BytesRead = 0; - if (ReadFile(FileHandle, (LPVOID)Result.Base, FileSize, (LPDWORD)(&BytesRead), NULL)) + if (ReadFile(FileHandle, (LPVOID)Result.Data.Base, FileSize, (LPDWORD)(&BytesRead), NULL)) { } else { u32 Error = GetLastError(); - // TODO(Peter): :ErrorLogging - Result.Size = 0; + VirtualFree(Result.Data.Base, 0, MEM_RELEASE); + Result.Data.Size = 0; Result.Error = PlatformMemory_UnknownError; } } + else + { + Result.Error = PlatformMemory_UnknownError; + } CloseHandle(FileHandle); } else { Result.Error = PlatformMemory_FileNotFound; - // TODO(Peter): :ErrorLogging } return Result; @@ -138,13 +141,5 @@ PLATFORM_GET_FILE_PATH(Win32SystemDialogueOpenFile) return Result; } -internal directory_listing -EnumerateDirectory(char* Path, memory_arena* Storage) -{ - directory_listing Result = {}; - // TODO(Peter): - return Result; -} - #define WIN32_FOLDHAUS_FILEIO_H #endif // WIN32_FOLDHAUS_FILEIO_H \ No newline at end of file diff --git a/src/gs_libs/gs_vector_matrix.h b/src/gs_libs/gs_vector_matrix.h index 3d1cfbd..1f187bc 100644 --- a/src/gs_libs/gs_vector_matrix.h +++ b/src/gs_libs/gs_vector_matrix.h @@ -75,6 +75,18 @@ union v4 float a; }; + struct + { + v2 xy; + v2 yz; + }; + + struct + { + v3 xyz; + float z; + }; + float E[4]; }; @@ -1271,11 +1283,10 @@ GetLookAtMatrix (v4 Position, v4 Target) v4 Up = Normalize(Cross(Forward, Right)); m44 RotationMatrix = M44( - Right.x, Up.x, Forward.x, 0, - Right.y, Up.y, Forward.y, 0, - Right.z, Up.z, Forward.z, 0, + Right.x, Right.y, Right.z, 0, + Up.x, Up.y, Up.z, 0, + Forward.x, Forward.y, Forward.z, 0, 0, 0, 0, 1); - return RotationMatrix; }