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

This commit is contained in:
Sam Lantinga
2024-07-08 11:28:29 -07:00
parent 849c905d8c
commit e22c89536a
2 changed files with 11 additions and 2 deletions

View File

@@ -1598,7 +1598,11 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, 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

@@ -812,7 +812,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,