From 09c6cb9e3be2655b842e13dd68879cb10cf52acf Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Mon, 21 Nov 2022 13:56:37 -0500 Subject: things --- main.cpp | 351 +++++++++++++-------------------------------------------------- 1 file changed, 73 insertions(+), 278 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 3cc976c..2d5b501 100644 --- a/main.cpp +++ b/main.cpp @@ -36,6 +36,11 @@ #define STB_IMAGE_WRITE_IMPLEMENTATION #include "lib/stb_image_write.h" +// TODO(fox): Used for thumbnails. The renderer could be expanded to do this +// much more efficiently. +#define STB_IMAGE_RESIZE_IMPLEMENTATION +#include "lib/stb_image_resize.h" + #include "defines.h" #include "my_math.h" #include "structs.h" @@ -61,18 +66,18 @@ static uint64 BitmapBlockSize; static instruction_mode InstructionMode = instruction_mode_scalar; static uint32 RandomGlobalIncrement = 0; +#if SD #include "lib/base64.c" #include +#include "stable_diffusion.cpp" +#endif #include "memory.cpp" #include "undo.cpp" #include "strings.cpp" -#if THREADED #include "threading.cpp" -#endif #include "createcalls.cpp" // #include "ffmpeg_backend.cpp" -#include "stable_diffusion.cpp" #include "my_imgui_widgets.cpp" #include "prenderer.cpp" #include "gl_calls.cpp" @@ -131,27 +136,35 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI, UI->Warp_WantSetPos = false; } - // NOTE(fox): The only requirement for something that needs to happen before the sort is anything that creates/deletes layers. - // The requirement for something after the sort is things that depend on the sort. (obvious) if (!io.WantCaptureKeyboard) ImGui_ProcessInputs(File, State, UI, Memory, io); sorted_file Sorted = File_Sort_Push(File, State, Memory); - if (ImGui::IsKeyPressed(ImGuiKey_T)) { - Interact_Transform_Begin(File, Memory, State, io.MousePos, Sorted.CompArray, Sorted.LayerArray); - } - - bool32 mod_key = io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl; - if (mod_key) { - if (ImGui::IsKeyPressed(ImGuiKey_C)) { - Clipboard_Store(File, State, Memory, Sorted.PropertyInfo, Sorted.PropertyArray); - } - if (ImGui::IsKeyPressed(ImGuiKey_V)) { - Clipboard_Paste(File, State, Memory, Sorted.LayerArray); + // These depend on sorting, so they can't be done in the ProcessInputs function: + if (State->HotkeyInput) { + switch (State->HotkeyInput) { + case hotkey_none: + { + Assert(0); + } break; + case hotkey_transform: + { + Interact_Transform_Begin(File, Memory, State, io.MousePos, Sorted.CompArray, Sorted.LayerArray); + } break; + case hotkey_copy: + { + Clipboard_Store(File, State, Memory, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyInfo, Sorted.PropertyArray); + } break; + case hotkey_paste: + { + Clipboard_Paste(File, State, Memory, Sorted.CompArray, Sorted.LayerArray); + } break; } + State->HotkeyInput = hotkey_none; } + ImGui::DockSpaceOverViewport(); if (Debug.ToggleWindow) { @@ -162,7 +175,6 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI, if (State->Initializing == 3) { Source_UICreateButton(File, State, Memory, Sorted.CompArray, Sorted.LayerArray); - /* block_layer *Layera = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 2); Layera->x.IsToggled = true; Layera->y.IsToggled = true; @@ -172,20 +184,17 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI, block_layer *Layerc = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 0); Layerc->x.IsToggled = true; Layerc->y.IsToggled = true; - */ - /* - Layer_Select(Memory, State, 0); - Layer_Select(Memory, State, 1); - Layer_Select(Memory, State, 2); + // Layer_Select(Memory, State, 0); + // Layer_Select(Memory, State, 1); + // Layer_Select(Memory, State, 2); } if (State->Initializing == 2) { - block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex); - Precomp_UICreateButton(File, State, Memory, MainComp, *Sorted.CompArray, Sorted.LayerArray); - Layer_DeselectAll(Memory, State, File->Layer_Count); - */ - // block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 0); + // block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex); + // Precomp_UICreateButton(File, State, Memory, MainComp, *Sorted.CompArray, Sorted.LayerArray); + // Layer_DeselectAll(Memory, State, File->Layer_Count); + + block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 0); Layer_Select(Memory, State, 0); - /* History_Entry_Commit(Memory, "Add keyframe"); property_channel *Property = &Layer->x; { @@ -200,6 +209,8 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI, bezier_point Point = { 1, {20, 300, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 }; Bezier_Add(Memory, Property, Point); } + History_Entry_End(Memory); + /* Property = &Layer->y; { bezier_point Point = { 1, {10, 50, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 }; @@ -239,17 +250,18 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI, */ } - ImGui_Viewport(File, State, UI, Memory, io, textureID, Sorted.CompArray, Sorted.LayerArray); ImGui_Timeline(File, State, Memory, UI, io, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyInfo, Sorted.PropertyArray); ImGui_File(File, State, Memory, io, Sorted.CompArray, Sorted.LayerArray); ImGui_PropertiesPanel(File, State, UI, Memory, io); ImGui_ColorPanel(File, State, UI, Memory, io); +#if SD ImGui_SD_Prompt(File, State, UI, Memory, io); - ImGui_SD_Thumbnail(File, State, UI, Memory, io); + ImGui_SD_Thumbnail(File, State, UI, Memory, io, Sorted.SourceArray, Sorted.TempSourceCount, textureID); +#endif ImGui_Menu(File, State, UI, Memory, io); - File_Sort_Pop(Memory, Sorted.Layer_SortSize, Sorted.Property_SortSize); + File_Sort_Pop(Memory, Sorted.Layer_SortSize, Sorted.Property_SortSize, Sorted.Source_SortSize); #if DEBUG Debug.Temp = {}; @@ -264,10 +276,9 @@ Render_Main(void *Data, void *OutputBuffer, render_type RenderType, rectangle Re bool32 IsRendering = true; Renderer_Start(Data, OutputBuffer, RenderType, RenderRegion); while (IsRendering) { - // SDL_Delay(1); + // Main_InputTest(File, State, &Memory, &UI); Renderer_Check(&IsRendering, RenderType); - // TODO(fox): Make interruptable if the render time gets too long. } } @@ -346,16 +357,24 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io layer_bitmap_state *BitmapState = &State->Render.Bitmap[Index_Physical]; void *BitmapAddress = NULL; + uint64 ScratchActive = 0; if (!Layer->IsPrecomp) { block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index); - if (Source->Type == source_type_principal) { if (State->Interact_Active == interact_type_brush && State->Brush.LayerToPaint_Index == Index_Physical) { - // Assert(0); - // Render_Main((void *)T, , RenderRegion); - BitmapAddress = Memory_Block_AddressAtIndex(Memory, F_PrincipalBitmaps, Source->Bitmap_Index); + void *SourceBitmapAddress = Memory_Block_AddressAtIndex(Memory, F_PrincipalBitmaps, Source->Bitmap_Index, 0); + rectangle RenderRegion = { 0, 0, Source->Width, Source->Height }; + // TODO(fox): Do all these extra precomputes really make a difference in the renderer? + direct_info Info = { (real32)Source->Width, (real32)Source->Height, (real32)Source->BytesPerPixel, (real32)Source->Width * Source->BytesPerPixel, + Bitmap_ByteInfo(Source->BytesPerPixel), blend_normal, + RenderRegion, State->Brush.TransientBitmap}; + ScratchActive = Source->Width * Source->Height * Source->BytesPerPixel; + void *SecondSourceBitmap = Memory_PushScratch(Memory, ScratchActive); + Memory_Copy((uint8 *)SecondSourceBitmap, (uint8 *)SourceBitmapAddress, ScratchActive); + Render_Main((void *)&Info, SecondSourceBitmap, render_type_notransform, RenderRegion); + BitmapAddress = SecondSourceBitmap; } else { - BitmapAddress = Memory_Block_AddressAtIndex(Memory, F_PrincipalBitmaps, Source->Bitmap_Index); + BitmapAddress = Memory_Block_AddressAtIndex(Memory, F_PrincipalBitmaps, Source->Bitmap_Index, 0); } } else { cache_entry *Entry = Memory_Cache_Search(State, Memory, cache_entry_type_source, Layer->Block_Source_Index, 0); @@ -407,6 +426,8 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io rectangle RenderRegion = {0, 0, Comp->Width, Comp->Height}; Render_Main((void *)&T, CompBuffer, render_type_main, RenderRegion); + if (ScratchActive) + Memory_PopScratch(Memory, ScratchActive); } } Entry_Main->CycleTime = GetCPUTime() - Comp_TimeStart; @@ -426,7 +447,7 @@ Main_Renderer(project_data *File, project_state *State, memory *Memory, SDL_Wind void *MainCompBuffer = Render_Comp(File, State, Memory, io, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyInfo, Sorted.PropertyArray, File->PrincipalCompIndex, State->Frame_Current); - File_Sort_Pop(Memory, Sorted.Layer_SortSize, Sorted.Property_SortSize); + File_Sort_Pop(Memory, Sorted.Layer_SortSize, Sorted.Property_SortSize, Sorted.Source_SortSize); glBindTexture(GL_TEXTURE_2D, textureID); @@ -476,6 +497,7 @@ int main(int argc, char *argv[]) { Memory_InitTable(&GlobalMemory, &Memory, 4 * 1024 * 1024, F_Strings, "Strings", sizeof(block_string)); Memory_InitTable(&GlobalMemory, &Memory, (uint64)50 * 1024 * 1024, F_PrincipalBitmaps, "Principal bitmap data", BitmapBlockSize); + Memory_InitTable(&GlobalMemory, &Memory, (uint64)5 * 1024 * 1024, B_Thumbnails, "Thumbnails"); Memory_InitTable(&GlobalMemory, &Memory, (uint64)64 * 1024 * 1024, B_ScratchSpace, "Scratch"); Memory_InitTable(&GlobalMemory, &Memory, (uint64)50 * 1024 * 1024, B_CachedBitmaps, "Cached bitmap buffer"); @@ -483,9 +505,9 @@ int main(int argc, char *argv[]) { #if ARM InstructionMode = instruction_mode_neon; #else - if (SDL_HasSSE2()) { - InstructionMode = instruction_mode_sse; - } + // if (SDL_HasSSE2()) { + // InstructionMode = instruction_mode_sse; + // } if (SDL_HasAVX2()) { InstructionMode = instruction_mode_avx; } @@ -518,12 +540,6 @@ int main(int argc, char *argv[]) { ui UI = {}; UI.Test = ImDrawListSplitter(); - // int ToolCount = (int)tool_count; - // for (int i = 0; i < ToolCount; i++) { - // glBindTexture(GL_TEXTURE_2D, textureID); - // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, MainComp->Width, MainComp->Height, 0, GL_RGBA, ByteFlag2, MainCompBuffer); - // } - block_composition *MainComp = (block_composition *)Memory_Block_AllocateAddress(&Memory, F_Precomps); MainComp->Width = 1280; @@ -537,232 +553,35 @@ int main(int argc, char *argv[]) { File->Comp_Count = 1; - /* - block_composition *Comp2 = (block_composition *)Memory_Block_AllocateAddress(&Memory, F_Precomps); - Comp2->Width = 500; - Comp2->Height = 500; - Comp2->FPS = 24; - Comp2->BytesPerPixel = 4; - Comp2->Frame_Count = 48; - Comp2->Frame_End = 48; - Comp2->Occupied = 1; - Comp2->Name_String_Index = String_AddToFile(&Memory, "Another comp"); - */ - +#if 1 { uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/a.jpg"); block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 0); Source->IsSelected = true; - - /* - { - Layer_CreateFromSource(File, State, &Memory, SourceIndex, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->Vertical_Offset = 6; - Layer->Col[0] = 1; - Layer->Col[1] = 0; - Layer->Col[2] = 0; - Layer->Block_Composition_Index = 0; - Layer->IsSelected = true; - - property_channel *Property = &Layer->x; - Property->Block_Bezier_Index[0] = Memory_Block_AllocateNew(&Memory, F_Bezier); - Property->Block_Bezier_Count = 1; - - block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(&Memory, F_Bezier, Property->Block_Bezier_Index[0]); - Bezier->Occupied = 1; - - Bezier->Point[0].Pos[0] = V2(0, 0); - Bezier->Point[1].Pos[0] = V2(20, 50); - Bezier->Point[2].Pos[0] = V2(40, -50); - Bezier->Point[0].Pos[1] = V2(-4, 0); - Bezier->Point[1].Pos[1] = V2(-4, 0); - Bezier->Point[2].Pos[1] = V2(-4, 0); - Bezier->Point[0].Pos[2] = V2(4, 0); - Bezier->Point[1].Pos[2] = V2(4, 0); - Bezier->Point[2].Pos[2] = V2(4, 0); - Bezier->Point[0].Type = interpolation_type_bezier; - Bezier->Point[1].Type = interpolation_type_bezier; - Bezier->Point[2].Type = interpolation_type_bezier; - Bezier->Point[1].IsSelected = false; - Bezier->Point[0].Occupied = true; - Bezier->Point[1].Occupied = true; - Bezier->Point[2].Occupied = true; - - property_channel *Property2 = &Layer->opacity; - Property2->Block_Bezier_Index[0] = Memory_Block_AllocateNew(&Memory, F_Bezier); - Property2->Block_Bezier_Count = 1; - - block_bezier *Bezier2 = (block_bezier *)Memory_Block_AddressAtIndex(&Memory, F_Bezier, Property2->Block_Bezier_Index[0]); - Bezier2->Occupied = 1; - - Bezier2->Point[0].Pos[0] = V2(0, 0); - Bezier2->Point[1].Pos[0] = V2(20, 1); - Bezier2->Point[0].Occupied = true; - Bezier2->Point[1].Occupied = true; - - property_channel *Property3 = &Layer->y; - Property3->Block_Bezier_Index[0] = Memory_Block_AllocateNew(&Memory, F_Bezier); - Property3->Block_Bezier_Count = 1; - - block_bezier *Bezier3 = (block_bezier *)Memory_Block_AddressAtIndex(&Memory, F_Bezier, Property3->Block_Bezier_Index[0]); - Bezier3->Occupied = 1; - - Bezier3->Point[0].Pos[0] = V2(0, -20); - Bezier3->Point[1].Pos[0] = V2(20, 300); - Bezier3->Point[2].Pos[0] = V2(40, 100); - Bezier3->Point[0].Pos[1] = V2(-4, 0); - Bezier3->Point[1].Pos[1] = V2(-4, 0); - Bezier3->Point[2].Pos[1] = V2(-4, 0); - Bezier3->Point[0].Pos[2] = V2(4, 0); - Bezier3->Point[1].Pos[2] = V2(4, 0); - Bezier3->Point[2].Pos[2] = V2(4, 0); - Bezier3->Point[0].Type = interpolation_type_bezier; - Bezier3->Point[1].Type = interpolation_type_bezier; - Bezier3->Point[2].Type = interpolation_type_bezier; - Bezier3->Point[0].Occupied = true; - Bezier3->Point[1].Occupied = true; - Bezier3->Point[2].Occupied = true; - } - */ - /* - { - Layer_CreateFromSource(File, State, &Memory, SourceIndex, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->Vertical_Offset = 2; - Layer->IsSelected = true; - Layer->ColIndex = 2; - Layer->Block_Composition_Index = 0; - } - { - Layer_CreateFromSource(File, State, &Memory, SourceIndex, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->Vertical_Offset = 5; - Layer->ColIndex = 0; - Layer->Block_Composition_Index = 0; - } - */ } { uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/b.jpg"); block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 1); - // Source->IsSelected = true; - /* - { - Layer_CreateFromSource(File, State, &Memory, SourceIndex, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->IsSelected = true; - Layer->Vertical_Offset = 3; - Layer->ColIndex = 1; - Layer->Block_Composition_Index = 0; - // Layer->IsSelected = true; - - property_channel *Property = &Layer->x; - Property->Block_Bezier_Index[0] = Memory_Block_AllocateNew(&Memory, F_Bezier); - Property->Block_Bezier_Count = 1; - - block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(&Memory, F_Bezier, Property->Block_Bezier_Index[0]); - Bezier->Occupied = 1; - - Bezier->Point[0].Pos[0] = V2(30, 0); - Bezier->Point[1].Pos[0] = V2(33, 250); - Bezier->Point[2].Pos[0] = V2(35, -50); - Bezier->Point[3].Pos[0] = V2(55, 0); - Bezier->Point[0].Pos[1] = V2(-1, 0); - Bezier->Point[1].Pos[1] = V2(-1, 0); - Bezier->Point[2].Pos[1] = V2(-1, 0); - Bezier->Point[3].Pos[1] = V2(-1, 0); - Bezier->Point[0].Pos[2] = V2(1, 0); - Bezier->Point[1].Pos[2] = V2(1, 0); - Bezier->Point[2].Pos[2] = V2(1, 0); - Bezier->Point[3].Pos[2] = V2(1, 0); - Bezier->Point[0].Type = interpolation_type_bezier; - Bezier->Point[1].Type = interpolation_type_bezier; - Bezier->Point[2].Type = interpolation_type_bezier; - Bezier->Point[3].Type = interpolation_type_bezier; - Bezier->Point[0].Occupied = true; - Bezier->Point[1].Occupied = true; - Bezier->Point[2].Occupied = true; - Bezier->Point[3].Occupied = true; - - property_channel *Property2 = &Layer->opacity; - Property2->Block_Bezier_Index[0] = Memory_Block_AllocateNew(&Memory, F_Bezier); - Property2->Block_Bezier_Count = 1; - - block_bezier *Bezier2 = (block_bezier *)Memory_Block_AddressAtIndex(&Memory, F_Bezier, Property2->Block_Bezier_Index[0]); - Bezier2->Occupied = 1; - - Bezier2->Point[0].Pos[0] = V2(25, 1); - Bezier2->Point[1].Pos[0] = V2(40, 0); - Bezier2->Point[0].Occupied = true; - Bezier2->Point[1].Occupied = true; - } - */ + Source->IsSelected = true; } { uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/c.jpg"); block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, 2); - // Source->IsSelected = true; - /* - { - Layer_CreateFromSource(File, State, &Memory, SourceIndex, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->Vertical_Offset = 1; - Layer->ColIndex = 3; - Layer->Block_Composition_Index = 0; - } - */ - // { - // Layer_CreateFromSource(File, State, &Memory, SourceIndex, MainComp->Frame_End); - // block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - // Layer->Vertical_Offset = 4; - // Layer->Col[0] = 0; - // Layer->Col[1] = 1; - // Layer->Col[2] = 1; - // Layer->Block_Composition_Index = 1; - // } - } - - /* - { - Layer_CreateFromSource(File, State, &Memory, 1, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->IsPrecomp = true; - Layer->Vertical_Offset = 9; - Layer->Col[0] = 1; - Layer->Col[1] = 1; - Layer->Col[2] = 1; - Layer->Block_Composition_Index = 0; - } - - { - Layer_CreateFromSource(File, State, &Memory, 1, MainComp->Frame_End); - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(&Memory, F_Layers, File->Layer_Count - 1); - Layer->IsPrecomp = true; - Layer->Vertical_Offset = 10; - Layer->Col[0] = 1; - Layer->Col[1] = 1; - Layer->Col[2] = 1; - Layer->Block_Composition_Index = 0; + Source->IsSelected = true; } - */ - - // History_Undo(&Memory); - // History_Redo(&Memory); +#endif SDL_Init(SDL_INIT_VIDEO); Semaphore = SDL_CreateSemaphore(0); -#if THREADED int Index[7]; for (int i = 0; i < 7; i++) { Index[i] = i; Thread[i] = SDL_CreateThread(TestThread, "thread", (void *)&Index[i]); } -#endif // Decide GL+GLSL versions SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); @@ -859,46 +678,23 @@ int main(int argc, char *argv[]) { Brush_CalcBitmapAlphaFromSize(&Memory, &State->Brush, 4); State_BindBrushTexture(&Memory, &State->Brush, 4); +#if SD curl_global_init(CURL_GLOBAL_ALL); curl_state MainHandle = {}; curl_state ProgHandle = {}; uint32 Inc = 0; +#endif while (State->IsRunning) { // State->Interact_Active = interact_type_layer_move; // State->Interact_Offset[1] = -3.0f; +#if SD if (State->CurlActive) { - if (State->CurlActive == -1) { - Curl_GET_Init(&MainHandle, State->Dump1, State->JSONPayload, State->SD.ServerAddress, State->SD.Mode); - Curl_Prog_Init(&ProgHandle, State->Dump2); - State->CurlActive = 1; - } else { - if (Curl_Check(&MainHandle) == 1) { - SD_JSONToSource(File, State, &Memory, State->Dump1, State->SD.Height, State->SD.Width); - Curl_Free(&ProgHandle); - curl_slist_free_all(ProgHandle.list); - Curl_Free(&MainHandle); - State->CurlActive = 0; - } - uint64 Time = ImGui::GetTime(); - if (Time - State->SDTimer > 0.3f) { - if (Curl_Check(&ProgHandle) == 1) { - SD_ParseProgress(State, (char *)State->Dump2); - curl_multi_remove_handle(ProgHandle.curlm, ProgHandle.curl); - curl_easy_reset(ProgHandle.curl); - ProgHandle.CurlData.size = 0; - curl_easy_setopt(ProgHandle.curl, CURLOPT_URL, "http://127.0.0.1:7860/sdapi/v1/progress"); - curl_easy_setopt(ProgHandle.curl, CURLOPT_WRITEFUNCTION, dumbcurlcallback); - curl_easy_setopt(ProgHandle.curl, CURLOPT_WRITEDATA, (void *)&ProgHandle.CurlData); - curl_multi_add_handle(ProgHandle.curlm, ProgHandle.curl); - } - State->SDTimer = Time; - } - Inc++; - } + Curl_Main(); } +#endif Main_InputTest(File, State, &Memory, &UI, window, textureID); @@ -916,7 +712,6 @@ int main(int argc, char *argv[]) { Main_RenderUI(io, clear_color, window); - // TODO(fox): Fix things that rely on this. if (State->Initializing) State->Initializing--; } -- cgit v1.2.3