mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-15 04:58:44 +02:00
SDL_syswm.h has been removed and replaced with window properties
This commit is contained in:
@@ -28,8 +28,6 @@
|
||||
#include "../SDL_d3dmath.h"
|
||||
#include "../../video/windows/SDL_windowsvideo.h"
|
||||
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#ifdef SDL_VIDEO_RENDER_D3D
|
||||
#define D3D_DEBUG_INFO
|
||||
#include <d3d9.h>
|
||||
@@ -1542,7 +1540,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
D3D_RenderData *data;
|
||||
SDL_SysWMinfo windowinfo;
|
||||
HRESULT result;
|
||||
D3DPRESENT_PARAMETERS pparams;
|
||||
IDirect3DSwapChain9 *chain;
|
||||
@@ -1552,12 +1549,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
SDL_DisplayID displayID;
|
||||
const SDL_DisplayMode *fullscreen_mode = NULL;
|
||||
|
||||
if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
|
||||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
|
||||
SDL_SetError("Couldn't get window handle");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
@@ -1611,7 +1602,7 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
}
|
||||
|
||||
SDL_zero(pparams);
|
||||
pparams.hDeviceWindow = windowinfo.info.win.window;
|
||||
pparams.hDeviceWindow = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd");
|
||||
pparams.BackBufferWidth = w;
|
||||
pparams.BackBufferHeight = h;
|
||||
pparams.BackBufferCount = 1;
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../SDL_d3dmath.h"
|
||||
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#include <d3d11_1.h>
|
||||
|
||||
#include "SDL_shaders_d3d11.h"
|
||||
@@ -827,18 +825,11 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
#endif
|
||||
} else {
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
SDL_SysWMinfo windowinfo;
|
||||
|
||||
if (SDL_GetWindowWMInfo(renderer->window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
|
||||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
|
||||
SDL_SetError("Couldn't get window handle");
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), "SDL.window.win32.hwnd");
|
||||
|
||||
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
|
||||
(IUnknown *)data->d3dDevice,
|
||||
windowinfo.info.win.window,
|
||||
hwnd,
|
||||
&swapChainDesc,
|
||||
NULL,
|
||||
NULL, /* Allow on all displays. */
|
||||
@@ -848,7 +839,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
goto done;
|
||||
}
|
||||
|
||||
IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||
IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||
#else
|
||||
SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to");
|
||||
goto done;
|
||||
|
||||
@@ -39,35 +39,14 @@ using namespace Windows::Graphics::Display;
|
||||
|
||||
#include <DXGI.h>
|
||||
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *sdlWindow = renderer->window;
|
||||
if (renderer->window == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_SysWMinfo sdlWindowInfo;
|
||||
if (SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
|
||||
sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) {
|
||||
SDL_SetError("Couldn't get window handle");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!sdlWindowInfo.info.winrt.window) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IInspectable *window = (IInspectable *)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), "SDL.window.winrt.window");
|
||||
ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL;
|
||||
if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) {
|
||||
if (!window || FAILED(window->QueryInterface(&coreWindow))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../SDL_d3dmath.h"
|
||||
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
#include "SDL_render_d3d12_xbox.h"
|
||||
#ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
|
||||
@@ -1153,7 +1151,6 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata;
|
||||
IDXGISwapChain1 *swapChain = NULL;
|
||||
HRESULT result = S_OK;
|
||||
SDL_SysWMinfo windowinfo;
|
||||
|
||||
/* Create a swap chain using the same adapter as the existing Direct3D device. */
|
||||
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
|
||||
@@ -1175,16 +1172,11 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT | /* To support SetMaximumFrameLatency */
|
||||
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */
|
||||
|
||||
if (SDL_GetWindowWMInfo(renderer->window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
|
||||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
|
||||
SDL_SetError("Couldn't get window handle");
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), "SDL.window.win32.hwnd");
|
||||
|
||||
result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd,
|
||||
(IUnknown *)data->commandQueue,
|
||||
windowinfo.info.win.window,
|
||||
hwnd,
|
||||
&swapChainDesc,
|
||||
NULL,
|
||||
NULL, /* Allow on all displays. */
|
||||
@@ -1194,7 +1186,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
goto done;
|
||||
}
|
||||
|
||||
D3D_CALL(data->dxgiFactory, MakeWindowAssociation, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||
D3D_CALL(data->dxgiFactory, MakeWindowAssociation, hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||
|
||||
result = D3D_CALL(swapChain, QueryInterface, D3D_GUID(SDL_IID_IDXGISwapChain4), (void **)&data->swapChain);
|
||||
if (FAILED(result)) {
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
/* Regenerate these with build-metal-shaders.sh */
|
||||
#ifdef __MACOS__
|
||||
@@ -160,20 +159,16 @@ typedef struct METAL_ShaderPipelines
|
||||
@implementation METAL_TextureData
|
||||
@end
|
||||
|
||||
static int IsMetalAvailable(const SDL_SysWMinfo *syswm)
|
||||
static SDL_bool IsMetalAvailable()
|
||||
{
|
||||
if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) {
|
||||
return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment.");
|
||||
}
|
||||
|
||||
// this checks a weak symbol.
|
||||
#if (defined(__MACOS__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100))
|
||||
// this checks a weak symbol.
|
||||
if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower.
|
||||
return SDL_SetError("Metal framework not available on this system");
|
||||
SDL_SetError("Metal framework not available on this system");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static const MTLBlendOperation invalidBlendOperation = (MTLBlendOperation)0xFFFFFFFF;
|
||||
@@ -1630,29 +1625,31 @@ static int METAL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
|
||||
static SDL_MetalView GetWindowView(SDL_Window *window)
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
if (SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) == 0) {
|
||||
#ifdef SDL_ENABLE_SYSWM_COCOA
|
||||
if (info.subsystem == SDL_SYSWM_COCOA) {
|
||||
NSView *view = info.info.cocoa.window.contentView;
|
||||
if (view.subviews.count > 0) {
|
||||
view = view.subviews[0];
|
||||
if (view.tag == SDL_METALVIEW_TAG) {
|
||||
return (SDL_MetalView)CFBridgingRetain(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_ENABLE_SYSWM_UIKIT
|
||||
if (info.subsystem == SDL_SYSWM_UIKIT) {
|
||||
UIView *view = info.info.uikit.window.rootViewController.view;
|
||||
if (view.tag == SDL_METALVIEW_TAG) {
|
||||
#ifdef SDL_VIDEO_DRIVER_COCOA
|
||||
NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window");
|
||||
NSInteger tag = (NSInteger)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.metal_view_tag");
|
||||
if (nswindow) {
|
||||
NSView *view = nswindow.contentView;
|
||||
if (view.subviews.count > 0) {
|
||||
view = view.subviews[0];
|
||||
if (view.tag == tag) {
|
||||
return (SDL_MetalView)CFBridgingRetain(view);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||
UIWindow *uiwindow = (__bridge UIWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.uikit.window");
|
||||
NSInteger tag = (NSInteger)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.uikit.metal_view_tag");
|
||||
if (uiwindow) {
|
||||
UIView *view = uiwindow.rootViewController.view;
|
||||
if (view.tag == tag) {
|
||||
return (SDL_MetalView)CFBridgingRetain(view);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -1664,7 +1661,6 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
id<MTLDevice> mtldevice = nil;
|
||||
SDL_MetalView view = NULL;
|
||||
CAMetalLayer *layer = nil;
|
||||
SDL_SysWMinfo syswm;
|
||||
NSError *err = nil;
|
||||
dispatch_data_t mtllibdata;
|
||||
char *constantdata;
|
||||
@@ -1740,11 +1736,7 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */
|
||||
};
|
||||
|
||||
if (SDL_GetWindowWMInfo(window, &syswm, SDL_SYSWM_CURRENT_VERSION) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (IsMetalAvailable(&syswm) == -1) {
|
||||
if (!IsMetalAvailable()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user