| 771 | } |
| 772 | |
| 773 | void Editor::SaveToFileSettings() |
| 774 | { |
| 775 | if (!ImGui::CollapsingHeader("Save To File")) |
| 776 | return; |
| 777 | |
| 778 | static char fileName[256] = "output"; |
| 779 | ImGui::InputText("File Name", fileName, sizeof(fileName)); |
| 780 | |
| 781 | static char savedFilename[256] = "output"; |
| 782 | |
| 783 | static bool imageSaved = false; |
| 784 | if (ImGui::Button("Save")) |
| 785 | { |
| 786 | std::string filePath; |
| 787 | uint32_t counter = 1; |
| 788 | |
| 789 | // Check if folder is created |
| 790 | if (!std::filesystem::exists("../../RenderedImages")) |
| 791 | { |
| 792 | std::filesystem::create_directories("../../RenderedImages"); |
| 793 | } |
| 794 | |
| 795 | filePath = "../../RenderedImages/" + std::string(fileName) + "_" + std::to_string(m_PathTracer.GetSamplesAccumulated()) + "spp_" + std::to_string((int)m_RenderTime) + "s.png"; |
| 796 | while(true) |
| 797 | { |
| 798 | if (!std::filesystem::exists(filePath)) |
| 799 | break; |
| 800 | |
| 801 | filePath = "../../RenderedImages/" + std::string(fileName) + "_" + std::to_string(m_PathTracer.GetSamplesAccumulated()) + "spp_" + std::to_string((int)m_RenderTime) + "s_" + std::to_string(counter++) + ".png"; |
| 802 | } |
| 803 | |
| 804 | PushDeferredTask(std::make_shared<std::string>(filePath), [this](VulkanHelper::CommandBuffer commandBuffer, std::shared_ptr<void> data) { |
| 805 | SaveToFile(*(std::string*)data.get(), commandBuffer); |
| 806 | }); |
| 807 | imageSaved = true; |
| 808 | strcpy(savedFilename, filePath.c_str() + 21); // +21 to remove the ../../RenderedImages/ part |
| 809 | } |
| 810 | |
| 811 | if (imageSaved) |
| 812 | ImGui::Text("File saved to: RenderedImages/%s", savedFilename); |
| 813 | } |
| 814 | |
| 815 | void Editor::SaveToFile(const std::string& filepath, VulkanHelper::CommandBuffer commandBuffer) |
| 816 | { |
nothing calls this directly
no test coverage detected