mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 18:59:59 +01:00
Disabling the framebuffer blit of output rendering
Blit of framebuffer is incompatible with the new features of Display View to adjust whitebalance and geometry of rendered frame on output windows.
This commit is contained in:
@@ -182,11 +182,8 @@ void RenderView::drawThumbnail()
|
||||
frame_thumbnail_ = new FrameBuffer( res_thumbnail );
|
||||
|
||||
// render
|
||||
if (Settings::application.render.blit) {
|
||||
if ( !frame_buffer_->blit(frame_thumbnail_) )
|
||||
throw std::runtime_error("no blit");
|
||||
}
|
||||
else {
|
||||
if ( !frame_buffer_->blit(frame_thumbnail_) ){
|
||||
// render anyway if blit failed
|
||||
FrameBufferSurface *thumb = new FrameBufferSurface(frame_buffer_);
|
||||
frame_thumbnail_->begin();
|
||||
thumb->draw(glm::identity<glm::mat4>(), frame_thumbnail_->projection());
|
||||
|
||||
@@ -1096,69 +1096,11 @@ bool RenderingWindow::draw(FrameBuffer *fb)
|
||||
Rendering::manager().pushAttrib(window_attributes_);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// blit framebuffer
|
||||
if (Settings::application.render.blit) {
|
||||
|
||||
if ( textureid_ != fb->texture()) {
|
||||
|
||||
textureid_ = fb->texture();
|
||||
|
||||
// create a new fbo in this opengl context
|
||||
if (fbo_ != 0)
|
||||
glDeleteFramebuffers(1, &fbo_);
|
||||
glGenFramebuffers(1, &fbo_);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
|
||||
|
||||
// attach the 2D texture to local FBO
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
|
||||
#ifndef NDEBUG
|
||||
Log::Info("Blit to output window enabled.");
|
||||
#endif
|
||||
}
|
||||
|
||||
// if not disabled
|
||||
if (!Settings::application.render.disabled) {
|
||||
|
||||
// calculate scaling factor of frame buffer inside window
|
||||
int rx, ry, rw, rh;
|
||||
float renderingAspectRatio = fb->aspectRatio();
|
||||
|
||||
if (Settings::application.windows[index_].scaled) {
|
||||
rx = 0;
|
||||
ry = 0;
|
||||
rw = window_attributes_.viewport.x;
|
||||
rh = window_attributes_.viewport.y;
|
||||
}
|
||||
else {
|
||||
if (aspectRatio() < renderingAspectRatio) {
|
||||
int nh = (int)( float(window_attributes_.viewport.x) / renderingAspectRatio);
|
||||
rx = 0;
|
||||
ry = (window_attributes_.viewport.y - nh) / 2;
|
||||
rw = window_attributes_.viewport.x;
|
||||
rh = (window_attributes_.viewport.y + nh) / 2;
|
||||
} else {
|
||||
int nw = (int)( float(window_attributes_.viewport.y) * renderingAspectRatio );
|
||||
rx = (window_attributes_.viewport.x - nw) / 2;
|
||||
ry = 0;
|
||||
rw = (window_attributes_.viewport.x + nw) / 2;
|
||||
rh = window_attributes_.viewport.y;
|
||||
}
|
||||
}
|
||||
|
||||
// select fbo texture read target
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_);
|
||||
|
||||
// select screen target
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
// blit operation from fbo (containing texture) to screen
|
||||
glBlitFramebuffer(0, fb->height(), fb->width(), 0, rx, ry, rw, rh, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
}
|
||||
}
|
||||
// make sure previous shader in another glcontext is disabled
|
||||
ShadingProgram::enduse();
|
||||
|
||||
// draw geometry
|
||||
else if (!Settings::application.render.disabled)
|
||||
if (!Settings::application.render.disabled)
|
||||
{
|
||||
// VAO is not shared between multiple contexts of different windows
|
||||
// so we have to create a new VAO for rendering the surface in this window
|
||||
|
||||
@@ -159,7 +159,6 @@ void Settings::Save(uint64_t runtime)
|
||||
XMLElement *RenderNode = xmlDoc.NewElement( "Render" );
|
||||
RenderNode->SetAttribute("vsync", application.render.vsync);
|
||||
RenderNode->SetAttribute("multisampling", application.render.multisampling);
|
||||
RenderNode->SetAttribute("blit", application.render.blit);
|
||||
RenderNode->SetAttribute("gpu_decoding", application.render.gpu_decoding);
|
||||
RenderNode->SetAttribute("ratio", application.render.ratio);
|
||||
RenderNode->SetAttribute("res", application.render.res);
|
||||
@@ -440,7 +439,6 @@ void Settings::Load()
|
||||
if (rendernode != nullptr) {
|
||||
rendernode->QueryIntAttribute("vsync", &application.render.vsync);
|
||||
rendernode->QueryIntAttribute("multisampling", &application.render.multisampling);
|
||||
rendernode->QueryBoolAttribute("blit", &application.render.blit);
|
||||
rendernode->QueryBoolAttribute("gpu_decoding", &application.render.gpu_decoding);
|
||||
rendernode->QueryIntAttribute("ratio", &application.render.ratio);
|
||||
rendernode->QueryIntAttribute("res", &application.render.res);
|
||||
|
||||
@@ -157,7 +157,6 @@ struct TransitionConfig
|
||||
struct RenderConfig
|
||||
{
|
||||
bool disabled;
|
||||
bool blit;
|
||||
int vsync;
|
||||
int multisampling;
|
||||
int ratio;
|
||||
@@ -169,7 +168,6 @@ struct RenderConfig
|
||||
|
||||
RenderConfig() {
|
||||
disabled = false;
|
||||
blit = false;
|
||||
vsync = 1;
|
||||
multisampling = 2;
|
||||
ratio = 3;
|
||||
|
||||
@@ -8466,11 +8466,9 @@ void Navigator::RenderMainPannelSettings()
|
||||
|
||||
static bool need_restart = false;
|
||||
static bool vsync = (Settings::application.render.vsync > 0);
|
||||
static bool blit = Settings::application.render.blit;
|
||||
static bool multi = (Settings::application.render.multisampling > 0);
|
||||
static bool gpu = Settings::application.render.gpu_decoding;
|
||||
bool change = false;
|
||||
change |= ImGuiToolkit::ButtonSwitch( "Blit framebuffer", &blit);
|
||||
#ifndef NDEBUG
|
||||
change |= ImGuiToolkit::ButtonSwitch( "Vertical synchronization", &vsync);
|
||||
change |= ImGuiToolkit::ButtonSwitch( "Antialiasing framebuffer", &multi);
|
||||
@@ -8486,7 +8484,6 @@ void Navigator::RenderMainPannelSettings()
|
||||
|
||||
if (change) {
|
||||
need_restart = ( vsync != (Settings::application.render.vsync > 0) ||
|
||||
blit != Settings::application.render.blit ||
|
||||
multi != (Settings::application.render.multisampling > 0) ||
|
||||
gpu != Settings::application.render.gpu_decoding );
|
||||
}
|
||||
@@ -8494,7 +8491,6 @@ void Navigator::RenderMainPannelSettings()
|
||||
ImGuiToolkit::Spacing();
|
||||
if (ImGui::Button( ICON_FA_POWER_OFF " Restart to apply", ImVec2(ImGui::GetContentRegionAvail().x - 50, 0))) {
|
||||
Settings::application.render.vsync = vsync ? 1 : 0;
|
||||
Settings::application.render.blit = blit;
|
||||
Settings::application.render.multisampling = multi ? 3 : 0;
|
||||
Settings::application.render.gpu_decoding = gpu;
|
||||
if (UserInterface::manager().TryClose())
|
||||
|
||||
Reference in New Issue
Block a user