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 )