diff options
author | Fox Caminiti <fox@foxcam.net> | 2023-02-13 11:12:47 -0500 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2023-02-13 11:12:47 -0500 |
commit | fffb3474ee0321d73a47db01dbc4b6b19670ddc5 (patch) | |
tree | af4c14469a6a49c59785c426f149be43f3bd1147 /src/main.cpp | |
parent | bd25daeae033e4f905ae0145831a7d8fdd92e471 (diff) |
drag and drop file loading
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0bac544..3152156 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -78,12 +78,22 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, sorted_ ImGuiIO& io = ImGui::GetIO(); SDL_Event event = {}; int test = 0; + // printf("%i\n", State->MenuFocused); while (SDL_PollEvent(&event)) { ImGui_ImplSDL2_ProcessEvent(&event); if (event.type == SDL_DROPFILE) { char *DropFile = event.drop.file; - Source_Generate(File, State, Memory, DropFile); + File_Open(File, State, Memory, DropFile); +#if 0 + if (State->MenuFocused) { + if (File_Open(File, State, Memory, DropFile)) { + State->UpdateFrame = true; + } + } else { + Source_Generate(File, State, Memory, DropFile); + } +#endif SDL_free(DropFile); } if (event.type == SDL_QUIT) @@ -776,7 +786,7 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, sorted_fil Arbitrary_Zero((uint8 *)CompBuffer, Size); - uint64 Comp_TimeStart = GetCPUTime(); + // uint64 Comp_TimeStart = GetCPUTime(); for (int i = 0; i < SortedCompStart->LayerCount; i++) { sorted_layer_array SortEntry = SortedLayerStart[i]; @@ -913,7 +923,7 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, sorted_fil } } - Entry_Main->CycleTime = GetCPUTime() - Comp_TimeStart; + // Entry_Main->CycleTime = GetCPUTime() - Comp_TimeStart; Entry_Main->IsCached = true; if (CompIndex == File->PrincipalCompIndex && State->LastCachedFrame != State->Frame_Current) { @@ -1293,6 +1303,7 @@ int main(int argc, char *argv[]) { while (State->IsRunning) { + // uint64 StartTime = GetCPUTime(); uint64 PerfFrequency = SDL_GetPerformanceFrequency(); uint64 PerfStart = SDL_GetPerformanceCounter(); @@ -1378,12 +1389,14 @@ int main(int argc, char *argv[]) { if (State->FirstFrame) State->UpdateScreen = 2; + // State->UpdateScreen = 1; + // TODO(fox): Do the same thing with the timeline and viewport to // reduce wasted rendering further; for now I am at least pausing all // UI when no inputs happen. - uint64 InputStart = SDL_GetPerformanceCounter(); + // uint64 InputStart = GetCPUTime(); State->UpdateScreen += Main_InputTest(File, State, &Memory, Sorted, &File->UI, window, textureID); - uint64 InputTime = SDL_GetPerformanceCounter() - InputStart; + // uint64 InputTime = GetCPUTime() - InputStart; if (State->IsPlaying) { block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(&Memory, F_Precomps, File->PrincipalCompIndex); @@ -1484,7 +1497,7 @@ int main(int argc, char *argv[]) { // frames, but we'd have to make sure the pop order stays the same in all scenarios. Assert(Debug.ScratchState == 0); - uint64 RenderStart = SDL_GetPerformanceCounter(); + // uint64 RenderStart = GetCPUTime(); bool32 UpdateScreen = 0; if (State->IsPlaying && State->HotFramePerf > 1 && FullyCached) { uint64 RenderTime = SDL_GetPerformanceCounter() - State->HotFramePerf; @@ -1501,7 +1514,7 @@ int main(int argc, char *argv[]) { UpdateScreen = 1; } } - uint64 RenderTime = SDL_GetPerformanceCounter() - RenderStart; + // uint64 RenderTime = GetCPUTime() - RenderStart; if (State->HotFramePerf == 1) { State->HotFramePerf = SDL_GetPerformanceCounter(); @@ -1522,7 +1535,10 @@ int main(int argc, char *argv[]) { if (TargetMS > FrameMS) SDL_Delay((uint64)(TargetMS - FrameMS)); } + + // uint64 TotalTime = GetCPUTime() - StartTime; // printf("TOTAL: %.2lu, (%.2f ms) - INPUTS: %.2lu - RENDERING: %.2lu\n", PerfTime, FrameMS, InputTime, RenderTime); + // printf("TOTAL: %.2lu - INPUTS: %.2lu (%.2f) - RENDERING: %.2lu (%.2f)\n", TotalTime, InputTime, (real64)InputTime / TotalTime, RenderTime, (real64)RenderTime / TotalTime); // printf("TOTAL: %.2lu, (%.2f ms) - RENDERING: %.2lu\n", PerfTime, FrameMS, PerfTime); } |