New mechanism to fade in&out the rendering view

This commit is contained in:
brunoherbelin
2020-07-05 16:55:17 +02:00
parent 21bad90974
commit d4a22992eb
5 changed files with 40 additions and 16 deletions

View File

@@ -75,6 +75,8 @@ void Settings::Save()
RenderNode->SetAttribute("vsync", application.render.vsync); RenderNode->SetAttribute("vsync", application.render.vsync);
RenderNode->SetAttribute("multisampling", application.render.multisampling); RenderNode->SetAttribute("multisampling", application.render.multisampling);
RenderNode->SetAttribute("blit", application.render.blit); RenderNode->SetAttribute("blit", application.render.blit);
RenderNode->SetAttribute("ratio", application.render.ratio);
RenderNode->SetAttribute("res", application.render.res);
pRoot->InsertEndChild(RenderNode); pRoot->InsertEndChild(RenderNode);
// Transition // Transition
@@ -91,8 +93,6 @@ void Settings::Save()
// save current view only if [mixing, geometry or layers] // save current view only if [mixing, geometry or layers]
int v = application.current_view > 3 ? 1 : application.current_view; int v = application.current_view > 3 ? 1 : application.current_view;
viewsNode->SetAttribute("current", v); viewsNode->SetAttribute("current", v);
viewsNode->SetAttribute("render_view_ar", application.render_view_ar);
viewsNode->SetAttribute("render_view_h", application.render_view_h);
map<int, Settings::ViewConfig>::iterator iter; map<int, Settings::ViewConfig>::iterator iter;
for (iter=application.views.begin(); iter != application.views.end(); iter++) for (iter=application.views.begin(); iter != application.views.end(); iter++)
@@ -213,6 +213,8 @@ void Settings::Load()
rendernode->QueryIntAttribute("vsync", &application.render.vsync); rendernode->QueryIntAttribute("vsync", &application.render.vsync);
rendernode->QueryIntAttribute("multisampling", &application.render.multisampling); rendernode->QueryIntAttribute("multisampling", &application.render.multisampling);
rendernode->QueryBoolAttribute("blit", &application.render.blit); rendernode->QueryBoolAttribute("blit", &application.render.blit);
rendernode->QueryIntAttribute("ratio", &application.render.ratio);
rendernode->QueryIntAttribute("res", &application.render.res);
} }
// Transition // Transition
@@ -255,8 +257,6 @@ void Settings::Load()
if (pElement) if (pElement)
{ {
pElement->QueryIntAttribute("current", &application.current_view); pElement->QueryIntAttribute("current", &application.current_view);
pElement->QueryIntAttribute("render_view_ar", &application.render_view_ar);
pElement->QueryIntAttribute("render_view_h", &application.render_view_h);
XMLElement* viewNode = pElement->FirstChildElement("View"); XMLElement* viewNode = pElement->FirstChildElement("View");
for( ; viewNode ; viewNode=viewNode->NextSiblingElement()) for( ; viewNode ; viewNode=viewNode->NextSiblingElement())

View File

@@ -94,14 +94,20 @@ struct TransitionConfig
struct RenderConfig struct RenderConfig
{ {
bool blit;
int vsync; int vsync;
int multisampling; int multisampling;
bool blit; int ratio;
int res;
float fading;
RenderConfig() { RenderConfig() {
blit = false;
vsync = 1; // todo GUI selection vsync = 1; // todo GUI selection
multisampling = 2; // todo GUI selection multisampling = 2; // todo GUI selection
blit = false; ratio = 3;
res = 1;
fading = 0.0;
} }
}; };
@@ -121,8 +127,6 @@ struct Application
// Settings of Views // Settings of Views
int current_view; int current_view;
int render_view_ar;
int render_view_h;
std::map<int, ViewConfig> views; std::map<int, ViewConfig> views;
// settings render // settings render
@@ -144,11 +148,7 @@ struct Application
accent_color = 0; accent_color = 0;
pannel_stick = false; pannel_stick = false;
smooth_transition = true; smooth_transition = true;
current_view = 1; current_view = 1;
render_view_ar = 3;
render_view_h = 1;
windows = std::vector<WindowConfig>(3); windows = std::vector<WindowConfig>(3);
windows[0].name = APP_NAME APP_TITLE; windows[0].name = APP_NAME APP_TITLE;
windows[0].w = 1600; windows[0].w = 1600;

View File

@@ -616,9 +616,9 @@ void UserInterface::showMenuFile()
navigator.hidePannel(); navigator.hidePannel();
} }
ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x );
ImGui::Combo("##AR", &Settings::application.render_view_ar, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ); ImGui::Combo("##AR", &Settings::application.render.ratio, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) );
ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x ); ImGui::SetNextItemWidth( ImGui::GetContentRegionAvail().x );
ImGui::Combo("##HEIGHT", &Settings::application.render_view_h, 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();

View File

@@ -295,7 +295,7 @@ uint MixingView::textureMixingQuadratic()
return texid; return texid;
} }
RenderView::RenderView() : View(RENDERING), frame_buffer_(nullptr) RenderView::RenderView() : View(RENDERING), frame_buffer_(nullptr), fading_overlay_(nullptr)
{ {
// set resolution to settings or default // set resolution to settings or default
setResolution(); setResolution();
@@ -305,26 +305,43 @@ RenderView::~RenderView()
{ {
if (frame_buffer_) if (frame_buffer_)
delete frame_buffer_; delete frame_buffer_;
if (fading_overlay_)
delete fading_overlay_;
}
void RenderView::setFading(float f)
{
if (fading_overlay_ == nullptr)
fading_overlay_ = new Surface;
fading_overlay_->shader()->color.a = CLAMP(f, 0.f, 1.f);
} }
void RenderView::setResolution(glm::vec3 resolution) void RenderView::setResolution(glm::vec3 resolution)
{ {
if (resolution.x < 128.f || resolution.y < 128.f) if (resolution.x < 128.f || resolution.y < 128.f)
resolution = FrameBuffer::getResolutionFromParameters(Settings::application.render_view_ar, Settings::application.render_view_h); resolution = FrameBuffer::getResolutionFromParameters(Settings::application.render.ratio, Settings::application.render.res);
// new frame buffer
if (frame_buffer_) if (frame_buffer_)
delete frame_buffer_; delete frame_buffer_;
// output frame is an RBG Multisamples FrameBuffer // output frame is an RBG Multisamples FrameBuffer
frame_buffer_ = new FrameBuffer(resolution, false, true); frame_buffer_ = new FrameBuffer(resolution, false, true);
// reset fading
setFading();
} }
void RenderView::draw() void RenderView::draw()
{ {
static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -SCENE_DEPTH, 1.f); static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -SCENE_DEPTH, 1.f);
// draw in frame buffer
glm::mat4 P = glm::scale( projection, glm::vec3(1.f / frame_buffer_->aspectRatio(), 1.f, 1.f)); glm::mat4 P = glm::scale( projection, glm::vec3(1.f / frame_buffer_->aspectRatio(), 1.f, 1.f));
frame_buffer_->begin(); frame_buffer_->begin();
scene.root()->draw(glm::identity<glm::mat4>(), P); scene.root()->draw(glm::identity<glm::mat4>(), P);
fading_overlay_->draw(glm::identity<glm::mat4>(), projection);
frame_buffer_->end(); frame_buffer_->end();
} }
@@ -832,6 +849,9 @@ View::Cursor TransitionView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
// request update // request update
s->touch(); s->touch();
// fade out output
return Cursor(Cursor_ResizeAll, info.str() ); return Cursor(Cursor_ResizeAll, info.str() );
} }

4
View.h
View File

@@ -7,6 +7,7 @@
#include "FrameBuffer.h" #include "FrameBuffer.h"
class Source; class Source;
class SessionSource; class SessionSource;
class Surface;
class View class View
{ {
@@ -100,6 +101,7 @@ private:
class RenderView : public View class RenderView : public View
{ {
FrameBuffer *frame_buffer_; FrameBuffer *frame_buffer_;
Surface *fading_overlay_;
public: public:
RenderView (); RenderView ();
@@ -110,6 +112,8 @@ public:
void setResolution (glm::vec3 resolution = glm::vec3(0.f)); void setResolution (glm::vec3 resolution = glm::vec3(0.f));
glm::vec3 resolution() const { return frame_buffer_->resolution(); } glm::vec3 resolution() const { return frame_buffer_->resolution(); }
void setFading(float f = 0.f);
inline FrameBuffer *frame () const { return frame_buffer_; } inline FrameBuffer *frame () const { return frame_buffer_; }
}; };