Enable resize of session frame buffer resolution

This commit is contained in:
brunoherbelin
2021-01-01 11:54:40 +01:00
parent b346403887
commit 25b58b76f3
3 changed files with 51 additions and 6 deletions

View File

@@ -10,7 +10,7 @@
const char* FrameBuffer::aspect_ratio_name[5] = { "4:3", "3:2", "16:10", "16:9", "21:9" }; 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) }; 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 }; 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; 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): FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool multiSampling):
textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0), textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0),
use_alpha_(useAlpha), use_multi_sampling_(multiSampling) use_alpha_(useAlpha), use_multi_sampling_(multiSampling)

View File

@@ -13,6 +13,7 @@ public:
static const char* resolution_name[4]; static const char* resolution_name[4];
static float resolution_height[4]; static float resolution_height[4];
static glm::vec3 getResolutionFromParameters(int ar, int h); static glm::vec3 getResolutionFromParameters(int ar, int h);
static glm::ivec2 getParametersFromResolution(glm::vec3 res);
// unbind any framebuffer object // unbind any framebuffer object
static void release(); static void release();

View File

@@ -811,10 +811,10 @@ void UserInterface::showMenuFile()
Mixer::manager().close(); Mixer::manager().close();
navigator.hidePannel(); navigator.hidePannel();
} }
ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x * 0.6f);
ImGui::Combo("##AR", &Settings::application.render.ratio, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ); ImGui::Combo("Ratio", &Settings::application.render.ratio, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) );
ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x * 0.6f);
ImGui::Combo("##HEIGHT", &Settings::application.render.res, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) ); ImGui::Combo("Height", &Settings::application.render.res, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) );
ImGui::Separator(); ImGui::Separator();
@@ -822,6 +822,8 @@ void UserInterface::showMenuFile()
if (ImGui::MenuItem( ICON_FA_FILE_UPLOAD " Open", CTRL_MOD "O")) if (ImGui::MenuItem( ICON_FA_FILE_UPLOAD " Open", CTRL_MOD "O"))
selectOpenFilename(); 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")) { if (ImGui::MenuItem( ICON_FA_FILE_EXPORT " Import")) {
// launch file dialog to open a session file // launch file dialog to open a session file
@@ -1119,6 +1121,23 @@ void UserInterface::RenderPreview()
{ {
if (ImGui::BeginMenu(IMGUI_TITLE_PREVIEW)) 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") ) if ( ImGui::MenuItem( ICON_FA_WINDOW_RESTORE " Show output window") )
Rendering::manager().outputWindow().show(); Rendering::manager().outputWindow().show();
@@ -1157,7 +1176,7 @@ void UserInterface::RenderPreview()
} }
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
// select profile // 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) ); ImGui::Combo("Codec", &Settings::application.record.profile, VideoRecorder::profile_name, IM_ARRAYSIZE(VideoRecorder::profile_name) );
} }