@@ -1072,7 +1072,18 @@ static void D3D11_DestroyDevice(FNA3D_Device *device)
1072
1072
swapchainData = renderer -> swapchainDatas [i ];
1073
1073
ID3D11RenderTargetView_Release (swapchainData -> swapchainRTView );
1074
1074
IDXGISwapChain_Release (swapchainData -> swapchain );
1075
- SDL_ClearProperty (SDL_GetWindowProperties (swapchainData -> windowHandle ), WINDOW_SWAPCHAIN_DATA );
1075
+ #if SDL_MAJOR_VERSION >= 3
1076
+ SDL_ClearProperty (
1077
+ SDL_GetWindowProperties (swapchainData -> windowHandle ),
1078
+ WINDOW_SWAPCHAIN_DATA
1079
+ );
1080
+ #else
1081
+ SDL_SetWindowData (
1082
+ (SDL_Window * ) swapchainData -> windowHandle ,
1083
+ WINDOW_SWAPCHAIN_DATA ,
1084
+ NULL
1085
+ );
1086
+ #endif
1076
1087
SDL_free (renderer -> swapchainDatas [i ]);
1077
1088
}
1078
1089
SDL_free (renderer -> swapchainDatas );
@@ -1533,11 +1544,18 @@ static void D3D11_SwapBuffers(
1533
1544
}
1534
1545
}
1535
1546
1547
+ #if SDL_MAJOR_VERSION >= 3
1536
1548
swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
1537
1549
SDL_GetWindowProperties (overrideWindowHandle ),
1538
1550
WINDOW_SWAPCHAIN_DATA ,
1539
1551
NULL
1540
1552
);
1553
+ #else
1554
+ swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
1555
+ (SDL_Window * ) overrideWindowHandle ,
1556
+ WINDOW_SWAPCHAIN_DATA
1557
+ );
1558
+ #endif
1541
1559
if (swapchainData == NULL )
1542
1560
{
1543
1561
D3D11_INTERNAL_CreateSwapChain (
@@ -1546,11 +1564,18 @@ static void D3D11_SwapBuffers(
1546
1564
(SDL_Window * ) overrideWindowHandle ,
1547
1565
NULL
1548
1566
);
1567
+ #if SDL_MAJOR_VERSION >= 3
1549
1568
swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
1550
1569
SDL_GetWindowProperties (overrideWindowHandle ),
1551
1570
WINDOW_SWAPCHAIN_DATA ,
1552
1571
NULL
1553
1572
);
1573
+ #else
1574
+ swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
1575
+ (SDL_Window * ) overrideWindowHandle ,
1576
+ WINDOW_SWAPCHAIN_DATA
1577
+ );
1578
+ #endif
1554
1579
D3D11_INTERNAL_UpdateSwapchainRT (
1555
1580
renderer ,
1556
1581
swapchainData ,
@@ -2548,7 +2573,18 @@ static void D3D11_INTERNAL_CreateSwapChain(
2548
2573
#ifdef FNA3D_DXVK_NATIVE
2549
2574
dxgiHandle = (HWND ) windowHandle ;
2550
2575
#else
2551
- dxgiHandle = (HWND ) SDL_GetProperty (SDL_GetWindowProperties (windowHandle ), SDL_PROP_WINDOW_WIN32_HWND_POINTER , NULL );
2576
+ #if SDL_MAJOR_VERSION >= 3
2577
+ dxgiHandle = (HWND ) SDL_GetProperty (
2578
+ SDL_GetWindowProperties (windowHandle ),
2579
+ SDL_PROP_WINDOW_WIN32_HWND_POINTER ,
2580
+ NULL
2581
+ );
2582
+ #else
2583
+ SDL_SysWMinfo info ;
2584
+ SDL_VERSION (& info .version );
2585
+ SDL_GetWindowWMInfo ((SDL_Window * ) windowHandle , & info );
2586
+ dxgiHandle = info .info .win .window ;
2587
+ #endif
2552
2588
#endif /* FNA3D_DXVK_NATIVE */
2553
2589
2554
2590
/* Initialize swapchain buffer descriptor */
@@ -2676,7 +2712,11 @@ static void D3D11_INTERNAL_CreateSwapChain(
2676
2712
swapchainData -> windowHandle = windowHandle ;
2677
2713
swapchainData -> swapchainRTView = NULL ;
2678
2714
swapchainData -> format = backBufferFormat ;
2715
+ #if SDL_MAJOR_VERSION >= 3
2679
2716
SDL_SetProperty (SDL_GetWindowProperties (windowHandle ), WINDOW_SWAPCHAIN_DATA , swapchainData );
2717
+ #else
2718
+ SDL_SetWindowData ((SDL_Window * ) windowHandle , WINDOW_SWAPCHAIN_DATA , swapchainData );
2719
+ #endif
2680
2720
if (growSwapchains )
2681
2721
{
2682
2722
if (renderer -> swapchainDataCount >= renderer -> swapchainDataCapacity )
@@ -2771,11 +2811,18 @@ static void D3D11_INTERNAL_CreateBackbuffer(
2771
2811
/* Create or update the swapchain */
2772
2812
if (parameters -> deviceWindowHandle != NULL )
2773
2813
{
2814
+ #if SDL_MAJOR_VERSION >= 3
2774
2815
swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
2775
2816
SDL_GetWindowProperties (parameters -> deviceWindowHandle ),
2776
2817
WINDOW_SWAPCHAIN_DATA ,
2777
2818
NULL
2778
2819
);
2820
+ #else
2821
+ swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
2822
+ (SDL_Window * ) parameters -> deviceWindowHandle ,
2823
+ WINDOW_SWAPCHAIN_DATA
2824
+ );
2825
+ #endif
2779
2826
if (swapchainData == NULL )
2780
2827
{
2781
2828
D3D11_INTERNAL_CreateSwapChain (
@@ -2784,11 +2831,18 @@ static void D3D11_INTERNAL_CreateBackbuffer(
2784
2831
parameters -> deviceWindowHandle ,
2785
2832
NULL
2786
2833
);
2834
+ #if SDL_MAJOR_VERSION >= 3
2787
2835
swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
2788
2836
SDL_GetWindowProperties (parameters -> deviceWindowHandle ),
2789
2837
WINDOW_SWAPCHAIN_DATA ,
2790
2838
NULL
2791
2839
);
2840
+ #else
2841
+ swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
2842
+ (SDL_Window * ) parameters -> deviceWindowHandle ,
2843
+ WINDOW_SWAPCHAIN_DATA
2844
+ );
2845
+ #endif
2792
2846
}
2793
2847
else
2794
2848
{
@@ -5214,6 +5268,9 @@ static uint8_t D3D11_PrepareWindowAttributes(uint32_t *flags)
5214
5268
}
5215
5269
5216
5270
/* No window flags required */
5271
+ #if SDL_MAJOR_VERSION < 3
5272
+ SDL_SetHint (SDL_HINT_VIDEO_EXTERNAL_CONTEXT , "1" );
5273
+ #endif
5217
5274
#ifdef FNA3D_DXVK_NATIVE
5218
5275
/* ... unless this is DXVK */
5219
5276
* flags = SDL_WINDOW_VULKAN ;
0 commit comments