# Multiwindow linux gl resource sharing?

**URL:** <https://discourse.libcinder.org/t/multiwindow-linux-gl-resource-sharing/687>\
**Category:** Using Cinder\
**Created:** [May 16, 2017, 7:21am UTC](https://discourse.libcinder.org/t/multiwindow-linux-gl-resource-sharing/687 "2017-05-16T07:21:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [May 16, 2017, 7:21am UTC](https://discourse.libcinder.org/t/multiwindow-linux-gl-resource-sharing/687/1 "2017-05-16T07:21:46Z")

</div>

Hi,

I encountered an issue when porting an OSX app to Linux. Created a basic test with and Fbo whose color texture should be shared between the two windows, but it isn’t. What is the correct way of doing this? If I remember correctly this has worked before for me on Linux.  
Latest Cinder git master with gtx 1080, proprietary driver 375.39, on Fedora 25.

Thanks,  
-Gabor

OSX:

 ![](https://canada1.discourse-cdn.com/flex030/uploads/libcinder/original/1X/db5e4d5c3f677a15e350d2a008c6892959e645ab.jpg)

Linux:

 ![](https://canada1.discourse-cdn.com/flex030/uploads/libcinder/original/1X/b3d0bf58b63094522f88957cd0a886857c89fd0d.png)

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

using namespace ci;
using namespace ci::app;

class MultiWindowTestApp : public App
{
 public:
	void setup() override;
	void update() override;

 private:
	app::WindowRef mWindow0;
	app::WindowRef mWindow1;

	void drawWindow( size_t windowId );

	void renderFbo();

	gl::FboRef mFbo;
};

void MultiWindowTestApp::setup()
{
    mFbo = gl::Fbo::create( 1920, 1080 );

	mWindow0 = app::getWindow();
	mWindow0->getSignalDraw().connect( [&]() { drawWindow( 0 ); } );

	mWindow1 = createWindow( Window::Format().size( ivec2( 400 ) ) );
	mWindow1->getSignalDraw().connect( [&]() { drawWindow( 1 ); } );
}

void MultiWindowTestApp::renderFbo()
{
	gl::ScopedFramebuffer fbo( mFbo );
	gl::ScopedViewport viewport( mFbo->getSize() );
	gl::clear( Color( 1.0f, 0.0f, 0.2f ) );
}

void MultiWindowTestApp::update()
{
	renderFbo();
}

void MultiWindowTestApp::drawWindow( size_t windowId )
{
	gl::viewport( getWindowSize() );
	gl::setMatricesWindow( getWindowSize() );

	gl::clear();
	gl::draw( mFbo->getColorTexture(), getWindowBounds() );
}

CINDER_APP( MultiWindowTestApp, RendererGl )

```

---

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [May 16, 2017, 8:34am UTC](https://discourse.libcinder.org/t/multiwindow-linux-gl-resource-sharing/687/2 "2017-05-16T08:34:02Z")

</div>

It seems I didn’t remember it right, I had to modify Cinder and pass the first window to `glfwCreateWindow` before to share the context.

---

<div class="post-metadata">

**Author:** ![petros](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/petros/32/26_2.png) [@petros](https://discourse.libcinder.org/u/petros)\
**Post date:** [May 16, 2017, 1:15pm UTC](https://discourse.libcinder.org/t/multiwindow-linux-gl-resource-sharing/687/3 "2017-05-16T13:15:39Z")

</div>

This is true.

Unfortunately in GLFW the abstractions make the concept of Window and Context virtually inseparable. The only way to share context in GLFW-land is the way you describe so we would have to figure out a way to allow this, potentially with a Linux-GLFW `ifdef` clause inside `cinder::app::Window::Format` which allows one to pass a pointer of the window to share context with.

Probably deserves an issue ticket on its own.

---

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [May 16, 2017, 1:34pm UTC](https://discourse.libcinder.org/t/multiwindow-linux-gl-resource-sharing/687/4 "2017-05-16T13:34:53Z")

</div>

Thanks Petros. The way I hacked it in, is that I’m sharing the context of the first window with all other windows automatically in `WindowImplLinux`. Is it how it works on other platforms, isn’t it?
