Fixed building for simulators or older iOS SDKs

This commit is contained in:
Sam Lantinga 2017-12-07 17:47:01 -08:00
parent 6deb1e7595
commit ba9c336e04
5 changed files with 24 additions and 13 deletions

View File

@ -1691,7 +1691,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
@ -1728,7 +1727,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
@ -1864,6 +1862,7 @@
GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include"; HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = SDL2; PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
}; };
@ -1881,6 +1880,7 @@
GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include"; HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = SDL2; PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
}; };

View File

@ -148,18 +148,25 @@
#define SDL_VIDEO_DRIVER_UIKIT 1 #define SDL_VIDEO_DRIVER_UIKIT 1
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
/* enable OpenGL ES */ /* Enable OpenGL ES */
#define SDL_VIDEO_OPENGL_ES2 1 #define SDL_VIDEO_OPENGL_ES2 1
#define SDL_VIDEO_OPENGL_ES 1 #define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES2 1 #define SDL_VIDEO_RENDER_OGL_ES2 1
/* Enable Metal and Vulkan support on 64-bit devices when an iOS 8+ SDK is used. */ /* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer */
#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && defined(__IPHONE_8_0) #if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 90000))
#define SDL_VIDEO_RENDER_METAL 1 #define SDL_PLATFORM_SUPPORTS_METAL 1
#define SDL_VIDEO_VULKAN 1
#else #else
#define SDL_VIDEO_VULKAN 0 #define SDL_PLATFORM_SUPPORTS_METAL 0
#endif
#if SDL_PLATFORM_SUPPORTS_METAL
#define SDL_VIDEO_RENDER_METAL 1
#endif
#if SDL_PLATFORM_SUPPORTS_METAL
#define SDL_VIDEO_VULKAN 1
#endif #endif
/* Enable system power support */ /* Enable system power support */

View File

@ -113,12 +113,12 @@ SDL_RenderDriver METAL_RenderDriver = {
static int static int
IsMetalAvailable(const SDL_SysWMinfo *syswm) IsMetalAvailable(const SDL_SysWMinfo *syswm)
{ {
if (syswm->subsystem != SDL_SYSWM_COCOA) { // !!! FIXME: SDL_SYSWM_UIKIT for iOS, too! if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) {
return SDL_SetError("Metal render target only supports Cocoa video target at the moment."); return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment.");
} }
// this checks a weak symbol. // this checks a weak symbol.
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100 #if defined(__MACOSX__)
if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower. if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower.
return SDL_SetError("Metal framework not available on this system"); return SDL_SetError("Metal framework not available on this system");
} }

View File

@ -32,6 +32,8 @@
#import "../SDL_sysvideo.h" #import "../SDL_sysvideo.h"
#import "SDL_uikitwindow.h" #import "SDL_uikitwindow.h"
#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <Metal/Metal.h> #import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h> #import <QuartzCore/CAMetalLayer.h>
@ -50,6 +52,8 @@ SDL_uikitmetalview* UIKit_Mtl_AddMetalView(SDL_Window* window);
void UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h); void UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */
#endif /* SDL_uikitmetalview_h_ */ #endif /* SDL_uikitmetalview_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View File

@ -28,7 +28,7 @@
#include "../../SDL_internal.h" #include "../../SDL_internal.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_UIKIT #if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
#import "../SDL_sysvideo.h" #import "../SDL_sysvideo.h"
#import "SDL_uikitwindow.h" #import "SDL_uikitwindow.h"
@ -133,4 +133,4 @@ UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h)
} }
} }
#endif #endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */