Add a new hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT that allows SDL_CreateWindowFrom() to set the pixel format of another SDL_Window (and also will set the SDL_WINDOW_OPENGL flag on the window created with SDL_CreateWindowFrom()).

The reasoning behind this change is that source2 in -tools mode has a single OpenGL context that is used with multiple different windows. Some of those windows are created outside the engine (i.e. with Qt) and therefore we need to use SDL_CreateWindowFrom() to get an SDL_Window for those. The requirement for sharing an OpenGL context across multiple different windows is that each window has the same pixel format. To facilitate this, I now set SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT for the main window before calling SDL_CreateWindowFrom(). When I do this, SDL_CreateWindowFrom() will:

1. Set the pixel format of the returned window to the same pixel format as this SDL_Window passed in with the hint
2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for OpenGL rendering.

I only currently implemented this for Win32/WGL so implementing it for other platforms (i.e. X11) remains a TODO.

// Now I need to create another window from hEternalHwnd for my swap chain that will have the same pixel format as mainWindow, so set the hint
SDL_SetHint( SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, CFmtStr( %p, mainWindow) );

// Create the secondary window. This returned window will have SDL_WINDOW_OPENGL set and share a pixel format with mainWindow from the hint
SDL_Window *secondaryWindow = SDL_CreateWindowFrom( hExternalHwnd );

// To render to the main window:
SDL_GL_MakeCurrent( mainWindow, onlyContext );
// Do some rendering to main window

// To render to the secondary window:
SDL_GLMakeCurrent( secondaryWindow, onlyContext );
// Do some rendering to secondary window

1.1 --- a/include/SDL_hints.h Thu Jan 30 12:27:24 2014 -0800
1.2 +++ b/include/SDL_hints.h Thu Jan 30 12:30:40 2014 -0800
1.3 @@ -329,6 +329,25 @@
1.4 #define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER"
1.5 1.6 /**
1.7 +* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p").
1.8 +*
1.9 +* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has
1.10 +* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
1.11 +* created SDL_Window:
1.12 +
1.13 +* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is
1.14 +* needed for example when sharing an OpenGL context across multiple windows.
1.15 +*
1.16 +* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for
1.17 +* OpenGL rendering.
1.18 +*
1.19 +* This variable can be set to the following values:
1.20 +* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should
1.21 +* share a pixel format with.
1.22 +*/
1.23 +#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
1.24 +
1.25 +/**
1.26 * \brief An enumeration of hint priorities
1.27 */
1.28 typedef enum