mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-27 19:19:41 +08:00
Don't try to use D3D11 or D3D12 if the window isn't backed with an HWND
Fixes https://github.com/libsdl-org/SDL/issues/10196
This commit is contained in:
@@ -2783,6 +2783,11 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
|||||||
{
|
{
|
||||||
D3D11_RenderData *data;
|
D3D11_RenderData *data;
|
||||||
|
|
||||||
|
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||||
|
if (!hwnd) {
|
||||||
|
return SDL_SetError("Couldn't get window handle");
|
||||||
|
}
|
||||||
|
|
||||||
SDL_SetupRendererColorspace(renderer, create_props);
|
SDL_SetupRendererColorspace(renderer, create_props);
|
||||||
|
|
||||||
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB &&
|
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB &&
|
||||||
|
|||||||
@@ -960,7 +960,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
|||||||
D3D_GUID(SDL_IID_IDXGIAdapter4),
|
D3D_GUID(SDL_IID_IDXGIAdapter4),
|
||||||
(void **)&data->dxgiAdapter);
|
(void **)&data->dxgiAdapter);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12CreateDevice"), result);
|
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory6::EnumAdapterByGpuPreference"), result);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3232,6 +3232,11 @@ int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propert
|
|||||||
{
|
{
|
||||||
D3D12_RenderData *data;
|
D3D12_RenderData *data;
|
||||||
|
|
||||||
|
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||||
|
if (!hwnd) {
|
||||||
|
return SDL_SetError("Couldn't get window handle");
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_TRANSPARENT) {
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_TRANSPARENT) {
|
||||||
/* D3D12 removed the swap effect needed to support transparent windows, use D3D11 instead */
|
/* D3D12 removed the swap effect needed to support transparent windows, use D3D11 instead */
|
||||||
return SDL_SetError("The direct3d12 renderer doesn't work with transparent windows");
|
return SDL_SetError("The direct3d12 renderer doesn't work with transparent windows");
|
||||||
|
|||||||
Reference in New Issue
Block a user