Cleanup Rendering and Display view code to get texture of output

This commit is contained in:
Bruno Herbelin
2023-02-28 19:12:51 +01:00
parent bc439829cf
commit 35507e7fbb
3 changed files with 20 additions and 18 deletions

View File

@@ -132,18 +132,14 @@ void DisplaysView::update(float dt)
{ {
View::update(dt); View::update(dt);
// a more complete update is requested // specific update when this view is active
if (View::need_deep_update_ > 0 && Mixer::manager().view() == this ) { if ( Mixer::manager().view() == this ) {
// update rendering of render frame // update rendering of render frame
FrameBuffer *render = Mixer::manager().session()->frame(); for (int i = 0; i < MAX_OUTPUT_WINDOW; ++i)
if (render) { windows_[i].render_->setTextureIndex( Rendering::manager().outputWindow(i).texture() );
output_ar = render->aspectRatio();
for (int i = 0; i < MAX_OUTPUT_WINDOW; ++i) output_ar = Mixer::manager().session()->frame()->aspectRatio();
windows_[i].render_->setTextureIndex( Rendering::manager().outputWindow(i).texture() );
}
else
output_ar = 1.f;
} }
} }
@@ -234,7 +230,6 @@ void DisplaysView::draw()
// update visible flag // update visible flag
windows_[i].root_->visible_ = true; windows_[i].root_->visible_ = true;
windows_[i].render_->visible_ = !Settings::application.render.disabled;
windows_[i].icon_->visible_ = Settings::application.render.disabled; windows_[i].icon_->visible_ = Settings::application.render.disabled;
if (windows_[i].render_->visible_) { if (windows_[i].render_->visible_) {
@@ -400,8 +395,7 @@ void DisplaysView::draw()
// Pattern output // Pattern output
ImGui::SameLine(0, 50); ImGui::SameLine(0, 50);
if ( ImGuiToolkit::ButtonIconToggle(10,1,11,1, &Settings::application.windows[1+current_window_].show_pattern, "Test pattern") ) 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 // // White ballance
// static DialogToolkit::ColorPickerDialog whitedialog; // static DialogToolkit::ColorPickerDialog whitedialog;

View File

@@ -1526,7 +1526,7 @@ void Mixer::setResolution(glm::vec3 res)
{ {
if (session_) { if (session_) {
session_->setResolution(res); session_->setResolution(res);
View::need_deep_update_+=2; ++View::need_deep_update_;
std::ostringstream info; std::ostringstream info;
info << "Session resolution changed to " << res.x << "x" << res.y; info << "Session resolution changed to " << res.x << "x" << res.y;
Log::Info("%s", info.str().c_str()); Log::Info("%s", info.str().c_str());

View File

@@ -489,7 +489,7 @@ void Rendering::draw()
g_timer_start(timer); g_timer_start(timer);
} }
// swap GL buffers // swap all GL buffers at once
main_.swap(); main_.swap();
for (auto it = outputs_.begin(); it != outputs_.end(); ++it) for (auto it = outputs_.begin(); it != outputs_.end(); ++it)
it->swap(); it->swap();
@@ -1019,8 +1019,9 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
// //
// Stream pattern // Stream pattern
// //
pattern_->open("videotestsrc pattern=smpte", 1280, 720); pattern_->open("videotestsrc pattern=smpte", 1024, 1024);
pattern_->play(true); pattern_->play(true);
textureid_ = Resource::getTextureBlack();
return true; return true;
} }
@@ -1044,6 +1045,7 @@ void RenderingWindow::terminate()
surface_ = nullptr; surface_ = nullptr;
fbo_ = 0; fbo_ = 0;
index_ = -1; index_ = -1;
textureid_ = Resource::getTextureBlack();
} }
void RenderingWindow::show() void RenderingWindow::show()
@@ -1088,6 +1090,7 @@ void RenderingWindow::swap()
bool RenderingWindow::draw(FrameBuffer *fb) bool RenderingWindow::draw(FrameBuffer *fb)
{ {
// cannot draw if there is no window or invalid framebuffer
if (!window_ || !fb) if (!window_ || !fb)
return false; return false;
@@ -1108,8 +1111,12 @@ bool RenderingWindow::draw(FrameBuffer *fb)
ShadingProgram::enduse(); ShadingProgram::enduse();
// draw geometry // draw geometry
if (!Settings::application.render.disabled) if (Settings::application.render.disabled)
{ // no draw; indicate texture is black
textureid_ = Resource::getTextureBlack();
else {
// normal draw
// VAO is not shared between multiple contexts of different windows // 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 // so we have to create a new VAO for rendering the surface in this window
if (surface_ == nullptr) if (surface_ == nullptr)
@@ -1130,6 +1137,7 @@ bool RenderingWindow::draw(FrameBuffer *fb)
// Display option: draw calibration pattern // Display option: draw calibration pattern
if ( Settings::application.windows[index_].show_pattern) { if ( Settings::application.windows[index_].show_pattern) {
// draw pattern texture
pattern_->update(); pattern_->update();
textureid_ = pattern_->texture(); textureid_ = pattern_->texture();
} }