Multiple Windows - ofGLProgrammableRenderer crashes

Hi
I’m trying to draw the same 3D scene but output it to different windows (for multiple projector output of a projection mapping application).
I’ve looked into using the examples/events/multiWindowOneAppExample example from OF 0.9.8 and adapting it to draw a simple test scene (simply an ofBoxPrimitive rednered in the centre of each output window)

The app launches and renders fine when drawing standard 2D graphics to each screen but the ofGLProgrammableRenderer throws an exception when trying to draw a mesh/geometry.

The exception is thrown at line 235:
drawElements(mesh.getVbo(),mode,mesh.getNumIndices());

I’ve tried it both sharing the gl context between windows and without.

This is using the multiWindowOneAppExample - I was hoping to be able to share the data and setup in the same app but draw it to multiple windows.

Is it possible to draw the same 3d primitive to different windows? Hopefully I’m just doing something wrong in the setup!

Thanks

It works if I create 2 instances of the geometry (i.e. cube1 & cube2) and then call their respective draw() methods from within that window’s own draw method. But not if I try and draw the same object twice (once for each window).

I’ve also tried using a pointer to the cube and calling cube->draw(); but the same exception’s thrown.

Maybe to do with the geometry’s index buffer not being reset or something?

you can’t share geometry like that between two windows, even when the context is shared between the two the geometry depends on a VAO which can’t be shared. if you really need to share it you can manually put the geometry in ofBufferObjects and pass it to 2 different ofVbos created while the context for each window is active and having the context shared.

to share the context, while creating the second window in main do:

settings.shareWith = firstWindow

Ok thanks @arturo - that makes sense.