Multiple windows using GLFW

GLFW 3.0 which is now included in the latest core supports multiple windows. Is there any way to take advantage of this in OF yet? I’ve had a look at the code and it’s looks very much oriented towards just a single window, but I could be wrong.

If it’s possible, it would be great to include an example of this.

no, not yet, we’ve been looking into it but finally we decided to postpone it to the next version.

Ah ok great. Looking forward to it then!

Who is working on the multiple window stuff for the post-0.8.0 version, now that GLFW is in place? Does someone have a Git branch somewhere I could test out and/or contribute to? The closest I’ve seen is underdoeg’s stuff (underdoeg:multiwindow) that was closed/postponed for 0.8.0.

Thanks,
Glen.

I’d like to know this too, OfxFenster is meant to be working now but I’m unable to get it compiled on osx

I am curious about this too; I’ve just realized that Windows7 can’t keep a single openGL context in Vertical Sync if it’s spanned across different monitors (you get random tearing). I think a solution could be to have 3 different fullscreen windows, each in its own monitor, under GLFW. Cinder allows that, and on a quick test, it seemed to solve the tearing issue.

Having a reliable and sufficiently easy/efficient way to create multiple windows is a great feature (think for example rendering the GUI or debug stuff onto a separate window - maybe even position in on a second monitor - and avoid cluttering the actual app).

I have made a series of multi-windows apps, but they were in straight OpenGL / GLFW. I have been quickly looking at the structure used in OF but it’s pretty convoluted and Im pretty stacked at the moment. If someone is working on this (with a clear understanding of the windowing workflow in OF) I will also be happy to give a hand on this …

PS: Im mostly interested in a solution that can work on Windows

BTW… ofxFenster doesnt really work (at least on Win / OF08)

(Ping!)

Sorry to be a nuisance, but any update on the status of GLFW multi-window support? Will it be in 0.8.1, or is it likely to be postponed again? It would be great to make the move to OF 0.8, but in the meantime, we’ll (have to) remain on ofxFenster and OF 0.7.4.

I made multiwindow with GLFW work yesterday. It was a very straight-forward hack, using GLFW functions directly. It’s really easy to do it, even with shared context.
Does anyone knows if this feature will be soon added to oF? I can make a simple example of what I’ve done if anyone is interested.

id like to see the example

cheers

Check out this little example:

It shows two windows side by side playing the same video.
on the setup method I get the GLFWwindow and I use it to create the auxiliar window, sharing the context this way.

We need to store the GLFWwindow pointers so we switch to the desired window when drawing.

Hope this is useful.

I have just created an addon based on your code – hope this will be useful. I also couldn’t get ofxFenster compiled.

1 Like

Well done genekogan! When I run the example I only see one window. I’ll take a look at it during the weekend.
Also, you can change the code on the ofxSecondWindow::draw method to:

glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

to have the coordinate system in pixels, just like a regular oF window.

Also, I would create a method with only this code, call it something like: ofxSecondWindow::begin(). it would start by switching to this window. then I would create another method called ofxSecondWindow::end() that would send to the primary window.

the reason you don’t see it is that the example makes a second window and offsets it by the width of your screen (to a second monitor or projector). if you comment that out and run instead something like:

secondWindow.setup("second window", 50, 50, 500, 500, false);

it’ll appear in the main window.

also thanks for the tip on coordinate system – i have changed it to be drawn using a begin and end block.

Does this work on Ubuntu as well?

i believe it should, but i have not tested it.

I tried, but it didn’t work. I need it for my app. Could you please help!

@Dhanoa

Can you post some code

I ran the example code with that secondWindow.setup(“second window”, 50, 50, 500, 500, false); change(mentioned above ) and only one window appeared.