mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-02 05:39:20 +00:00
Updated SDL_syswm.h for SDL 3.0
* The header is no longer dependent on SDL build configuration * The structures are versioned separately from the rest of SDL * SDL_GetWindowWMInfo() now returns a standard result code and is passed the version expected by the application * Updated WhatsNew.txt and docs/README-migration.md with the first API changes in SDL 3.0
This commit is contained in:
@@ -29,11 +29,13 @@
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../SDL_d3dmath.h"
|
||||
#include "../../video/windows/SDL_windowsvideo.h"
|
||||
|
||||
#define SDL_ENABLE_SYSWM_WINDOWS
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
#define D3D_DEBUG_INFO
|
||||
#include <d3d9.h>
|
||||
@@ -1596,6 +1598,12 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
int displayIndex;
|
||||
|
||||
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) {
|
||||
SDL_OutOfMemory();
|
||||
@@ -1643,9 +1651,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->driverdata = data;
|
||||
|
||||
SDL_VERSION(&windowinfo.version);
|
||||
SDL_GetWindowWMInfo(window, &windowinfo);
|
||||
|
||||
window_flags = SDL_GetWindowFlags(window);
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
SDL_GetWindowDisplayMode(window, &fullscreen_mode);
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
#endif
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../SDL_d3dmath.h"
|
||||
|
||||
#define SDL_ENABLE_SYSWM_WINDOWS
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#include <d3d11_1.h>
|
||||
|
||||
#include "SDL_shaders_d3d11.h"
|
||||
@@ -829,8 +831,13 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
||||
} else {
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
SDL_SysWMinfo windowinfo;
|
||||
SDL_VERSION(&windowinfo.version);
|
||||
SDL_GetWindowWMInfo(renderer->window, &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;
|
||||
}
|
||||
|
||||
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
|
||||
(IUnknown *)data->d3dDevice,
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
extern "C" {
|
||||
#include "../SDL_sysrender.h"
|
||||
@@ -40,6 +39,9 @@ using namespace Windows::Graphics::Display;
|
||||
|
||||
#include <DXGI.h>
|
||||
|
||||
#define SDL_ENABLE_SYSWM_WINRT
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
|
||||
@@ -52,8 +54,9 @@ D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
}
|
||||
|
||||
SDL_SysWMinfo sdlWindowInfo;
|
||||
SDL_VERSION(&sdlWindowInfo.version);
|
||||
if ( ! SDL_GetWindowWMInfo(sdlWindow, &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;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,12 @@
|
||||
#include "../../video/windows/SDL_windowswindow.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../SDL_d3dmath.h"
|
||||
|
||||
#define SDL_ENABLE_SYSWM_WINDOWS
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
#include "SDL_render_d3d12_xbox.h"
|
||||
#ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
|
||||
@@ -1175,7 +1177,7 @@ static HRESULT
|
||||
D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
||||
{
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata;
|
||||
IDXGISwapChain1* swapChain;
|
||||
IDXGISwapChain1* swapChain = NULL;
|
||||
HRESULT result = S_OK;
|
||||
SDL_SysWMinfo windowinfo;
|
||||
|
||||
@@ -1199,8 +1201,12 @@ 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 */
|
||||
|
||||
SDL_VERSION(&windowinfo.version);
|
||||
SDL_GetWindowWMInfo(renderer->window, &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;
|
||||
}
|
||||
|
||||
result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd,
|
||||
(IUnknown *)data->commandQueue,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#if SDL_VIDEO_RENDER_METAL && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_metal.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
|
||||
@@ -31,10 +30,16 @@
|
||||
#import <Metal/Metal.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
#ifdef __MACOSX__
|
||||
#ifdef SDL_VIDEO_DRIVER_COCOA
|
||||
#import <AppKit/NSWindow.h>
|
||||
#import <AppKit/NSView.h>
|
||||
#define SDL_ENABLE_SYSWM_COCOA
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||
#import <UIKit/UIKit.h>
|
||||
#define SDL_ENABLE_SYSWM_UIKIT
|
||||
#endif
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
/* Regenerate these with build-metal-shaders.sh */
|
||||
#ifdef __MACOSX__
|
||||
@@ -1599,9 +1604,8 @@ static SDL_MetalView GetWindowView(SDL_Window *window)
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
if (SDL_GetWindowWMInfo(window, &info)) {
|
||||
#ifdef __MACOSX__
|
||||
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) {
|
||||
@@ -1611,7 +1615,8 @@ static SDL_MetalView GetWindowView(SDL_Window *window)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#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) {
|
||||
@@ -1683,8 +1688,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */
|
||||
};
|
||||
|
||||
SDL_VERSION(&syswm.version);
|
||||
if (!SDL_GetWindowWMInfo(window, &syswm)) {
|
||||
if (SDL_GetWindowWMInfo(window, &syswm, SDL_SYSWM_CURRENT_VERSION) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user