BugFix changing resolution of session

This commit is contained in:
Bruno
2021-08-14 23:15:18 +02:00
parent bc8c4e3c7b
commit ef5f3efd2e
4 changed files with 48 additions and 36 deletions

View File

@@ -1269,6 +1269,17 @@ void Mixer::set(Session *s)
sessionSwapRequested_ = true; sessionSwapRequested_ = true;
} }
void Mixer::setResolution(glm::vec3 res)
{
if (session_) {
session_->setResolution(res);
++View::need_deep_update_;
std::ostringstream info;
info << "Session resolution changed to " << res.x << "x" << res.y;
Log::Info("%s", info.str().c_str());
}
}
void Mixer::paste(const std::string& clipboard) void Mixer::paste(const std::string& clipboard)
{ {
tinyxml2::XMLDocument xmlDoc; tinyxml2::XMLDocument xmlDoc;

View File

@@ -107,6 +107,7 @@ public:
void merge (Session *session); void merge (Session *session);
void merge (SessionSource *source); void merge (SessionSource *source);
void set (Session *session); void set (Session *session);
void setResolution(glm::vec3 res);
// operations depending on transition mode // operations depending on transition mode
void close (bool smooth = false); void close (bool smooth = false);

View File

@@ -831,8 +831,9 @@ void RenderingWindow::draw(FrameBuffer *fb)
// attach the 2D texture to local FBO // attach the 2D texture to local FBO
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
#ifndef NDEBUG
Log::Info("Blit to output window enabled."); Log::Info("Blit to output window enabled.");
#endif
} }
// calculate scaling factor of frame buffer inside window // calculate scaling factor of frame buffer inside window

View File

@@ -4136,48 +4136,46 @@ void Navigator::RenderMainPannelVimix()
const FrameBuffer *output = Mixer::manager().session()->frame(); const FrameBuffer *output = Mixer::manager().session()->frame();
if (output) if (output)
{ {
// get parameters to edit resolution // Show info text bloc (dark background)
glm::ivec2 p = FrameBuffer::getParametersFromResolution(output->resolution());
ImGuiTextBuffer info; ImGuiTextBuffer info;
info.appendf("%s", SystemToolkit::filename(sessionfilename).c_str()); info.appendf("%s", SystemToolkit::filename(sessionfilename).c_str());
// Show info text bloc (dark background)
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.14f, 0.14f, 0.14f, 0.9f)); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.14f, 0.14f, 0.14f, 0.9f));
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::InputText("##Info", (char *)info.c_str(), info.size(), ImGuiInputTextFlags_ReadOnly); ImGui::InputText("##Info", (char *)info.c_str(), info.size(), ImGuiInputTextFlags_ReadOnly);
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
// Kept for later? Larger info box with more details on the session file... // Kept for later? Larger info box with more details on the session file...
// ImGuiTextBuffer info; // ImGuiTextBuffer info;
// if (!sessionfilename.empty()) // if (!sessionfilename.empty())
// info.appendf("%s\n", SystemToolkit::filename(sessionfilename).c_str()); // info.appendf("%s\n", SystemToolkit::filename(sessionfilename).c_str());
// else // else
// info.append("<unsaved>\n"); // info.append("<unsaved>\n");
// info.appendf("%dx%dpx", output->width(), output->height()); // info.appendf("%dx%dpx", output->width(), output->height());
// if (p.x > -1) // if (p.x > -1)
// info.appendf(", %s", FrameBuffer::aspect_ratio_name[p.x]); // info.appendf(", %s", FrameBuffer::aspect_ratio_name[p.x]);
// // content info // // content info
// const uint N = Mixer::manager().session()->numSource(); // const uint N = Mixer::manager().session()->numSource();
// if (N > 1) // if (N > 1)
// info.appendf("\n%d sources", N); // info.appendf("\n%d sources", N);
// else if (N > 0) // else if (N > 0)
// info.append("\n1 source"); // info.append("\n1 source");
// const size_t M = MediaPlayer::registered().size(); // const size_t M = MediaPlayer::registered().size();
// if (M > 0) { // if (M > 0) {
// info.appendf("\n%d media files:", M); // info.appendf("\n%d media files:", M);
// for (auto mit = MediaPlayer::begin(); mit != MediaPlayer::end(); ++mit) // for (auto mit = MediaPlayer::begin(); mit != MediaPlayer::end(); ++mit)
// info.appendf("\n- %s", SystemToolkit::filename((*mit)->filename()).c_str()); // info.appendf("\n- %s", SystemToolkit::filename((*mit)->filename()).c_str());
// } // }
// // Show info text bloc (multi line, dark background) // // Show info text bloc (multi line, dark background)
// ImGuiToolkit::PushFont( ImGuiToolkit::FONT_MONO ); // ImGuiToolkit::PushFont( ImGuiToolkit::FONT_MONO );
// ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.14f, 0.14f, 0.14f, 0.9f)); // ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.14f, 0.14f, 0.14f, 0.9f));
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); // ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
// ImGui::InputTextMultiline("##Info", (char *)info.c_str(), info.size(), ImVec2(IMGUI_RIGHT_ALIGN, 2*ImGui::GetTextLineHeightWithSpacing()), ImGuiInputTextFlags_ReadOnly); // ImGui::InputTextMultiline("##Info", (char *)info.c_str(), info.size(), ImVec2(IMGUI_RIGHT_ALIGN, 2*ImGui::GetTextLineHeightWithSpacing()), ImGuiInputTextFlags_ReadOnly);
// ImGui::PopStyleColor(1); // ImGui::PopStyleColor(1);
// ImGui::PopFont(); // ImGui::PopFont();
// change resolution (height only) // change resolution (height only)
// get parameters to edit resolution
glm::ivec2 p = FrameBuffer::getParametersFromResolution(output->resolution());
if (p.y > -1) { if (p.y > -1) {
// cannot change resolution when recording // cannot change resolution when recording
if ( UserInterface::manager().isRecording() ) { if ( UserInterface::manager().isRecording() ) {
@@ -4192,19 +4190,20 @@ void Navigator::RenderMainPannelVimix()
ImGui::InputText("Height", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::InputText("Height", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly);
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
} }
// offer to change ratio and resolution
else { else {
// combo boxes to select Rario and Height // combo boxes to select Rario and Height
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::Combo("Ratio", &p.x, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ) ) if (ImGui::Combo("Ratio", &p.x, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ) )
{ {
glm::vec3 res = FrameBuffer::getResolutionFromParameters(p.x, p.y); glm::vec3 res = FrameBuffer::getResolutionFromParameters(p.x, p.y);
Mixer::manager().session()->setResolution(res); Mixer::manager().setResolution(res);
} }
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::Combo("Height", &p.y, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) ) ) if (ImGui::Combo("Height", &p.y, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) ) )
{ {
glm::vec3 res = FrameBuffer::getResolutionFromParameters(p.x, p.y); glm::vec3 res = FrameBuffer::getResolutionFromParameters(p.x, p.y);
Mixer::manager().session()->setResolution(res); Mixer::manager().setResolution(res);
} }
} }
} }