Files
ppsspp/headless/SDLCocoaMetalLayer.mm
T
libretroadmin f0b97a2e90 Remove the standalone frontends
The libretro core is the frontend, and the headless tools are the test and
debugging hosts. The Windows, UWP, Android, iOS, macOS and SDL apps, the UI
framework and imgui go, along with what only they used: the Win32 debugger
hooks (g_frameMutex, the shutdown lock), JNI thread attachment, the Android
text drawer, RAIntegration, Discord, recent files, game installs, tilt input,
the audio resamplers, the control mapper, memstick moving and the remote ISO
and upload server modes. The web server keeps the debugger. The MSVC, Gradle
and ndk-build projects go too.
2026-10-09 04:56:10 +02:00

40 lines
1.1 KiB
Plaintext

#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC)
#import <Cocoa/Cocoa.h>
#else
#import <UIKit/UIKit.h>
#endif
#import <QuartzCore/CAMetalLayer.h>
#include "SDLCocoaMetalLayer.h"
void *makeWindowMetalCompatible(void *window) {
// https://github.com/KhronosGroup/MoltenVK/issues/78#issuecomment-371118536
#if PPSSPP_PLATFORM(MAC)
NSWindow *nsWindow = (__bridge NSWindow *)window;
NSView *view = nsWindow.contentView;
assert([view isKindOfClass:[NSView class]]);
if (![view.layer isKindOfClass:[CAMetalLayer class]])
{
[view setLayer:[CAMetalLayer layer]];
[[view layer] setContentsScale:[nsWindow backingScaleFactor]];
}
return (__bridge void *)view.layer;
#else
UIView *view = (__bridge UIView *)window;
assert([view isKindOfClass:[UIView class]]);
CAMetalLayer *metalLayer = [CAMetalLayer new];
CGSize viewSize = view.frame.size;
metalLayer.frame = view.frame;
metalLayer.opaque = true;
metalLayer.framebufferOnly = true;
metalLayer.drawableSize = viewSize;
metalLayer.pixelFormat = (MTLPixelFormat)80;//BGRA8Unorm==80
[view.layer addSublayer:metalLayer];
return (__bridge void *)metalLayer;
#endif
}