mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-30 00:17:40 +00:00
Make sure we're actually running on Windows before using D3D renderers
This commit is contained in:
parent
4d5f139f0f
commit
d6c8485f28
4 changed files with 17 additions and 5 deletions
|
@ -1595,6 +1595,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||||
{
|
{
|
||||||
D3D_RenderData *data;
|
D3D_RenderData *data;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
HWND hwnd;
|
||||||
D3DPRESENT_PARAMETERS pparams;
|
D3DPRESENT_PARAMETERS pparams;
|
||||||
IDirect3DSwapChain9 *chain;
|
IDirect3DSwapChain9 *chain;
|
||||||
D3DCAPS9 caps;
|
D3DCAPS9 caps;
|
||||||
|
@ -1603,6 +1604,11 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||||
SDL_DisplayID displayID;
|
SDL_DisplayID displayID;
|
||||||
const SDL_DisplayMode *fullscreen_mode = NULL;
|
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);
|
SDL_SetupRendererColorspace(renderer, create_props);
|
||||||
|
|
||||||
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
|
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);
|
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.BackBufferWidth = w;
|
||||||
pparams.BackBufferHeight = h;
|
pparams.BackBufferHeight = h;
|
||||||
pparams.BackBufferCount = 1;
|
pparams.BackBufferCount = 1;
|
||||||
|
|
|
@ -976,6 +976,11 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||||
} else {
|
} else {
|
||||||
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
|
#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);
|
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,
|
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
|
||||||
(IUnknown *)data->d3dDevice,
|
(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 */
|
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);
|
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,
|
result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd,
|
||||||
(IUnknown *)data->commandQueue,
|
(IUnknown *)data->commandQueue,
|
||||||
|
|
|
@ -58,10 +58,6 @@ static void InitCreateRenderer(void *arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
|
|
||||||
renderer_name = SDL_SOFTWARE_RENDERER;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer = SDL_CreateRenderer(window, renderer_name);
|
renderer = SDL_CreateRenderer(window, renderer_name);
|
||||||
SDLTest_AssertPass("SDL_CreateRenderer()");
|
SDLTest_AssertPass("SDL_CreateRenderer()");
|
||||||
SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result: %s", renderer != NULL ? "success" : SDL_GetError());
|
SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result: %s", renderer != NULL ? "success" : SDL_GetError());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue