I recently wrote a short demo program on how to setup a Multi-window Multi-context OpenGL demo using GLFW3. I thought I’d write a tutorial on how to setup this demo for yourself.
The tutorial is specific to MS Visual Studio 2012, however all the code and 3rd party libs are platform independent, so it shouldn’t be hard to port this to Mac/Linux.
The full source code is available here.
Update: Full source code for Visual Studio 2013 can be found here.
GLFW3, the successor to the popular GLFW2 cross-platform window management framework is nearing release. Update: GLFW3 was release some time ago now. Among it’s new features is support for multiple windows (each with a separate OpenGL context). Seeing this i decided to give it a go.
The Goal is to draw the same scene to two different windows, giving each window a separate camera so they can see the scene from different angles. for the demo we’ll use a simple rotating quad as the “scene”.
Using multiple windows involves solving several challenges, including:
- Tracking which OpenGL Context is active.
- Sharing Data between the different OpenGl Contexts (and therefor Window).
- Being able to re-size each window individually and have the correct OpenGL Context update.
- Closing windows at any time.