mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Cleanup Rendering and Display view code to get texture of output
This commit is contained in:
@@ -132,18 +132,14 @@ void DisplaysView::update(float dt)
|
||||
{
|
||||
View::update(dt);
|
||||
|
||||
// a more complete update is requested
|
||||
if (View::need_deep_update_ > 0 && Mixer::manager().view() == this ) {
|
||||
// specific update when this view is active
|
||||
if ( Mixer::manager().view() == this ) {
|
||||
|
||||
// update rendering of render frame
|
||||
FrameBuffer *render = Mixer::manager().session()->frame();
|
||||
if (render) {
|
||||
output_ar = render->aspectRatio();
|
||||
for (int i = 0; i < MAX_OUTPUT_WINDOW; ++i)
|
||||
windows_[i].render_->setTextureIndex( Rendering::manager().outputWindow(i).texture() );
|
||||
}
|
||||
else
|
||||
output_ar = 1.f;
|
||||
for (int i = 0; i < MAX_OUTPUT_WINDOW; ++i)
|
||||
windows_[i].render_->setTextureIndex( Rendering::manager().outputWindow(i).texture() );
|
||||
|
||||
output_ar = Mixer::manager().session()->frame()->aspectRatio();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +230,6 @@ void DisplaysView::draw()
|
||||
|
||||
// update visible flag
|
||||
windows_[i].root_->visible_ = true;
|
||||
windows_[i].render_->visible_ = !Settings::application.render.disabled;
|
||||
windows_[i].icon_->visible_ = Settings::application.render.disabled;
|
||||
|
||||
if (windows_[i].render_->visible_) {
|
||||
@@ -400,8 +395,7 @@ void DisplaysView::draw()
|
||||
|
||||
// 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
|
||||
ImGuiToolkit::ButtonIconToggle(10,1,11,1, &Settings::application.windows[1+current_window_].show_pattern, "Test pattern");
|
||||
|
||||
// // White ballance
|
||||
// static DialogToolkit::ColorPickerDialog whitedialog;
|
||||
|
||||
@@ -1526,7 +1526,7 @@ void Mixer::setResolution(glm::vec3 res)
|
||||
{
|
||||
if (session_) {
|
||||
session_->setResolution(res);
|
||||
View::need_deep_update_+=2;
|
||||
++View::need_deep_update_;
|
||||
std::ostringstream info;
|
||||
info << "Session resolution changed to " << res.x << "x" << res.y;
|
||||
Log::Info("%s", info.str().c_str());
|
||||
|
||||
@@ -489,7 +489,7 @@ void Rendering::draw()
|
||||
g_timer_start(timer);
|
||||
}
|
||||
|
||||
// swap GL buffers
|
||||
// swap all GL buffers at once
|
||||
main_.swap();
|
||||
for (auto it = outputs_.begin(); it != outputs_.end(); ++it)
|
||||
it->swap();
|
||||
@@ -1019,8 +1019,9 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
|
||||
//
|
||||
// Stream pattern
|
||||
//
|
||||
pattern_->open("videotestsrc pattern=smpte", 1280, 720);
|
||||
pattern_->open("videotestsrc pattern=smpte", 1024, 1024);
|
||||
pattern_->play(true);
|
||||
textureid_ = Resource::getTextureBlack();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1044,6 +1045,7 @@ void RenderingWindow::terminate()
|
||||
surface_ = nullptr;
|
||||
fbo_ = 0;
|
||||
index_ = -1;
|
||||
textureid_ = Resource::getTextureBlack();
|
||||
}
|
||||
|
||||
void RenderingWindow::show()
|
||||
@@ -1088,6 +1090,7 @@ void RenderingWindow::swap()
|
||||
|
||||
bool RenderingWindow::draw(FrameBuffer *fb)
|
||||
{
|
||||
// cannot draw if there is no window or invalid framebuffer
|
||||
if (!window_ || !fb)
|
||||
return false;
|
||||
|
||||
@@ -1108,8 +1111,12 @@ bool RenderingWindow::draw(FrameBuffer *fb)
|
||||
ShadingProgram::enduse();
|
||||
|
||||
// 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
|
||||
// so we have to create a new VAO for rendering the surface in this window
|
||||
if (surface_ == nullptr)
|
||||
@@ -1130,6 +1137,7 @@ bool RenderingWindow::draw(FrameBuffer *fb)
|
||||
|
||||
// Display option: draw calibration pattern
|
||||
if ( Settings::application.windows[index_].show_pattern) {
|
||||
// draw pattern texture
|
||||
pattern_->update();
|
||||
textureid_ = pattern_->texture();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user