mirror of https://github.com/encounter/SDL.git
d76c2cc1da
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 |
||
---|---|---|
.. | ||
SDL.h | ||
SDL_assert.h | ||
SDL_atomic.h | ||
SDL_audio.h | ||
SDL_bits.h | ||
SDL_blendmode.h | ||
SDL_clipboard.h | ||
SDL_config.h | ||
SDL_config.h.cmake | ||
SDL_config.h.in | ||
SDL_config_android.h | ||
SDL_config_iphoneos.h | ||
SDL_config_macosx.h | ||
SDL_config_minimal.h | ||
SDL_config_pandora.h | ||
SDL_config_psp.h | ||
SDL_config_windows.h | ||
SDL_config_wiz.h | ||
SDL_copying.h | ||
SDL_cpuinfo.h | ||
SDL_egl.h | ||
SDL_endian.h | ||
SDL_error.h | ||
SDL_events.h | ||
SDL_filesystem.h | ||
SDL_gamecontroller.h | ||
SDL_gesture.h | ||
SDL_haptic.h | ||
SDL_hints.h | ||
SDL_joystick.h | ||
SDL_keyboard.h | ||
SDL_keycode.h | ||
SDL_loadso.h | ||
SDL_log.h | ||
SDL_main.h | ||
SDL_messagebox.h | ||
SDL_mouse.h | ||
SDL_mutex.h | ||
SDL_name.h | ||
SDL_opengl.h | ||
SDL_opengles.h | ||
SDL_opengles2.h | ||
SDL_pixels.h | ||
SDL_platform.h | ||
SDL_power.h | ||
SDL_quit.h | ||
SDL_rect.h | ||
SDL_render.h | ||
SDL_revision.h | ||
SDL_rwops.h | ||
SDL_scancode.h | ||
SDL_shape.h | ||
SDL_stdinc.h | ||
SDL_surface.h | ||
SDL_system.h | ||
SDL_syswm.h | ||
SDL_test.h | ||
SDL_test_assert.h | ||
SDL_test_common.h | ||
SDL_test_compare.h | ||
SDL_test_crc32.h | ||
SDL_test_font.h | ||
SDL_test_fuzzer.h | ||
SDL_test_harness.h | ||
SDL_test_images.h | ||
SDL_test_log.h | ||
SDL_test_md5.h | ||
SDL_test_random.h | ||
SDL_thread.h | ||
SDL_timer.h | ||
SDL_touch.h | ||
SDL_types.h | ||
SDL_version.h | ||
SDL_video.h | ||
begin_code.h | ||
close_code.h | ||
doxyfile |