void* getNativeWindow(SDL_Window* sdlWindow) { SDL_SysWMinfo wmi; SDL_VERSION(&wmi.version); ASSERT_POSTCONDITION(SDL_GetWindowWMInfo(sdlWindow, &wmi), "SDL version unsupported!"); HDC win = (HDC) wmi.info.win.hdc; return (void*) win; }
/** * @brief Call to SDL_GetWindowWMInfo */ int syswm_getWindowWMInfo(void *arg) { SDL_bool result; SDL_Window *window; SDL_SysWMinfo info; window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN); SDLTest_AssertPass("Call to SDL_CreateWindow()"); SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); if (window == NULL) { return TEST_ABORTED; } /* Initialize info structure with SDL version info */ SDL_VERSION(&info.version); /* Make call */ result = SDL_GetWindowWMInfo(window, &info); SDLTest_AssertPass("Call to SDL_GetWindowWMInfo"); SDLTest_Log((result == SDL_TRUE) ? "Got window information" : "Couldn't get window information"); SDL_DestroyWindow(window); SDLTest_AssertPass("Call to SDL_DestroyWindow()"); return TEST_COMPLETED; }
void setWindow(SDL_Window* window) { SDL_SysWMinfo window_info; SDL_VERSION(&window_info.version); SDL_GetWindowWMInfo(window, &window_info); g_window = window_info.info.win.window; }
DataType WindowSDL::getHandle() { SDL_SysWMinfo info; SDL_VERSION(&info.version); SDL_GetWindowWMInfo(m_sdlWindow, &info); return info.info.win.window; }
void OVR_SDL2_app::conf_OVR() { // Configure the renderer. Zeroing the configuration stucture causes all // display, window, and device specifications to take on current values // as put in place by SDL. This should work cross-platform, but doesn't. // A workaround is currently (0.4.3b) required under linux. SDL_SysWMinfo info; ovrGLConfig cfg; memset(&info, 0, sizeof (SDL_SysWMinfo)); memset(&cfg, 0, sizeof (ovrGLConfig)); SDL_VERSION(&info.version); SDL_GetWindowWMInfo(window, &info); cfg.OGL.Header.API = ovrRenderAPI_OpenGL; cfg.OGL.Header.RTSize.w = hmd->Resolution.w; cfg.OGL.Header.RTSize.h = hmd->Resolution.h; #ifdef __linux__ cfg.OGL.Disp = info.info.x11.display; cfg.OGL.Win = info.info.x11.window; #endif // Set the configuration and receive eye render descriptors in return. ovrHmd_ConfigureRendering(hmd, &cfg.Config, ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive, hmd->DefaultEyeFov, erd); offset[0] = erd[0].HmdToEyeViewOffset; offset[1] = erd[1].HmdToEyeViewOffset; // Determine the buffer size required by each eye of the current HMD. ovrSizei size[2]; size[0] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, hmd->DefaultEyeFov[0], 1); size[1] = ovrHmd_GetFovTextureSize(hmd, ovrEye_Right, hmd->DefaultEyeFov[1], 1); // Initialize the off-screen render buffers. We're using one buffer per-eye // instead of concatenating both eyes into a single buffer. for (int i = 0; i < 2; i++) { if ((buffer[i] = new framebuffer(size[i].w, size[i].h))) { ovrGLTexture *p = reinterpret_cast<ovrGLTexture*>(tex + i); memset(p, 0, sizeof (ovrGLTexture)); p->OGL.Header.API = ovrRenderAPI_OpenGL; p->OGL.Header.TextureSize = size[i]; p->OGL.Header.RenderViewport.Size = size[i]; p->OGL.TexId = buffer[i]->color; } } }
bool Init(SDL_Window *window) { ImGuiIO &io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those // indices to peek into the io.KeyDown[] // array. io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP; io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN; io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME; io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END; io.KeyMap[ImGuiKey_Delete] = SDLK_DELETE; io.KeyMap[ImGuiKey_Backspace] = SDLK_BACKSPACE; io.KeyMap[ImGuiKey_Enter] = SDLK_RETURN; io.KeyMap[ImGuiKey_Escape] = SDLK_ESCAPE; io.KeyMap[ImGuiKey_A] = SDLK_a; io.KeyMap[ImGuiKey_C] = SDLK_c; io.KeyMap[ImGuiKey_V] = SDLK_v; io.KeyMap[ImGuiKey_X] = SDLK_x; io.KeyMap[ImGuiKey_Y] = SDLK_y; io.KeyMap[ImGuiKey_Z] = SDLK_z; io.RenderDrawListsFn = RenderDrawLists; io.SetClipboardTextFn = SetClipboardText; io.GetClipboardTextFn = GetClipboardText; #ifdef _MSC_VER SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(window, &wmInfo); io.ImeWindowHandle = wmInfo.info.win.window; #endif return true; }
void SDLWindow::Alert (const char* message, const char* title) { #ifdef HX_WINDOWS int count = 0; int speed = 0; bool stopOnForeground = true; SDL_SysWMinfo info; SDL_VERSION (&info.version); SDL_GetWindowWMInfo (sdlWindow, &info); FLASHWINFO fi; fi.cbSize = sizeof (FLASHWINFO); fi.hwnd = info.info.win.window; fi.dwFlags = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER; fi.uCount = count; fi.dwTimeout = speed; FlashWindowEx (&fi); #endif if (message) { SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, title, message, sdlWindow); } }
int init_aclip() { SDL_SysWMinfo info; int retval; retval = -1; SDL_VERSION(&info.version); #if SDL_VERSION_ATLEAST(2, 0, 0) if ( SDL_GetWindowWMInfo(host->video->Window(), &info) ) #else if ( SDL_GetWMInfo(&info) ) #endif { /* Save the information for later use */ if ( info.subsystem == SDL_SYSWM_X11 ) { SDL_Display = info.info.x11.display; SDL_window = info.info.x11.window; #if !SDL_VERSION_ATLEAST(2, 0, 0) Lock_Display = info.info.x11.lock_func; Unlock_Display = info.info.x11.unlock_func; #endif /* Enable the special window hook events */ SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); retval = 0; } else { SDL_SetError("SDL is not running on X11"); } } return retval; }
int SDL_COMPAT_GetWMInfo(SDL_SysWMinfo *info) { if(g_window) return SDL_GetWindowWMInfo(g_window, info); return -1; }
bool SDLGameWindow::VInit() { /* Initialize SDL */ if (SDL_Init(SDL_INIT_TIMER) != 0) { DebugPrintF(VTEXT("SDL Failed to Initialize")); return false; } /*Create the SDL_Window handle*/ #ifdef UNICODE UConverter convert; std::string title = convert.to_bytes(m_params.title); #else std::string title = m_params.title; #endif m_windowHandle = SDL_CreateWindow(title.c_str(), m_params.x <= 0 ? SDL_WINDOWPOS_CENTERED : m_params.x, m_params.y <= 0 ? SDL_WINDOWPOS_CENTERED : m_params.y, m_params.width, m_params.height, SDL_WINDOW_OPENGL); if (!m_windowHandle) { SDL_Quit(); DebugPrintF(VTEXT("Failed to created SDL_Window handle")); return false; } #ifdef VIX_SYS_WINDOWS SDL_SysWMinfo info; SDL_VERSION(&info.version); if (SDL_GetWindowWMInfo(m_windowHandle, &info)) { m_nativeHandle = info.info.win.window; if (m_renderer) m_renderer->VAttachNativeHandle(m_nativeHandle); } #endif #ifdef VIX_SYS_LINUX //for now SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); /*create OpenGL context*/ m_context = SDL_GL_CreateContext(m_windowHandle); if (!m_context) { SDL_Quit(); DebugPrintF(VTEXT("Failed to create SDL_GL_Context handle")); return false; } #endif if (m_renderer && !m_renderer->VInitialize()) { DebugPrintF(VTEXT("Renderer failed to initialize")); return false; } return true; }
static inline IDirectFBWindow *get_dfb_window(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_VERSION(&wm_info.version); SDL_GetWindowWMInfo(window, &wm_info); return wm_info.info.dfb.window; }
static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_VERSION(&wm_info.version); SDL_GetWindowWMInfo(window, &wm_info); return wm_info.info.dfb.surface; }
void browseFile(SDL_Window *window, const char *url) { SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version); if (SDL_GetWindowWMInfo(window, &wminfo) == 1) { HWND hwnd = wminfo.info.win.window; ::ShellExecute(hwnd, "open", url, 0, 0, SW_SHOWNORMAL); } }
void setWindow(SDL_Window* window) { SDL_SysWMinfo window_info; SDL_VERSION(&window_info.version); SDL_GetWindowWMInfo(window, &window_info); Lumix::Engine::PlatformData platform_data = {}; g_window = window_info.info.win.window; }
Ogre::RenderWindow *ApplicationContext::createWindow() { mRoot->initialise(false, mAppName); Ogre::NameValuePairList miscParams; #if OGRE_PLATFORM == OGRE_PLATFORM_NACL miscParams["pp::Instance"] = Ogre::StringConverter::toString((unsigned long)mNaClInstance); miscParams["SwapCallback"] = Ogre::StringConverter::toString((unsigned long)mNaClSwapCallback); // create 1x1 window - we will resize later return mRoot->createRenderWindow(mAppName, mInitWidth, mInitHeight, false, &miscParams); #elif OGRE_PLATFORM == OGRE_PLATFORM_ANDROID miscParams["externalWindowHandle"] = Ogre::StringConverter::toString(reinterpret_cast<size_t>(mAWindow)); miscParams["androidConfig"] = Ogre::StringConverter::toString(reinterpret_cast<size_t>(mAConfig)); miscParams["preserveContext"] = "true"; //Optionally preserve the gl context, prevents reloading all resources, this is false by default return Ogre::Root::getSingleton().createRenderWindow(mAppName, 0, 0, false, &miscParams); #else Ogre::ConfigOptionMap ropts = mRoot->getRenderSystem()->getConfigOptions(); Ogre::uint32 w, h; std::istringstream mode(ropts["Video Mode"].currentValue); Ogre::String token; mode >> w; // width mode >> token; // 'x' as seperator between width and height mode >> h; // height miscParams["FSAA"] = ropts["FSAA"].currentValue; miscParams["vsync"] = ropts["VSync"].currentValue; #if OGRE_BITES_HAVE_SDL if(!SDL_WasInit(SDL_INIT_VIDEO)) { SDL_InitSubSystem(SDL_INIT_VIDEO); } mSDLWindow = SDL_CreateWindow(mAppName.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_RESIZABLE); #if OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN SDL_GL_CreateContext(mSDLWindow); miscParams["currentGLContext"] = "true"; #else SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(mSDLWindow, &wmInfo); #endif #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX miscParams["parentWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.x11.window)); #elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32 miscParams["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.win.window)); #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE assert(wmInfo.subsystem == SDL_SYSWM_COCOA); miscParams["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.cocoa.window)); #endif #endif return mRoot->createRenderWindow(mAppName, w, h, false, &miscParams); #endif }
static bool ImGui_ImplSDL2_Init(SDL_Window* window) { g_Window = window; // Setup back-end capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) #if SDL_HAS_WARP_MOUSE_GLOBAL io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) #endif // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array. io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB; io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP; io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN; io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP; io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN; io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME; io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END; io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT; io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE; io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE; io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE; io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN; io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE; io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A; io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C; io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V; io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X; io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y; io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z; io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText; io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText; io.ClipboardUserData = NULL; g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL); g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS); g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); #ifdef _WIN32 SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(window, &wmInfo); io.ImeWindowHandle = wmInfo.info.win.window; #else (void)window; #endif return true; }
void UpdateHardwareGamma(void) { float gamma = (vid_gamma->value); int i; Display* dpy = NULL; SDL_SysWMinfo info; #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_VERSION(&info.version); if(!SDL_GetWindowWMInfo(window, &info)) #else if(SDL_GetWMInfo(&info) != 1) #endif { VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n"); return; } dpy = info.info.x11.display; XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window); if(res == NULL) { VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n"); return; } for(i=0; i < res->ncrtc; ++i) { int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]); size_t rampSize = len*sizeof(Uint16); Uint16* ramp = malloc(rampSize); // TODO: check for NULL if(ramp == NULL) { VID_Printf(PRINT_ALL, "Couldn't allocate &zd byte of memory for gamma ramp - OOM?!\n", rampSize); return; } CalculateGammaRamp(gamma, ramp, len); XRRCrtcGamma* gamma = XRRAllocGamma(len); memcpy(gamma->red, ramp, rampSize); memcpy(gamma->green, ramp, rampSize); memcpy(gamma->blue, ramp, rampSize); free(ramp); XRRSetCrtcGamma(dpy, res->crtcs[i], gamma); XRRFreeGamma(gamma); } XRRFreeScreenResources(res); }
bool SDLGameWindow::VInit() { /* Initialize SDL */ if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) { DebugPrintF(VTEXT("SDL Failed to Initialize")); return false; } /*Create the SDL_Window handle*/ #ifdef UNICODE UConverter convert; std::string title = convert.to_bytes(m_params.title); #else std::string title = m_params.title; #endif m_windowHandle = SDL_CreateWindow(title.c_str(), m_params.x <= 0 ? SDL_WINDOWPOS_CENTERED : m_params.x, m_params.y <= 0 ? SDL_WINDOWPOS_CENTERED : m_params.y, m_params.width, m_params.height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN); if (!m_windowHandle) { SDL_Quit(); DebugPrintF(VTEXT("Failed to created SDL_Window handle")); return false; } #ifdef VIX_SYS_WINDOWS SDL_SysWMinfo info; SDL_VERSION(&info.version); if (SDL_GetWindowWMInfo(m_windowHandle, &info)) { m_nativeHandle = info.info.win.window; } #endif #ifdef VIX_SYS_LINUX //for now SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); /*create OpenGL context*/ m_context = SDL_GL_CreateContext(m_windowHandle); if (!m_context) { SDL_Quit(); DebugPrintF(VTEXT("Failed to create SDL_GL_Context handle")); return false; } #endif m_mouseState = new SDLMouseState; m_keyboardState = new SDLKeyboardState; m_controllerState = new SDLControllerState; m_running = true; return true; }
static void RestoreGamma() { int i=0; SDL_SysWMinfo info; Display* dpy = NULL; if(gammaRamps == NULL) return; #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_VERSION(&info.version); if(!SDL_GetWindowWMInfo(window, &info)) #else if(SDL_GetWMInfo(&info) != 1) #endif { VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n"); return; } dpy = info.info.x11.display; XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window); if(res == NULL) { VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n"); return; } for(i=0; i < noGammaRamps; ++i) { // in case a display was unplugged or something, noGammaRamps may be > res->ncrtc if(i < res->ncrtc) { int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]); if(len != gammaRamps[i]->size) { VID_Printf(PRINT_ALL, "WTF, gamma ramp size for display %d has changed from %d to %d!\n", i, gammaRamps[i]->size, len); continue; } XRRSetCrtcGamma(dpy, res->crtcs[i], gammaRamps[i]); } // the ramp needs to be free()d either way XRRFreeGamma(gammaRamps[i]); gammaRamps[i] = NULL; } XRRFreeScreenResources(res); free(gammaRamps); gammaRamps = NULL; VID_Printf(PRINT_ALL, "Restored original Gamma\n"); }
static SDL_INLINE IDirectFBWindow *get_dfb_window(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo)); SDL_VERSION(&wm_info.version); SDL_GetWindowWMInfo(window, &wm_info); return wm_info.info.dfb.window; }
void w32_messageBox(const char* title, const char* text, int flags) { SDL_SysWMinfo info; SDL_VERSION(&info.version); if(SDL_GetWindowWMInfo(os::window, &info)) { wchar_t* title16 = util::utf8to16(title); wchar_t* text16 = util::utf8to16(text); MessageBoxW(info.info.win.window, text16, title16, flags); free(text16); free(title16); } }
void* SDL_Window::getBackendId() { SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(this->window, &wmInfo); if (wmInfo.subsystem == SDL_SYSWM_WINDOWS) { return (void*)wmInfo.info.win.window; } return NULL; }
void Initialize() { if (interface::Cvar_GetInteger("com_abnormalExit")) { interface::Cvar_Set("r_mode", util::VarArgs("%d", R_MODE_FALLBACK)); interface::Cvar_Set("r_fullscreen", "0"); interface::Cvar_Set("r_centerWindow", "0"); interface::Cvar_Set("com_abnormalExit", "0"); } // Create the window and set up the context if (StartDriverAndSetMode(g_cvars.mode.getInt(), g_cvars.fullscreen.getBool(), g_cvars.noborder.getBool())) goto success; if (g_cvars.noborder.getBool()) { // Try again with a window border if (StartDriverAndSetMode(g_cvars.mode.getInt(), g_cvars.fullscreen.getBool(), false)) goto success; } // Finally, try the default screen resolution if (g_cvars.mode.getInt() != R_MODE_FALLBACK) { interface::Printf("Setting r_mode %d failed, falling back on r_mode %d\n", g_cvars.mode.getInt(), R_MODE_FALLBACK); if (StartDriverAndSetMode(R_MODE_FALLBACK, false, false)) goto success; } // Nothing worked, give up interface::FatalError("Could not load OpenGL subsystem"); success: // This depends on SDL_INIT_VIDEO, hence having it here interface::IN_Init(SDL_window); SDL_SysWMinfo wmi; SDL_VERSION(&wmi.version); if (SDL_GetWindowWMInfo(SDL_window, &wmi) == SDL_FALSE) { interface::FatalError("SDL_GetWindowWMInfo: %s", SDL_GetError()); } bgfx::PlatformData pd = {}; #ifdef WIN32 pd.nwh = wmi.info.win.window; #else pd.ndt = wmi.info.x11.display; pd.nwh = (void*)(uintptr_t)wmi.info.x11.window; #endif bgfx::setPlatformData(pd); }
/** * @brief Disables the filter if active */ void IN_DisableDingFilter() { Com_DPrintf("Disabling dingy filter\n"); if (LegacyWndProc) { SDL_SysWMinfo wmInfo; SDL_GetVersion(&wmInfo.version); SDL_GetWindowWMInfo(mainScreen, &wmInfo); SetWindowLongPtr(wmInfo.info.win.window, GWLP_WNDPROC, (LONG_PTR)LegacyWndProc); LegacyWndProc = NULL; } }
GLuint OpenGL::getDefaultFBO() const { #ifdef LOVE_IOS // Hack: iOS uses a custom FBO. SDL_SysWMinfo info = {}; SDL_VERSION(&info.version); SDL_GetWindowWMInfo(SDL_GL_GetCurrentWindow(), &info); return info.info.uikit.framebuffer; #else return 0; #endif }
int getStartupFontSize(SDL_Window *window) { int result = DEFAULT_FONT_SIZE; SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version); if (SDL_GetWindowWMInfo(window, &wminfo) == 1) { HWND hwnd = wminfo.info.win.window; HDC hdc = GetDC(hwnd); result = MulDiv(DEFAULT_FONT_SIZE_PTS, GetDeviceCaps(hdc, LOGPIXELSY), 72); ReleaseDC(hwnd, hdc); } return result; }
// // Get platform-specific window handle // void *SDL2_GetWindowHandle(void) { #ifdef _WIN32 SDL_SysWMinfo info; SDL_VERSION(&info.version); if(mainwindow && SDL_GetWindowWMInfo(mainwindow, &info)) return info.info.win.window; #endif return nullptr; }
void Renderer::CreateSDLWindow(const String& windowTitle, const Vec2i& displayMode, bool fullscreen, Ogre::NameValuePairList& options) { // Create the window int windowFlags = 0; if (fullscreen) windowFlags |= SDL_WINDOW_FULLSCREEN; mWindow = SDL_CreateWindow(windowTitle.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, displayMode.x, displayMode.y, windowFlags); // Check that the window was successfully created if (mWindow == nullptr) { // TODO: Error assert(0); } // Get the native window handle SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(mWindow, &wmInfo); String winHandle; switch (wmInfo.subsystem) { #if DW_PLATFORM == DW_WIN32 case SDL_SYSWM_WINDOWS: winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.win.window); break; #elif DW_PLATFORM == DW_MAC_OSX case SDL_SYSWM_COCOA: options["macAPI"] = "cocoa"; options["macAPICocoaUseNSView"] = "true"; winHandle = Ogre::StringConverter::toString(getWindowContentViewHandle(wmInfo)); break; #elif DW_PLATFORM == DW_LINUX case SDL_SYSWM_X11: winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.x11.window); break; #else # error Unhandled SDL2 platform #endif default: // TODO: Error! break; } #if DW_PLATFORM == DW_WIN32 options["externalWindowHandle"] = winHandle; #else options["parentWindowHandle"] = winHandle; #endif }
HWND windows_tray_notification::get_window_handle() { SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); sdl::twindow* window = CVideo::get_singleton().get_window(); // SDL 1.2 keeps track of window handles internally whereas SDL 2.0 allows the caller control over which window to use if (!window || SDL_GetWindowWMInfo (static_cast<SDL_Window *> (*window), &wmInfo) != SDL_TRUE) { return nullptr; } return wmInfo.info.win.window; }
SDL_SysWMinfo window::get_wm_info() const { SDL_SysWMinfo info; SDL_VERSION(&info.version); if (!SDL_GetWindowWMInfo(handle.get(), &info)) { throw std::runtime_error("SDL_GetWindowWMInfo failed!"); } return info; }