mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
GUI Selection of rendering resolution for session and settings.
This commit is contained in:
@@ -11,13 +11,16 @@ glm::vec2 FrameBuffer::aspect_ratio_size[4] = { glm::vec2(4.f,3.f), glm::vec2(3.
|
|||||||
const char* FrameBuffer::resolution_name[4] = { "720p", "1080p", "1440", "4K" };
|
const char* FrameBuffer::resolution_name[4] = { "720p", "1080p", "1440", "4K" };
|
||||||
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 };
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer(ResolutionAspectRatio aspect_ratio, ResolutionHeight height): textureid_(0), framebufferid_(0), usedepth_(false)
|
|
||||||
|
glm::vec3 FrameBuffer::getResolutionFromParameters(int ar, int h)
|
||||||
{
|
{
|
||||||
float width = aspect_ratio_size[aspect_ratio].x * resolution_height[height] / aspect_ratio_size[aspect_ratio].y;
|
float width = aspect_ratio_size[ar].x * resolution_height[h] / aspect_ratio_size[ar].y;
|
||||||
attrib_.viewport = glm::ivec2( int(width), resolution_height[height] );
|
glm::vec3 res = glm::vec3( width, resolution_height[h] , 0.f);
|
||||||
attrib_.clear_color = glm::vec4(0.f);
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer(glm::vec3 resolution): textureid_(0), framebufferid_(0), usedepth_(false)
|
FrameBuffer::FrameBuffer(glm::vec3 resolution): textureid_(0), framebufferid_(0), usedepth_(false)
|
||||||
{
|
{
|
||||||
attrib_.viewport = glm::ivec2(resolution);
|
attrib_.viewport = glm::ivec2(resolution);
|
||||||
|
|||||||
@@ -12,23 +12,8 @@ public:
|
|||||||
static glm::vec2 aspect_ratio_size[4];
|
static glm::vec2 aspect_ratio_size[4];
|
||||||
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);
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
AR_4_3 = 0,
|
|
||||||
AR_3_2,
|
|
||||||
AR_16_10,
|
|
||||||
AR_16_9
|
|
||||||
} ResolutionAspectRatio;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RES_720 = 0,
|
|
||||||
RES_1080,
|
|
||||||
RES_1440,
|
|
||||||
RES_2160
|
|
||||||
} ResolutionHeight;
|
|
||||||
|
|
||||||
|
|
||||||
FrameBuffer(ResolutionAspectRatio aspect_ratio = AR_16_9, ResolutionHeight height = RES_720);
|
|
||||||
FrameBuffer(glm::vec3 resolution);
|
FrameBuffer(glm::vec3 resolution);
|
||||||
FrameBuffer(uint width, uint height, bool useDepthBuffer = false);
|
FrameBuffer(uint width, uint height, bool useDepthBuffer = false);
|
||||||
~FrameBuffer();
|
~FrameBuffer();
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ void Mixer::newSession()
|
|||||||
delete back_session_;
|
delete back_session_;
|
||||||
|
|
||||||
// create empty session
|
// create empty session
|
||||||
back_session_ = new Session;
|
back_session_ = new Session;
|
||||||
|
|
||||||
// swap current with empty
|
// swap current with empty
|
||||||
swap();
|
swap();
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ void Settings::Save()
|
|||||||
applicationNode->SetAttribute("stats_corner", application.stats_corner);
|
applicationNode->SetAttribute("stats_corner", application.stats_corner);
|
||||||
applicationNode->SetAttribute("logs", application.logs);
|
applicationNode->SetAttribute("logs", application.logs);
|
||||||
applicationNode->SetAttribute("toolbox", application.toolbox);
|
applicationNode->SetAttribute("toolbox", application.toolbox);
|
||||||
|
applicationNode->SetAttribute("framebuffer_ar", application.framebuffer_ar);
|
||||||
|
applicationNode->SetAttribute("framebuffer_h", application.framebuffer_h);
|
||||||
pRoot->InsertEndChild(applicationNode);
|
pRoot->InsertEndChild(applicationNode);
|
||||||
|
|
||||||
// bloc views
|
// bloc views
|
||||||
@@ -162,6 +164,8 @@ void Settings::Load()
|
|||||||
pElement->QueryBoolAttribute("logs", &application.logs);
|
pElement->QueryBoolAttribute("logs", &application.logs);
|
||||||
pElement->QueryBoolAttribute("toolbox", &application.toolbox);
|
pElement->QueryBoolAttribute("toolbox", &application.toolbox);
|
||||||
pElement->QueryIntAttribute("stats_corner", &application.stats_corner);
|
pElement->QueryIntAttribute("stats_corner", &application.stats_corner);
|
||||||
|
pElement->QueryIntAttribute("framebuffer_ar", &application.framebuffer_ar);
|
||||||
|
pElement->QueryIntAttribute("framebuffer_h", &application.framebuffer_h);
|
||||||
|
|
||||||
// bloc windows
|
// bloc windows
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ struct Application
|
|||||||
// Settings of Views
|
// Settings of Views
|
||||||
int current_view;
|
int current_view;
|
||||||
std::map<int, ViewConfig> views;
|
std::map<int, ViewConfig> views;
|
||||||
|
int framebuffer_ar;
|
||||||
|
int framebuffer_h;
|
||||||
|
|
||||||
// multiple windows handling
|
// multiple windows handling
|
||||||
// TODO: manage other windows
|
// TODO: manage other windows
|
||||||
@@ -92,6 +94,8 @@ struct Application
|
|||||||
shader_editor = false;
|
shader_editor = false;
|
||||||
toolbox = false;
|
toolbox = false;
|
||||||
current_view = 1;
|
current_view = 1;
|
||||||
|
framebuffer_ar = 3;
|
||||||
|
framebuffer_h = 1;
|
||||||
windows.push_back(WindowConfig(APP_TITLE));
|
windows.push_back(WindowConfig(APP_TITLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -461,10 +461,6 @@ void UserInterface::Terminate()
|
|||||||
|
|
||||||
void UserInterface::showMenuFile()
|
void UserInterface::showMenuFile()
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem( ICON_FA_FILE " New", "Ctrl+W")) {
|
|
||||||
Mixer::manager().newSession();
|
|
||||||
navigator.hidePannel();
|
|
||||||
}
|
|
||||||
if (ImGui::MenuItem( ICON_FA_FILE_UPLOAD " Open", "Ctrl+O")) {
|
if (ImGui::MenuItem( ICON_FA_FILE_UPLOAD " Open", "Ctrl+O")) {
|
||||||
// launch file dialog to open a session file
|
// launch file dialog to open a session file
|
||||||
std::thread (FileDialogOpen, Settings::application.recentSessions.path).detach();
|
std::thread (FileDialogOpen, Settings::application.recentSessions.path).detach();
|
||||||
@@ -479,6 +475,18 @@ void UserInterface::showMenuFile()
|
|||||||
navigator.hidePannel();
|
navigator.hidePannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::MenuItem( ICON_FA_FILE " New", "Ctrl+W")) {
|
||||||
|
Mixer::manager().newSession();
|
||||||
|
navigator.hidePannel();
|
||||||
|
}
|
||||||
|
ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x );
|
||||||
|
ImGui::Combo("##AR", &Settings::application.framebuffer_ar, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) );
|
||||||
|
ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x );
|
||||||
|
ImGui::Combo("##HEIGHT", &Settings::application.framebuffer_h, FrameBuffer::resolution_name, IM_ARRAYSIZE(FrameBuffer::resolution_name) );
|
||||||
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::MenuItem( ICON_FA_POWER_OFF " Quit", "Ctrl+Q")) {
|
if (ImGui::MenuItem( ICON_FA_POWER_OFF " Quit", "Ctrl+Q")) {
|
||||||
Rendering::manager().Close();
|
Rendering::manager().Close();
|
||||||
@@ -1124,10 +1132,11 @@ void Navigator::RenderMainPannel()
|
|||||||
UserInterface::manager().showMenuFile();
|
UserInterface::manager().showMenuFile();
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
|
||||||
// combo box with list of recent session files from Settings
|
// combo box with list of recent session files from Settings
|
||||||
static bool recentselected = false;
|
static bool recentselected = false;
|
||||||
recentselected = false;
|
recentselected = false;
|
||||||
|
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
if (ImGui::BeginCombo("##Recent", "Open recent"))
|
if (ImGui::BeginCombo("##Recent", "Open recent"))
|
||||||
{
|
{
|
||||||
std::for_each(Settings::application.recentSessions.filenames.begin(),
|
std::for_each(Settings::application.recentSessions.filenames.begin(),
|
||||||
@@ -1154,13 +1163,6 @@ void Navigator::RenderMainPannel()
|
|||||||
ImGuiToolkit::ButtonSwitch( ICON_FA_TACHOMETER_ALT " Metrics", &Settings::application.stats);
|
ImGuiToolkit::ButtonSwitch( ICON_FA_TACHOMETER_ALT " Metrics", &Settings::application.stats);
|
||||||
ImGuiToolkit::ButtonSwitch( ICON_FA_LIST " Logs", &Settings::application.logs, "Ctrl + L");
|
ImGuiToolkit::ButtonSwitch( ICON_FA_LIST " Logs", &Settings::application.logs, "Ctrl + L");
|
||||||
|
|
||||||
// ImGui::Text(" ");
|
|
||||||
// ImGui::Text("Rendering");
|
|
||||||
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
|
||||||
// if ( ImGui::Combo("Aspect ratio", &Settings::application.output.resolution, Settings::resolution_name, IM_ARRAYSIZE(Settings::resolution_name) ) ){
|
|
||||||
// Settings::application.output.update();
|
|
||||||
// }
|
|
||||||
|
|
||||||
ImGui::Text(" ");
|
ImGui::Text(" ");
|
||||||
ImGui::Text("Appearance");
|
ImGui::Text("Appearance");
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
|
|||||||
25
View.cpp
25
View.cpp
@@ -181,21 +181,8 @@ uint MixingView::textureMixingQuadratic()
|
|||||||
|
|
||||||
RenderView::RenderView() : View(RENDERING), frame_buffer_(nullptr)
|
RenderView::RenderView() : View(RENDERING), frame_buffer_(nullptr)
|
||||||
{
|
{
|
||||||
// application default
|
|
||||||
glm::vec3 default_resolution(1280.f, 720.f, 0.f);
|
|
||||||
|
|
||||||
// read default settings
|
|
||||||
if ( Settings::application.views[View::RENDERING].name.empty() ) {
|
|
||||||
// no settings found: store application default
|
|
||||||
Settings::application.views[View::RENDERING].name = "Render";
|
|
||||||
// store default setting
|
|
||||||
Settings::application.views[View::RENDERING].default_scale = default_resolution;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
default_resolution = Settings::application.views[View::RENDERING].default_scale;
|
|
||||||
|
|
||||||
// set resolution to settings or default
|
// set resolution to settings or default
|
||||||
setResolution( default_resolution );
|
setResolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderView::~RenderView()
|
RenderView::~RenderView()
|
||||||
@@ -208,7 +195,7 @@ RenderView::~RenderView()
|
|||||||
void RenderView::setResolution(glm::vec3 resolution)
|
void RenderView::setResolution(glm::vec3 resolution)
|
||||||
{
|
{
|
||||||
if (resolution.x < 100.f || resolution.y < 100)
|
if (resolution.x < 100.f || resolution.y < 100)
|
||||||
resolution = Settings::application.views[View::RENDERING].default_scale;
|
resolution = FrameBuffer::getResolutionFromParameters(Settings::application.framebuffer_ar, Settings::application.framebuffer_h);
|
||||||
|
|
||||||
if (frame_buffer_)
|
if (frame_buffer_)
|
||||||
delete frame_buffer_;
|
delete frame_buffer_;
|
||||||
@@ -216,14 +203,6 @@ void RenderView::setResolution(glm::vec3 resolution)
|
|||||||
frame_buffer_ = new FrameBuffer(resolution);
|
frame_buffer_ = new FrameBuffer(resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void RenderView::setResolution(glm::vec3 resolution)
|
|
||||||
//{
|
|
||||||
// if (frame_buffer_)
|
|
||||||
// delete frame_buffer_;
|
|
||||||
|
|
||||||
// frame_buffer_ = new FrameBuffer(resolution);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void RenderView::draw()
|
void RenderView::draw()
|
||||||
{
|
{
|
||||||
static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, SCENE_DEPTH, 0.f);
|
static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, SCENE_DEPTH, 0.f);
|
||||||
|
|||||||
3
View.h
3
View.h
@@ -57,8 +57,7 @@ public:
|
|||||||
|
|
||||||
void draw () override;
|
void draw () override;
|
||||||
|
|
||||||
void setResolution (FrameBuffer::ResolutionAspectRatio aspect_ratio, FrameBuffer::ResolutionHeight height) {}
|
void setResolution (glm::vec3 resolution = glm::vec3(0.f));
|
||||||
void setResolution (glm::vec3 resolution);
|
|
||||||
glm::vec3 resolution() const { return frame_buffer_->resolution(); }
|
glm::vec3 resolution() const { return frame_buffer_->resolution(); }
|
||||||
|
|
||||||
inline FrameBuffer *frameBuffer () const { return frame_buffer_; }
|
inline FrameBuffer *frameBuffer () const { return frame_buffer_; }
|
||||||
|
|||||||
Reference in New Issue
Block a user