mirror of https://github.com/libsdl-org/SDL
Make sure we're actually running on Windows before using D3D renderers
This commit is contained in:
parent
4d5f139f0f
commit
d6c8485f28
|
@ -1595,6 +1595,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
|||
{
|
||||
D3D_RenderData *data;
|
||||
HRESULT result;
|
||||
HWND hwnd;
|
||||
D3DPRESENT_PARAMETERS pparams;
|
||||
IDirect3DSwapChain9 *chain;
|
||||
D3DCAPS9 caps;
|
||||
|
@ -1603,6 +1604,11 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
|||
SDL_DisplayID displayID;
|
||||
const SDL_DisplayMode *fullscreen_mode = NULL;
|
||||
|
||||
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);
|
||||
|
||||
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
|
||||
|
@ -1654,7 +1660,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
|||
}
|
||||
|
||||
SDL_zero(pparams);
|
||||
pparams.hDeviceWindow = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
pparams.hDeviceWindow = hwnd;
|
||||
pparams.BackBufferWidth = w;
|
||||
pparams.BackBufferHeight = h;
|
||||
pparams.BackBufferCount = 1;
|
||||
|
|
|
@ -976,6 +976,11 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
|||
} else {
|
||||
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
|
||||
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
if (!hwnd) {
|
||||
SDL_SetError("Couldn't get window handle");
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
|
||||
(IUnknown *)data->d3dDevice,
|
||||
|
|
|
@ -1311,6 +1311,11 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
|||
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */
|
||||
|
||||
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
if (!hwnd) {
|
||||
SDL_SetError("Couldn't get window handle");
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd,
|
||||
(IUnknown *)data->commandQueue,
|
||||
|
|
|
@ -58,10 +58,6 @@ static void InitCreateRenderer(void *arg)
|
|||
return;
|
||||
}
|
||||
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
|
||||
renderer_name = SDL_SOFTWARE_RENDERER;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, renderer_name);
|
||||
SDLTest_AssertPass("SDL_CreateRenderer()");
|
||||
SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result: %s", renderer != NULL ? "success" : SDL_GetError());
|
||||
|
|
Loading…
Reference in New Issue