From f4c52b7ed32c69b166d0c73515cb4074be6ba649 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sun, 19 Sep 2021 11:07:13 +0200 Subject: [PATCH] Fixed output monitor disablling --- RenderingManager.cpp | 101 ++++++++++++++++++++------------------- UserInterfaceManager.cpp | 16 +++---- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/RenderingManager.cpp b/RenderingManager.cpp index 40d89d0..6267020 100644 --- a/RenderingManager.cpp +++ b/RenderingManager.cpp @@ -816,28 +816,28 @@ void RenderingWindow::draw(FrameBuffer *fb) Rendering::manager().pushAttrib(window_attributes_); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - // if not disabled - if (!Settings::application.render.disabled) { + // blit framebuffer + if (Settings::application.render.blit) { - // blit framebuffer - if (Settings::application.render.blit) { + if ( textureid_ != fb->texture()) { - if ( textureid_ != fb->texture()) { + 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_); - // 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 + } - // 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; @@ -866,43 +866,44 @@ void RenderingWindow::draw(FrameBuffer *fb) glBlitFramebuffer(0, fb->height(), fb->width(), 0, rx, ry, rw, rh, GL_COLOR_BUFFER_BIT, GL_LINEAR); } - // draw geometry - else - { - // 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 - if (surface_ == 0) - surface_ = new WindowSurface; - - // calculate scaling factor of frame buffer inside window - float windowAspectRatio = aspectRatio(); - float renderingAspectRatio = fb->aspectRatio(); - glm::vec3 scale; - if (windowAspectRatio < renderingAspectRatio) - scale = glm::vec3(1.f, windowAspectRatio / renderingAspectRatio, 1.f); - else - scale = glm::vec3(renderingAspectRatio / windowAspectRatio, 1.f, 1.f); - - // make sure previous shader in another glcontext is disabled - ShadingProgram::enduse(); - - // draw - glBindTexture(GL_TEXTURE_2D, fb->texture()); - // surface->shader()->color.a = 0.4f; // TODO alpha blending ? - static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); - surface_->draw(glm::scale(glm::identity(), scale), projection); - - // done drawing (unload shader from this glcontext) - ShadingProgram::enduse(); - glBindTexture(GL_TEXTURE_2D, 0); - } - } - // restore attribs - Rendering::manager().popAttrib(); + + // draw geometry + else 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 + if (surface_ == 0) + surface_ = new WindowSurface; + + // calculate scaling factor of frame buffer inside window + float windowAspectRatio = aspectRatio(); + float renderingAspectRatio = fb->aspectRatio(); + glm::vec3 scale; + if (windowAspectRatio < renderingAspectRatio) + scale = glm::vec3(1.f, windowAspectRatio / renderingAspectRatio, 1.f); + else + scale = glm::vec3(renderingAspectRatio / windowAspectRatio, 1.f, 1.f); + + // make sure previous shader in another glcontext is disabled + ShadingProgram::enduse(); + + // draw + glBindTexture(GL_TEXTURE_2D, fb->texture()); + // surface->shader()->color.a = 0.4f; // TODO alpha blending ? + static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); + surface_->draw(glm::scale(glm::identity(), scale), projection); + + // done drawing (unload shader from this glcontext) + ShadingProgram::enduse(); + glBindTexture(GL_TEXTURE_2D, 0); + } } + // restore attribs + Rendering::manager().popAttrib(); + // give back context ownership glfwMakeContextCurrent(master_); } diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 172b2ea..e239929 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -1061,23 +1061,20 @@ void UserInterface::RenderPreview() Settings::application.widget.preview = false; if (ImGui::BeginMenu(IMGUI_TITLE_PREVIEW)) { - if ( ImGui::MenuItem( ICON_FA_PLUS " Insert Rendering Source") ) - Mixer::manager().addSource( Mixer::manager().createSourceRender() ); - - if ( ImGui::MenuItem( ICON_FA_WINDOW_RESTORE " Show output window") ) + // Output window menu + if ( ImGui::MenuItem( ICON_FA_WINDOW_RESTORE " Show window") ) Rendering::manager().outputWindow().show(); bool isfullscreen = Rendering::manager().outputWindow().isFullscreen(); - if ( ImGui::MenuItem( ICON_FA_EXPAND_ALT " Fullscreen output window", nullptr, &isfullscreen) ) { + if ( ImGui::MenuItem( ICON_FA_EXPAND_ALT " Fullscreen window", nullptr, &isfullscreen) ) { Rendering::manager().outputWindow().show(); Rendering::manager().outputWindow().toggleFullscreen(); } - ImGui::MenuItem( ICON_FA_EYE_SLASH " Disable output", NULL, &Settings::application.render.disabled); - + ImGui::MenuItem( ICON_FA_EYE_SLASH " Disable", NULL, &Settings::application.render.disabled); + // output manager menu ImGui::Separator(); - bool pinned = Settings::application.widget.preview_view == Settings::application.current_view; if ( ImGui::MenuItem( ICON_FA_MAP_PIN " Pin window to view", nullptr, &pinned) ){ if (pinned) @@ -1163,8 +1160,9 @@ void UserInterface::RenderPreview() // ImGui::EndMenu(); } - if (ImGui::BeginMenu("Share stream")) + if (ImGui::BeginMenu("Share")) { + #if defined(LINUX_NOT_YET_WORKING) bool on = webcam_emulator_ != nullptr; if ( ImGui::MenuItem( ICON_FA_CAMERA " Emulate video camera", NULL, &on) ) {