Multiwindow update/draw call issue


#1

I have encountered a strange issue in a multiwindow setting on OSX 10.12 that I haven’t seen before.
If I call some gl commands from update, like drawing to an Fbo, it seems to be interfering with the multiwindow draw methods.

Here’s a small sample that opens two windows and draws a window size rectangle in both of them that should look like this:

But sometimes (about 2 out of 5 times) it looks like this when switching between the windows.

As far as I know update is called before all the window draw's, so I don’t really understand what is happening. Am I doing something wrong? Any help would be appreciated.

#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"

using namespace ci;
using namespace ci::app;

class MultiWindowApp : public App
{
 public:
	void setup() override;
	void update() override;
	void drawWindow1();
	void drawWindow2();

 private:
	app::WindowRef mWindow1;
	app::WindowRef mWindow2;
};

void MultiWindowApp::setup()
{
	mWindow1 = app::getWindow();
	mWindow1->setTitle( "Window1" );
	mWindow1->getSignalDraw().connect( std::bind( &MultiWindowApp::drawWindow1, this ) );

	mWindow2 = createWindow( Window::Format().size( 800, 600 ) );
	mWindow2->setTitle( "Window2" );
	mWindow2->getSignalDraw().connect( std::bind( &MultiWindowApp::drawWindow2, this ) );
}

void MultiWindowApp::update()
{
	// this triggers the weird behaviour
	gl::ScopedViewport viewport( getWindowSize() / 2 );
}

void MultiWindowApp::drawWindow1()
{
	gl::ScopedViewport viewport( getWindowSize() );
	gl::ScopedMatrices matrices;
	gl::setMatricesWindow( getWindowSize() );

	gl::clear();
	gl::ScopedColor color( Color( 1, 0, 0 ) );
	gl::drawSolidRect( getWindowBounds() );
}

void MultiWindowApp::drawWindow2()
{
	gl::ScopedViewport viewport( getWindowSize() );
	gl::ScopedMatrices matrices;
	gl::setMatricesWindow( getWindowSize() );

	gl::clear();
	gl::ScopedColor color( Color( 1, 0, 1 ) );
	gl::drawSolidRect( getWindowBounds() );
}

CINDER_APP( MultiWindowApp, RendererGl )

#2

I am wondering if you need to specify which WindowSize you want to apply in the viewport for that window.

You could try getWindowIndex(…)->getSize() or something like that…

L


#3

Thanks. I think it should work like this, but tried using mWindow1->getSize(), mWindow1->getBounds(), etc, but it didn’t help.