mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 10:49:59 +01:00
New mechanism to fade in&out the rendering view
This commit is contained in:
@@ -75,6 +75,8 @@ void Settings::Save()
|
||||
RenderNode->SetAttribute("vsync", application.render.vsync);
|
||||
RenderNode->SetAttribute("multisampling", application.render.multisampling);
|
||||
RenderNode->SetAttribute("blit", application.render.blit);
|
||||
RenderNode->SetAttribute("ratio", application.render.ratio);
|
||||
RenderNode->SetAttribute("res", application.render.res);
|
||||
pRoot->InsertEndChild(RenderNode);
|
||||
|
||||
// Transition
|
||||
@@ -91,8 +93,6 @@ void Settings::Save()
|
||||
// save current view only if [mixing, geometry or layers]
|
||||
int v = application.current_view > 3 ? 1 : application.current_view;
|
||||
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;
|
||||
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("multisampling", &application.render.multisampling);
|
||||
rendernode->QueryBoolAttribute("blit", &application.render.blit);
|
||||
rendernode->QueryIntAttribute("ratio", &application.render.ratio);
|
||||
rendernode->QueryIntAttribute("res", &application.render.res);
|
||||
}
|
||||
|
||||
// Transition
|
||||
@@ -255,8 +257,6 @@ void Settings::Load()
|
||||
if (pElement)
|
||||
{
|
||||
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");
|
||||
for( ; viewNode ; viewNode=viewNode->NextSiblingElement())
|
||||
|
||||
16
Settings.h
16
Settings.h
@@ -94,14 +94,20 @@ struct TransitionConfig
|
||||
|
||||
struct RenderConfig
|
||||
{
|
||||
bool blit;
|
||||
int vsync;
|
||||
int multisampling;
|
||||
bool blit;
|
||||
int ratio;
|
||||
int res;
|
||||
float fading;
|
||||
|
||||
RenderConfig() {
|
||||
blit = false;
|
||||
vsync = 1; // 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
|
||||
int current_view;
|
||||
int render_view_ar;
|
||||
int render_view_h;
|
||||
std::map<int, ViewConfig> views;
|
||||
|
||||
// settings render
|
||||
@@ -144,11 +148,7 @@ struct Application
|
||||
accent_color = 0;
|
||||
pannel_stick = false;
|
||||
smooth_transition = true;
|
||||
|
||||
current_view = 1;
|
||||
render_view_ar = 3;
|
||||
render_view_h = 1;
|
||||
|
||||
windows = std::vector<WindowConfig>(3);
|
||||
windows[0].name = APP_NAME APP_TITLE;
|
||||
windows[0].w = 1600;
|
||||
|
||||
@@ -616,9 +616,9 @@ void UserInterface::showMenuFile()
|
||||
navigator.hidePannel();
|
||||
}
|
||||
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::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();
|
||||
|
||||
|
||||
24
View.cpp
24
View.cpp
@@ -295,7 +295,7 @@ uint MixingView::textureMixingQuadratic()
|
||||
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
|
||||
setResolution();
|
||||
@@ -305,26 +305,43 @@ RenderView::~RenderView()
|
||||
{
|
||||
if (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)
|
||||
{
|
||||
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_)
|
||||
delete frame_buffer_;
|
||||
|
||||
// output frame is an RBG Multisamples FrameBuffer
|
||||
frame_buffer_ = new FrameBuffer(resolution, false, true);
|
||||
|
||||
// reset fading
|
||||
setFading();
|
||||
}
|
||||
|
||||
void RenderView::draw()
|
||||
{
|
||||
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));
|
||||
frame_buffer_->begin();
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), P);
|
||||
fading_overlay_->draw(glm::identity<glm::mat4>(), projection);
|
||||
frame_buffer_->end();
|
||||
}
|
||||
|
||||
@@ -832,6 +849,9 @@ View::Cursor TransitionView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
||||
// request update
|
||||
s->touch();
|
||||
|
||||
// fade out output
|
||||
|
||||
|
||||
return Cursor(Cursor_ResizeAll, info.str() );
|
||||
}
|
||||
|
||||
|
||||
4
View.h
4
View.h
@@ -7,6 +7,7 @@
|
||||
#include "FrameBuffer.h"
|
||||
class Source;
|
||||
class SessionSource;
|
||||
class Surface;
|
||||
|
||||
class View
|
||||
{
|
||||
@@ -100,6 +101,7 @@ private:
|
||||
class RenderView : public View
|
||||
{
|
||||
FrameBuffer *frame_buffer_;
|
||||
Surface *fading_overlay_;
|
||||
|
||||
public:
|
||||
RenderView ();
|
||||
@@ -110,6 +112,8 @@ public:
|
||||
void setResolution (glm::vec3 resolution = glm::vec3(0.f));
|
||||
glm::vec3 resolution() const { return frame_buffer_->resolution(); }
|
||||
|
||||
void setFading(float f = 0.f);
|
||||
|
||||
inline FrameBuffer *frame () const { return frame_buffer_; }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user