Make sure we're actually running on Windows before using D3D renderers

(cherry picked from commit e22c89536a)
This commit is contained in:
Sam Lantinga
2024-07-08 11:28:29 -07:00
parent 7b11fff2ee
commit d3765b27c2
2 changed files with 11 additions and 2 deletions

View File

@@ -1610,7 +1610,11 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->driverdata = data;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(window, &windowinfo);
if (!SDL_GetWindowWMInfo(window, &windowinfo) ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
SDL_free(data);
return SDL_SetError("Couldn't get window handle");
}
window_flags = SDL_GetWindowFlags(window);
SDL_GetWindowSizeInPixels(window, &w, &h);

View File

@@ -813,7 +813,12 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
if (!SDL_GetWindowWMInfo(renderer->window, &windowinfo) ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
SDL_SetError("Couldn't get window handle");
result = E_FAIL;
goto done;
}
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
(IUnknown *)data->d3dDevice,