ext-SDL/include
Sam Lantinga d76c2cc1da 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.

CR: SamL

Some pseudocode that shows how this is used in Source2:

HWND hExternalHwnd; // HWND that was established outside of SDL

// Create main window (happens inside platwindow.cpp)
SDL_Window *mainWindow = SDL_CreateWindow( , SDL_WINDOW_OPENGL .. );
// Create GL context, happens inside rendersystemgl
SDL_GLContext onlyContext = SDL_GL_CreateContext( mainWindow );

// 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
2014-01-30 12:30:40 -08:00
..
begin_code.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
close_code.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
doxyfile Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_assert.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_atomic.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_audio.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_bits.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_blendmode.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_clipboard.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_config_android.h We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config_iphoneos.h We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config_macosx.h We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config_minimal.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_config_pandora.h We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config_psp.h We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config_windows.h Added SDL_vsscanf(). 2013-11-24 23:35:38 -05:00
SDL_config_wiz.h We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_config.h.cmake We don't need to check for snprintf() anymore, we don't use it. 2013-11-24 23:36:15 -05:00
SDL_config.h.in Dynamic loading support for Wayland 2014-01-09 13:56:21 -03:00
SDL_copying.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_cpuinfo.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_egl.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_endian.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_error.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_events.h Added support for double-clicks, through a new "clicks" field in the mouse button event. 2013-12-23 12:17:52 -08:00
SDL_filesystem.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_gamecontroller.h Added missing header for file IO 2013-12-05 09:54:22 -08:00
SDL_gesture.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_haptic.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_hints.h 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()). 2014-01-30 12:30:40 -08:00
SDL_joystick.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_keyboard.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_keycode.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_loadso.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_log.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_main.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_messagebox.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_mouse.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_mutex.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_name.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_opengl.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_opengles2.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_opengles.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_pixels.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_platform.h Bump SDL to build with 10.7 SDK. 2013-12-27 10:18:11 -08:00
SDL_power.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_quit.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_rect.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_render.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_revision.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_rwops.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_scancode.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_shape.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_stdinc.h Added SDL_vsscanf(). 2013-11-24 23:35:38 -05:00
SDL_surface.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_system.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_syswm.h Preserve binary compatibility in SDL_SYSWM_TYPE (thanks Gerry JJ!) 2014-01-28 09:13:46 -03:00
SDL_test_assert.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_common.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_compare.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_crc32.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_font.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_fuzzer.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_harness.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_images.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_log.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_md5.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test_random.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_test.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_thread.h Implemented the Dynamic API magic. 2013-12-09 16:03:18 -05:00
SDL_timer.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_touch.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_types.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_version.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL_video.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00
SDL.h Improve Android pause/resume behavior. 2013-11-29 10:06:08 -03:00