Multiple screens 2014

Hello
Everything I found about multiple screens was about 5 years old or didnt have an answer. On the addons page I found many libraries but didnt know which is the newest, best etc… Im using OF0.8.1…

Maybe this could be a little collection for possibilities to make multiple screens in 2014.
In my case I need two windows: one for an interface and one for the graphics (maybe as fullscreen on another display?)

What do I have to do?
Thank you!

What platform is this for? I have some WIP code for doing multiple windows super easily on OS X.

Here is a simple example app for OF 0.8.1 for OS X
The code ‘should’ work on other platforms.

The app allows you to create new windows with key press ‘n’
Close current window with key press ‘c’
‘f’ toggles fullscreen

The app automatically loads and saves the window positions to xml.

If you add the files to a new Xcode project you will need to add the Carbon framework to the ‘link binary with library’ stage of Build Stages. You will also need to set the file type of AppGLFWMultiWindow.cpp to Objective-C++ or rename to AppGLFWMultiWindow.mm

Its WIP - but its been working pretty well for me.

You can load images in your main app and share all GL stuff across the different windows.

http://theo.tw/OF/multiWindowExample.zip

Thanks for the code Theo, this is super helpful!

I should also have some code lying around somewhere to control multiple screens on multiple graphic cards running linux.

Okay, seems to solve all my problems… especially because I had problems with ofxMultiGLFWWindow. Even works with different monitors and fullscreens. Thanks a lot!
(Im working on OS X, so dont know how it works on other platforms.)

@theo I just fixed your stuff to work with the new RC 0.8.2 with the updated GLFW callbacks

http://makeitdoathing.com/multiWindowExample.zip

thanks @theDANtheMAN !

I plan on turning this into an add-on.
so will probably put on my GH soon.

there are still a few little kinks - like windows sometimes being created when you start your app that you have to toggle fullscreen to get to appear.

what I like about this approach though is that it didn’t require any changes to ofApp - you get all the same callbacks as you would and you just query which window they are coming from with getActiveWindow() - so it makes it super easy to add into a project.

no yeah its super awesome and dead simple. screw the addon…lets put it in the core #Target 0.9.0!!!

@Theo I’m like haxoring this code and fixing some things that I call bugs. Like when I close all the windows and make a new one it picks up where I left off and keeps pushing back new pointers to new windows.

Make a repo so I can push things to it!!

Sounds good - going to put up a repo today.

The reason for always incrementing the window ID was it gets fairly complex if you open 3 windows. close the second one and then open a new one etc. You want the window ID for your windows not to change. However if they are all closed - it could be a good idea to reset the window counter.

Thanks. This is good stuff and would agree that the classes be added to the core. With the programmable renderer, I see the same issue with my implementation: it will draw to the additional windows if I set - setOpenGLVersion(3,2) on OS X, but 3,2 breaks on Windows 7/8 (VS). Any insight into this issue?

@theDANtheMAN - here is the repo!

I ended up making it an addon so the naming changed ever so slightly.
PR away! :slight_smile:

It seems to be related to issuing the same draw function on different windows. For example with two calls to the function ofCircle(), one on each window, the circle will be drawn only on the first window. Two different draw commands, will render correctly. This happens on all both Linux and Windows, but works on OS X.

I have the same issue on this and the other multi-window variations: ofxSecondWindow and ofxMultiGLFWWindow

Hey, is there a possibility to grab the screenpixels of the second window with ofImage::grabScreen? How can I access the screenpixels? best regards

So there is no solution?

I think vertex array objects aren’t being shared on PC. Thankfully someone wrote in a way to disable them globally. Add this in the setup method on Windows/Linux:

ofVbo::disableVAOs();

As far as grabbing the contents of another window, maybe you can just draw into an FBO and read to pixels…

the problem is VAO’s are necessary under the programmable renderer so you can’t disable them. also shaders aren’t shareable and there’s some of them used by the programmable renderer.

i was looking at how to integrate multiple windows in the core and we’ll need to change the architecture of OF a bit, there should be a renderer per window instead of a global one, that way the VAO’s used for drawing basic shapes will have an instance per window

This seems to be working for the render calls I’m making. Though I’d prefer to use VAOs, so I like the idea of a renderer per context or window.

I’m not having any issue with shaders…I thought they could be shared, no?
https://www.opengl.org/sdk/docs/man3/xhtml/glCreateShader.xml

So disabling VBOs works on my ATI card, but not NVIDIA. Guess I’ll be looking into implementing multiple renderers next week…or at least mulitple VBOs. Thanks!