diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index 8841e53..3836049 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -10,7 +10,7 @@ const char* FrameBuffer::aspect_ratio_name[5] = { "4:3", "3:2", "16:10", "16:9", "21:9" }; glm::vec2 FrameBuffer::aspect_ratio_size[5] = { glm::vec2(4.f,3.f), glm::vec2(3.f,2.f), glm::vec2(16.f,10.f), glm::vec2(16.f,9.f) , glm::vec2(21.f,9.f) }; -const char* FrameBuffer::resolution_name[4] = { "720", "1080", "1440", "4K" }; +const char* FrameBuffer::resolution_name[4] = { "720", "1080", "1440", "2160" }; float FrameBuffer::resolution_height[4] = { 720.f, 1080.f, 1440.f, 2160.f }; @@ -22,6 +22,31 @@ glm::vec3 FrameBuffer::getResolutionFromParameters(int ar, int h) return res; } +glm::ivec2 FrameBuffer::getParametersFromResolution(glm::vec3 res) +{ + glm::ivec2 p = glm::ivec2(-1); + + // get aspect ratio parameter + static int num_ar = ((int)(sizeof(FrameBuffer::aspect_ratio_size) / sizeof(*FrameBuffer::aspect_ratio_size))); + float myratio = res.x / res.y; + for(int ar = 0; ar < num_ar; ar++) { + if ( myratio - (FrameBuffer::aspect_ratio_size[ar].x / FrameBuffer::aspect_ratio_size[ar].y ) < EPSILON){ + p.x = ar; + break; + } + } + // get height parameter + static int num_height = ((int)(sizeof(FrameBuffer::resolution_height) / sizeof(*FrameBuffer::resolution_height))); + for(int h = 0; h < num_height; h++) { + if ( res.y - FrameBuffer::resolution_height[h] < 1){ + p.y = h; + break; + } + } + + return p; +} + FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool multiSampling): textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0), use_alpha_(useAlpha), use_multi_sampling_(multiSampling) diff --git a/FrameBuffer.h b/FrameBuffer.h index e4da633..628d930 100644 --- a/FrameBuffer.h +++ b/FrameBuffer.h @@ -13,6 +13,7 @@ public: static const char* resolution_name[4]; static float resolution_height[4]; static glm::vec3 getResolutionFromParameters(int ar, int h); + static glm::ivec2 getParametersFromResolution(glm::vec3 res); // unbind any framebuffer object static void release(); diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index d0c9add..a2534b6 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -811,10 +811,10 @@ void UserInterface::showMenuFile() Mixer::manager().close(); navigator.hidePannel(); } - ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); - ImGui::Combo("##AR", &Settings::application.render.ratio, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ); - ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); - ImGui::Combo("##HEIGHT", &Settings::application.render.res, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) ); + ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x * 0.6f); + ImGui::Combo("Ratio", &Settings::application.render.ratio, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ); + ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x * 0.6f); + ImGui::Combo("Height", &Settings::application.render.res, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) ); ImGui::Separator(); @@ -822,6 +822,8 @@ void UserInterface::showMenuFile() if (ImGui::MenuItem( ICON_FA_FILE_UPLOAD " Open", CTRL_MOD "O")) selectOpenFilename(); + if (ImGui::MenuItem( ICON_FA_FILE_UPLOAD " Re-Open", CTRL_MOD "+Shift+O")) + Mixer::manager().load( Mixer::manager().session()->filename() ); if (ImGui::MenuItem( ICON_FA_FILE_EXPORT " Import")) { // launch file dialog to open a session file @@ -1119,6 +1121,23 @@ void UserInterface::RenderPreview() { if (ImGui::BeginMenu(IMGUI_TITLE_PREVIEW)) { + glm::ivec2 p = FrameBuffer::getParametersFromResolution(output->resolution()); + std::ostringstream info; + info << "Resolution " << output->width() << "x" << output->height(); + if (p.x > -1) + info << " " << FrameBuffer::aspect_ratio_name[p.x] ; + ImGui::MenuItem(info.str().c_str(), nullptr, false, false); + // cannot change resolution when recording + if (rec == nullptr && p.y > -1) { + ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); + if (ImGui::Combo("Height", &p.y, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) ) ) + { + glm::vec3 res = FrameBuffer::getResolutionFromParameters(p.x, p.y); + Mixer::manager().session()->setResolution(res); + } + } + ImGui::Separator(); + if ( ImGui::MenuItem( ICON_FA_WINDOW_RESTORE " Show output window") ) Rendering::manager().outputWindow().show(); @@ -1157,7 +1176,7 @@ void UserInterface::RenderPreview() } ImGui::PopStyleColor(1); // select profile - ImGui::SetNextItemWidth(300); + ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::Combo("Codec", &Settings::application.record.profile, VideoRecorder::profile_name, IM_ARRAYSIZE(VideoRecorder::profile_name) ); }