From bc439829cfb43edec0afd6ab5cd800ca2d9dfd13 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Tue, 28 Feb 2023 00:24:19 +0100 Subject: [PATCH] DRAFT feature for showing test pattern on output window --- rsc/images/icons.dds | Bin 1638528 -> 1638528 bytes src/DisplaysView.cpp | 48 ++++++++++++++++++++++++++++++++++++++- src/Mixer.cpp | 2 +- src/RenderingManager.cpp | 28 +++++++++++++++++------ src/RenderingManager.h | 3 +++ src/Settings.h | 3 ++- 6 files changed, 74 insertions(+), 10 deletions(-) diff --git a/rsc/images/icons.dds b/rsc/images/icons.dds index 850dd053278b50eab4cd892712fdf0fc351c346d..6654a7be066efabac0cfa7e210bf9029985c5cf2 100644 GIT binary patch delta 9649 zcmeHN4@?|Y8lT>(-wz*yO{!H&`I@fS?YAL?^zS(`V zZ>AFDG`V=`OCR(%-#6dC-+OP~yrF%^W9{(oH9KJ2r#S){+;XX$p_=-}G9(^UI}IG(j+l@KEhW#FP3 zFJp_S_7cE>I3gsf-nacr;0dZ9BPU*E^{>U#A&}1`^czTwsDs8EjF^zwD9Goi1415B z0EfvYGDNS%3uWa}xw|>MmMENu+mp=qP0Tk-sFvYoJzGM2i1ln23MP?_Kpn@(UQ@P4 z993Uw0{azIKe}mwa$Z~hQa>2T$85#NjyeVLFMYN@N>Z)mJ%{iaH^&hzVJ&0oBt~8; z0zxt)T9Twfy}uF~#SLZk ze)@m>ZN}TYKoJwbvbqr$TY(s<_j6Ez*Vqb3tv|CYS>Cauca?y{rU)AK@mJ4?3-Vk*f`o1W^XX#R%QR>;lqdZjWfQgfWH2wkl44{ z;``P=4Ys$p7g5_j`RP7*3(_~`ZaHAUC&OD`X60Ss+?_0by6?X2u!|I^J*8z?9V@>E zSG2rac=__>hv^LsWpW{VgBfr0KI^!8^=diQA8|eFfCO}h5mheK_pRZeRom>W6cju) zC<4Rr`z~BS9N@TLoABo>p3~ooX0jo6M27Vg zPRX0$rIr$j+7Y$w;fM7B6j581E70P0kS3pe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U~;s8q|ZKKY( z)Ex@;)mA67l2QR}Fe1_%{v8;x^YXzJ^AsVmr!aHcMdiA0DawMR)KD6y`{;VkSB0YA z)|H0omLx2|Nj^$9(-E35N-yQ@TMuBR6_)Evf1`>-J27Fk8tlr1o3|=2Em9s4n!#no z)%{+N4-`~l4N{|UB0N^qkxC&n4$}Gk!EyJ z+o-Sy9~dZ zxSd3f$dhVa2l(MInCUlLo6(Rg@GLWIlk!(yA18yyv7j7Lh(Zjap-U}QxkA?Uru!Qj7x28!!IY(L zfF4aL}^E>PJm0vY86VvQrqODhSVk$+Jg z!?+86@ELo1@|*O4CP$$Il+Xu#>r|HC@^jkhQ+TQK1>@_)F3&E`b-&Nvu>=>uV|=+&)K*Sj$VKEK@(~3H1)(Ae5k-h% QLaspectRatio(); for (int i = 0; i < MAX_OUTPUT_WINDOW; ++i) - windows_[i].render_->setTextureIndex( render->texture() ); + windows_[i].render_->setTextureIndex( Rendering::manager().outputWindow(i).texture() ); } else output_ar = 1.f; @@ -395,6 +395,52 @@ void DisplaysView::draw() else ImGuiToolkit::Icon(19, 4, false); + // Modify current window + if (current_window_ > -1) { + + // Pattern output + ImGui::SameLine(0, 50); + if ( ImGuiToolkit::ButtonIconToggle(10,1,11,1, &Settings::application.windows[1+current_window_].show_pattern, "Test pattern") ) + View::need_deep_update_ += 2; // two frames update to get pattern initialized + +// // White ballance +// static DialogToolkit::ColorPickerDialog whitedialog; +// ImGui::SameLine(0, 30); +// ImGuiToolkit::Icon(5, 4); +// static ImVec4 white = ImVec4(1.f, 1.f, 1.f, 1.f); +// ImGui::SameLine(); +// ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT); +// if (ImGui::ColorButton("White", white, ImGuiColorEditFlags_NoAlpha)) { +// whitedialog.setRGB( std::make_tuple(white.x, white.y, white.z) ); +// whitedialog.open(); +// } +// ImGui::PopFont(); +// // get picked color if dialog finished +// if (whitedialog.closed()){ +// std::tuple c = whitedialog.RGB(); +// white.x = std::get<0>(c); +// white.y = std::get<1>(c); +// white.z = std::get<2>(c); +// } + +// ImGui::SameLine(); +// ImGuiToolkit::Icon(3,4); +// static ImVec4 grey = ImVec4(0.5f, 0.5f, 0.5f, 1.f); +// ImGui::SameLine(); +// ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT); +// ImGui::ColorButton("Grey", grey, ImGuiColorEditFlags_NoAlpha); +// ImGui::PopFont(); + +// ImGui::SameLine(); +// ImGuiToolkit::Icon(4,4); +// static ImVec4 black = ImVec4(0.f, 0.f, 0.f, 1.f); +// ImGui::SameLine(); +// ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT); +// ImGui::ColorButton("Black", black, ImGuiColorEditFlags_NoAlpha); +// ImGui::PopFont(); + + + } ImGui::PopStyleColor(14); // 14 colors diff --git a/src/Mixer.cpp b/src/Mixer.cpp index b5155bb..9c92998 100644 --- a/src/Mixer.cpp +++ b/src/Mixer.cpp @@ -1526,7 +1526,7 @@ void Mixer::setResolution(glm::vec3 res) { if (session_) { session_->setResolution(res); - ++View::need_deep_update_; + View::need_deep_update_+=2; std::ostringstream info; info << "Session resolution changed to " << res.x << "x" << res.y; Log::Info("%s", info.str().c_str()); diff --git a/src/RenderingManager.cpp b/src/RenderingManager.cpp index 8fc97c2..53a4eff 100644 --- a/src/RenderingManager.cpp +++ b/src/RenderingManager.cpp @@ -60,6 +60,7 @@ // vimix #include "defines.h" #include "Log.h" +#include "Stream.h" #include "Resource.h" #include "Settings.h" #include "ImageShader.h" @@ -693,6 +694,7 @@ WindowSurface::WindowSurface(Shader *s) : Primitive(s) RenderingWindow::RenderingWindow() : window_(NULL), master_(NULL), index_(-1), dpi_scale_(1.f), textureid_(0), fbo_(0), surface_(nullptr), request_change_fullscreen_(false) { + pattern_ = new Stream; } RenderingWindow::~RenderingWindow() @@ -1014,6 +1016,12 @@ bool RenderingWindow::init(int index, GLFWwindow *share) window_attributes_.clear_color = glm::vec4(COLOR_BGROUND, 1.f); } + // + // Stream pattern + // + pattern_->open("videotestsrc pattern=smpte", 1280, 720); + pattern_->play(true); + return true; } @@ -1108,10 +1116,11 @@ bool RenderingWindow::draw(FrameBuffer *fb) surface_ = new WindowSurface; // calculate scaling factor of frame buffer inside window - float windowAspectRatio = aspectRatio(); - float renderingAspectRatio = fb->aspectRatio(); + const float windowAspectRatio = aspectRatio(); + const float renderingAspectRatio = fb->aspectRatio(); glm::vec3 scale = glm::vec3(1.f, 1.f, 1.f); + // Display option: scaled or corrected aspect ratio if (!Settings::application.windows[index_].scaled) { if (windowAspectRatio < renderingAspectRatio) scale = glm::vec3(1.f, windowAspectRatio / renderingAspectRatio, 1.f); @@ -1119,12 +1128,17 @@ bool RenderingWindow::draw(FrameBuffer *fb) scale = glm::vec3(renderingAspectRatio / windowAspectRatio, 1.f, 1.f); } - // make sure previous shader in another glcontext is disabled - ShadingProgram::enduse(); + // Display option: draw calibration pattern + if ( Settings::application.windows[index_].show_pattern) { + pattern_->update(); + textureid_ = pattern_->texture(); + } + else + // draw normal texture + textureid_ = fb->texture(); - // draw - glBindTexture(GL_TEXTURE_2D, fb->texture()); - // surface->shader()->color.a = 0.4f; // TODO alpha blending ? + // actual render of the textured surface + glBindTexture(GL_TEXTURE_2D, textureid_); 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); diff --git a/src/RenderingManager.h b/src/RenderingManager.h index 62a2f83..f39acdc 100644 --- a/src/RenderingManager.h +++ b/src/RenderingManager.h @@ -16,6 +16,7 @@ typedef struct GLFWmonitor GLFWmonitor; typedef struct GLFWwindow GLFWwindow; class FrameBuffer; +class Stream; struct RenderingAttrib { @@ -37,6 +38,7 @@ class RenderingWindow // objects to render uint textureid_; uint fbo_; + Stream *pattern_; class WindowSurface *surface_; protected: @@ -65,6 +67,7 @@ public: // draw a framebuffer bool draw(FrameBuffer *fb); + inline uint texture() const {return textureid_; } void swap(); // fullscreen diff --git a/src/Settings.h b/src/Settings.h index 887aabe..0342d8c 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -63,9 +63,10 @@ struct WindowConfig bool scaled; bool decorated; std::string monitor; + bool show_pattern; WindowConfig() : name(APP_TITLE), x(15), y(15), w(1280), h(720), - fullscreen(false), scaled(false), decorated(true), monitor("") { } + fullscreen(false), scaled(false), decorated(true), monitor(""), show_pattern(false) { } };